Esempio n. 1
0
    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("delete_network() called\n")
        db.validate_network_ownership(tenant_id, net_id)
        net = db.network_get(net_id)
        if net:
            if len(net[const.NETWORKPORTS]) > 0:
                ports_on_net = db.port_list(net_id)
                for port in ports_on_net:
                    if port[const.INTERFACEID]:
                        raise exc.NetworkInUse(net_id=net_id)
                for port in ports_on_net:
                    self.delete_port(tenant_id, net_id, port[const.UUID])

            self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
            net_dict = cutil.make_net_dict(net[const.UUID],
                                           net[const.NETWORKNAME],
                                           [])
            self._release_vlan_for_tenant(tenant_id, net_id)
            cdb.remove_vlan_binding(net_id)
            db.network_destroy(net_id)
            return net_dict
        # Network not found
        raise exc.NetworkNotFound(net_id=net_id)
Esempio n. 2
0
 def update_network(self, tenant_id, net_id, **kwargs):
     """
     Updates the symbolic name belonging to a particular
     Virtual Network.
     """
     LOG.debug("update_network() called\n")
     db.validate_network_ownership(tenant_id, net_id)
     network = db.network_update(net_id, tenant_id, **kwargs)
     self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, kwargs])
     net_dict = cutil.make_net_dict(network[const.UUID], network[const.NETWORKNAME], [])
     return net_dict
Esempio n. 3
0
    def create_port(self, tenant_id, net_id, port_state=None, **kwargs):
        """
        Creates a port on the specified Virtual Network.
        """
        LOG.debug("create_port() called\n")

        db.validate_network_ownership(tenant_id, net_id)
        port = db.port_create(net_id, port_state)
        unique_port_id_string = port[const.UUID]
        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, port_state, unique_port_id_string])
        new_port_dict = cutil.make_port_dict(
            port[const.UUID], port[const.PORTSTATE], port[const.NETWORKID], port[const.INTERFACEID]
        )
        return new_port_dict
Esempio n. 4
0
    def create_multiport(self, tenant_id, net_id_list, port_state, ports_desc):
        """
        Creates multiple ports on the specified Virtual Network.
        """
        LOG.debug("create_ports() called\n")
        ports_num = len(net_id_list)
        ports_id_list = []
        ports_dict_list = []

        for net_id in net_id_list:
            db.validate_network_ownership(tenant_id, net_id)
            port = db.port_create(net_id, port_state)
            ports_id_list.append(port[const.UUID])
            port_dict = {const.PORT_ID: port[const.UUID]}
            ports_dict_list.append(port_dict)

        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id_list, ports_num, ports_id_list])
        return ports_dict_list
Esempio n. 5
0
    def get_all_ports(self, tenant_id, net_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("get_all_ports() called\n")
        db.validate_network_ownership(tenant_id, net_id)
        network = db.network_get(net_id)
        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
        ports_list = network[const.NETWORKPORTS]
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(
                port[const.UUID], port[const.PORTSTATE], port[const.NETWORKID], port[const.INTERFACEID]
            )
            ports_on_net.append(new_port)

        return ports_on_net
Esempio n. 6
0
    def get_network_details(self, tenant_id, net_id):
        """
        Gets the details of a particular network
        """
        LOG.debug("get_network_details() called\n")
        db.validate_network_ownership(tenant_id, net_id)
        network = db.network_get(net_id)
        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id])
        ports_list = network[const.NETWORKPORTS]
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(
                port[const.UUID], port[const.PORTSTATE], port[const.NETWORKID], port[const.INTERFACEID]
            )
            ports_on_net.append(new_port)

        new_network = cutil.make_net_dict(network[const.UUID], network[const.NETWORKNAME], ports_on_net)

        return new_network