Пример #1
0
    def execute(self, lpar_wrap):
        # We will have two types of network infos.  One is for newly created
        # vifs.  The others are those that exist, but should be re-'treated'
        for network_info in self.network_infos:
            if self._vif_exists(network_info):
                self.update_network_infos.append(network_info)
            else:
                self.crt_network_infos.append(network_info)

        # If there are no vifs to create or update, then just exit immediately.
        if not self.crt_network_infos and not self.update_network_infos:
            return []

        # Check to see if the LPAR is OK to add VIFs to.
        modifiable, reason = lpar_wrap.can_modify_io()
        if not modifiable and self.crt_network_infos:
            LOG.error(
                "Unable to create VIF(s) in the instance's current "
                "state. The reason reported by the system is: "
                "%(reason)s", {'reason': reason},
                instance=self.instance)
            raise exception.VirtualInterfaceCreateException()

        # TODO(KYLEH): We're setting up to wait for an instance event.  The
        # event needs to come back to our compute manager so we need to ensure
        # the instance.host is set to our host.  We shouldn't need to do this
        # but in the evacuate/recreate case it may reflect the old host.
        # See: https://bugs.launchpad.net/nova/+bug/1535918
        undo_host_change = False
        if self.instance.host != CONF.host:
            LOG.warning(
                'Instance was not assigned to this host. '
                'It was assigned to: %s',
                self.instance.host,
                instance=self.instance)
            # Update the instance...
            old_host = self.instance.host
            self.instance.host = CONF.host
            self.instance.save()
            undo_host_change = True

        # For existing VIFs that we just need to update, run the plug but do
        # not wait for the neutron event as that likely won't be sent (it was
        # already done).
        for network_info in self.update_network_infos:
            LOG.info("Updating VIF with mac %(mac)s",
                     {'mac': network_info['address']},
                     instance=self.instance)
            vif.plug(self.adapter,
                     self.host_uuid,
                     self.instance,
                     network_info,
                     self.slot_mgr,
                     new_vif=False)

        # For the VIFs, run the creates (and wait for the events back)
        try:
            with self.virt_api.wait_for_instance_event(
                    self.instance,
                    self._get_vif_events(),
                    deadline=CONF.vif_plugging_timeout,
                    error_callback=self._vif_callback_failed):
                for network_info in self.crt_network_infos:
                    LOG.info('Creating VIF with mac %(mac)s.',
                             {'mac': network_info['address']},
                             instance=self.instance)
                    new_vif = vif.plug(self.adapter,
                                       self.host_uuid,
                                       self.instance,
                                       network_info,
                                       self.slot_mgr,
                                       new_vif=True)
                    if self.cnas is not None and isinstance(
                            new_vif, pvm_net.CNA):
                        self.cnas.append(new_vif)
        except eventlet.timeout.Timeout:
            LOG.error('Error waiting for VIF to be created.',
                      instance=self.instance)
            raise exception.VirtualInterfaceCreateException()
        finally:
            if undo_host_change:
                LOG.info('Undoing temporary host assignment to instance.',
                         instance=self.instance)
                self.instance.host = old_host
                self.instance.save()

        return self.cnas
Пример #2
0
 def _vif_callback_failed(self, event_name, instance):
     LOG.error('VIF plug failure for callback on event %(event)s.',
               {'event': event_name},
               instance=instance)
     if CONF.vif_plugging_is_fatal:
         raise exception.VirtualInterfaceCreateException()
 def _neutron_failed_callback(self, event_name, instance):
     LOG.error("Neutron Reported failure on event %s for instance",
               event_name,
               instance=instance)
     if CONF.vif_plugging_is_fatal:
         raise exception.VirtualInterfaceCreateException()
Пример #4
0
 def finish_migration(self, *args, **kwargs):
     raise exception.VirtualInterfaceCreateException()
Пример #5
0
 def _vif_callback_failed(self, event_name, instance):
     LOG.error('VIF Plug failure for callback on event %s for instance.',
               event_name,
               instance=self.instance)
     if CONF.vif_plugging_is_fatal:
         raise exception.VirtualInterfaceCreateException()
