PowerFlex Manager API
PowerFlex Manager API
PowerFlex Manager API
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 use case demonstrates how to create an NVMe host in PowerFlex Manager.
Name of host
The host nqn identifier
The maximum number of paths
The maximum number of target ports
#Import modules
import requests
import json
import urllib3
url = f'https://{pfxm}/api/types/Host/instances'
payload = json.dumps({
"name": f"{hostName}",
"nqn": f"{hostNqn}",
"maxNumPaths": f"{maxPaths}",
"maxNumSysPorts": f"{maxTargetPorts}"
3
PowerFlex Manager API
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
return response.content
#PFxM host
pfxm = 'pfmp.powerflex.lab'
hostName = 'host1'
hostNqn = 'nqn.2014-08.org.nvmexpress:uuid:4c1c111-0031-4710-8036-
b8c04f425a32'
maxPaths = '4'
maxTargetPorts = '10'
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
import urllib3
url = f'https
://{pfxm}/Api/V1/Deployment/{deploymentID}/addvolumes'
payload = json.dumps({
"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',
return response
#PFxM host
pfxm = 'pfmp.powerflex.lab'
username = 'admin'
password = 'Password'
deploymentID = '8aaa3a1c82c8df1a0182cc226f6b79d3'
volName = 'restvol001'
volSize = '16777216'
spID = 'c5d4313100000000'
volType = 'thin'
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
X-dell.auth-key
X-dell-auth-signature
X-dell-auth-timestamp
Authentication process:
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
loginUri = "https://{}/Api/V1/Authenticate".format(Srv)
'Accept': 'application/json'}
Conn = requests.Session()
Conn.headers = hdr
Conn.verify = False
authCred = {
"username": Usr,
"domain": Domain,
"password": Pwd
# print(item)
# print(rAuth.text)
AuthJson = rAuth.json()
# print(item)
fmApiKey = str.format(AuthJson.get('apiKey'))
fmApiKeyEnc = fmApiKey.encode()
8
PowerFlex Manager API
# print(type(fmApiKey))
fmApiSecret = str.format(AuthJson.get('apiSecret'))
fmApiSecretEnc = fmApiSecret.encode()
# print(type(fmApiSecret))
timerightnow = str(int(datetime.datetime.now().timestamp()))
# print(type(timerightnow))
# uAgent = "PostmanRuntime/7.28.2"
deployURI =
"https://{}/Api/V1/Deployment/2c9e649e78d6b7c00178e2a59ff63f9a/firmware/compli
ancereport".format(Srv)
deployURIpath =
"/Api/V1/Deployment/2c9e649e78d6b7c00178e2a59ff63f9a/firmware/compliancerep
ort"
reqStringEnc = reqString.encode()
print("reqString is : {}".format(reqString))
# print(type(reqString))
9
PowerFlex Manager API
reqHeadHash = hmac.digest(fmApiSecretEnc, reqStringEnc, hashlib.sha256)
# print(type(reqHeadHash))
reqHeadHashb64 = base64.b64encode(reqHeadHash)
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
Conn.headers = reqHeaderNow
rDeployments = Conn.get(deployURI)
print("status is : {}".format(rDeployments.status_code))
print(rDeployments.text)
10
PowerFlex Manager API