def delete_vifinfo(self, interface_id):
     LOG.debug("delete_vifinfo() called")
     port = dbe.get_plugged_port(interface_id)
     if self._port_attachable(port):
         network = db.network_get(port.network_id)
         self._detach(network.tenant_id, network.uuid, port.uuid)
     ndb.del_vifinfo(interface_id)
Esempio n. 2
0
    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("LinuxBridgePlugin.delete_network() called")
        net = db.network_get(net_id)
        if net:
            ports_on_net = db.port_list(net_id)
            if len(ports_on_net) > 0:
                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])

            net_dict = cutil.make_net_dict(net[const.UUID],
                                           net[const.NETWORKNAME],
                                           [], net[const.OPSTATUS])
            try:
                self._release_vlan_for_tenant(tenant_id, net_id)
                cdb.remove_vlan_binding(net_id)
            except Exception as excp:
                LOG.warning("Exception: %s" % excp)
                db.network_update(net_id, tenant_id, {const.OPSTATUS:
                                                      OperationalStatus.DOWN})
            db.network_destroy(net_id)
            return net_dict
        # Network not found
        raise exc.NetworkNotFound(net_id=net_id)
Esempio n. 3
0
 def get_network(self, tenant_id, network_id):
     db.validate_network_ownership(tenant_id, network_id)
     try:
         network = db.network_get(network_id)
     except:
         raise exc.NetworkNotFound(net_id=network_id)
     return network
Esempio n. 4
0
    def delete_network(self, tenant_id, net_id):
        """
        Deletes the network with the specified network identifier
        belonging to the specified tenant.
        """
        LOG.debug("LinuxBridgePlugin.delete_network() called")
        db.validate_network_ownership(tenant_id, net_id)
        net = db.network_get(net_id)
        if net:
            ports_on_net = db.port_list(net_id)
            if len(ports_on_net) > 0:
                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])

            net_dict = cutil.make_net_dict(net[const.UUID],
                                           net[const.NETWORKNAME], [],
                                           net[const.OPSTATUS])
            try:
                self._release_vlan_for_tenant(tenant_id, net_id)
                cdb.remove_vlan_binding(net_id)
            except Exception as excp:
                LOG.warning("Exception: %s" % excp)
                db.network_update(net_id, tenant_id,
                                  {const.OPSTATUS: OperationalStatus.DOWN})
            db.network_destroy(net_id)
            return net_dict
        # Network not found
        raise exc.NetworkNotFound(net_id=net_id)
 def add_vifinfo(self, interface_id, datapath_id, port_no, vlan_id=65535):
     LOG.debug("add_vifinfo() called")
     ndb.add_vifinfo(interface_id, datapath_id, port_no, vlan_id)
     port = dbe.get_plugged_port(interface_id)
     if self._port_attachable(port):
         network = db.network_get(port.network_id)
         self._attach(network.tenant_id, network.uuid, port.uuid,
                      interface_id)
 def _get_network(self, tenant_id, network_id):
     network = db.network_get(network_id)
     # Network must exist and belong to the appropriate tenant.
     if network.tenant_id != tenant_id:
         LOG.warning("_get_network(): mismatch tenant_id = %s, "
                     "network_id = %s, network.tenant_id = %s" %
                     (tenant_id, network_id, network.tenant_id))
         raise exc.NetworkNotFound(net_id=network_id)
     return network
Esempio n. 7
0
 def get_port_details(self, tenant_id, net_id, port_id):
     """
     This method allows the user to retrieve a remote interface
     that is attached to this particular port.
     """
     LOG.debug("LinuxBridgePlugin.get_port_details() called")
     network = db.network_get(net_id)
     port = db.port_get(port_id, net_id)
     new_port_dict = cutil.make_port_dict(port)
     return new_port_dict
Esempio n. 8
0
 def update_network(self, tenant_id, net_id, **kwargs):
     """
     Updates the symbolic name belonging to a particular
     Virtual Network.
     """
     LOG.debug("UCSVICPlugin:update_network() called\n")
     self._set_ucsm(kwargs[const.DEVICE_IP])
     network = db.network_get(net_id)
     net_dict = cutil.make_net_dict(network[const.UUID],
                                    network[const.NETWORKNAME], [])
     return net_dict
Esempio n. 9
0
    def update_port(self, tenant_id, net_id, port_id, **kwargs):
        """
        Updates the attributes of a port on the specified Virtual Network.
        """
        LOG.debug("LinuxBridgePlugin.update_port() called")
        network = db.network_get(net_id)
        self._validate_port_state(kwargs["state"])
        port = db.port_update(port_id, net_id, **kwargs)

        new_port_dict = cutil.make_port_dict(port)
        return new_port_dict
