Exemplo n.º 1
0
 def plug_interface(self, tenant_id, net_id, port_id,
                    remote_interface_id):
     """
     Provides connectivity to a remote interface to the
     specified Virtual Network.
     """
     LOG.debug("plug_interface() called\n")
     db.validate_port_ownership(tenant_id, net_id, port_id)
     network = db.network_get(net_id)
     port = db.port_get(net_id, port_id)
     attachment_id = port[const.INTERFACEID]
     if attachment_id is None:
         raise cexc.InvalidAttach(port_id=port_id, net_id=net_id,
                                  att_id=remote_interface_id)
     attachment_id = attachment_id[:const.UUID_LENGTH]
     remote_interface_id = remote_interface_id[:const.UUID_LENGTH]
     if remote_interface_id != attachment_id:
         LOG.debug("Existing attachment_id:%s, remote_interface_id:%s" %
                   (attachment_id, remote_interface_id))
         raise exc.PortInUse(port_id=port_id, net_id=net_id,
                             att_id=attachment_id)
     self._invoke_device_plugins(self._func_name(), [tenant_id,
                                                     net_id, port_id,
                                                     attachment_id])
     db.port_unset_attachment(net_id, port_id)
     db.port_set_attachment(net_id, port_id, attachment_id)
Exemplo n.º 2
0
    def update_port(self, tenant_id, net_id, port_id, **kwargs):
        """
        Updates the state of a port on the specified Virtual Network.
        """
        LOG.debug("update_port() called\n")
        db.validate_port_ownership(tenant_id, net_id, port_id)
        network = db.network_get(net_id)
        self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, port_id, kwargs])
        self._validate_port_state(kwargs["state"])
        db.port_update(port_id, net_id, **kwargs)

        new_port_dict = cutil.make_port_dict(port_id, kwargs["state"], net_id, None)
        return new_port_dict
Exemplo n.º 3
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("get_port_details() called\n")
     db.validate_port_ownership(tenant_id, net_id, port_id)
     network = db.network_get(net_id)
     self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, port_id])
     port = db.port_get(net_id, port_id)
     new_port_dict = cutil.make_port_dict(
         port[const.UUID], port[const.PORTSTATE], port[const.NETWORKID], port[const.INTERFACEID]
     )
     return new_port_dict
Exemplo n.º 4
0
 def unplug_interface(self, tenant_id, net_id, port_id):
     """
     Removes connectivity of a remote interface to the
     specified Virtual Network.
     """
     LOG.debug("unplug_interface() called\n")
     db.validate_port_ownership(tenant_id, net_id, port_id)
     network = db.network_get(net_id)
     port = db.port_get(net_id, port_id)
     attachment_id = port[const.INTERFACEID]
     if attachment_id is None:
         raise exc.InvalidDetach(port_id=port_id, net_id=net_id, att_id=remote_interface_id)
     self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, port_id])
     attachment_id = attachment_id[: const.UUID_LENGTH]
     attachment_id = attachment_id + const.UNPLUGGED
     db.port_unset_attachment(net_id, port_id)
     db.port_set_attachment(net_id, port_id, attachment_id)
Exemplo n.º 5
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 should first be un-plugged and
     then the port can be deleted.
     """
     LOG.debug("delete_port() called\n")
     db.validate_port_ownership(tenant_id, net_id, port_id)
     network = db.network_get(net_id)
     port = db.port_get(net_id, port_id)
     attachment_id = port[const.INTERFACEID]
     if not attachment_id:
         self._invoke_device_plugins(self._func_name(), [tenant_id, net_id, port_id])
         db.port_destroy(net_id, port_id)
         new_port_dict = cutil.make_port_dict(port_id, None, None, None)
         return new_port_dict
     else:
         raise exc.PortInUse(port_id=port_id, net_id=net_id, att_id=attachment_id)