Пример #6
0
 def _virtual_interface_create_failed(*args, **kwargs):
     # A real error that could come out of driver.spawn() during rebuild
     raise exception.VirtualInterfaceCreateException()
Пример #7
0
    def execute(self, lpar_wrap):
        LOG.info(_LI('Plugging the Network Interfaces to instance %s'),
                 self.instance.name)

        # Get the current adapters on the system
        cna_w_list = vm.get_cnas(self.adapter, self.instance, self.host_uuid)

        # Trim the VIFs down to the ones that haven't yet been created.
        crt_vifs = []
        for vif in self.network_info:
            for cna_w in cna_w_list:
                if vm.norm_mac(cna_w.mac) == vif['address']:
                    break
            else:
                crt_vifs.append(vif)

        # If there are no vifs to create, then just exit immediately.
        if len(crt_vifs) == 0:
            return []

        # Check to see if the LPAR is OK to add VIFs to.
        modifiable, reason = lpar_wrap.can_modify_io()
        if not modifiable:
            LOG.error(_LE('Unable to create VIF(s) for instance %(sys)s.  The '
                          'VM was in a state where VIF plugging is not '
                          'acceptable.  The reason from the system is: '
                          '%(reason)s'), {
                              'sys': self.instance.name,
                              'reason': reason
                          },
                      instance=self.instance)
            raise exception.VirtualInterfaceCreateException()

        # TODO(KYLEH): We're setting up to wait for an instance event.  The
        # event needs to come back to our compute manager so we need to ensure
        # the instance.host is set to our host.  We shouldn't need to do this
        # but in the evacuate/recreate case it may reflect the old host.
        # See: https://bugs.launchpad.net/nova/+bug/1535918
        undo_host_change = False
        if self.instance.host != CONF.host:
            LOG.warning(_LW('Instance was not assigned to this host. '
                            'It was assigned to: %s'),
                        self.instance.host,
                        instance=self.instance)
            # Update the instance...
            old_host = self.instance.host
            self.instance.host = CONF.host
            self.instance.save()
            undo_host_change = True

        # For the VIFs, run the creates (and wait for the events back)
        try:
            with self.virt_api.wait_for_instance_event(
                    self.instance,
                    self._get_vif_events(),
                    deadline=CONF.vif_plugging_timeout,
                    error_callback=self._vif_callback_failed):
                for vif in crt_vifs:
                    LOG.info(_LI('Creating VIF with mac %(mac)s for instance '
                                 '%(sys)s'), {
                                     'mac': vif['address'],
                                     'sys': self.instance.name
                                 },
                             instance=self.instance)
                    vm.crt_vif(self.adapter, self.instance, self.host_uuid,
                               vif)
        except eventlet.timeout.Timeout:
            LOG.error(_LE('Error waiting for VIF to be created for instance '
                          '%(sys)s'), {'sys': self.instance.name},
                      instance=self.instance)
            raise exception.VirtualInterfaceCreateException()
        finally:
            if undo_host_change:
                LOG.info(_LI('Undoing temporary host assignment to instance.'),
                         instance=self.instance)
                self.instance.host = old_host
                self.instance.save()

        # Return the list of created VIFs.
        return cna_w_list
Пример #8
0
 def _vif_callback_failed(self, event_name, instance):
     LOG.error(_LE('VIF Plug failure for callback on event '
                   '%(event)s for instance %(uuid)s'),
               {'event': event_name, 'uuid': instance.uuid})
     if CONF.vif_plugging_is_fatal:
         raise exception.VirtualInterfaceCreateException()
Пример #9
0
 def _neutron_failed_callback(self, event_name, instance):
     LOG.error(_LE('Neutron Reported failure on event '
                   '%(event)s for instance %(uuid)s'),
               {'event': event_name, 'uuid': instance.name})
     if CONF.vif_plugging_is_fatal:
         raise exception.VirtualInterfaceCreateException()