blob: e87a4090ce16947932a5067776c98e2679c92b2a [file] [log] [blame]
Ray Milkey4ff514c2015-09-01 09:02:03 -07001#! /usr/bin/env python
2
3import requests
4import sys
5import urllib
6
7from requests.auth import HTTPBasicAuth
8
9if len(sys.argv) != 4:
10 print "usage: find-host onos-node name device-id"
11 sys.exit(1)
12
13node = sys.argv[1]
14name = sys.argv[2]
15id = sys.argv[3]
16
17hostRequest = requests.get('http://' + node + ':8181/onos/v1/hosts/' +
18 urllib.quote_plus(id),
19 auth=HTTPBasicAuth('onos', 'rocks'))
20
21if hostRequest.status_code != 200:
22 print hostRequest.text
23 sys.exit(1)
24
25hostJson = hostRequest.json()
26
27print "@stc " + name + "Id=" + hostJson["id"]
28print "@stc " + name + "Mac=" + hostJson["mac"]
29print "@stc " + name + "IpAddress=" + hostJson["ipAddresses"][0]
30
31sys.exit(0)
32
33
34
35
36