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:
parent
d25ccaaa01
commit
2e557ad97c
|
@ -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]
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue