Beispiel #1
0
    def get_all_ports(self, tenant_id, netw_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.

        :returns: a list of mapping sequences with the following signature:
                     [{'port-id': uuid representing a particular port
                                    on the specified quantum network
                      },
                       ....
                       {'port-id': uuid representing a particular port
                                     on the specified quantum network
                      }
                     ]
        :raises: exception.NetworkNotFound
        """
        ids = []
        filters = kwargs.get("filter_opts") or {}
        if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
            raise exception.NetworkNotFound(net_id=netw_id)
        LOG.debug("Getting logical ports on lswitch: %s" % netw_id)
        lports = nvplib.query_ports(self.controller, netw_id, fields="uuid",
                                    filters=filters)
        for port in lports:
            ids.append({"port-id": port["uuid"]})

        # Delete from the filter so that Quantum doesn't attempt to filter on
        # this too
        if filters and "attachment" in filters:
            del filters["attachment"]

        LOG.debug("get_all_ports() completed for tenant: %s" % tenant_id)
        LOG.debug("returning port listing:")
        LOG.debug(ids)
        return ids
Beispiel #2
0
    def get_network_details(self, tenant_id, netw_id):
        """
        Retrieves a list of all the remote vifs that
        are attached to the network.

        :returns: a sequence of mappings with the following signature:
                    {'net-id': uuid that uniquely identifies the
                                particular quantum network
                     'net-name': a human-readable name associated
                                 with network referenced by net-id
                     'net-ifaces': ['vif1_on_network_uuid',
                                    'vif2_on_network_uuid',...,'vifn_uuid']
                   }
        :raises: exception.NetworkNotFound
        :raises: exception.QuantumException
        """
        if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
            raise exception.NetworkNotFound(net_id=netw_id)
        result = None
        remote_vifs = []
        switch = netw_id
        lports = nvplib.query_ports(self.controller, switch, relations="LogicalPortAttachment")

        for port in lports:
            relation = port["_relations"]
            vic = relation["LogicalPortAttachment"]
            if "vif_uuid" in vic:
                remote_vifs.append(vic["vif_uuid"])

        if not result:
            result = nvplib.get_network(self.controller, switch)

        d = {"net-id": netw_id, "net-ifaces": remote_vifs, "net-name": result["display_name"], "net-op-status": "UP"}
        LOG.debug("get_network_details() completed for tenant %s: %s" % (tenant_id, d))
        return d
Beispiel #3
0
    def get_network_details(self, tenant_id, netw_id):
        """
        Retrieves a list of all the remote vifs that
        are attached to the network.

        :returns: a sequence of mappings with the following signature:
                    {'net-id': uuid that uniquely identifies the
                                particular quantum network
                     'net-name': a human-readable name associated
                                 with network referenced by net-id
                     'net-ifaces': ['vif1_on_network_uuid',
                                    'vif2_on_network_uuid',...,'vifn_uuid']
                   }
        :raises: exception.NetworkNotFound
        :raises: exception.QuantumException
        """
        if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
            raise exception.NetworkNotFound(net_id=netw_id)
        result = None
        remote_vifs = []
        switch = netw_id
        lports = nvplib.query_ports(self.controller,
                                    switch,
                                    relations="LogicalPortAttachment")

        for port in lports:
            relation = port["_relations"]
            vic = relation["LogicalPortAttachment"]
            if "vif_uuid" in vic:
                remote_vifs.append(vic["vif_uuid"])

        if not result:
            result = nvplib.get_network(self.controller, switch)

        d = {
            "net-id": netw_id,
            "net-ifaces": remote_vifs,
            "net-name": result["display_name"],
            "net-op-status": "UP",
        }
        LOG.debug("get_network_details() completed for tenant %s: %s" %
                  (tenant_id, d))
        return d
Beispiel #4
0
    def get_all_ports(self, tenant_id, netw_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.

        :returns: a list of mapping sequences with the following signature:
                     [{'port-id': uuid representing a particular port
                                    on the specified quantum network
                      },
                       ....
                       {'port-id': uuid representing a particular port
                                     on the specified quantum network
                      }
                     ]
        :raises: exception.NetworkNotFound
        """
        ids = []
        filters = kwargs.get("filter_opts") or {}
        if not nvplib.check_tenant(self.controller, netw_id, tenant_id):
            raise exception.NetworkNotFound(net_id=netw_id)
        LOG.debug("Getting logical ports on lswitch: %s" % netw_id)
        lports = nvplib.query_ports(self.controller,
                                    netw_id,
                                    fields="uuid",
                                    filters=filters)
        for port in lports:
            ids.append({"port-id": port["uuid"]})

        # Delete from the filter so that Quantum doesn't attempt to filter on
        # this too
        if filters and "attachment" in filters:
            del filters["attachment"]

        LOG.debug("get_all_ports() completed for tenant: %s" % tenant_id)
        LOG.debug("returning port listing:")
        LOG.debug(ids)
        return ids