def plug_port(self, amphora, port): try: interface = self.nova_client.servers.interface_attach( server=amphora.compute_id, net_id=None, fixed_ip=None, port_id=port.id) plugged_interface = self._nova_interface_to_octavia_interface( amphora.compute_id, interface) except nova_client_exceptions.NotFound as e: if 'Instance' in str(e): raise base.AmphoraNotFound(str(e)) elif 'Network' in str(e): raise base.NetworkNotFound(str(e)) else: raise base.PlugNetworkException(str(e)) except nova_client_exceptions.Conflict: LOG.info('Port %(portid)s is already plugged, ' 'skipping', {'portid': port.id}) plugged_interface = n_data_models.Interface( compute_id=amphora.compute_id, network_id=port.network_id, port_id=port.id, fixed_ips=port.fixed_ips) except Exception: message = _('Error plugging amphora (compute_id: ' '{compute_id}) into port ' '{port_id}.').format(compute_id=amphora.compute_id, port_id=port.id) LOG.exception(message) raise base.PlugNetworkException(message) return plugged_interface
def plug_port(self, amphora, port): try: self.nova_client.servers.interface_attach( server=amphora.compute_id, net_id=None, fixed_ip=None, port_id=port.id) except nova_client_exceptions.NotFound as e: if 'Instance' in e.message: raise base.AmphoraNotFound(e.message) elif 'Network' in e.message: raise base.NetworkNotFound(e.message) else: raise base.PlugNetworkException(e.message) except nova_client_exceptions.Conflict: LOG.info( _LI('Port %(portid)s is already plugged, ' 'skipping') % {'portid': port.id}) except Exception: message = _LE('Error plugging amphora (compute_id: ' '{compute_id}) into port ' '{port_id}.').format(compute_id=amphora.compute_id, port_id=port.id) LOG.exception(message) raise base.PlugNetworkException(message)
def plug_network(self, compute_id, network_id, ip_address=None): try: interface = self.compute.attach_network_or_port( compute_id=compute_id, network_id=network_id, ip_address=ip_address) except exceptions.NotFound as e: if 'Instance' in str(e): raise base.AmphoraNotFound(str(e)) if 'Network' in str(e): raise base.NetworkNotFound(str(e)) raise base.PlugNetworkException(str(e)) except Exception as e: message = _('Error plugging amphora (compute_id: {compute_id}) ' 'into network {network_id}.').format( compute_id=compute_id, network_id=network_id) LOG.exception(message) raise base.PlugNetworkException(message) from e return self._nova_interface_to_octavia_interface(compute_id, interface)
def plug_network(self, compute_id, network_id, ip_address=None): try: interface = self.nova_client.servers.interface_attach( server=compute_id, net_id=network_id, fixed_ip=ip_address, port_id=None) except nova_client_exceptions.NotFound as e: if 'Instance' in e.message: raise base.AmphoraNotFound(e.message) elif 'Network' in e.message: raise base.NetworkNotFound(e.message) else: raise base.PlugNetworkException(e.message) except Exception: message = _('Error plugging amphora (compute_id: {compute_id}) ' 'into network {network_id}.').format( compute_id=compute_id, network_id=network_id) LOG.exception(message) raise base.PlugNetworkException(message) return self._nova_interface_to_octavia_interface(compute_id, interface)