blob: bc69d98025da17f83317a515dd4f9fab8499759f [file] [log] [blame]
#! /usr/bin/env python
import requests
from requests.auth import HTTPBasicAuth
import sys
if len(sys.argv) != 5:
print "usage: change-device-portstate onos-node device-id port new_enabled_state"
sys.exit(1)
node = sys.argv[1]
device_id = sys.argv[2]
port = sys.argv[3]
new_enabled_state = sys.argv[4]
payload = '{ "enabled": ' + new_enabled_state + ' }'
change_request = requests.post('http://' + node + ':8181/onos/v1/devices/' + device_id + '/portstate/' + port,
auth=HTTPBasicAuth('onos', 'rocks'),
data=payload)
if change_request.status_code != 200:
print change_request.text
sys.exit(1)
sys.exit(0)