예제 #1
0
    def unplug_network(self, compute_id, network_id, ip_address=None):
        interfaces = self.get_plugged_networks(compute_id)
        if not interfaces:
            msg = ('Amphora with compute id {compute_id} does not have any '
                   'plugged networks').format(compute_id=compute_id)
            raise base.NetworkNotFound(msg)

        unpluggers = self._get_interfaces_to_unplug(interfaces,
                                                    network_id,
                                                    ip_address=ip_address)
        for index, unplugger in enumerate(unpluggers):
            self.compute.detach_port(compute_id=compute_id,
                                     port_id=unplugger.port_id)
예제 #2
0
파일: base.py 프로젝트: mallow111/octavia
 def get_network(self, network_id):
     try:
         network = self.neutron_client.show_network(network_id)
         return utils.convert_network_dict_to_model(network)
     except neutron_client_exceptions.NotFound:
         message = _LE(
             'Network not found '
             '(network id: {network_id}.').format(network_id=network_id)
         LOG.exception(message)
         raise base.NetworkNotFound(message)
     except Exception:
         message = _LE(
             'Error retrieving network '
             '(network id: {network_id}.').format(network_id=network_id)
         LOG.exception(message)
         raise base.NetworkException(message)
예제 #3
0
    def unplug_network(self, compute_id, network_id, ip_address=None):
        interfaces = self.get_plugged_networks(compute_id)
        if not interfaces:
            msg = ('Amphora with compute id {compute_id} does not have any '
                   'plugged networks').format(compute_id=compute_id)
            raise base.NetworkNotFound(msg)

        unpluggers = self._get_interfaces_to_unplug(interfaces,
                                                    network_id,
                                                    ip_address=ip_address)
        for index, unplugger in enumerate(unpluggers):
            try:
                self.nova_client.servers.interface_detach(
                    server=compute_id, port_id=unplugger.port_id)
            except Exception:
                LOG.warning('Error unplugging port {port_id} from amphora '
                            'with compute ID {compute_id}. '
                            'Skipping.'.format(port_id=unplugger.port_id,
                                               compute_id=compute_id))
예제 #4
0
    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)
예제 #5
0
    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)