Add the nics argument in servers context

The servers context require to set network id
when multiple possible networks found.

Change-Id: I2e524ce9683e738fb913b6ce9ed10c10bc708b84
Closes-Bug:#1592292
This commit is contained in:
chenhb-zte 2016-06-14 15:54:21 -04:00
parent d25ccaaa01
commit 2e557ad97c
2 changed files with 13 additions and 1 deletions

12
rally/plugins/openstack/context/nova/servers.py Normal file → Executable file
View File

@ -59,6 +59,14 @@ class ServerGenerator(context.Context):
},
"auto_assign_nic": {
"type": "boolean",
},
"nics": {
"type": "array",
"properties": {
"net-id": {
"type": "string"
}
}
}
},
"required": ["image", "flavor"],
@ -76,6 +84,7 @@ class ServerGenerator(context.Context):
flavor = self.config["flavor"]
auto_nic = self.config["auto_assign_nic"]
servers_per_tenant = self.config["servers_per_tenant"]
kwargs = {"nics": self.config.get("nics", [])}
clients = osclients.Clients(self.context["users"][0]["credential"])
image_id = types.GlanceImage.transform(clients=clients,
@ -102,7 +111,8 @@ class ServerGenerator(context.Context):
servers = nova_scenario._boot_servers(image_id, flavor_id,
requests=servers_per_tenant,
auto_assign_nic=auto_nic)
auto_assign_nic=auto_nic,
**kwargs)
current_servers = [server.id for server in servers]

View File

@ -114,10 +114,12 @@ class ServerGeneratorTestCase(test.ScenarioTestCase):
flavor_id = mock_flavor_transform.return_value
servers_ctx_config = self.context["config"]["servers"]
expected_auto_nic = servers_ctx_config.get("auto_assign_nic", False)
expected_nics = servers_ctx_config.get("nics", [])
expected_requests = servers_ctx_config.get("servers_per_tenant", False)
called_times = len(tenants)
mock_calls = [mock.call(image_id, flavor_id,
auto_assign_nic=expected_auto_nic,
nics=expected_nics,
requests=expected_requests)
for i in range(called_times)]
mock_nova_scenario__boot_servers.assert_has_calls(mock_calls)