From 6fccce5d52b023497b41fc79136c098a09b2cc8b Mon Sep 17 00:00:00 2001 From: maxinjian Date: Fri, 20 Jan 2017 08:28:39 -0500 Subject: [PATCH] Add properties argument when create ironic node This commit simply adds local boot argument to ironic creation process. Change-Id: Id1435d6e9bb2a33ccd0e10a0f920070a8e37537d --- rally-jobs/rally-ironic.yaml | 4 +++- .../plugins/openstack/scenarios/ironic/nodes.py | 16 ++++++++++------ .../plugins/openstack/scenarios/ironic/utils.py | 5 ++++- .../scenarios/ironic/create-and-delete-node.json | 5 ++++- .../scenarios/ironic/create-and-delete-node.yaml | 2 ++ .../openstack/scenarios/ironic/test_nodes.py | 16 ++++++++++------ .../openstack/scenarios/ironic/test_utils.py | 5 +++-- 7 files changed, 36 insertions(+), 17 deletions(-) diff --git a/rally-jobs/rally-ironic.yaml b/rally-jobs/rally-ironic.yaml index cc5c1aff..bd6811db 100644 --- a/rally-jobs/rally-ironic.yaml +++ b/rally-jobs/rally-ironic.yaml @@ -4,6 +4,8 @@ - args: driver: "fake" + properties: + capabilities: "boot_option:local" runner: type: "constant" times: 100 @@ -15,4 +17,4 @@ sla: failure_rate: max: 0 - {% endfor %} \ No newline at end of file + {% endfor %} diff --git a/rally/plugins/openstack/scenarios/ironic/nodes.py b/rally/plugins/openstack/scenarios/ironic/nodes.py index 23a47d97..fbe8ff80 100644 --- a/rally/plugins/openstack/scenarios/ironic/nodes.py +++ b/rally/plugins/openstack/scenarios/ironic/nodes.py @@ -32,12 +32,14 @@ from rally.task import validation name="IronicNodes.create_and_list_node") class CreateAndListNode(utils.IronicScenario): - def run(self, driver, associated=None, maintenance=None, detail=False, - sort_dir=None, marker=None, limit=None, sort_key=None, - **kwargs): + def run(self, driver, properties=None, associated=None, maintenance=None, + detail=False, sort_dir=None, marker=None, limit=None, + sort_key=None, **kwargs): """Create and list nodes. :param driver: The name of the driver used to manage this Node. + :param properties: Key/value pair describing the physical + characteristics of the node. :param associated: Optional argument of list request. Either a Boolean or a string representation of a Boolean that indicates whether to return a list of associated (True or "True") or unassociated @@ -56,7 +58,7 @@ class CreateAndListNode(utils.IronicScenario): :param kwargs: Optional additional arguments for node creation """ - node = self._create_node(driver, **kwargs) + node = self._create_node(driver, properties, **kwargs) list_nodes = self._list_nodes( associated=associated, maintenance=maintenance, detail=detail, sort_dir=sort_dir) @@ -70,11 +72,13 @@ class CreateAndListNode(utils.IronicScenario): name="IronicNodes.create_and_delete_node") class CreateAndDeleteNode(utils.IronicScenario): - def run(self, driver, **kwargs): + def run(self, driver, properties=None, **kwargs): """Create and delete node. :param driver: The name of the driver used to manage this Node. + :param properties: Key/value pair describing the physical + characteristics of the node. :param kwargs: Optional additional arguments for node creation """ - node = self._create_node(driver, **kwargs) + node = self._create_node(driver, properties, **kwargs) self._delete_node(node) diff --git a/rally/plugins/openstack/scenarios/ironic/utils.py b/rally/plugins/openstack/scenarios/ironic/utils.py index 1e1d8456..4dded38d 100644 --- a/rally/plugins/openstack/scenarios/ironic/utils.py +++ b/rally/plugins/openstack/scenarios/ironic/utils.py @@ -61,15 +61,18 @@ class IronicScenario(scenario.OpenStackScenario): RESOURCE_NAME_ALLOWED_CHARACTERS = string.ascii_lowercase + string.digits @atomic.action_timer("ironic.create_node") - def _create_node(self, driver, **kwargs): + def _create_node(self, driver, properties, **kwargs): """Create node immediately. :param driver: The name of the driver used to manage this Node. + :param properties: Key/value pair describing the physical + characteristics of the node. :param kwargs: optional parameters to create image :returns: node object """ kwargs["name"] = self.generate_random_name() node = self.admin_clients("ironic").node.create(driver=driver, + properties=properties, **kwargs) self.sleep_between(CONF.benchmark.ironic_node_create_poll_interval) diff --git a/samples/tasks/scenarios/ironic/create-and-delete-node.json b/samples/tasks/scenarios/ironic/create-and-delete-node.json index 1e4a42fd..615206b1 100644 --- a/samples/tasks/scenarios/ironic/create-and-delete-node.json +++ b/samples/tasks/scenarios/ironic/create-and-delete-node.json @@ -2,7 +2,10 @@ "IronicNodes.create_and_delete_node": [ { "args": { - "driver": "pxe_ssh" + "driver": "pxe_ssh", + "properties": { + "capabilities": "boot_option:local" + } }, "runner": { "type": "constant", diff --git a/samples/tasks/scenarios/ironic/create-and-delete-node.yaml b/samples/tasks/scenarios/ironic/create-and-delete-node.yaml index 9fb1b33c..3e9e5fa4 100644 --- a/samples/tasks/scenarios/ironic/create-and-delete-node.yaml +++ b/samples/tasks/scenarios/ironic/create-and-delete-node.yaml @@ -3,6 +3,8 @@ - args: driver: "pxe_ssh" + properties: + capabilities: "boot_option:local" runner: type: "constant" times: 10 diff --git a/tests/unit/plugins/openstack/scenarios/ironic/test_nodes.py b/tests/unit/plugins/openstack/scenarios/ironic/test_nodes.py index 9d7cc0f0..76096525 100644 --- a/tests/unit/plugins/openstack/scenarios/ironic/test_nodes.py +++ b/tests/unit/plugins/openstack/scenarios/ironic/test_nodes.py @@ -33,6 +33,7 @@ class IronicNodesTestCase(test.ScenarioTestCase): return_value=[Node(name) for name in ("node_obj1", "node_obj2", "node_obj3")]) driver = "foo" + properties = "fake_prop" fake_params = { "sort_dir": "foo1", "associated": "foo2", @@ -42,9 +43,9 @@ class IronicNodesTestCase(test.ScenarioTestCase): } # Positive case: - scenario.run(driver, **fake_params) + scenario.run(driver, properties, **fake_params) - scenario._create_node.assert_called_once_with(driver, + scenario._create_node.assert_called_once_with(driver, properties, fake_parameter1="foo7") scenario._list_nodes.assert_called_once_with( sort_dir="foo1", associated="foo2", detail=True, @@ -53,9 +54,9 @@ class IronicNodesTestCase(test.ScenarioTestCase): # Negative case: created node not in the list of available nodes scenario._create_node = mock.Mock(uuid="foooo") self.assertRaises(exceptions.RallyAssertionError, - scenario.run, driver, **fake_params) + scenario.run, driver, properties, **fake_params) - scenario._create_node.assert_called_with(driver, + scenario._create_node.assert_called_with(driver, properties, fake_parameter1="foo7") scenario._list_nodes.assert_called_with( sort_dir="foo1", associated="foo2", detail=True, @@ -68,10 +69,13 @@ class IronicNodesTestCase(test.ScenarioTestCase): scenario._delete_node = mock.Mock() driver = "fake" + properties = "fake_prop" - scenario.run(driver, fake_parameter1="fake1", fake_parameter2="fake2") + scenario.run(driver, properties, fake_parameter1="fake1", + fake_parameter2="fake2") scenario._create_node.assert_called_once_with( - driver, fake_parameter1="fake1", fake_parameter2="fake2") + driver, properties, fake_parameter1="fake1", + fake_parameter2="fake2") scenario._delete_node.assert_called_once_with( scenario._create_node.return_value) diff --git a/tests/unit/plugins/openstack/scenarios/ironic/test_utils.py b/tests/unit/plugins/openstack/scenarios/ironic/test_utils.py index 0a9d012f..609fe9fe 100644 --- a/tests/unit/plugins/openstack/scenarios/ironic/test_utils.py +++ b/tests/unit/plugins/openstack/scenarios/ironic/test_utils.py @@ -29,10 +29,11 @@ class IronicScenarioTestCase(test.ScenarioTestCase): scenario = utils.IronicScenario(self.context) scenario.generate_random_name = mock.Mock() - scenario._create_node(driver="fake", fake_param="foo") + scenario._create_node(driver="fake", properties="fake_prop", + fake_param="foo") self.admin_clients("ironic").node.create.assert_called_once_with( - driver="fake", fake_param="foo", + driver="fake", properties="fake_prop", fake_param="foo", name=scenario.generate_random_name.return_value) self.assertTrue(mock_wait_for_status.called) self._test_atomic_action_timer(scenario.atomic_actions(),