Allow specifying empty amp_boot_network_list
Some nova deployments automatically select their networks on boot. We can allow for this by assuming there will be some default network if the amp_boot_network_list is empty. Change-Id: I38ccfb45afb93795860c12efaf5a32f9bd1689fd
This commit is contained in:
parent
875cb2db03
commit
4fcbb833d5
|
@ -212,9 +212,15 @@ class VirtualMachineManager(compute_base.ComputeBase):
|
|||
|
||||
try:
|
||||
inf_list = nova_response.interface_list()
|
||||
no_boot_networks = (
|
||||
not CONF.controller_worker.amp_boot_network_list)
|
||||
for interface in inf_list:
|
||||
net_id = interface.net_id
|
||||
if net_id in CONF.controller_worker.amp_boot_network_list:
|
||||
is_boot_network = (
|
||||
net_id in CONF.controller_worker.amp_boot_network_list)
|
||||
# Pick the first fixed_ip if this is a boot network or if
|
||||
# there are no boot networks configured (use default network)
|
||||
if is_boot_network or no_boot_networks:
|
||||
lb_network_ip = interface.fixed_ips[0]['ip_address']
|
||||
break
|
||||
except Exception:
|
||||
|
|
|
@ -91,6 +91,7 @@ class TestNovaClient(base.TestCase):
|
|||
|
||||
def setUp(self):
|
||||
conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
|
||||
self.conf = conf
|
||||
self.net_name = "lb-mgmt-net"
|
||||
conf.config(group="networking", lb_network_name=self.net_name)
|
||||
conf.config(group="controller_worker",
|
||||
|
@ -204,6 +205,33 @@ class TestNovaClient(base.TestCase):
|
|||
self.assertEqual(
|
||||
15, len(self.manager.manager.create.call_args[1]['name']))
|
||||
|
||||
def test_build_with_default_boot_network(self):
|
||||
self.conf.config(group="controller_worker",
|
||||
amp_boot_network_list='')
|
||||
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
|
||||
key_name=1,
|
||||
sec_groups=1,
|
||||
network_ids=None,
|
||||
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=[{'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=None
|
||||
)
|
||||
|
||||
def test_bad_build(self):
|
||||
self.manager.manager.create.side_effect = Exception
|
||||
self.assertRaises(exceptions.ComputeBuildException, self.manager.build)
|
||||
|
|
Loading…
Reference in New Issue