def test_unplug_interface(self): """Support for the Quantum core API call""" LOG.debug("test_unplug_interface - START") self.net_id = db.network_create(tenant_id, net_name)[const.UUID] self._l2network_multiblade.create_network([tenant_id, net_name, self.net_id, vlan_name(self.net_id), vlan_id]) cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id) self.port_id = db.port_create(self.net_id, port_state)[const.UUID] self._l2network_multiblade.create_port([tenant_id, self.net_id, port_state, self.port_id]) self._l2network_multiblade.plug_interface([tenant_id, self.net_id, self.port_id, interface_id]) db.port_set_attachment(self.net_id, self.port_id, interface_id) interface = self._l2network_multiblade.unplug_interface([tenant_id, self.net_id, self.port_id]) self.assertEqual(self.port_id, interface[0][const.PORTID]) LOG.debug("test_unplug_interface - END")
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") 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)
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") network = db.network_get(net_id) port = db.port_get(net_id, port_id) attachment_id = port[const.INTERFACEID] if attachment_id == 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)
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") network = db.network_get(net_id) port = db.port_get(net_id, port_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) 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)
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") 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)
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("plug_interface() called\n") network = db.network_get(net_id) port = db.port_get(net_id, port_id) attachment_id = port[const.INTERFACEID] if attachment_id and remote_interface_id != attachment_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, remote_interface_id]) if attachment_id == None: db.port_set_attachment(net_id, port_id, remote_interface_id)
def plug_interface(self, net_id, port_id, int_id): """Plug interface to a port""" try: port = db.port_set_attachment(net_id, port_id, int_id) LOG.debug("Attached interface to 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 plug interface: %s" % str(exc))
def test_unplug_interface(self): """Support for the Quantum core API call""" LOG.debug("test_unplug_interface - START") self.net_id = db.network_create(tenant_id, net_name)[const.UUID] self._l2network_multiblade.create_network([ tenant_id, net_name, self.net_id, vlan_name(self.net_id), vlan_id ]) cdb.add_vlan_binding(vlan_id, vlan_name(self.net_id), self.net_id) self.port_id = db.port_create(self.net_id, port_state)[const.UUID] self._l2network_multiblade.create_port( [tenant_id, self.net_id, port_state, self.port_id]) self._l2network_multiblade.plug_interface( [tenant_id, self.net_id, self.port_id, interface_id]) db.port_set_attachment(self.net_id, self.port_id, interface_id) interface = self._l2network_multiblade.unplug_interface( [tenant_id, self.net_id, self.port_id]) self.assertEqual(self.port_id, interface[0][const.PORTID]) LOG.debug("test_unplug_interface - END")
def plug_interface(self, net_id, port_id, int_id): """Plug interface to a port.""" try: port = db.port_set_attachment(net_id, port_id, int_id) LOG.debug("Attached interface to 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 as exc: raise Exception("Failed to plug interface: %s" % str(exc))