def test_crt_lpar(self, mock_vld, mock_vmbldr): self.inst.flavor.extra_specs = {'powervm:dedicated_proc': 'true'} mock_bldr = mock.Mock(spec=lpar_bld.LPARBuilder) mock_vmbldr.return_value.lpar_builder.return_value = mock_bldr mock_pend_lpar = mock.create_autospec(pvm_lpar.LPAR, instance=True) mock_bldr.build.return_value = mock_pend_lpar vm.create_lpar(self.apt, 'host', self.inst) mock_vmbldr.assert_called_once_with('host', self.apt) mock_vmbldr.return_value.lpar_builder.assert_called_once_with( self.inst) mock_bldr.build.assert_called_once_with() mock_vld.assert_called_once_with(mock_pend_lpar, 'host') mock_vld.return_value.validate_all.assert_called_once_with() mock_pend_lpar.create.assert_called_once_with(parent='host') # Test to verify the LPAR Creation with invalid name specification mock_vmbldr.side_effect = lpar_bld.LPARBuilderException("Invalid Name") self.assertRaises(exception.BuildAbortException, vm.create_lpar, self.apt, 'host', self.inst) # HttpError mock_vmbldr.side_effect = pvm_exc.HttpError(mock.Mock()) self.assertRaises(exception.PowerVMAPIFailed, vm.create_lpar, self.apt, 'host', self.inst)
def test_crt_lpar(self, mock_vld, mock_vmbldr): mock_bldr = mock.Mock(spec=lpar_bld.LPARBuilder) mock_vmbldr.return_value.lpar_builder.return_value = mock_bldr mock_pend_lpar = mock.create_autospec(pvm_lpar.LPAR, instance=True) mock_bldr.build.return_value = mock_pend_lpar vm.create_lpar(self.apt, 'host', self.inst) mock_vmbldr.assert_called_once_with('host', self.apt) mock_vmbldr.return_value.lpar_builder.assert_called_once_with( self.inst) mock_bldr.build.assert_called_once_with() mock_vld.assert_called_once_with(mock_pend_lpar, 'host') mock_vld.return_value.validate_all.assert_called_once_with() mock_pend_lpar.create.assert_called_once_with(parent='host')
def execute(self): wrap = vm.create_lpar(self.adapter, self.host_wrapper, self.instance) # Get rid of any stale storage and/or mappings associated with the new # LPAR's ID, so it doesn't accidentally have access to something it # oughtn't. LOG.info('Scrubbing stale storage.', instance=self.instance) pvm_stg.add_lpar_storage_scrub_tasks([wrap.id], self.stg_ftsk, lpars_exist=True) return wrap
def execute(self): wrap = vm.create_lpar(self.adapter, self.host_wrapper, self.instance) # Get rid of any stale storage and/or mappings associated with the new # LPAR's ID, so it doesn't accidentally have access to something it # oughtn't. ftsk = pvm_tpar.build_active_vio_feed_task( self.adapter, name='create_scrubber', xag={pvm_const.XAG.VIO_SMAP, pvm_const.XAG.VIO_FMAP}) pvm_stg.add_lpar_storage_scrub_tasks([wrap.id], ftsk, lpars_exist=True) LOG.info('Scrubbing stale storage.', instance=self.instance) ftsk.execute()