def query_networks(controller, tenant_id, fields="*", tags=None): if isinstance(controller, aicq.blue.Blue): blue = controller try: resp = blue.query_networks(tenant_id, fields, tags) except aiclib.nvp.NVPException: raise exception.QuantumException() if not resp: return [] switches = resp["results"] nets = [{"id": switch["uuid"], "name": switch["display_name"]} for switch in switches] return nets
def get_all_networks(controller, tenant_id, networks): if isinstance(controller, aicq.blue.Blue): blue = controller try: resp = blue.query_networks(tenant_id, fields=["uuid", "display_name"]) except aiclib.nvp.NVPException: raise exception.QuantumException() switches = resp["results"] for switch in switches: net_id = switch["uuid"] if net_id not in [x["id"] for x in networks]: networks.append({"id": net_id, "name": switch["display_name"]}) return networks