Created
January 18, 2017 20:14
-
-
Save allthingsclowd/00537c177d6bef818985b2bcec6ee6e0 to your computer and use it in GitHub Desktop.
Snippet of K5 router routes update
This file contains 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 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