Categorygithub.com/Seagate/seagate-exos-x-api-go

# README

seagate-exos-x-api-go

Go Report Card Go Reference

MC API Client v2.0.0

This is a Go language library for interfacing with Seagate's Management Controller (MC) CLI/API. This library is used to generate an MC OpenAPI specification and then use that specification to generate a Go CLient API library. The OpenAPI specification is generated using an input yaml file and then gathering meta data from the MC API to create the OpenAPI specification. This library leverages an HTTP interface to communicate with the Management Controller of a live Seagate RAID Storage System. In addition, a higher-level API layer is used by clients such as the CSI Driver, and that higher layer relies on the auto-generated Go Client library.

The Seagate EXOS X API.

The HTTP API operations are used to execute provisioning and management commands.

MC API Design

This library was designed to generate an MC OpenAPI specification, as well as provide a library that clients can use to communicate with the MC in a Seagate storage array.

For most users of this library, you will only need to access the generated MC API Go library. The original library (v1) was written by hand and included support for a handful of commands used by the Kubernetes CSI Driver. The current library (v2) uses openapi tools to auto-generated a Go Language Client library. This library uses the MC OpenAPI Specification (api/mc-openapi.yaml) to auto-generate the Go client library. That same spec can be used to generate a Python, JavaScript, or other libraries.

This design uses a layered approach to the client API - where clients can call the pkg/client functions to communicate with an MC, or use the pkg/v1 or pkg/v2 client API functions. The pkg/v1 was created to support the original CSI driver and uses the hand-written code which parses XML responses from the MC. The pkg/v2 client API was also hand-written and leverages the auto-generated pkg/client functions. The v2 client parses JSON data returned from the MC and is 4-5 times faster than v1 based on regression test suite timings. Having both a v1 and v2 versions allowed for an easy transition in any client from importing github.com/Seagate/seagate-exos-x-api-go/pkg/v1 to github.com/Seagate/seagate-exos-x-api-go/pkg/v2 without having to change function calls.

This library also includes code written to auto-generate a new MC OpenAPI specification, but that step should not be required in most cases. Below are notes regarding current support, a road map, and regression testing notes.

OpenAPI Implementation

This section defines the commands, response status codes, and resource objects implemented in the OpenAPI specification. This is a superset of what was developed in API v1. Commands were added that are being used by other clients needing to interface with the MC Storage Controller API.

The following table provides a list of all possible MC API commands and which ones are supported currently in the MC OpenAPI spec and Go Client library. There are a total of 291 commands, with 29 supported, roughly 10%.

