blob: bc69d98025da17f83317a515dd4f9fab8499759f [file] [log] [blame]
Ray Milkeyf16975b2018-05-15 14:14:24 -07001#! /usr/bin/env python
2
3import requests
4
5from requests.auth import HTTPBasicAuth
6import sys
7
8
9
10if len(sys.argv) != 5:
11 print "usage: change-device-portstate onos-node device-id port new_enabled_state"
12 sys.exit(1)
13
14node = sys.argv[1]
15device_id = sys.argv[2]
16port = sys.argv[3]
17new_enabled_state = sys.argv[4]
18
19payload = '{ "enabled": ' + new_enabled_state + ' }'
20
21change_request = requests.post('http://' + node + ':8181/onos/v1/devices/' + device_id + '/portstate/' + port,
22 auth=HTTPBasicAuth('onos', 'rocks'),
23 data=payload)
24
25if change_request.status_code != 200:
26 print change_request.text
27 sys.exit(1)
28
29sys.exit(0)
30
31
32