Last active
January 18, 2017 17:37
-
-
Save allthingsclowd/5dba8fc8566eb92ef5eb71ac95bc0346 to your computer and use it in GitHub Desktop.
K5 Port creation API call
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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