Home > Storage > PowerFlex > White Papers > PowerFlex REST API Introduction > 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:
#Import modules
import requests
import json
from pfauth import authenticate
import urllib3
def createHost(pfxm, accessToken, hostName, hostNqn, maxPaths, maxTargetPorts):
url = f'https://{pfxm}/api/types/Host/instances'
payload = json.dumps({
"name": f"{hostName}",
"nqn": f"{hostNqn}",
"maxNumPaths": f"{maxPaths}",
"maxNumSysPorts": f"{maxTargetPorts}"
})
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {accessToken}'
}
response = requests.post(url, headers=headers, data=payload, verify=False)
return response.content
#Prompt user for PowerFlex Manager username and password.
username = input('Enter PowerFlex Manager username:')
password = getpass.getpass('Enter password:')
#Pass variables to the authenticate() function.
accessToken = authenticate(username, password)
#PFxM host
pfxm = 'pfmp.powerflex.lab'
#Variables for JSON payload
hostName = 'host1'
hostNqn = 'nqn.2014-08.org.nvmexpress:uuid:4c1c111-0031-4710-8036-b8c04f425a32'
maxPaths = '4'
maxTargetPorts = '10'
#Call createHost function
response = createHost(hostName, hostNqn, maxPaths, maxTargetPorts)