def unplug_interface(self, net_id, port_id):
     """Unplug interface to a port"""
     try:
         db.port_unset_attachment(port_id, net_id)
         LOG.debug("Detached interface from port %s", port_id)
     except Exception, exc:
         LOG.error("Failed to unplug interface: %s", str(exc))
Example #2
0
 def unplug_interface(self, net_id, port_id):
     """Unplug interface to a port."""
     try:
         db.port_unset_attachment(port_id, net_id)
         LOG.debug("Detached interface from port %s", port_id)
     except Exception as exc:
         LOG.error("Failed to unplug interface: %s", str(exc))
Example #3
0
    def unplug_interface(self, tenant_id, net_id, port_id):
        """
        Detaches a remote interface from the specified port on the
        specified Virtual Network.

        :returns: None
        :raises: exception.NetworkNotFound
        :raises: exception.PortNotFound
        """
        LOG.debug("QuantumRestProxy: unplug_interface() called")
        self.get_port(tenant_id, net_id, port_id)

        # Update DB
        db.port_unset_attachment(port_id, net_id)

        # delete from network ctrl. Remote error on delete is ignored
        try:
            resource = '/tenants/%s/networks/%s/ports/%s/attachment' % (
                    tenant_id, net_id, port_id)
            ret = self.servers.delete(resource)
            if not self.servers.action_success(ret):
                raise RemoteRestError(ret[2])
        except RemoteRestError as e:
            LOG.error(
                'QuantumRestProxy: Unable to update remote port: %s' %
                e.message)
Example #4
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.

        :returns: None
        :raises: exception.NetworkNotFound
        :raises: exception.PortNotFound
        :raises: exception.AlreadyAttached
                    (? should the network automatically unplug/replug)
        """
        LOG.debug("QuantumRestProxy: plug_interface() called")
        port = self.get_port(tenant_id, net_id, port_id)
        self.validate_attachment(tenant_id, net_id, port_id,
                                  remote_interface_id)
        if port['interface_id']:
            raise exc.PortInUse(net_id=net_id, port_id=port_id,
                                att_id=port['interface_id'])

        # Update DB
        db.port_set_attachment(port_id, net_id, remote_interface_id)

        # update attachment on network controller
        try:
            net_name = self.get_network(tenant_id, net_id).name
            gateway = self.nova.get_gateway(net_id)
            mac = self.nova.get_mac(remote_interface_id)

            if gateway is not None:
                resource = '/tenants/%s/networks/%s' % (
                        tenant_id, net_id)
                data = {
                    "network": {
                        "id": net_id,
                        "gateway": gateway,
                        "name": net_name,
                    }
                }
                ret = self.servers.put(resource, data)
                if not self.servers.action_success(ret):
                    raise RemoteRestError(ret[2])

            if mac is not None:
                resource = '/tenants/%s/networks/%s/ports/%s/attachment' % (
                        tenant_id, net_id, port_id)
                data = {"attachment": {
                    "id": remote_interface_id,
                    "mac": mac,
                }}
                ret = self.servers.put(resource, data)
                if not self.servers.action_success(ret):
                    raise RemoteRestError(ret[2])
        except RemoteRestError as e:
            LOG.error(
                'QuantumRestProxy: Unable to update remote network: %s' %
                e.message)
            # undo the connect
            db.port_unset_attachment(port_id, net_id)
            raise
Example #5
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("FakePlugin.unplug_interface() called")
     self._get_port(tenant_id, net_id, port_id)
     # TODO(salvatore-orlando):
     # Should unplug on port without attachment raise an Error?
     db.port_unset_attachment(port_id, net_id)
 def unplug_interface(self, tenant_id, network_id, port_id):
     """
     Detaches a remote interface from the specified port on the
     specified Virtual Network.
     """
     LOG.debug("unplug_interface() called")
     port = self._get_port(tenant_id, network_id, port_id)
     if self._port_attachable(port):
         self._detach(tenant_id, network_id, port_id)
     db.port_unset_attachment(port_id, network_id)
Example #7
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("FakePlugin.unplug_interface() called")
     self._get_port(tenant_id, net_id, port_id)
     # TODO(salvatore-orlando):
     # Should unplug on port without attachment raise an Error?
     db.port_unset_attachment(port_id, net_id)
Example #8
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")
     db.validate_port_ownership(tenant_id, net_id, port_id)
     port = db.port_get(port_id, net_id)
     attachment_id = port[const.INTERFACEID]
     if attachment_id is None:
         return
     db.port_unset_attachment(port_id, net_id)
     db.port_update(port_id, net_id, op_status=OperationalStatus.DOWN)
Example #9
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")
     db.validate_port_ownership(tenant_id, net_id, port_id)
     port = db.port_get(port_id, net_id)
     attachment_id = port[const.INTERFACEID]
     if attachment_id is None:
         return
     db.port_unset_attachment(port_id, net_id)
     db.port_update(port_id, net_id, op_status=OperationalStatus.DOWN)
 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)
 def unplug_interface(self, net_id, port_id):
     """Unplug interface to a port"""
     try:
         port = db.port_unset_attachment(net_id, port_id)
         LOG.debug("Detached interface from port %s" % port.uuid)
         port_dict = {}
         port_dict["port-id"] = str(port.uuid)
         port_dict["net-id"] = str(port.network_id)
         port_dict["int-id"] = port.interface_id
         port_dict["state"] = port.state
         return port_dict
     except Exception, exc:
         raise Exception("Failed to unplug interface: %s" % str(exc))