def update_port(self, tenant_id, net_id, port_id, **kwargs): """ Updates the state of a port on the specified Virtual Network. """ db.validate_port_ownership(tenant_id, net_id, port_id) port = db.port_get(port_id, net_id) db.port_update(port_id, net_id, **kwargs) return self._make_port_dict(port)
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") port = db.port_get(port_id, net_id) db.port_update(port_id, net_id, **kwargs) return self._make_port_dict(port)
def update_port(self, tenant_id, net_id, port_id, port_state): """ Updates the state of a port on the specified Virtual Network. """ LOG.debug("update_port() called\n") port = db.port_get(port_id, net_id) db.port_set_state(port_id, net_id, port_state) return self._make_port_dict(str(port.uuid), port.state, port.network_id, port.interface_id)
def _get_port(self, tenant_id, network_id, port_id): net = self._get_network(tenant_id, network_id) try: port = db.port_get(port_id, network_id) except: raise exc.PortNotFound(net_id=network_id, port_id=port_id) # Port must exist and belong to the appropriate network. if port['network_id'] != net['uuid']: raise exc.PortNotFound(net_id=network_id, port_id=port_id) return port
def _verify_unplug_iface(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) # Fill CLI template output = cli.prepare_output( "unplug_iface", self.tenant_id, dict(network_id=network_id, port_id=port['uuid'])) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
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") db.validate_port_ownership(tenant_id, net_id, port_id) port = db.port_get(port_id, net_id) new_port_dict = cutil.make_port_dict(port) return new_port_dict
def _verify_unplug_iface(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) # Fill CLI template output = cli.prepare_output("unplug_iface", self.tenant_id, dict(network_id=network_id, port_id=port['uuid'])) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _get_port(self, tenant_id, network_id, port_id): network = self._get_network(tenant_id, network_id) port = db.port_get(port_id, network_id) # Port must exist and belong to the appropriate network. if port.network_id != network_id: LOG.warning("_get_port(): mismatch network_id = %s, " "port_id = %s, port.network_id = %s" % (network_id, port_id, port.network_id)) raise exc.PortNotFound(net_id=network_id, port_id=port_id) return port
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
def _verify_update_port(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state} # Fill CLI template output = cli.prepare_output( 'update_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_update_port(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state} # Fill CLI template output = cli.prepare_output('update_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
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)
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 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") 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: 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)
def _verify_show_iface(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) iface = {'id': port.interface_id or '<none>'} # Fill CLI template output = cli.prepare_output('show_iface', self.tenant_id, dict(network_id=network_id, port_id=port.uuid, iface=iface), self.version) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def get_port(self, net_id, port_id): """Get a port.""" port_list = [] port = db.port_get(port_id, net_id) try: LOG.debug("Getting port: %s", port.uuid) port_dict = {} port_dict["id"] = str(port.uuid) port_dict["net-id"] = str(port.network_id) port_dict["attachment"] = port.interface_id port_dict["state"] = port.state port_list.append(port_dict) return port_list except Exception as exc: LOG.error("Failed to get port: %s", str(exc))
def get_port(self, net_id, port_id): """Get a port""" port_list = [] port = db.port_get(net_id, port_id) try: LOG.debug("Getting 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 port_list.append(port_dict) return port_list except Exception, exc: LOG.error("Failed to get port: %s" % str(exc))
def _verify_show_port(self, network_id, port_id): # Verification - get raw result from db port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state, 'attachment': {'id': port.interface_id or '<none>'}, 'op-status': port.op_status} # Fill CLI template output = cli.prepare_output('show_port', self.tenant_id, dict(network_id=network_id, port=port_data), self.version) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def _verify_show_port(self, network_id, port_id): # Verification - get raw result from db # TODO(salvatore-orlando): Must resolve this issue with # attachment in separate bug fix. port = db.port_get(port_id, network_id) port_data = {'id': port.uuid, 'state': port.state, 'attachment': "<none>"} if port.interface_id is not None: port_data['attachment'] = port.interface_id # Fill CLI template output = cli.prepare_output('show_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
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)
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") db.validate_port_ownership(tenant_id, net_id, port_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)
def _verify_show_port(self, network_id, port_id): # Verification - get raw result from db # TODO(salvatore-orlando): Must resolve this issue with # attachment in separate bug fix. port = db.port_get(port_id, network_id) port_data = { 'id': port.uuid, 'state': port.state, 'attachment': "<none>" } if port.interface_id is not None: port_data['attachment'] = port.interface_id # Fill CLI template output = cli.prepare_output( 'show_port', self.tenant_id, dict(network_id=network_id, port=port_data)) # Verify! # Must add newline at the end to match effect of print call self.assertEquals(self.fake_stdout.make_string(), output + '\n')
def get_port_details(self, tenant_id, net_id, port_id): port = db.port_get(port_id, net_id) return self._make_port_dict(port)
def get_interface_details(self, tenant_id, net_id, port_id): db.validate_port_ownership(tenant_id, net_id, port_id) res = db.port_get(port_id, net_id) return res.interface_id
def get_port_details(self, tenant_id, net_id, port_id): db.validate_port_ownership(tenant_id, net_id, port_id) port = db.port_get(port_id, net_id) return self._make_port_dict(port)
def get_port_details(self, tenant_id, net_id, port_id): port = db.port_get(port_id, net_id) return self._make_port_dict(str(port.uuid), port.state, port.network_id, port.interface_id)
def get_interface_details(self, tenant_id, net_id, port_id): res = db.port_get(port_id, net_id) return res.interface_id