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'])
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)
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)
def getInventory(credentials): url = endpoints.getEndpoints()['inventory']['url'] % credentials.socket() print(url) return sendRequest(credentials=credentials, url=url, method = endpoints.getEndpoints()['inventory']['method'])