PowerFlex Manager API
(PowerFlex REST API Introduction)
Mar 2023
1
Table Of Contents
Use cases
Create an NVMe host
Add volume to a resource group
Get compliance report
2
PowerFlex Manager API
Use cases
This section provides examples for the PowerFlex block API.
Create an NVMe host
Add a volume to a resource group
Get deployment compliance report (PowerFlex Manager 3.x)
Create an NVMe host
This use case demonstrates how to create an NVMe host in PowerFlex Manager.
The following data is required for our JSON payload:
Name of host
The host nqn identifier
The maximum number of paths
The maximum number of target ports
#Import modules
import requests
import json
from pfauth import authenticate
import urllib3
def createHost(pfxm, accessToken, hostName, hostNqn, maxPaths,
maxTargetPorts):
url = f'[Link]
payload = [Link]({
"name": f"{hostName}",
"nqn": f"{hostNqn}",
"maxNumPaths": f"{maxPaths}",
"maxNumSysPorts": f"{maxTargetPorts}"
3
PowerFlex Manager API
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {accessToken}'
response = [Link](url, headers=headers, data=payload, verify=False)
return [Link]
#Prompt user for PowerFlex Manager username and password.
username = input('Enter PowerFlex Manager username:')
password = [Link]('Enter password:')
#Pass variables to the authenticate() function.
accessToken = authenticate(username, password)
#PFxM host
pfxm = '[Link]'
#Variables for JSON payload
hostName = 'host1'
hostNqn = '[Link]:uuid:4c1c111-0031-4710-8036-
b8c04f425a32'
maxPaths = '4'
maxTargetPorts = '10'
#Call createHost function
response = createHost(hostName, hostNqn, maxPaths, maxTargetPorts)
Add volume to a resource group
4
PowerFlex Manager API
This use case demonstrates the steps required to add a volume to a storage-only
resource group.
#Import modules
import requests
import json
from pfauth import authenticate
import urllib3
#Expand resource group by adding volume
def addVolume(pfxm, accessToken, deploymentID, volName, volSize, spID,
volType):
url = f'https
://{pfxm}/Api/V1/Deployment/{deploymentID}/addvolumes'
payload = [Link]({
"volumeRequests": [{
"numAutoGenerateVolumes": 0,
"volumeActionType": "NEW",
"volume": {
"name":f'{volName}',
"compressionMethod": "false",
"sizeInKb": f'{volSize}',
"storagePoolId": f'{spID}',
"volumeType": f'{volType}'}
}]
})
5
PowerFlex Manager API
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {accessToken}'
response = [Link](url, headers=headers, data=payload, verify=False)
return response
#PFxM host
pfxm = '[Link]'
#PowerFlex Manager username and password.
username = 'admin'
password = 'Password'
#Pass variables to the authenticate() function.
accessToken = authenticate(username, password)
#Target Deployment/Resource Group
deploymentID = '8aaa3a1c82c8df1a0182cc226f6b79d3'
#Variables for JSON payload
volName = 'restvol001'
volSize = '16777216'
spID = 'c5d4313100000000'
volType = 'thin'
#Call the addVolume function and pass required variables.
returnCode = addVolume(deploymentID,volName,volSize,spID,volType)
print (f'{returnCode}')
6
PowerFlex Manager API
Get compliance report
This use case prints the compliance report for a specified deployment. This example
uses PowerFlex Manager 3.x, which uses three custom headers for authentication.
Custom headers
[Link]-key
X-dell-auth-signature
X-dell-auth-timestamp
Authentication process:
1. Call POST /Api/V1/Authenticate.
2. Concatenate the five values returned from the authentication call.
3. Compute a Base64 encoded SHA-256 HMAC digest of the concatenated request
string using the apiSecret obtained from the POST to /Api/V1/Authenticate call.
a. Compute the SHA-256 HMAC digest
b. Encode the HMAC digest using Base64
4. Set the three custom headers
import datetime
import hmac
import hashlib
import requests
import base64
import time
import sys
import getpass
# PFxM credentials
Usr = "admin"
Pwd = "password123"
Domain = "VXLOCAL"
7
PowerFlex Manager API
# PFxM IP address
srv: str = "[Link]"
loginUri = "[Link]
# print("loginUri is: {}".format(loginUri))
hdr = {'content-type': 'application/json',
'Accept': 'application/json'}
Conn = [Link]()
[Link] = hdr
[Link] = False
authCred = {
"username": Usr,
"domain": Domain,
"password": Pwd
# for item in [Link]():
# print(item)
rAuth = [Link](loginUri, json=authCred)
# print([Link])
AuthJson = [Link]()
# for item in AuthJson:
# print(item)
fmApiKey = [Link]([Link]('apiKey'))
fmApiKeyEnc = [Link]()
print("the api key is : {}".format(fmApiKey))
8
PowerFlex Manager API
# print(type(fmApiKey))
# print("the api keyenc is : {}".format(fmApiKeyEnc))
fmApiSecret = [Link]([Link]('apiSecret'))
fmApiSecretEnc = [Link]()
print("the api secret is : {}".format(fmApiSecret))
# print(type(fmApiSecret))
# print("the api secret enc is : {}".format(fmApiSecretEnc))
timerightnow = str(int([Link]().timestamp()))
print("the time is : {}".format(timerightnow))
# print(type(timerightnow))
# uAgent = "PostmanRuntime/7.28.2"
uAgent = "My User Agent 1.0"
print("user agent is : {}".format(uAgent))
deployURI =
"[Link]
ancereport".format(Srv)
print("the uri is : {}".format(deployURI))
deployURIpath =
"/Api/V1/Deployment/2c9e649e78d6b7c00178e2a59ff63f9a/firmware/compliancerep
ort"
print("the uri path is : {}".format(deployURIpath))
reqString = fmApiKey + ":" + "GET" + ":" + deployURIpath + ":" + uAgent + ":" +
timerightnow
reqStringEnc = [Link]()
print("reqString is : {}".format(reqString))
# print(type(reqString))
9
PowerFlex Manager API
reqHeadHash = [Link](fmApiSecretEnc, reqStringEnc, hashlib.sha256)
# print(type(reqHeadHash))
# print("the digest is : {}".format(reqHeadHash))
reqHeadHashb64 = base64.b64encode(reqHeadHash)
print("the base 64 encoded value is : {}".format(reqHeadHashb64))
reqHeaderNow = {
'content-type': 'application/json',
'Accept': 'application/json',
'User-Agent': uAgent,
'x-dell-auth-key': fmApiKey,
'x-dell-auth-signature': reqHeadHashb64,
'x-dell-auth-timestamp': timerightnow
[Link] = reqHeaderNow
rDeployments = [Link](deployURI)
print("status is : {}".format(rDeployments.status_code))
print([Link])
10
PowerFlex Manager API