def _test__get_instance_image_info(self, show_mock): properties = {'properties': {u'kernel_id': u'instance_kernel_uuid', u'ramdisk_id': u'instance_ramdisk_uuid'}} expected_info = {'ramdisk': ('instance_ramdisk_uuid', os.path.join(CONF.pxe.tftp_root, self.node.uuid, 'ramdisk')), 'kernel': ('instance_kernel_uuid', os.path.join(CONF.pxe.tftp_root, self.node.uuid, 'kernel'))} show_mock.return_value = properties self.context.auth_token = 'fake' image_info = pxe._get_instance_image_info(self.node, self.context) show_mock.assert_called_once_with(mock.ANY, 'glance://image_uuid', method='get') self.assertEqual(expected_info, image_info) # test with saved info show_mock.reset_mock() image_info = pxe._get_instance_image_info(self.node, self.context) self.assertEqual(expected_info, image_info) self.assertFalse(show_mock.called) self.assertEqual('instance_kernel_uuid', self.node.instance_info.get('kernel')) self.assertEqual('instance_ramdisk_uuid', self.node.instance_info.get('ramdisk'))
def _test__get_instance_image_info(self, show_mock): properties = {"properties": {u"kernel_id": u"instance_kernel_uuid", u"ramdisk_id": u"instance_ramdisk_uuid"}} expected_info = { "ramdisk": ("instance_ramdisk_uuid", os.path.join(CONF.pxe.tftp_root, self.node.uuid, "ramdisk")), "kernel": ("instance_kernel_uuid", os.path.join(CONF.pxe.tftp_root, self.node.uuid, "kernel")), } show_mock.return_value = properties self.context.auth_token = "fake" image_info = pxe._get_instance_image_info(self.node, self.context) show_mock.assert_called_once_with(mock.ANY, "glance://image_uuid", method="get") self.assertEqual(expected_info, image_info) # test with saved info show_mock.reset_mock() image_info = pxe._get_instance_image_info(self.node, self.context) self.assertEqual(expected_info, image_info) self.assertFalse(show_mock.called) self.assertEqual("instance_kernel_uuid", self.node.instance_info["kernel"]) self.assertEqual("instance_ramdisk_uuid", self.node.instance_info["ramdisk"])
def prepare_ramdisk(self, task, ramdisk_params): node = task.node # TODO(deva): optimize this if rerun on existing files if CONF.pxe.ipxe_enabled: # Copy the iPXE boot script to HTTP root directory bootfile_path = os.path.join( CONF.deploy.http_root, os.path.basename(CONF.pxe.ipxe_boot_script)) shutil.copyfile(CONF.pxe.ipxe_boot_script, bootfile_path) prov_ip = self._plug_provisioning(task) task.ports = objects.Port.list_by_node_id(task.context, node.id) pxe_info = pxe._get_deploy_image_info(node) # NODE: Try to validate and fetch instance images only # if we are in DEPLOYING state. if node.provision_state == states.DEPLOYING: pxe_info.update(pxe._get_instance_image_info(node, task.context)) pxe_options = pxe._build_pxe_config_options(task, pxe_info) pxe_options.update(ramdisk_params) pxe_options['advertise_host'] = prov_ip if deploy_utils.get_boot_mode_for_deploy(node) == 'uefi': pxe_config_template = CONF.pxe.uefi_pxe_config_template else: pxe_config_template = CONF.pxe.pxe_config_template pxe_utils.create_pxe_config(task, pxe_options, pxe_config_template) deploy_utils.try_set_boot_device(task, boot_devices.PXE) # FIXME(lucasagomes): If it's local boot we should not cache # the image kernel and ramdisk (Or even require it). pxe._cache_ramdisk_kernel(task.context, node, pxe_info)
def test__get_instance_image_info_whole_disk_image(self, show_mock): properties = {"properties": None} show_mock.return_value = properties self.node.driver_internal_info["is_whole_disk_image"] = True image_info = pxe._get_instance_image_info(self.node, self.context) self.assertEqual({}, image_info)
def test__get_instance_image_info_localboot(self, boot_opt_mock): self.node.driver_internal_info["is_whole_disk_image"] = False self.node.save() image_info = pxe._get_instance_image_info(self.node, self.context) self.assertEqual({}, image_info) boot_opt_mock.assert_called_once_with(self.node)
def test__get_instance_image_info_whole_disk_image(self, show_mock): properties = {'properties': None} show_mock.return_value = properties self.node.driver_internal_info['is_whole_disk_image'] = True image_info = pxe._get_instance_image_info(self.node, self.context) self.assertEqual({}, image_info)
def test__get_instance_image_info_localboot(self, boot_opt_mock): self.node.driver_internal_info['is_whole_disk_image'] = False self.node.save() image_info = pxe._get_instance_image_info(self.node, self.context) self.assertEqual({}, image_info) boot_opt_mock.assert_called_once_with(self.node)