Terminate if accommodation is not satisfied
Also rename parameter 'vm_accommodation' into 'accommodation'. Change-Id: I362213023f2fd7bdb7133044d67ffddd18571884
This commit is contained in:
parent
d120e3ecd3
commit
37ac860fb8
@ -4,7 +4,7 @@ description:
|
||||
|
||||
deployment:
|
||||
template: instance_metadata.hot
|
||||
vm_accommodation: [single_room, density: 2, compute_nodes: 1]
|
||||
accommodation: [single_room, density: 2, compute_nodes: 1]
|
||||
|
||||
execution:
|
||||
tests:
|
||||
|
@ -6,7 +6,7 @@ description:
|
||||
|
||||
deployment:
|
||||
template: l2.hot
|
||||
vm_accommodation: [pair, single_room]
|
||||
accommodation: [pair, single_room]
|
||||
|
||||
execution:
|
||||
tests:
|
||||
|
@ -5,7 +5,7 @@ description:
|
||||
|
||||
deployment:
|
||||
template: l2.hot
|
||||
vm_accommodation: [pair, single_room, density: 4, compute_nodes: 2]
|
||||
accommodation: [pair, single_room, density: 4, compute_nodes: 2]
|
||||
|
||||
execution:
|
||||
size: 'quadratic_progression'
|
||||
|
@ -4,7 +4,7 @@ description:
|
||||
|
||||
deployment:
|
||||
template: l3_east_west.hot
|
||||
vm_accommodation: [pair, single_room]
|
||||
accommodation: [pair, single_room]
|
||||
|
||||
execution:
|
||||
tests:
|
||||
|
@ -5,7 +5,7 @@ description:
|
||||
|
||||
deployment:
|
||||
template: l3_north_south.hot
|
||||
vm_accommodation: [pair, double_room]
|
||||
accommodation: [pair, double_room]
|
||||
|
||||
execution:
|
||||
size: 'quadratic_progression'
|
||||
|
@ -3,7 +3,7 @@ description:
|
||||
|
||||
deployment:
|
||||
template: dummy.hot
|
||||
vm_accommodation: [single_room]
|
||||
accommodation: [single_room]
|
||||
|
||||
execution:
|
||||
tests:
|
||||
|
@ -26,9 +26,9 @@ from shaker.openstack.clients import openstack
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def generate_agents(compute_nodes, vm_accommodation, unique):
|
||||
def generate_agents(compute_nodes, accommodation, unique):
|
||||
density = 1
|
||||
for s in vm_accommodation:
|
||||
for s in accommodation:
|
||||
if isinstance(s, dict):
|
||||
if s.get('density'):
|
||||
density = s.get('density')
|
||||
@ -38,41 +38,41 @@ def generate_agents(compute_nodes, vm_accommodation, unique):
|
||||
cn_count = len(compute_nodes)
|
||||
iterations = cn_count * density
|
||||
|
||||
if 'single_room' in vm_accommodation and 'pair' in vm_accommodation:
|
||||
if 'single_room' in accommodation and 'pair' in accommodation:
|
||||
iterations //= 2
|
||||
node_formula = lambda x: compute_nodes[x % cn_count]
|
||||
|
||||
agents = {}
|
||||
|
||||
for i in range(iterations):
|
||||
if 'pair' in vm_accommodation:
|
||||
if 'pair' in accommodation:
|
||||
master_id = '%s_master_%s' % (unique, i)
|
||||
slave_id = '%s_slave_%s' % (unique, i)
|
||||
master = dict(id=master_id, mode='master', slave_id=slave_id)
|
||||
slave = dict(id=slave_id, mode='slave', master_id=master_id)
|
||||
|
||||
if 'single_room' in vm_accommodation:
|
||||
if 'single_room' in accommodation:
|
||||
master['node'] = node_formula(i * 2)
|
||||
slave['node'] = node_formula(i * 2 + 1)
|
||||
elif 'double_room' in vm_accommodation:
|
||||
elif 'double_room' in accommodation:
|
||||
master['node'] = node_formula(i)
|
||||
slave['node'] = node_formula(i)
|
||||
elif 'mixed_room' in vm_accommodation:
|
||||
elif 'mixed_room' in accommodation:
|
||||
master['node'] = node_formula(i)
|
||||
slave['node'] = node_formula(i + 1)
|
||||
|
||||
agents[master['id']] = master
|
||||
agents[slave['id']] = slave
|
||||
else:
|
||||
if 'single_room' in vm_accommodation:
|
||||
if 'single_room' in accommodation:
|
||||
agent_id = '%s_agent_%s' % (unique, i)
|
||||
agents[agent_id] = dict(id=agent_id, node=node_formula(i),
|
||||
mode='alone')
|
||||
|
||||
if not agents:
|
||||
LOG.warning('Not enough compute nodes %(cn)s for requested '
|
||||
'instance accommodation %(acc)s',
|
||||
dict(cn=compute_nodes, acc=vm_accommodation))
|
||||
raise Exception('Not enough compute nodes %(cn)s for requested '
|
||||
'instance accommodation %(acc)s' %
|
||||
dict(cn=compute_nodes, acc=accommodation))
|
||||
|
||||
return agents
|
||||
|
||||
@ -145,7 +145,8 @@ class Deployment(object):
|
||||
def _deploy_from_hot(self, specification, base_dir=None):
|
||||
agents = generate_agents(
|
||||
nova.get_available_compute_nodes(self.openstack_client.nova),
|
||||
specification['vm_accommodation'],
|
||||
specification.get('accommodation') or
|
||||
specification.get('vm_accommodation'),
|
||||
self.stack_name)
|
||||
|
||||
# render template by jinja
|
||||
|
@ -56,6 +56,11 @@ class TestDeploy(testtools.TestCase):
|
||||
unique)
|
||||
self.assertEqual(expected, actual)
|
||||
|
||||
def test_generate_agents_pair_single_room_not_enough(self):
|
||||
unique = 'UU1D'
|
||||
self.assertRaises(Exception, deploy.generate_agents, ['uno'],
|
||||
['pair', 'single_room'], unique) # NOQA
|
||||
|
||||
def test_generate_agents_pair_double_room(self):
|
||||
unique = 'UU1D'
|
||||
expected = {
|
||||
|
Loading…
Reference in New Issue
Block a user