예제 #1
0
def getFlowDetails(credentials, topologyIdentity):
    t1 = credentials.socket()
    t2 = (topologyIdentity.openFlowSwitch(), topologyIdentity.table, topologyIdentity.id)
    t = t1 + t2

    url = endpoints.getEndpoints()['flowdetails']['url'] % t
  
    print(url)

    return sendRequest(credentials=credentials, url=url, method = endpoints.getEndpoints()['flowdetails']['method'])
예제 #2
0
def addFlow(credentials, topologyIdentity, data):
    t1 = credentials.socket()
    t2 = (topologyIdentity.openFlowSwitch(), topologyIdentity.table, topologyIdentity.id)
    t = t1 + t2

    print(t)

    url = endpoints.getEndpoints()['addflow']['url'] % t
  
    print(url)

    payload = json.dumps(data)

    print(payload)

    return sendRequest(credentials=credentials, url=url, method = endpoints.getEndpoints()['addflow']['method'], data = payload)
예제 #3
0
def getTopology():
    global _ip, _port, _headers, _username, _password
    auth = (_username, _password)
    url = endpoints.getEndpoints()['topology']['url'] % (_ip, _port)
    print(url)

    response = requests.get(url, auth=auth, headers=_headers)
    data = "undefined"

    if response.status_code / 100 == 2:
        print("response status: %d " % response.status_code)
        data = response.text
        return (response.status_code, data)
    else:
        print("response status: %d " % response.status_code)
        print(response)
        exit(0)
예제 #4
0
def getInventory(credentials):
    url = endpoints.getEndpoints()['inventory']['url'] % credentials.socket()
    print(url)

    return sendRequest(credentials=credentials, url=url, method = endpoints.getEndpoints()['inventory']['method'])