Home > Storage > PowerFlex > White Papers > PowerFlex REST API Introduction > Add volume to a resource group
This use case demonstrates the steps required to add a volume to a storage-only resource group.
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 = json.dumps({
"volumeRequests": [{
"numAutoGenerateVolumes": 0,
"volumeActionType": "NEW",
"volume": {
"name":f'{volName}',
"compressionMethod": "false",
"sizeInKb": f'{volSize}',
"storagePoolId": f'{spID}',
"volumeType": f'{volType}'}
}]
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {accessToken}'
}
response = requests.post(url, headers=headers, data=payload, verify=False)
return response
#PFxM host
pfxm = 'pfmp.powerflex.lab'
#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}')