Allow a configuration option for random Amphora name
Also do a minor config file cleanup (looks like a bad previous merge). Change-Id: I66e71795a4910c91cc2af4107fc60cc5aae72c79 Closes-Bug: #1663037
This commit is contained in:
parent
9cd1bab382
commit
f345b4273b
|
@ -274,9 +274,16 @@
|
|||
# endpoint_type = publicURL
|
||||
|
||||
# CA certificates file to verify neutron connections when TLS is enabled
|
||||
# insecure = False
|
||||
# ca_certificates_file =
|
||||
|
||||
# Disable certificate validation on SSL connections
|
||||
# insecure = False
|
||||
|
||||
# If non-zero, generate a random name of the length provided for each amphora,
|
||||
# in the format "a[A-Z0-9]*".
|
||||
# Otherwise, the default name format will be used: "amphora-{UUID}".
|
||||
# random_amphora_name_length = 0
|
||||
|
||||
[glance]
|
||||
# The name of the glance service in the keystone catalog
|
||||
# service_name =
|
||||
|
|
|
@ -392,12 +392,16 @@ nova_opts = [
|
|||
help=_('CA certificates file path')),
|
||||
cfg.BoolOpt('insecure',
|
||||
default=False,
|
||||
help=_('Disable certificate validation on SSL connections ')),
|
||||
help=_('Disable certificate validation on SSL connections')),
|
||||
cfg.BoolOpt('enable_anti_affinity', default=False,
|
||||
help=_('Flag to indicate if nova anti-affinity feature is '
|
||||
'turned on.'))
|
||||
'turned on.')),
|
||||
cfg.IntOpt('random_amphora_name_length', default=0,
|
||||
help=_('If non-zero, generate a random name of the length '
|
||||
'provided for each amphora, in the format "a[A-Z0-9]*". '
|
||||
'Otherwise, the default name format will be used: '
|
||||
'"amphora-{UUID}".')),
|
||||
]
|
||||
|
||||
neutron_opts = [
|
||||
cfg.StrOpt('service_name',
|
||||
help=_('The name of the neutron service in the '
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import random
|
||||
import string
|
||||
|
||||
from novaclient import exceptions as nova_exceptions
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
@ -133,6 +136,14 @@ class VirtualMachineManager(compute_base.ComputeBase):
|
|||
|
||||
image_id = _get_image_uuid(
|
||||
self._glance_client, image_id, image_tag, image_owner)
|
||||
|
||||
if CONF.nova.random_amphora_name_length:
|
||||
r = random.SystemRandom()
|
||||
name = "a{}".format("".join(
|
||||
[r.choice(string.ascii_uppercase + string.digits)
|
||||
for i in range(CONF.nova.random_amphora_name_length - 1)]
|
||||
))
|
||||
|
||||
amphora = self.manager.create(
|
||||
name=name, image=image_id, flavor=amphora_flavor,
|
||||
key_name=key_name, security_groups=sec_groups,
|
||||
|
|
|
@ -16,6 +16,8 @@ import mock
|
|||
import testtools
|
||||
|
||||
from octavia.common import clients
|
||||
# needed for tests to function when run independently:
|
||||
from octavia.common import config # noqa: F401
|
||||
|
||||
|
||||
class TestCase(testtools.TestCase):
|
||||
|
|
|
@ -94,6 +94,7 @@ class TestNovaClient(base.TestCase):
|
|||
self.net_name = "lb-mgmt-net"
|
||||
conf.config(group="networking", lb_network_name=self.net_name)
|
||||
conf.config(group="controller_worker", amp_boot_network_list=[1, 2])
|
||||
self.conf = conf
|
||||
|
||||
self.amphora = models.Amphora(
|
||||
compute_id=uuidutils.generate_uuid(),
|
||||
|
@ -163,6 +164,15 @@ class TestNovaClient(base.TestCase):
|
|||
config_drive=True,
|
||||
scheduler_hints=None)
|
||||
|
||||
def test_build_with_random_amphora_name_length(self):
|
||||
self.conf.config(group="nova", random_amphora_name_length=15)
|
||||
self.addCleanup(self.conf.config,
|
||||
group='nova', random_amphora_name_length=0)
|
||||
|
||||
self.manager.build(name="b" * 50, image_id=1)
|
||||
self.assertEqual(
|
||||
15, len(self.manager.manager.create.call_args[1]['name']))
|
||||
|
||||
def test_bad_build(self):
|
||||
self.manager.manager.create.side_effect = Exception
|
||||
self.assertRaises(exceptions.ComputeBuildException, self.manager.build)
|
||||
|
|
Loading…
Reference in New Issue