| from requests.auth import HTTPBasicAuth |
| print "usage: find-link onos-node name src-device-id src-port dst-device-id dst-port" |
| srcDeviceId = sys.argv[3] |
| dstDeviceId = sys.argv[5] |
| linksRequest = requests.get('http://' + node + ':8181/onos/v1/links?device=' + |
| srcDeviceId + '&port=' + srcPort, |
| auth=HTTPBasicAuth('onos', 'rocks')) |
| if linksRequest.status_code != 200: |
| linksJson = linksRequest.json() |
| for link in linksJson["links"]: |
| if srcDeviceId == link["src"]["device"]: |
| if dstDeviceId == link["dst"]["device"]: |
| print "@stc " + name + "SrcDevice=" + link["src"]["device"] |
| print "@stc " + name + "SrcPort=" + link["src"]["port"] |
| print "@stc " + name + "DstDevice=" + link["dst"]["device"] |
| print "@stc " + name + "DstPort=" + link["dst"]["port"] |
| print "@stc " + name + "Type=" + link["type"] |
| print "@stc " + name + "State=" + link["state"] |