def test_deactivate_bootloader_for_nonexistent_instance(self): self._create_node() self.instance['uuid'] = 'fake-uuid' pxe_path = pxe.get_pxe_config_file_path(self.instance) self.mox.StubOutWithMock(utils, 'unlink_without_raise') self.mox.StubOutWithMock(utils, 'rmtree_without_raise') self.mox.StubOutWithMock(pxe, 'get_tftp_image_info') self.mox.StubOutWithMock(self.driver, '_collect_mac_addresses') extra_specs = dict(extra_specs={ 'baremetal:deploy_ramdisk_id': 'ignore', 'baremetal:deploy_kernel_id': 'ignore'}) pxe.get_tftp_image_info(self.instance, extra_specs).\ AndRaise(exception.NovaException) utils.unlink_without_raise(pxe_path) self.driver._collect_mac_addresses(self.context, self.node).\ AndRaise(db_exc.DBError) utils.rmtree_without_raise( os.path.join(CONF.baremetal.tftp_root, 'fake-uuid')) self.mox.ReplayAll() self.driver.deactivate_bootloader( self.context, self.node, self.instance) self.mox.VerifyAll()
def test_activate_bootloader_passes_details(self): self._create_node() macs = [nic['address'] for nic in self.nic_info] macs.sort() image_info = { 'deploy_kernel': [None, 'aaaa'], 'deploy_ramdisk': [None, 'bbbb'], 'kernel': [None, 'cccc'], 'ramdisk': [None, 'dddd'], } self.instance['uuid'] = 'fake-uuid' iqn = "iqn-%s" % self.instance['uuid'] pxe_config = 'this is a fake pxe config' pxe_path = pxe.get_pxe_config_file_path(self.instance) pxe.get_image_file_path(self.instance) self.mox.StubOutWithMock(self.driver.virtapi, 'instance_type_get') self.mox.StubOutWithMock(pxe, 'get_tftp_image_info') self.mox.StubOutWithMock(pxe, 'get_partition_sizes') self.mox.StubOutWithMock(utils, 'random_alnum') self.mox.StubOutWithMock(pxe, 'build_pxe_config') self.mox.StubOutWithMock(utils, 'write_to_file') self.mox.StubOutWithMock(utils, 'create_link_without_raise') self.driver.virtapi.instance_type_get( self.context, self.instance['instance_type_id']).AndReturn({}) pxe.get_tftp_image_info(self.instance, {}).AndReturn(image_info) pxe.get_partition_sizes(self.instance).AndReturn((0, 0)) utils.random_alnum(32).AndReturn('alnum') pxe.build_pxe_config( self.node['id'], 'alnum', iqn, 'aaaa', 'bbbb', 'cccc', 'dddd').AndReturn(pxe_config) utils.write_to_file(pxe_path, pxe_config) for mac in macs: utils.create_link_without_raise( pxe_path, pxe.get_pxe_mac_path(mac)) self.mox.ReplayAll() self.driver.activate_bootloader(self.context, self.node, self.instance) self.mox.VerifyAll()
def test_pxe_config_file_path(self): self.instance['uuid'] = 'aaaa-bbbb-cccc' self.assertEqual( pxe.get_pxe_config_file_path(self.instance), os.path.join(CONF.baremetal.tftp_root, 'aaaa-bbbb-cccc', 'config'))