From 3167175624673ea44bbe042ba2f5970d282d0165 Mon Sep 17 00:00:00 2001 From: Ramakrishnan G Date: Mon, 22 Sep 2014 10:40:20 +0530 Subject: [PATCH] Pass ipa-driver-name to agent ramdisk This commit adds the change to pass ipa-driver-name to agent ramdisk. This enables agent ramdisk to do vendor-passthru lookup on the actual driver instead of the default 'agent_ipmitool' driver. Change-Id: I750097dc24e11b44d4ed6d7c314cb8fb470dfcb0 Closes-bug: #1371505 --- ironic/drivers/modules/agent.py | 11 +++++++---- ironic/drivers/modules/agent_config.template | 2 +- ironic/drivers/modules/ilo/deploy.py | 2 +- ironic/tests/drivers/agent_pxe_config.template | 2 +- ironic/tests/drivers/ilo/test_deploy.py | 2 +- ironic/tests/drivers/test_agent.py | 8 ++++++-- ironic/tests/test_pxe_utils.py | 1 + 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/ironic/drivers/modules/agent.py b/ironic/drivers/modules/agent.py index 5f330d7efa..ec135707c3 100644 --- a/ironic/drivers/modules/agent.py +++ b/ironic/drivers/modules/agent.py @@ -72,9 +72,10 @@ def _get_client(): return client -def build_agent_options(): +def build_agent_options(node): """Build the options to be passed to the agent ramdisk. + :param node: an ironic node object :returns: a dictionary containing the parameters to be passed to agent ramdisk. """ @@ -82,15 +83,17 @@ def build_agent_options(): keystone.get_service_url()).rstrip('/') return { 'ipa-api-url': ironic_api, + 'ipa-driver-name': node.driver } -def _build_pxe_config_options(pxe_info): +def _build_pxe_config_options(node, pxe_info): """Builds the pxe config options for booting agent. This method builds the config options to be replaced on the agent pxe config template. + :param node: an ironic node object :param pxe_info: A dict containing the 'deploy_kernel' and 'deploy_ramdisk' for the agent pxe config template. :returns: a dict containing the options to be applied on @@ -101,7 +104,7 @@ def _build_pxe_config_options(pxe_info): 'deployment_ari_path': pxe_info['deploy_ramdisk'][1], 'pxe_append_params': CONF.agent.agent_pxe_append_params, } - agent_opts = build_agent_options() + agent_opts = build_agent_options(node) agent_config_opts.update(agent_opts) return agent_config_opts @@ -268,7 +271,7 @@ class AgentDeploy(base.DeployInterface): """ node = task.node pxe_info = _get_tftp_image_info(task.node) - pxe_options = _build_pxe_config_options(pxe_info) + pxe_options = _build_pxe_config_options(task.node, pxe_info) pxe_utils.create_pxe_config(task, pxe_options, CONF.agent.agent_pxe_config_template) diff --git a/ironic/drivers/modules/agent_config.template b/ironic/drivers/modules/agent_config.template index dae973f752..a8e4119f72 100644 --- a/ironic/drivers/modules/agent_config.template +++ b/ironic/drivers/modules/agent_config.template @@ -2,4 +2,4 @@ default deploy label deploy kernel {{ pxe_options.deployment_aki_path }} -append initrd={{ pxe_options.deployment_ari_path }} text {{ pxe_options.pxe_append_params }} {% if pxe_options['ipa-api-url'] %}ipa-api-url={{ pxe_options['ipa-api-url'] }}{% endif %} +append initrd={{ pxe_options.deployment_ari_path }} text {{ pxe_options.pxe_append_params }} ipa-api-url={{ pxe_options['ipa-api-url'] }} ipa-driver-name={{ pxe_options['ipa-driver-name'] }} diff --git a/ironic/drivers/modules/ilo/deploy.py b/ironic/drivers/modules/ilo/deploy.py index 194422269e..fe85bf4c25 100644 --- a/ironic/drivers/modules/ilo/deploy.py +++ b/ironic/drivers/modules/ilo/deploy.py @@ -352,7 +352,7 @@ class IloVirtualMediaAgentDeploy(base.DeployInterface): image. :raises: IloOperationError, if some operation on iLO fails. """ - deploy_ramdisk_opts = agent.build_agent_options() + deploy_ramdisk_opts = agent.build_agent_options(task.node) deploy_iso_uuid = task.node.driver_info['ilo_deploy_iso'] deploy_iso = 'glance:' + deploy_iso_uuid _reboot_into(task, deploy_iso, deploy_ramdisk_opts) diff --git a/ironic/tests/drivers/agent_pxe_config.template b/ironic/tests/drivers/agent_pxe_config.template index 08b821f753..74b9ae869d 100644 --- a/ironic/tests/drivers/agent_pxe_config.template +++ b/ironic/tests/drivers/agent_pxe_config.template @@ -2,4 +2,4 @@ default deploy label deploy kernel /tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_kernel -append initrd=/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_ramdisk text test_param ipa-api-url=http://192.168.122.184:6385 +append initrd=/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_ramdisk text test_param ipa-api-url=http://192.168.122.184:6385 ipa-driver-name=agent_ipmitool diff --git a/ironic/tests/drivers/ilo/test_deploy.py b/ironic/tests/drivers/ilo/test_deploy.py index 98cd0ecde3..4108b0d203 100644 --- a/ironic/tests/drivers/ilo/test_deploy.py +++ b/ironic/tests/drivers/ilo/test_deploy.py @@ -300,7 +300,7 @@ class IloVirtualMediaAgentDeployTestCase(base.TestCase): returned_state = task.driver.deploy.deploy(task) - build_options_mock.assert_called_once_with() + build_options_mock.assert_called_once_with(task.node) reboot_into_mock.assert_called_once_with(task, 'glance:deploy-iso-uuid', deploy_opts) diff --git a/ironic/tests/drivers/test_agent.py b/ironic/tests/drivers/test_agent.py index 685d7ba18d..274c2554e9 100644 --- a/ironic/tests/drivers/test_agent.py +++ b/ironic/tests/drivers/test_agent.py @@ -39,19 +39,23 @@ CONF = cfg.CONF class TestAgentMethods(db_base.DbTestCase): def setUp(self): super(TestAgentMethods, self).setUp() + self.node = object_utils.create_test_node(self.context, + driver='fake_agent') def test_build_agent_options_conf(self): self.config(api_url='api-url', group='conductor') - options = agent.build_agent_options() + options = agent.build_agent_options(self.node) self.assertEqual('api-url', options['ipa-api-url']) + self.assertEqual('fake_agent', options['ipa-driver-name']) @mock.patch.object(keystone, 'get_service_url') def test_build_agent_options_keystone(self, get_url_mock): self.config(api_url=None, group='conductor') get_url_mock.return_value = 'api-url' - options = agent.build_agent_options() + options = agent.build_agent_options(self.node) self.assertEqual('api-url', options['ipa-api-url']) + self.assertEqual('fake_agent', options['ipa-driver-name']) class TestAgentDeploy(db_base.DbTestCase): diff --git a/ironic/tests/test_pxe_utils.py b/ironic/tests/test_pxe_utils.py index e4470a8d59..df96dbea44 100644 --- a/ironic/tests/test_pxe_utils.py +++ b/ironic/tests/test_pxe_utils.py @@ -61,6 +61,7 @@ class TestPXEUtils(db_base.DbTestCase): 'aki_path': u'/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/' u'kernel', 'ipa-api-url': 'http://192.168.122.184:6385', + 'ipa-driver-name': 'agent_ipmitool', 'deployment_aki_path': u'/tftpboot/1be26c0b-03f2-4d2e-ae87-' u'c02d7f33c123/deploy_kernel', }