Merge "Add option to choose an availability_zone for amps"

This commit is contained in:
Jenkins 2017-02-14 00:23:19 +00:00 committed by Gerrit Code Review
commit 7c9baeb9d1
4 changed files with 38 additions and 2 deletions

View File

@ -281,6 +281,9 @@
# in the format "a[A-Z0-9]*".
# Otherwise, the default name format will be used: "amphora-{UUID}".
# random_amphora_name_length = 0
#
# Availability zone to use for creating Amphorae
# availability_zone =
[glance]
# The name of the glance service in the keystone catalog

View File

@ -401,6 +401,8 @@ nova_opts = [
'provided for each amphora, in the format "a[A-Z0-9]*". '
'Otherwise, the default name format will be used: '
'"amphora-{UUID}".')),
cfg.StrOpt('availability_zone', default=None,
help=_('Availability zone to use for creating Amphorae')),
]
neutron_opts = [
cfg.StrOpt('service_name',

View File

@ -151,7 +151,8 @@ class VirtualMachineManager(compute_base.ComputeBase):
files=config_drive_files,
userdata=user_data,
config_drive=True,
scheduler_hints=server_group
scheduler_hints=server_group,
availability_zone=CONF.nova.availability_zone
)
return amphora.id

View File

@ -162,7 +162,37 @@ class TestNovaClient(base.TestCase):
files='Files Blah',
userdata='Blah',
config_drive=True,
scheduler_hints=None)
scheduler_hints=None,
availability_zone=None
)
def test_build_with_availability_zone(self):
FAKE_AZ = "my_availability_zone"
self.conf.config(group="nova", availability_zone=FAKE_AZ)
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
key_name=1,
sec_groups=1,
network_ids=[1],
port_ids=[2],
user_data='Blah',
config_drive_files='Files Blah')
self.assertEqual(self.amphora.compute_id, amphora_id)
self.manager.manager.create.assert_called_with(
name="amphora_name",
nics=[{'net-id': 1}, {'port-id': 2}],
image=1,
flavor=1,
key_name=1,
security_groups=1,
files='Files Blah',
userdata='Blah',
config_drive=True,
scheduler_hints=None,
availability_zone=FAKE_AZ
)
def test_build_with_random_amphora_name_length(self):
self.conf.config(group="nova", random_amphora_name_length=15)