Created
January 18, 2017 20:20
-
-
Save allthingsclowd/648bb8743b9858873e883f0d993a9ea0 to your computer and use it in GitHub Desktop.
Snippet of K5 API call to update subnet routes
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 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