CommandIn MC OpenAPI SpecNot Supported Yet
loginsupported
abort copynot supported
abort replicationnot supported
abort scrubnot supported
activate certificatenot supported
activate disk-firmwarenot supported
activate firmwarenot supported
add disk-groupnot supported
add event-subscribernot supported
add host-group-membersnot supported
add host-membersnot supported
add ipv6-addressnot supported
add sparesnot supported
add storagenot supported
add volume-group-membersnot supported
check firmware-upgrade-healthnot supported
clear cachenot supported
clear disk-metadatanot supported
clear dns-parametersnot supported
clear eventsnot supported
clear expander-statusnot supported
clear failed-disknot supported
clear fde-keysnot supported
clear replication-queuenot supported
clear slow-disknot supported
create certificate-signing-requestnot supported
create certificatenot supported
create custom-profilenot supported
create host-groupnot supported
create hostnot supported
create peer-connectionnot supported
create remote-systemnot supported
create replication-setnot supported
create schedulenot supported
create snapshotssupported
create snmpdConfnot supported
create user-groupnot supported
create volume-groupnot supported
create volume-setnot supported
create volumesupported
delete all-snapshotsnot supported
delete chap-recordnot supported
delete disk-firmwarenot supported
delete event-subscribernot supported
delete host-groupsnot supported
delete hostssupported
delete initiator-nicknamesupported
delete peer-connectionnot supported
delete poolsnot supported
delete remote-systemnot supported
delete replication-setnot supported
delete schedulenot supported
delete snapshotsupported
delete tasknot supported
delete user-groupnot supported
delete usernot supported
delete volume-groupsnot supported
delete volumessupported
dequarantinenot supported
down disknot supported
erase disknot supported
exitnot supported
expand disk-groupnot supported
expand volumesupported
failnot supported
helpnot supported
map volumesupported
metasupported
pingnot supported
query metricsnot supported
query peer-connectionnot supported
recover disk-groupnot supported
recover replication-setnot supported
recover volumenot supported
release volumenot supported
remove certificatenot supported
remove disk-groupsnot supported
remove host-group-membersnot supported
remove host-membersnot supported
remove ipv6-addressnot supported
remove mas-servicenot supported
remove sparesnot supported
remove volume-group-membersnot supported
replicatenot supported
rescannot supported
reset all-statisticsnot supported
reset ciphersnot supported
reset controller-statisticsnot supported
reset disk-error-statisticsnot supported
reset disk-group-statisticsnot supported
reset disk-statisticsnot supported
reset dns-management-hostnamenot supported
reset host-linknot supported
reset host-port-statisticsnot supported
reset pool-statisticsnot supported
reset smis-configurationnot supported
reset snapshotnot supported
reset volume-statisticsnot supported
restart controllernot supported
restart disknot supported
restart mcnot supported
restart scnot supported
restore defaultsnot supported
resume replication-setnot supported
rollback volumenot supported
scrub disk-groupsnot supported
scrub volumenot supported
set advanced-settingsnot supported
set alertnot supported
set chap-recordnot supported
set ciphersnot supported
set cli-parametersnot supported
set controller-datenot supported
set custom-profilenot supported
set debug-log-parametersnot supported
set degraded-disk-thresholdnot supported
set disk-firmware-update-settingsnot supported
set disk-groupnot supported
set disk-parametersnot supported
set disknot supported
set dns-management-hostnamenot supported
set dns-parametersnot supported
set email-parametersnot supported
set enclosurenot supported
set event-subscribernot supported
set expander-fault-isolationnot supported
set expander-phynot supported
set fde-import-keynot supported
set fde-statenot supported
set host-groupnot supported
set host-parametersnot supported
set host-port-modenot supported
set hostnot supported
set infiniband-parametersnot supported
set initiatorsupported
set ipv6-addressnot supported
set ipv6-network-parametersnot supported
set ldap-parametersnot supported
set lednot supported
set linearnot supported
set mas-servicenot supported
set network-parametersnot supported
set ntp-parametersnot supported
set passwordnot supported
set peer-connectionnot supported
set poolnot supported
set promptnot supported
set protocolsnot supported
set proxy-servernot supported
set redfish-persistent-datanot supported
set remote-systemnot supported
set replication-setnot supported
set schedulenot supported
set slow-disk-policynot supported
set slow-disk-thresholdnot supported
set snapshot-spacenot supported
set snmp-parametersnot supported
set stratus-hybridnot supported
set support-assist-esenot supported
set syslog-parametersnot supported
set systemnot supported
set tasknot supported
set update-servernot supported
set user-groupnot supported
set usernot supported
set volume-groupnot supported
set volumenot supported
show advanced-settingssupported
show alertsnot supported
show audit-lognot supported
show cache-parameterssupported
show certificatessupported
show chap-recordsnot supported
show ciphersnot supported
show cli-parametersnot supported
show configurationnot supported
show controller-datesupported
show controller-statisticsnot supported
show controllerssupported
show debug-log-parametersnot supported
show debug-lognot supported
show degraded-disk-policynot supported
show degraded-disk-thresholdsnot supported
show disk-affinitynot supported
show disk-firmware-update-settingsnot supported
show disk-group-statisticsnot supported
show disk-groupssupported
show disk-parametersnot supported
show disk-statisticsnot supported
show diskssupported
show dns-management-hostnamenot supported
show dns-parametersnot supported
show email-parametersnot supported
show enclosuressupported
show event-subscribernot supported
show eventsnot supported
show expander-statusnot supported
show factory-default-statusnot supported
show fan-modulesnot supported
show fanssupported
show fde-statenot supported
show featuresnot supported
show fenced-datanot supported
show firmware-bundlesnot supported
show firmware-update-statusnot supported
show frusnot supported
show host-groupssupported
show host-phy-statisticsnot supported
show host-port-statisticsnot supported
show infiniband-parametersnot supported
show initiatorssupported
show inquirynot supported
show ipv6-addressesnot supported
show ipv6-network-parametersnot supported
show iscsi-parametersnot supported
show kms-parametersnot supported
show ldap-parametersnot supported
show led-statesnot supported
show licensenot supported
show mapssupported
show mas-servicenot supported
show metrics-listnot supported
show muinot supported
show network-parametersnot supported
show ntp-statusnot supported
show peer-connectionsnot supported
show pool-statisticsnot supported
show poolssupported
show portsnot supported
show power-suppliessupported
show profilenot supported
show profilesnot supported
show protocolsnot supported
show provisioningnot supported
show proxy-servernot supported
show redfish-persistent-datanot supported
show redundancy-modenot supported
show refresh-countersnot supported
show remote-systemsnot supported
show replication-setsnot supported
show replication-snapshot-historynot supported
show sas-link-healthnot supported
show scemnot supported
show schedulesnot supported
show sensor-statusnot supported
show service-tag-infonot supported
show sessionsnot supported
show shutdown-statusnot supported
show slow-disk-policynot supported
show slow-disk-thresholdsnot supported
show smis-debugnot supported
show snapshot-spacenot supported
show snapshotssupported
show snmp-parametersnot supported
show spear-errorsnot supported
show storage-configurationsnot supported
show support-assist-contactnot supported
show support-assist-esenot supported
show support-assist-telemetry-statusnot supported
show support-assistnot supported
show syslog-parametersnot supported
show system-parametersnot supported
show systemsupported
show tasksnot supported
show tier-statisticsnot supported
show tiersnot supported
show timezonesnot supported
show unwritable-cachenot supported
show update-servernot supported
show user-groupsnot supported
show user-interactionsnot supported
show usersnot supported
show versionssupported
show volume-copiesnot supported
show volume-labelsnot supported
show volume-namesnot supported
show volume-reservationsnot supported
show volume-statisticsnot supported
show volumessupported
show workloadnot supported
shutdownnot supported
simulate fru-faultnot supported
start metricsnot supported
stop metricsnot supported
suspend replication-setnot supported
trustnot supported
unfail controllernot supported
unfence controllernot supported
uninstall licensenot supported
unmap volumesupported
verify disk-performancenot supported

