def __delete_host(self, tenant_id, network_id, host_ip): ret = {} try: hosts = mul.get_fabric_host_all(1) check = 0 for host in hosts: host_flow = host.host_flow if str(tenant_id) == str(mul.nbapi_uuid_to_str( host.tenant_id)) and str(network_id) == str( mul.nbapi_uuid_to_str(host.network_id) ) and str(host_ip) == str( mul.nbapi_fab_parse_nw_addr_to_str(host_flow)): host_mac = mul.nbapi_parse_mac_to_str(host_flow.dl_src) check = mul.delete_fabric_host(str(tenant_id), str(network_id), str(host_ip), str(host_mac)) if check == 1: ret.update({'delete host': 'success'}) break elif check == -1: raise Exception, 'Malformed tenant_id' elif check == -2: raise Exception, 'Malformed network_id' elif check == -3: raise Exception, 'Malformed host_ip(nw_src)' elif check == -4: raise Exception, 'Malformed host_mac(dl_src)' elif check == -5: raise Exception, 'failed to delete host' if check == 0: raise Exception, 'no such host' except Exception, e: ret.update({'fail': 'failed to delete host', 'reason': str(e)})
def __delete_host(self, tenant_id, network_id, host_ip): ret = {} try: hosts = mul.get_fabric_host_all(1) check = 0 for host in hosts: host_flow = host.host_flow if ( str(tenant_id) == str(mul.nbapi_uuid_to_str(host.tenant_id)) and str(network_id) == str(mul.nbapi_uuid_to_str(host.network_id)) and str(host_ip) == str(mul.nbapi_fab_parse_nw_addr_to_str(host_flow)) ): host_mac = mul.nbapi_parse_mac_to_str(host_flow.dl_src) check = mul.delete_fabric_host(str(tenant_id), str(network_id), str(host_ip), str(host_mac)) if check == 1: ret.update({"delete host": "success"}) break elif check == -1: raise Exception, "Malformed tenant_id" elif check == -2: raise Exception, "Malformed network_id" elif check == -3: raise Exception, "Malformed host_ip(nw_src)" elif check == -4: raise Exception, "Malformed host_mac(dl_src)" elif check == -5: raise Exception, "failed to delete host" if check == 0: raise Exception, "no such host" except Exception, e: ret.update({"fail": "failed to delete host", "reason": str(e)})
def __delete_host(self, tenant_id, network_id, host_ip): try: hosts = mul.get_fabric_host_all(1, 0) ret = {} check = 0 for host in hosts: host_flow = host.host_flow if str(tenant_id) == str(mul.nbapi_uuid_to_str(host.tenant_id)) and str(network_id) == str(mul.nbapi_uuid_to_str(host.network_id)) and str(host_ip) == str(mul.nbapi_fab_parse_nw_addr_to_str(host_flow)): host_mac = mul.nbapi_parse_mac_to_str(host_flow.dl_src) check = mul.delete_fabric_host(str(tenant_id), str(network_id), str(host_ip), str(host_mac)) if check == 1: ret.update({'delete host' : 'success'}) break elif check == -1: raise Exception , 'Malformed tenant_id' elif check == -2: raise Exception , 'Malformed network_id' elif check == -3: raise Exception , 'Malformed host_ip(nw_src)' elif check == -4: raise Exception , 'Malformed host_mac(dl_src)' elif check == -5: raise Exception , 'failed to delete host' if check == 0: raise Exception , 'no such host' except Exception, e: ret.update({'fail' : 'failed to delete host', 'reason' : str(e)})
def get(self): #, tenant_id=None, network_id=None, host_id=None): logger.debug("request url - %s", self.get_request_uri()) hosts = mul.get_fabric_host_all(1) logger.debug(str(len(hosts))) ret = [] for host in hosts: host_flow = host.host_flow host_ip = mul.nbapi_fab_parse_nw_addr_to_str(host_flow) host_mac = mul.nbapi_parse_mac_to_str(host_flow.dl_src) res_d = { 'tenant_id': mul.nbapi_uuid_to_str(host.tenant_id), 'network_id': mul.nbapi_uuid_to_str(host.network_id), 'dl_src': host_mac, 'nw_src': host_ip, 'switch_dpid': '0x%lx' % host.switch_id.datapath_id, 'port': '%4hu' % host_flow.in_port } ret.append(res_d) self.finish({'hosts': ret})
def get(self): # , tenant_id=None, network_id=None, host_id=None): logger.debug("request url - %s", self.get_request_uri()) hosts = mul.get_fabric_host_all(1) logger.debug(str(len(hosts))) ret = [] for host in hosts: host_flow = host.host_flow host_ip = mul.nbapi_fab_parse_nw_addr_to_str(host_flow) host_mac = mul.nbapi_parse_mac_to_str(host_flow.dl_src) res_d = { "tenant_id": mul.nbapi_uuid_to_str(host.tenant_id), "network_id": mul.nbapi_uuid_to_str(host.network_id), "dl_src": host_mac, "nw_src": host_ip, "switch_dpid": "0x%lx" % host.switch_id.datapath_id, "port": "%4hu" % host_flow.in_port, } ret.append(res_d) self.finish({"hosts": ret})
def get(self):#, tenant_id=None, network_id=None, host_id=None): logger.debug("request url - %s", self.get_request_uri()) hosts = mul.get_fabric_host_all(1) logger.debug(str(len(hosts))) ret = [] for host in hosts: host_flow = host.host_flow host_ip = mul.nbapi_fab_parse_nw_addr_to_str(host_flow) host_mac = mul.nbapi_parse_mac_to_str(host_flow.dl_src) res_d = { 'tenant_id' : mul.nbapi_uuid_to_str(host.tenant_id), 'network_id' : mul.nbapi_uuid_to_str(host.network_id), 'dl_src' : host_mac, 'nw_src' : host_ip, 'switch_dpid' : '0x%lx' % host.switch_id.datapath_id, 'port' : '%4hu' %host_flow.in_port } ret.append(res_d) self.finish({'hosts' : ret })