Esempio n. 10
0
    def delete_network(self, tenant_id, net_id):
        net = db.network_get(net_id)

        # Verify that no attachments are plugged into the network
        for port in db.port_list(net_id):
            if port.interface_id:
                raise q_exc.NetworkInUse(net_id=net_id)
        net = db.network_destroy(net_id)
        ovs_db.remove_vlan_binding(net_id)
        self.vmap.release(net_id)
        return self._make_net_dict(str(net.uuid), net.name, [])
Esempio n. 11
0
    def delete_network(self, tenant_id, net_id):
        net = db.network_get(net_id)

        # Verify that no attachments are plugged into the network
        for port in db.port_list(net_id):
            if port.interface_id:
                raise q_exc.NetworkInUse(net_id=net_id)
        net = db.network_destroy(net_id)
        ovs_db.remove_vlan_binding(net_id)
        self.vmap.release(net_id)
        return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
Esempio n. 12
0
    def delete_network(self, tenant_id, net_id):
        db.validate_network_ownership(tenant_id, net_id)
        net = db.network_get(net_id)

        # Verify that no attachments are plugged into the network
        for port in db.port_list(net_id):
            if port.interface_id:
                raise q_exc.NetworkInUse(net_id=net_id)
        net = db.network_destroy(net_id)
        self.driver.delete_network(net)
        return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
Esempio n. 13
0
    def delete_network(self, tenant_id, net_id):
        db.validate_network_ownership(tenant_id, net_id)
        net = db.network_get(net_id)

        # Verify that no attachments are plugged into the network
        for port in db.port_list(net_id):
            if port.interface_id:
                raise q_exc.NetworkInUse(net_id=net_id)
        net = db.network_destroy(net_id)
        self.driver.delete_network(net)
        return self._make_net_dict(str(net.uuid), net.name, [], net.op_status)
Esempio n. 14
0
 def update_network(self, tenant_id, net_id, **kwargs):
     """
     Updates the symbolic name belonging to a particular
     Virtual Network.
     """
     LOG.debug("UCSVICPlugin:update_network() called\n")
     self._set_ucsm(kwargs[const.DEVICE_IP])
     network = db.network_get(net_id)
     net_dict = cutil.make_net_dict(network[const.UUID],
                                    network[const.NETWORKNAME],
                                    [])
     return net_dict
Esempio n. 15
0
 def get_network(self, network_id):
     """Get a network"""
     net = []
     try:
         for net in db.network_get(network_id):
             LOG.debug("Getting network: %s", net.uuid)
             net_dict = {}
             net_dict["tenant_id"] = net.tenant_id
             net_dict["id"] = str(net.uuid)
             net_dict["name"] = net.name
             net.append(net_dict)
     except Exception, exc:
         LOG.error("Failed to get network: %s", str(exc))
 def get_network(self, network_id):
     """Get a network"""
     net = []
     try:
         for net in db.network_get(network_id):
             LOG.debug("Getting network: %s" % net.uuid)
             net_dict = {}
             net_dict["tenant-id"] = net.tenant_id
             net_dict["net-id"] = str(net.uuid)
             net_dict["net-name"] = net.name
             net.append(net_dict)
     except Exception, exc:
         LOG.error("Failed to get network: %s" % str(exc))
Esempio n. 17
0
 def plug_interface(self, tenant_id, net_id, port_id, remote_interface_id):
     """
     Attaches a remote interface to the specified port on the
     specified Virtual Network.
     """
     LOG.debug("LinuxBridgePlugin.plug_interface() called")
     network = db.network_get(net_id)
     port = db.port_get(port_id, net_id)
     attachment_id = port[const.INTERFACEID]
     if attachment_id:
         raise exc.PortInUse(port_id=port_id, net_id=net_id,
                             att_id=attachment_id)
     db.port_set_attachment(port_id, net_id, remote_interface_id)
Esempio n. 18
0
 def unplug_interface(self, tenant_id, net_id, port_id):
     """
     Detaches a remote interface from the specified port on the
     specified Virtual Network.
     """
     LOG.debug("LinuxBridgePlugin.unplug_interface() called")
     network = db.network_get(net_id)
     port = db.port_get(port_id, net_id)
     attachment_id = port[const.INTERFACEID]
     if attachment_id == None:
         raise exc.InvalidDetach(port_id=port_id, net_id=net_id,
                                 att_id=remote_interface_id)
     db.port_unset_attachment(port_id, net_id)
     db.port_update(port_id, net_id, op_status=OperationalStatus.DOWN)