Generation Steps

CommandNotes
Update generator/mc-commands.yamlModify this YAML file which controls MC command generation
make generatorBuilds a generator executable for creating the OpenAPI YAML file
make rungExecutes: go run generator/cmd/main.go -config generator/generator.conf
make validateUse openapi-generator-cli to validate the MC OpenAPI spec
make generateUse openapi-generator-cli to generate a Go MC client library
make validatorBuilds a validator executable for testing the generated client library
make runvExecutes: go run validator/cmd/main.go -config validator/validator.conf

Note: validator/cmd/main.go is used to validate a handful of MC client library commands, extend as desired.

MC OpenAPI Roadmap

This section describes proposed next steps for implementing remaining commands.

  • Create a new MC API command that returns a list of all supported commands along with their parameters and other information needed to auto-generate mc-commands.yaml.
  • Expand MC OpenAPI support to include all commands.
  • Expand MC OpenAPI support to include all command parameters and variations.
  • Work on a system of having multiple versions of the MC OpenAPI spec corresponding to various product releases.

Steps Needed to Update the MC OpenAPI Specification

In order to add a new command that is supported by the MC OpenAPI specification and also supported by the Go Client Library, follow these steps:

  • Update internal/generator/mc-commands.yaml to include the new command and save your changes:
    • The main sections to include are: command URI, meta, include, nested, and options.
    • The command URI is essentially how you would run a command in a shell. For example, show volumes becomes /show/volumes.
    • The meta tag value is displayed when you run a command and have it return JSON data, it is one of the properties in the JSON dictionary.
    • The include tagn almost always contains status.
    • The nested tag describes all other JSON dictionaries that are nested, and this can be recursive. Review the JSON data returned for a command.
    • The options tag describes all possible command arguments, their types, required or not, keyword required or not, and an optional description.
  • In a terminal, run make generator
  • In an editor, copy internal/generator/generator-example.conf to internal/generator/generator.conf and modify as needed. This conf file specifies which storage array use for generation.
  • In a terminal, run make rung to create a new api/mc-openapi.yaml
  • Note: The next two commands require docker to be installed and working.
  • In a terminal, run make validate to validate that api/mc-openapi.yaml contains no OpenAPI errors
  • In a terminal, run make generate to generate a new Go client library in pkg/client
  • Note: You may need to update a file or create a new file in pkg/v2 that leverages the new command generated. This isn't required, but the v2 layer was created to provide a simplified layer between the CSI Driver and the MC API.
  • The last step is to run the regression test suite for v1 and/or v2.

