Add properties argument when create ironic node

This commit simply adds local boot argument to ironic
creation process.

Change-Id: Id1435d6e9bb2a33ccd0e10a0f920070a8e37537d
This commit is contained in:
maxinjian 2017-01-20 08:28:39 -05:00
parent cc7836fd59
commit 6fccce5d52
7 changed files with 36 additions and 17 deletions

View File

@ -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 %}
{% endfor %}

View File

@ -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)

View File

@ -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)

View File

@ -2,7 +2,10 @@
"IronicNodes.create_and_delete_node": [
{
"args": {
"driver": "pxe_ssh"
"driver": "pxe_ssh",
"properties": {
"capabilities": "boot_option:local"
}
},
"runner": {
"type": "constant",

View File

@ -3,6 +3,8 @@
-
args:
driver: "pxe_ssh"
properties:
capabilities: "boot_option:local"
runner:
type: "constant"
times: 10

View File

@ -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)

View File

@ -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(),