Skip to content

Commit

Permalink
Merge "Updated _boot_server() to handle floating ip/external networks"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Jul 25, 2014
2 parents 7501233 + 48408ab commit 648f681
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
13 changes: 13 additions & 0 deletions rally/benchmark/scenarios/nova/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ def _boot_server(self, server_name, image_id, flavor_id, **kwargs):
Returns when the server is actually booted and is in the "Active"
state.
If multiple networks are present, the first network found that
isn't associated with a floating IP pool is used.
:param server_name: String used to name the server
:param image_id: ID of the image to be used for server creation
:param flavor_id: ID of the flavor to be used for server creation
Expand All @@ -92,6 +95,16 @@ def _boot_server(self, server_name, image_id, flavor_id, **kwargs):
elif allow_ssh_secgroup not in kwargs['security_groups']:
kwargs['security_groups'].append(allow_ssh_secgroup)

nets = self.clients("nova").networks.list()
fip_pool = [
pool.name
for pool in self.clients("nova").floating_ip_pools.list()
]
for net in nets:
if net.label not in fip_pool:
kwargs['nics'] = [{'net-id': net.id}]
break

server = self.clients("nova").servers.create(server_name, image_id,
flavor_id, **kwargs)

Expand Down
21 changes: 21 additions & 0 deletions tests/benchmark/scenarios/nova/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,27 @@ def test__boot_server(self, mock_clients):
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
'nova.boot_server')

@mock.patch(NOVA_UTILS + '.NovaScenario.clients')
def test__boot_server_with_network(self, mock_clients):
mock_clients("nova").servers.create.return_value = self.server
nova = fakes.FakeNovaClient()
networks = [
nova.networks.create('net-1'),
nova.networks.create('net-2')
]
mock_clients("nova").networks.list.return_value = networks
nova_scenario = utils.NovaScenario(context={})
return_server = nova_scenario._boot_server('server_name', 'image_id',
'flavor_id')
self._test_assert_called_once_with(
self.wait_for.mock, self.server,
CONF.benchmark.nova_server_boot_poll_interval,
CONF.benchmark.nova_server_boot_timeout)
self.res_is.mock.assert_has_calls(mock.call('ACTIVE'))
self.assertEqual(self.wait_for.mock(), return_server)
self._test_atomic_action_timer(nova_scenario.atomic_actions(),
'nova.boot_server')

@mock.patch(NOVA_UTILS + '.NovaScenario.clients')
def test__boot_server_with_ssh(self, mock_clients):
mock_clients("nova").servers.create.return_value = self.server
Expand Down

0 comments on commit 648f681

Please sign in to comment.