Browse Source

Allow granular host selection

This commit is to allow the use of the following syntax in the
scenario_availability_zone parameter:

scenario_availability_zone = availability_zone:compute_host

Change-Id: I5b93d1083ce019e1d61199ad6d7b8b478a5678b9
Closes-Bug: 1807278
changes/42/623342/2
Sphicas, Phil (ps3910) 3 years ago
parent
commit
249ad453a4
  1. 4
      shaker/engine/deploy.py
  2. 84
      shaker/tests/test_deploy.py

4
shaker/engine/deploy.py

@ -61,7 +61,9 @@ def generate_agents(compute_nodes, accommodation, unique):
zones = accommodation.get('zones')
if zones:
compute_nodes = [c for c in compute_nodes if c['zone'] in zones]
compute_nodes = [
c for c in compute_nodes if c['zone'] in zones or
':'.join(filter(None, [c['zone'], c['host']])) in zones]
if 'cross_az' in accommodation:
# sort nodes to interleave hosts from different zones
compute_nodes = prepare_for_cross_az(compute_nodes, zones)

84
shaker/tests/test_deploy.py

@ -72,6 +72,24 @@ class TestDeploy(testtools.TestCase):
unique)
self.assertEqual(expected, actual)
def test_generate_agents_alone_single_room_az_host(self):
unique = 'UU1D'
expected = {
'UU1D_agent_0': {
'id': 'UU1D_agent_0',
'mode': 'alone',
'availability_zone': '%s:uno' % ZONE,
'zone': ZONE,
'node': 'uno'},
}
zones = ['%s:uno' % ZONE]
accommodation = deploy.normalize_accommodation(
['single_room', {'zones': zones}])
actual = deploy.generate_agents(nodes_helper('uno', 'dos'),
accommodation,
unique)
self.assertEqual(expected, actual)
def test_generate_agents_pair_single_room(self):
unique = 'UU1D'
expected = {
@ -96,6 +114,32 @@ class TestDeploy(testtools.TestCase):
unique)
self.assertEqual(expected, actual)
def test_generate_agents_pair_single_room_az_host(self):
unique = 'UU1D'
expected = {
'UU1D_master_0': {
'id': 'UU1D_master_0',
'mode': 'master',
'availability_zone': '%s:uno' % ZONE,
'node': 'uno',
'zone': ZONE,
'slave_id': 'UU1D_slave_0'},
'UU1D_slave_0': {
'id': 'UU1D_slave_0',
'master_id': 'UU1D_master_0',
'mode': 'slave',
'availability_zone': '%s:dos' % ZONE,
'zone': ZONE,
'node': 'dos'},
}
zones = ['%s:uno' % ZONE, '%s:dos' % ZONE]
accommodation = deploy.normalize_accommodation(
['pair', 'single_room', {'zones': zones}])
actual = deploy.generate_agents(nodes_helper('uno', 'dos', 'tre'),
accommodation,
unique)
self.assertEqual(expected, actual)
def test_generate_agents_pair_single_room_not_enough(self):
unique = 'UU1D'
accommodation = deploy.normalize_accommodation(['pair', 'single_room'])
@ -161,6 +205,46 @@ class TestDeploy(testtools.TestCase):
unique)
self.assertEqual(expected, actual)
def test_generate_agents_pair_double_room_az_host(self):
unique = 'UU1D'
expected = {
'UU1D_master_0': {
'id': 'UU1D_master_0',
'mode': 'master',
'availability_zone': '%s:uno' % ZONE,
'node': 'uno',
'zone': ZONE,
'slave_id': 'UU1D_slave_0'},
'UU1D_slave_0': {
'id': 'UU1D_slave_0',
'master_id': 'UU1D_master_0',
'mode': 'slave',
'availability_zone': '%s:uno' % ZONE,
'zone': ZONE,
'node': 'uno'},
'UU1D_master_1': {
'id': 'UU1D_master_1',
'mode': 'master',
'availability_zone': '%s:dos' % ZONE,
'node': 'dos',
'zone': ZONE,
'slave_id': 'UU1D_slave_1'},
'UU1D_slave_1': {
'id': 'UU1D_slave_1',
'master_id': 'UU1D_master_1',
'mode': 'slave',
'availability_zone': '%s:dos' % ZONE,
'zone': ZONE,
'node': 'dos'},
}
zones = ['%s:uno' % ZONE, '%s:dos' % ZONE]
accommodation = deploy.normalize_accommodation(
['pair', 'double_room', {'zones': zones}])
actual = deploy.generate_agents(nodes_helper('uno', 'dos', 'tre'),
accommodation,
unique)
self.assertEqual(expected, actual)
def test_generate_agents_pair_mixed_room(self):
unique = 'UU1D'
expected = {

Loading…
Cancel
Save