Regression Testing Using A Live System

This option runs a API Regression test suite using Ginkgo expressive tests.

This option requires a configuration file, for example: api-regression.conf.

Each user should create their own copy of api-regression.conf and not check it in. Please see api-regression-example.conf as an example. Use the ./api-regression -config <filename> option to specify your configuration file.

#
# api-regression configuration
#
# Properties:
#   'mc-ip-addrs:' is required and is the IP Addresses of the storage controller(s) used for testing. At least one address must be specified
#   'protocol" specifies http or https
#   'username' is required and is the login credentials for the storage controller
#   'password' is required and is the login credentials for the storage controller
#
#   'initiator' is an array of host initiators, such as the iSCSI IQN value, or SAS, or FC
#   'pool' is the storage pool used for creating volumes
#
# Notes:
#    To find the iSCSI initiator:
#    sudo cat /etc/iscsi/initiatorname.iscsi | grep -v "##" | awk -F= '{print $2}'
api-regression: 1.0.0

# Example Controller
mc-ip-addrs: ["<ipaddress-a>", "<ipaddress-b>"]
protocol: "https"
username: "<username>"
password: "<password>"
initiator: ["iqn.2004-10.com.ubuntu:01:b6f76364a18"]
pool: "A"

The suggestion is to create your own configuration file and do not check it into the repo. For example: cp api-regression.conf myconfig.conf and then run ./api-regression -debug 4 -config myconfig.conf --ginkgo.v.

There are many options for running Ginkgo test cases, here are a few using an i1.conf configuration file:

  • make regession to build the api-regression executable.
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast --ginkgo.focus "v1" to run all the v1 tests
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast --ginkgo.focus "v2" to run all the v2 tests
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast --ginkgo.focus "v2Login" to run only the v2 Login tests
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast --ginkgo.focus "v2System" to run only the v2 System tests
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast --ginkgo.focus "v2Volume" to run only v2 Volume tests
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast --ginkgo.focus "v2Snapshot" to run only v2 Snapshot tests
  • ./api-regression -config i1.conf -debug 4 --ginkgo.v --ginkgo.fail-fast to run only all tests

There are also many command line flags:

  • ./api-regression --help to see all options
  • -debug level to set the debug level to 0, 1, 2, 3, or 4
  • -config filename to use an alternate configuration file
  • -version to display the api-regression version and exit
  • --ginkgo.fail-fast to stop testing after the first failure
  • --ginkgo.v to run testing in verbose mode

# Packages

No description provided by the author