コード例 #1
0
ファイル: nvplib.py プロジェクト: roaet/aicq
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
コード例 #2
0
ファイル: nvplib.py プロジェクト: roaet/aicq
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