Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Last active January 18, 2017 17:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save allthingsclowd/5dba8fc8566eb92ef5eb71ac95bc0346 to your computer and use it in GitHub Desktop.
Save allthingsclowd/5dba8fc8566eb92ef5eb71ac95bc0346 to your computer and use it in GitHub Desktop.
K5 Port creation API call
def create_port(k5token, name, netid, sg_id, az, region):
portURL = 'https://networking.' + region + \
'.cloud.global.fujitsu.com/v2.0/ports'
try:
response = requests.post(portURL,
headers={
'X-Auth-Token': k5token, 'Content-Type': 'application/json', 'Accept': 'application/json'},
json={"port":
{"network_id": netid,
"name": name,
"admin_state_up": True,
"availability_zone": az,
"security_groups":
[sg_id]}})
return response
except:
return ("\nUnexpected error:", sys.exc_info())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment