Пример #1
0
    def execute(self, lpar_wrap):
        # If the state is not in an OK state for deleting, then throw an
        # error up front.
        modifiable, reason = lpar_wrap.can_modify_io()
        if not modifiable:
            LOG.error(
                "Unable to remove VIFs in the instance's current state. "
                "The reason reported by the system is: %(reason)s",
                {'reason': reason},
                instance=self.instance)
            raise exception.VirtualInterfaceUnplugException(reason=reason)

        # Get all the current Client Network Adapters (CNA) on the VM itself.
        cna_w_list = vm.get_cnas(self.adapter, self.instance)

        # Walk through the VIFs and delete the corresponding CNA on the VM.
        for network_info in self.network_infos:
            vif.unplug(self.adapter,
                       self.host_uuid,
                       self.instance,
                       network_info,
                       self.slot_mgr,
                       cna_w_list=cna_w_list)

        return cna_w_list
Пример #2
0
    def test_unplug(self, mock_event, mock_bld_drv):
        """Test the top-level unplug method."""
        mock_vif = {'address': 'MAC', 'type': 'pvm_sea'}
        slot_mgr = mock.Mock()

        # 1) With slot deregistration, default cna_w_list
        mock_bld_drv.return_value.unplug.return_value = 'vnet_w'
        vif.unplug(self.adpt, 'host_uuid', 'instance', mock_vif, slot_mgr)
        mock_bld_drv.assert_called_once_with(self.adpt, 'host_uuid',
                                             'instance', mock_vif)
        mock_bld_drv.return_value.unplug.assert_called_once_with(
            mock_vif, cna_w_list=None)
        slot_mgr.drop_vnet.assert_called_once_with('vnet_w')
        mock_event.assert_called_once_with(self.adpt, 'unplug', 'vnet_w',
                                           mock.ANY, 'pvm_sea')

        # Clean up
        mock_bld_drv.reset_mock()
        mock_bld_drv.return_value.unplug.reset_mock()
        slot_mgr.drop_vnet.reset_mock()
        mock_event.reset_mock()

        # 2) Without slot deregistration, specified cna_w_list
        mock_bld_drv.return_value.unplug.return_value = None
        vif.unplug(self.adpt, 'host_uuid', 'instance', mock_vif, slot_mgr,
                   cna_w_list='cnalist')
        mock_bld_drv.assert_called_once_with(self.adpt, 'host_uuid',
                                             'instance', mock_vif)
        mock_bld_drv.return_value.unplug.assert_called_once_with(
            mock_vif, cna_w_list='cnalist')
        slot_mgr.drop_vnet.assert_not_called()
        # When unplug doesn't find a vif, we don't push an event
        mock_event.assert_not_called()
Пример #3
0
    def execute_impl(self, lpar_wrap):
        # If the state is not in an OK state for deleting, then throw an
        # error up front.
        modifiable, reason = lpar_wrap.can_modify_io()
        if not modifiable:
            LOG.error(_LE('Unable to remove VIFs from instance %(inst)s '
                          'because the system is not in a correct state.  '
                          'The reason reported by the system is: %(reason)s'),
                      {'inst': self.instance.name, 'reason': reason},
                      instance=self.instance)
            raise VirtualInterfaceUnplugException()

        # Get all the current Client Network Adapters (CNA) on the VM itself.
        cna_w_list = vm.get_cnas(self.adapter, self.instance)

        # Walk through the VIFs and delete the corresponding CNA on the VM.
        for network_info in self.network_infos:
            vif.unplug(self.adapter, self.host_uuid, self.instance,
                       network_info, self.slot_mgr, cna_w_list=cna_w_list)

        return cna_w_list
Пример #4
0
    def revert_impl(self, lpar_wrap, result, flow_failures):
        if not self.network_infos:
            return

        # The parameters have to match the execute method, plus the response +
        # failures even if only a subset are used.
        LOG.warning(_LW('VIF creation being rolled back for instance '
                        '%(inst)s'), {'inst': self.instance.name},
                    instance=self.instance)

        # Get the current adapters on the system
        cna_w_list = vm.get_cnas(self.adapter, self.instance)
        for network_info in self.network_infos:
            try:
                vif.unplug(self.adapter, self.host_uuid, self.instance,
                           network_info, self.slot_mgr, cna_w_list=cna_w_list)
            except Exception as e:
                LOG.exception(e)
                LOG.warning(_LW("An exception occurred during an unplug "
                                "in the vif rollback.  Ignoring."),
                            instance=self.instance)
Пример #5
0
    def revert_impl(self, lpar_wrap, result, flow_failures):
        if not self.network_infos:
            return

        # The parameters have to match the execute method, plus the response +
        # failures even if only a subset are used.
        LOG.warning(_LW('VIF creation being rolled back for instance '
                        '%(inst)s'), {'inst': self.instance.name},
                    instance=self.instance)

        # Get the current adapters on the system
        cna_w_list = vm.get_cnas(self.adapter, self.instance)
        for network_info in self.crt_network_infos:
            try:
                vif.unplug(self.adapter, self.host_uuid, self.instance,
                           network_info, self.slot_mgr, cna_w_list=cna_w_list)
            except Exception as e:
                LOG.exception(e)
                LOG.warning(_LW("An exception occurred during an unplug "
                                "in the vif rollback.  Ignoring."),
                            instance=self.instance)
Пример #6
0
    def revert(self, lpar_wrap, result, flow_failures):
        if not self.network_infos:
            return

        # The parameters have to match the execute method, plus the response +
        # failures even if only a subset are used.
        LOG.warning('VIF creation is being rolled back.',
                    instance=self.instance)

        # Get the current adapters on the system
        cna_w_list = vm.get_cnas(self.adapter, self.instance)
        for network_info in self.crt_network_infos:
            try:
                vif.unplug(self.adapter,
                           self.host_uuid,
                           self.instance,
                           network_info,
                           self.slot_mgr,
                           cna_w_list=cna_w_list)
            except Exception:
                LOG.exception(
                    "Error unplugging during vif rollback. "
                    "Ignoring.",
                    instance=self.instance)