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
This commit is contained in:
Ramakrishnan G 2014-09-22 10:40:20 +05:30
parent 4674aef9e4
commit 3167175624
7 changed files with 18 additions and 10 deletions

View File

@ -72,9 +72,10 @@ def _get_client():
return client return client
def build_agent_options(): def build_agent_options(node):
"""Build the options to be passed to the agent ramdisk. """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 :returns: a dictionary containing the parameters to be passed to
agent ramdisk. agent ramdisk.
""" """
@ -82,15 +83,17 @@ def build_agent_options():
keystone.get_service_url()).rstrip('/') keystone.get_service_url()).rstrip('/')
return { return {
'ipa-api-url': ironic_api, '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. """Builds the pxe config options for booting agent.
This method builds the config options to be replaced on This method builds the config options to be replaced on
the agent pxe config template. the agent pxe config template.
:param node: an ironic node object
:param pxe_info: A dict containing the 'deploy_kernel' and :param pxe_info: A dict containing the 'deploy_kernel' and
'deploy_ramdisk' for the agent pxe config template. 'deploy_ramdisk' for the agent pxe config template.
:returns: a dict containing the options to be applied on :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], 'deployment_ari_path': pxe_info['deploy_ramdisk'][1],
'pxe_append_params': CONF.agent.agent_pxe_append_params, '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) agent_config_opts.update(agent_opts)
return agent_config_opts return agent_config_opts
@ -268,7 +271,7 @@ class AgentDeploy(base.DeployInterface):
""" """
node = task.node node = task.node
pxe_info = _get_tftp_image_info(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_utils.create_pxe_config(task,
pxe_options, pxe_options,
CONF.agent.agent_pxe_config_template) CONF.agent.agent_pxe_config_template)

View File

@ -2,4 +2,4 @@ default deploy
label deploy label deploy
kernel {{ pxe_options.deployment_aki_path }} 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'] }}

View File

@ -352,7 +352,7 @@ class IloVirtualMediaAgentDeploy(base.DeployInterface):
image. image.
:raises: IloOperationError, if some operation on iLO fails. :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_uuid = task.node.driver_info['ilo_deploy_iso']
deploy_iso = 'glance:' + deploy_iso_uuid deploy_iso = 'glance:' + deploy_iso_uuid
_reboot_into(task, deploy_iso, deploy_ramdisk_opts) _reboot_into(task, deploy_iso, deploy_ramdisk_opts)

View File

@ -2,4 +2,4 @@ default deploy
label deploy label deploy
kernel /tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/deploy_kernel 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

View File

@ -300,7 +300,7 @@ class IloVirtualMediaAgentDeployTestCase(base.TestCase):
returned_state = task.driver.deploy.deploy(task) 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, reboot_into_mock.assert_called_once_with(task,
'glance:deploy-iso-uuid', 'glance:deploy-iso-uuid',
deploy_opts) deploy_opts)

View File

@ -39,19 +39,23 @@ CONF = cfg.CONF
class TestAgentMethods(db_base.DbTestCase): class TestAgentMethods(db_base.DbTestCase):
def setUp(self): def setUp(self):
super(TestAgentMethods, self).setUp() super(TestAgentMethods, self).setUp()
self.node = object_utils.create_test_node(self.context,
driver='fake_agent')
def test_build_agent_options_conf(self): def test_build_agent_options_conf(self):
self.config(api_url='api-url', group='conductor') 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('api-url', options['ipa-api-url'])
self.assertEqual('fake_agent', options['ipa-driver-name'])
@mock.patch.object(keystone, 'get_service_url') @mock.patch.object(keystone, 'get_service_url')
def test_build_agent_options_keystone(self, get_url_mock): def test_build_agent_options_keystone(self, get_url_mock):
self.config(api_url=None, group='conductor') self.config(api_url=None, group='conductor')
get_url_mock.return_value = 'api-url' 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('api-url', options['ipa-api-url'])
self.assertEqual('fake_agent', options['ipa-driver-name'])
class TestAgentDeploy(db_base.DbTestCase): class TestAgentDeploy(db_base.DbTestCase):

View File

@ -61,6 +61,7 @@ class TestPXEUtils(db_base.DbTestCase):
'aki_path': u'/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/' 'aki_path': u'/tftpboot/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/'
u'kernel', u'kernel',
'ipa-api-url': 'http://192.168.122.184:6385', 'ipa-api-url': 'http://192.168.122.184:6385',
'ipa-driver-name': 'agent_ipmitool',
'deployment_aki_path': u'/tftpboot/1be26c0b-03f2-4d2e-ae87-' 'deployment_aki_path': u'/tftpboot/1be26c0b-03f2-4d2e-ae87-'
u'c02d7f33c123/deploy_kernel', u'c02d7f33c123/deploy_kernel',
} }