Ray Milkey | a0f983b | 2016-06-23 19:39:55 -0700 | [diff] [blame] | 1 | #! /usr/bin/env python |
| 2 | |
| 3 | import requests |
| 4 | |
| 5 | from requests.auth import HTTPBasicAuth |
| 6 | import sys |
| 7 | |
| 8 | if len(sys.argv) != 3: |
| 9 | print "usage: post-netcfg onos-node json-file-name" |
| 10 | sys.exit(1) |
| 11 | |
| 12 | node = sys.argv[1] |
| 13 | configFileName = sys.argv[2] |
| 14 | |
| 15 | jsonFile = open(configFileName, 'rb') |
| 16 | configJson = jsonFile.read() |
| 17 | |
| 18 | request = requests.post('http://' + node + ':8181/onos/v1/network/configuration', |
| 19 | auth=HTTPBasicAuth('onos', 'rocks'), |
| 20 | data=configJson) |
| 21 | |
| 22 | if request.status_code != 200: |
| 23 | print request.text |
| 24 | sys.exit(1) |
| 25 | |
| 26 | sys.exit(0) |
| 27 | |
| 28 | |
| 29 | |