Huawei

OceanStor Storage API

Links:

API URL-Schema:

https://${ip}:${port}/deviceManager/rest/${deviceId}

Authentifizierung über /sessions-Endpoint. Zurückgeliefertes Cookie und iBaseToken speichern:

curl --silent --insecure --request POST \
    --data '{"username":"user", "password":"pass", "scope": "0"}' \
    --cookie-jar cookie.txt \
    https://$IP:$PORT/deviceManager/rest/$DEVICEID/sessions/ | jq

Ergebnis:

{
  "data": {
    "accountstate": 1,
    "deviceid": "4711",
    "iBaseToken": "81CDA80F4CADB5D4C04C3EB628E0A2282825D68",
    "lastloginip": "192.168.209.74",
    "lastlogintime": 1637141739,
    "pwdchangetime": 3600,
    "roleId": "13",
    "usergroup": "",
    "userid": "user",
    "username": "user",
    "userscope": "0"
  },
  "error": {
    "code": 0,
    "description": "0"
  }
}

iBaseToken notieren, und damit die nächste Abfrage tätigen, z.B. um Informationen über das System erhalten:

IBASETOKEN='81CDA80F4CADB5D4C04C3EB628E0A2282825D68'
curl --silent --insecure  \
    --header "iBaseToken:$IBASETOKEN" \
    --header 'Content-Type:application/json' \
    --cookie cookie.txt \
    https://$IP:$PORT/deviceManager/rest/$DEVICEID/system/ | jq

Ergebnis:

{
  "data": {
    "CACHEWRITEQUOTA": "333",
    "CONFIGMODEL": "1",
    "DESCRIPTION": "",
    "DOMAINNAME": "",
    "FREEDISKSCAPACITY": "0",
    "HEALTHSTATUS": "1",
    "HOTSPAREDISKSCAPACITY": "0",
    "ID": "4711",
    "LOCATION": "my-location",
    "MEMBERDISKSCAPACITY": "1560000000000",
    "NAME": "my-dorado",
    "PRODUCTMODE": "816",
    "PRODUCTVERSION": "V600R005C03",
    "RUNNINGSTATUS": "1",
    "SECTORSIZE": "512",
    "STORAGEPOOLCAPACITY": "1314781829494",
    "STORAGEPOOLFREECAPACITY": "1295813864102",
    "STORAGEPOOLHOSTSPARECAPACITY": "13874861011",
    "STORAGEPOOLRAWCAPACITY": "1442985545244",
    "STORAGEPOOLUSEDCAPACITY": "18967965392",
    "THICKLUNSALLOCATECAPACITY": "0",
    "THICKLUNSUSEDCAPACITY": "-1",
    "THINLUNSALLOCATECAPACITY": "54351129344",
    "THINLUNSMAXCAPACITY": "755914244096",
    "THINLUNSUSEDCAPACITY": "-1",
    "TOTALCAPACITY": "1560000000000",
    "TYPE": 201,
    "UNAVAILABLEDISKSCAPACITY": "0",
    "USEDCAPACITY": "18967965392",
    "VASA_ALTERNATE_NAME": "my-dorado",
    "VASA_SUPPORT_BLOCK": "FC,FCOE,ISCSI,Others",
    "VASA_SUPPORT_FILESYSTEM": "",
    "VASA_SUPPORT_PROFILE": "BlockDeviceProfile,CapabilityProfile,VirtualVolumeProfile",
    "WRITETHROUGHSW": "1",
    "WRITETHROUGHTIME": "192",
    "mappedLunsCountCapacity": "755914244096",
    "patchVersion": "SPH12",
    "pointRelease": "6.1.0.SPH12",
    "productModeString": "OceanStor Dorado 8000 V6",
    "unMappedLunsCountCapacity": "0",
    "userFreeCapacity": "2700793283293",
    "wwn": "2100046eca"
  },
  "error": {
    "code": 0,
    "description": "0"
  }
}

Falls man trotz korrekter Credentials ein This operation fails to be performed because of the unauthorized REST. Before performing this operation, ensure that REST is authorized. erhält, hat evtl. ein Rate Limit zugeschlagen - meistens hilft es, die Abfrage direkt im Anschluss einfach nochmal zu wiederholen:

{
  "data": {},
  "error": {
    "code": -401,
    "description": "This operation fails to be performed because of the unauthorized REST.",
    "suggestion": "Before performing this operation, ensure that REST is authorized."
  }
}

Built on 2022-06-03