Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Created January 18, 2017 20:20
Show Gist options
  • Select an option

  • Save allthingsclowd/648bb8743b9858873e883f0d993a9ea0 to your computer and use it in GitHub Desktop.

Select an option

Save allthingsclowd/648bb8743b9858873e883f0d993a9ea0 to your computer and use it in GitHub Desktop.
Snippet of K5 API call to update subnet routes
def add_static_route_to_subnet(k5token, subnetid, routes, region):
# e.g. routes = = [{'destination': '192.168.101.0/24', 'nexthop': u'192.168.100.2'},{'destination': '192.168.100.0/24', 'nexthop': u'192.168.100.2'}]
subnetURL = 'https://networking.' + region + \
'.cloud.global.fujitsu.com/v2.0/subnets/' + subnetid
try:
response = requests.put(subnetURL,
headers={'X-Auth-Token': k5token,
'Content-Type': 'application/json'},
json={"subnet": {"host_routes": routes}})
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