Esempio n. 19
0
    def get_all_ports(self, tenant_id, net_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("UCSVICPlugin:get_all_ports() called\n")
        self._set_ucsm(kwargs[const.DEVICE_IP])
        network = db.network_get(net_id)
        ports_list = network[const.NETWORKPORTS]
        ports_on_net = []
        for port in ports_list:
            port_binding = udb.get_portbinding(port[const.UUID])
            ports_on_net.append(port_binding)

        return ports_on_net
Esempio n. 20
0
    def get_all_ports(self, tenant_id, net_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("LinuxBridgePlugin.get_all_ports() called")
        network = db.network_get(net_id)
        ports_list = db.port_list(net_id)
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(port)
            ports_on_net.append(new_port)

        # This plugin does not perform filtering at the moment
        return ports_on_net
Esempio n. 21
0
    def get_all_ports(self, tenant_id, net_id, **kwargs):
        """
        Retrieves all port identifiers belonging to the
        specified Virtual Network.
        """
        LOG.debug("UCSVICPlugin:get_all_ports() called\n")
        self._set_ucsm(kwargs[const.DEVICE_IP])
        network = db.network_get(net_id)
        ports_list = network[const.NETWORKPORTS]
        ports_on_net = []
        for port in ports_list:
            port_binding = udb.get_portbinding(port[const.UUID])
            ports_on_net.append(port_binding)

        return ports_on_net
Esempio n. 22
0
 def delete_port(self, tenant_id, net_id, port_id):
     """
     Deletes a port on a specified Virtual Network,
     if the port contains a remote interface attachment,
     the remote interface is first un-plugged and then the port
     is deleted.
     """
     LOG.debug("LinuxBridgePlugin.delete_port() called")
     network = db.network_get(net_id)
     port = db.port_get(port_id, net_id)
     attachment_id = port[const.INTERFACEID]
     if not attachment_id:
         db.port_destroy(port_id, net_id)
         new_port_dict = cutil.make_port_dict(port)
         return new_port_dict
     else:
         raise exc.PortInUse(port_id=port_id, net_id=net_id,
                             att_id=attachment_id)
Esempio n. 23
0
    def get_network_details(self, tenant_id, net_id):
        """
        retrieved a list of all the remote vifs that
        are attached to the network
        """
        LOG.debug("LinuxBridgePlugin.get_network_details() called")
        network = db.network_get(net_id)
        ports_list = db.port_list(net_id)
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(port)
            ports_on_net.append(new_port)

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

        return new_network
Esempio n. 24
0
    def get_network_details(self, tenant_id, net_id):
        """
        retrieved a list of all the remote vifs that
        are attached to the network
        """
        LOG.debug("LinuxBridgePlugin.get_network_details() called")
        db.validate_network_ownership(tenant_id, net_id)
        network = db.network_get(net_id)
        ports_list = db.port_list(net_id)
        ports_on_net = []
        for port in ports_list:
            new_port = cutil.make_port_dict(port)
            ports_on_net.append(new_port)

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

        return new_network
Esempio n. 25
0
    def get_network_details(self, tenant_id, net_id, **kwargs):
        """
        Deletes the Virtual Network belonging to a the
        spec
        """
        LOG.debug("UCSVICPlugin:get_network_details() called\n")
        self._set_ucsm(kwargs[const.DEVICE_IP])
        network = db.network_get(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
Esempio n. 26
0
    def get_network_details(self, tenant_id, net_id, **kwargs):
        """
        Deletes the Virtual Network belonging to a the
        spec
        """
        LOG.debug("UCSVICPlugin:get_network_details() called\n")
        self._set_ucsm(kwargs[const.DEVICE_IP])
        network = db.network_get(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
Esempio n. 27
0
 def get_network_details(self, tenant_id, net_id):
     db.validate_network_ownership(tenant_id, net_id)
     net = db.network_get(net_id)
     ports = self.get_all_ports(tenant_id, net_id)
     return self._make_net_dict(str(net.uuid), net.name,
                                ports, net.op_status)
Esempio n. 28
0
 def _get_network(self, tenant_id, network_id):
     try:
         network = db.network_get(network_id)
     except:
         raise exc.NetworkNotFound(net_id=network_id)
     return network
Esempio n. 29
0
 def get_network_details(self, tenant_id, net_id):
     net = db.network_get(net_id)
     ports = self.get_all_ports(tenant_id, net_id)
     return self._make_net_dict(str(net.uuid), net.name, ports)
Esempio n. 30
0
 def get_network_details(self, tenant_id, net_id):
     db.validate_network_ownership(tenant_id, net_id)
     net = db.network_get(net_id)
     ports = self.get_all_ports(tenant_id, net_id)
     return self._make_net_dict(str(net.uuid), net.name, ports,
                                net.op_status)
Esempio n. 31
0
 def _get_network(self, tenant_id, network_id):
     try:
         network = db.network_get(network_id)
     except:
         raise exc.NetworkNotFound(net_id=network_id)
     return network