Skip to content

Instantly share code, notes, and snippets.

@allthingsclowd
Created January 18, 2017 20:14
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/00537c177d6bef818985b2bcec6ee6e0 to your computer and use it in GitHub Desktop.
Save allthingsclowd/00537c177d6bef818985b2bcec6ee6e0 to your computer and use it in GitHub Desktop.
Snippet of K5 router routes update
def update_router_routes(k5token, routerid, routes, region):
# e.g. routes = [{'destination': '192.168.10.0/24', 'nexthop': u'192.168.100.2'}, {'destination': '192.168.11.0/24', 'nexthop': u'192.168.100.2'}]
try:
routerURL = 'https://networking-ex.' + region + \
'.cloud.global.fujitsu.com/v2.0/routers/' + routerid
response = requests.put(routerURL,
headers={'X-Auth-Token': k5token,
'Content-Type': 'application/json'},
json={"router": {"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