Fix badly named function _get_kernel_params()

Renamed _get_kernel_params() to _get_agent_params() and
appropriate module-level attribute KPARAMS to APARAMS.

Updated agent tests to match new function name.

Change-Id: I4cdf1defee7487785967a092c81c906d40bf3214
Closes-Bug: #1367917
This commit is contained in:
Clif Houck
2014-12-04 23:38:06 +00:00
parent 00812813a0
commit 7341511b98
2 changed files with 18 additions and 18 deletions

View File

@@ -47,7 +47,7 @@ def _read_params_from_file(filepath):
return params
def _get_kernel_params():
def _get_agent_params():
"""Gets parameters passed to the agent via kernel cmdline or vmedia.
Parameters can be passed using either the kernel commandline or through
@@ -124,64 +124,64 @@ def _get_vmedia_params():
return params
KPARAMS = _get_kernel_params()
APARAMS = _get_agent_params()
cli_opts = [
cfg.StrOpt('api_url',
required=('ipa-api-url' not in KPARAMS),
default=KPARAMS.get('ipa-api-url'),
required=('ipa-api-url' not in APARAMS),
default=APARAMS.get('ipa-api-url'),
deprecated_name='api-url',
help='URL of the Ironic API'),
cfg.StrOpt('listen_host',
default=KPARAMS.get('ipa-listen-host', '0.0.0.0'),
default=APARAMS.get('ipa-listen-host', '0.0.0.0'),
deprecated_name='listen-host',
help='The IP address to listen on.'),
cfg.IntOpt('listen_port',
default=int(KPARAMS.get('ipa-listen-port', 9999)),
default=int(APARAMS.get('ipa-listen-port', 9999)),
deprecated_name='listen-port',
help='The port to listen on'),
cfg.StrOpt('advertise_host',
default=KPARAMS.get('ipa-advertise-host', None),
default=APARAMS.get('ipa-advertise-host', None),
deprecated_name='advertise_host',
help='The host to tell Ironic to reply and send '
'commands to.'),
cfg.IntOpt('advertise_port',
default=int(KPARAMS.get('ipa-advertise-port', 9999)),
default=int(APARAMS.get('ipa-advertise-port', 9999)),
deprecated_name='advertise-port',
help='The port to tell Ironic to reply and send '
'commands to.'),
cfg.IntOpt('ip_lookup_attempts',
default=int(KPARAMS.get('ipa-ip-lookup-attempts', 3)),
default=int(APARAMS.get('ipa-ip-lookup-attempts', 3)),
deprecated_name='ip-lookup-attempts',
help='The number of times to try and automatically'
'determine the agent IPv4 address.'),
cfg.IntOpt('ip_lookup_sleep',
default=int(KPARAMS.get('ipa-ip-lookup-timeout', 10)),
default=int(APARAMS.get('ipa-ip-lookup-timeout', 10)),
deprecated_name='ip-lookup-sleep',
help='The amaount of time to sleep between attempts'
'to determine IP address.'),
cfg.StrOpt('network_interface',
default=KPARAMS.get('ipa-network-interface', None),
default=APARAMS.get('ipa-network-interface', None),
deprecated_name='network-interface',
help='The interface to use when looking for an IP'
'address.'),
cfg.IntOpt('lookup_timeout',
default=int(KPARAMS.get('ipa-lookup-timeout', 300)),
default=int(APARAMS.get('ipa-lookup-timeout', 300)),
deprecated_name='lookup-timeout',
help='The amount of time to retry the initial lookup '
'call to Ironic. After the timeout, the agent '
'will exit with a non-zero exit code.'),
cfg.IntOpt('lookup_interval',
default=int(KPARAMS.get('ipa-lookup-timeout', 1)),
default=int(APARAMS.get('ipa-lookup-timeout', 1)),
deprecated_name='lookup-interval',
help='The initial interval for retries on the initial '
'lookup call to Ironic. The interval will be '
@@ -189,7 +189,7 @@ cli_opts = [
'exceeded.'),
cfg.StrOpt('driver_name',
default=KPARAMS.get('ipa-driver-name', 'agent_ipmitool'),
default=APARAMS.get('ipa-driver-name', 'agent_ipmitool'),
deprecated_name='driver-name',
help='The Ironic driver in use for this node')
]

View File

@@ -326,17 +326,17 @@ class TestAgentCmd(test_base.BaseTestCase):
self.assertFalse('baz' in params)
@mock.patch.object(agent_cmd, '_read_params_from_file')
def test__get_kernel_params_kernel_cmdline(self, read_params_mock):
def test__get_agent_params_kernel_cmdline(self, read_params_mock):
expected_params = {'a': 'b'}
read_params_mock.return_value = expected_params
returned_params = agent_cmd._get_kernel_params()
returned_params = agent_cmd._get_agent_params()
read_params_mock.assert_called_once_with('/proc/cmdline')
self.assertEqual(expected_params, returned_params)
@mock.patch.object(agent_cmd, '_get_vmedia_params')
@mock.patch.object(agent_cmd, '_read_params_from_file')
def test__get_kernel_params_vmedia(self, read_params_mock,
def test__get_agent_params_vmedia(self, read_params_mock,
get_vmedia_params_mock):
kernel_params = {'boot_method': 'vmedia'}
@@ -346,7 +346,7 @@ class TestAgentCmd(test_base.BaseTestCase):
read_params_mock.return_value = kernel_params
get_vmedia_params_mock.return_value = vmedia_params
returned_params = agent_cmd._get_kernel_params()
returned_params = agent_cmd._get_agent_params()
read_params_mock.assert_called_once_with('/proc/cmdline')
self.assertEqual(expected_params, returned_params)