Update amp_network to allow multiple networks

Currently the amp_network is a stringOpt and in code it
translates that to a list for processing. It may
be required to deploy with multiple networks,
a listOpt for amp_network option allows this.

Change-Id: I4364c1d03d4c7b560f0d8030b7d66412583a31ae
This commit is contained in:
ptoohill1 2016-04-08 00:29:42 -05:00
parent 5d5dcf9951
commit 4230e00a2c
9 changed files with 56 additions and 39 deletions

View File

@ -152,11 +152,11 @@ function build_mgmt_network {
}
function configure_octavia_tempest {
# Load the amp_network_list to tempest.conf and copy to tree
# Load the amp_boot_network_list to tempest.conf and copy to tree
# TODO (ptoohill): remove check when tempest structure merges
if ! [ $OCTAVIA_TEMPEST == 'disabled' ] ; then
iniset $TEMPEST_CONFIG controller_worker amp_network $1
iniset $TEMPEST_CONFIG controller_worker amp_boot_network_list [$1]
cp $TEMPEST_CONFIG $OCTAVIA_TEMPEST_DIR/etc
fi
}
@ -188,7 +188,7 @@ function octavia_start {
build_mgmt_network
OCTAVIA_AMP_NETWORK_ID=$(neutron net-list | awk '/ lb-mgmt-net / {print $2}')
iniset $OCTAVIA_CONF controller_worker amp_network ${OCTAVIA_AMP_NETWORK_ID}
iniset $OCTAVIA_CONF controller_worker amp_boot_network_list [${OCTAVIA_AMP_NETWORK_ID}]
if is_service_enabled tempest; then
configure_octavia_tempest ${OCTAVIA_AMP_NETWORK_ID}

View File

@ -137,7 +137,22 @@
# amp_flavor_id =
# amp_ssh_key_name =
# amp_ssh_allowed_access = True
# Networks to attach to the Amphorae examples:
# - One primary network
# - amp_boot_network_list = ['22222222-3333-4444-5555-666666666666']
# - Multiple networks
# - amp_boot_network_list = [
# '11111111-2222-33333-4444-555555555555',
# '22222222-3333-4444-5555-666666666666'
# ]
# - All networks defined in the list will be attached to each ampohra
# amp_boot_network_list =
# Takes a single network id that is attached to amphorae on boot
# Deprecated...
# amp_network =
# amp_secgroup_list =
# client_ca = /etc/octavia/certs/ca_01.pem
@ -271,4 +286,4 @@
# CA certificates file to verify neutron connections when TLS is enabled
# insecure = False
# ca_certificates_file =
# ca_certificates_file =

View File

@ -219,12 +219,19 @@ controller_worker_opts = [
default=True,
help=_('Determines whether or not to allow access '
'to the Amphorae')),
cfg.ListOpt('amp_boot_network_list',
default='',
help=_('List of networks to attach to the Amphorae. '
'All networks defined in the list will '
'be attached to each amphora.')),
cfg.StrOpt('amp_network',
deprecated_for_removal=True,
deprecated_reason='Replaced by amp_boot_network_list.',
default='',
help=_('Network to attach to the Amphora')),
help=_('Network to attach to the Amphorae.')),
cfg.ListOpt('amp_secgroup_list',
default='',
help=_('List of security groups to attach to the Amphora')),
help=_('List of security groups to attach to the Amphora.')),
cfg.StrOpt('client_ca',
default='/etc/octavia/certs/ca_01.pem',
help=_('Client CA for the amphora agent to use')),

View File

@ -198,8 +198,13 @@ class VirtualMachineManager(compute_base.ComputeBase):
try:
inf_list = nova_response.interface_list()
for interface in inf_list:
if (getattr(interface, 'net_id') ==
CONF.controller_worker.amp_network):
net_id = getattr(interface, 'net_id')
if net_id in CONF.controller_worker.amp_boot_network_list:
lb_network_ip = getattr(
interface, 'fixed_ips')[0]['ip_address']
break
elif net_id == CONF.controller_worker.amp_network:
# TODO(ptoohill) deprecated, remove this block when ready..
lb_network_ip = getattr(
interface, 'fixed_ips')[0]['ip_address']
break
@ -207,18 +212,6 @@ class VirtualMachineManager(compute_base.ComputeBase):
LOG.debug('Extracting virtual interfaces through nova '
'os-interfaces extension failed.')
if not lb_network_ip:
# Try os-networks extension
# TODO(bharath) Remove when RAX doesn't need that any longer
try:
net_name = self._nova_client.networks.get(
CONF.controller_worker.amp_network).label
if net_name in nova_response.addresses:
lb_network_ip = nova_response.addresses[
net_name][0]['addr']
except Exception:
LOG.exception(_LE('Error retrieving nova virtual interfaces'))
response = models.Amphora(
compute_id=getattr(nova_response, 'id'),
status=getattr(nova_response, 'status'),

View File

@ -55,6 +55,10 @@ class ComputeCreate(BaseComputeTask):
:returns: an amphora
"""
ports = ports or []
network_ids = CONF.controller_worker.amp_boot_network_list
# TODO(ptoohill) amp_network is now deprecated, remove when ready...
if CONF.controller_worker.amp_network:
network_ids.append(CONF.controller_worker.amp_network)
config_drive_files = config_drive_files or {}
user_data = None
LOG.debug("Compute create execute for amphora with id %s", amphora_id)
@ -81,7 +85,7 @@ class ComputeCreate(BaseComputeTask):
image_tag=CONF.controller_worker.amp_image_tag,
key_name=key_name,
sec_groups=CONF.controller_worker.amp_secgroup_list,
network_ids=[CONF.controller_worker.amp_network],
network_ids=network_ids,
port_ids=[port.id for port in ports],
config_drive_files=config_drive_files,
user_data=user_data,

View File

@ -54,8 +54,11 @@ class CalculateAmphoraDelta(BaseNetworkTask):
# Figure out what networks we want
# seed with lb network(s)
subnet = self.network_driver.get_subnet(loadbalancer.vip.subnet_id)
desired_network_ids = {CONF.controller_worker.amp_network,
subnet.network_id}
# TODO(ptoohill): amp_network is deprecated, remove when ready...
desired_network_ids = {subnet.network_id}.union(
CONF.controller_worker.amp_boot_network_list)
if CONF.controller_worker.amp_network:
desired_network_ids.add(CONF.controller_worker.amp_network)
if not loadbalancer.listeners:
return None

View File

@ -92,6 +92,9 @@ class TestNovaClient(base.TestCase):
self.net_name = "lb-mgmt-net"
CONF.set_override(group='networking', name='lb_network_name',
override=self.net_name, enforce_type=True)
CONF.set_override(group='controller_worker',
name='amp_boot_network_list',
override=[1, 2], enforce_type=True)
self.amphora = models.Amphora(
compute_id=uuidutils.generate_uuid(),
@ -104,7 +107,7 @@ class TestNovaClient(base.TestCase):
self.nova_response.status = 'ACTIVE'
self.interface_list = mock.MagicMock()
self.interface_list.net_id = CONF.controller_worker.amp_network
self.interface_list.net_id = 1
self.interface_list.fixed_ips = [mock.MagicMock()]
self.interface_list.fixed_ips[0] = {'ip_address': '10.0.0.1'}
@ -220,14 +223,6 @@ class TestNovaClient(base.TestCase):
self.manager._translate_amphora(self.nova_response).lb_network_ip)
self.nova_response.interface_list.called_with()
def test_translate_amphora_nova_networks(self):
self.nova_response.interface_list.side_effect = Exception
self.manager._nova_client.networks.get.return_value = self.nova_network
amphora = self.manager._translate_amphora(self.nova_response)
self.assertEqual(self.amphora, amphora)
self.assertTrue(self.nova_response.interface_list.called)
self.manager._nova_client.networks.get.called_with(self.net_name)
def test_create_server_group(self):
self.manager.server_groups.create.return_value = self.server_group_mock

View File

@ -29,7 +29,7 @@ AMP_FLAVOR_ID = 10
AMP_IMAGE_ID = 11
AMP_IMAGE_TAG = 'glance_tag'
AMP_SSH_KEY_NAME = None
AMP_NET = uuidutils.generate_uuid()
AMP_NET = [uuidutils.generate_uuid()]
AMP_SEC_GROUPS = []
AMP_WAIT = 12
AMPHORA_ID = uuidutils.generate_uuid()
@ -66,7 +66,7 @@ class TestComputeTasks(base.TestCase):
conf.config(group="controller_worker", amp_image_tag=AMP_IMAGE_TAG)
conf.config(group="controller_worker",
amp_ssh_key_name=AMP_SSH_KEY_NAME)
conf.config(group="controller_worker", amp_network=AMP_NET)
conf.config(group="controller_worker", amp_boot_network_list=AMP_NET)
conf.config(group="controller_worker", amp_active_wait_sec=AMP_WAIT)
conf.config(group="keystone_authtoken", auth_version=AUTH_VERSION)
@ -100,7 +100,7 @@ class TestComputeTasks(base.TestCase):
image_tag=AMP_IMAGE_TAG,
key_name=AMP_SSH_KEY_NAME,
sec_groups=AMP_SEC_GROUPS,
network_ids=[AMP_NET],
network_ids=AMP_NET,
port_ids=[PORT_ID],
config_drive_files={'/etc/octavia/'
'amphora-agent.conf': 'test_conf'},
@ -160,7 +160,7 @@ class TestComputeTasks(base.TestCase):
image_tag=AMP_IMAGE_TAG,
key_name=AMP_SSH_KEY_NAME,
sec_groups=AMP_SEC_GROUPS,
network_ids=[AMP_NET],
network_ids=AMP_NET,
port_ids=[PORT_ID],
config_drive_files=None,
user_data='test_ud_conf',
@ -219,7 +219,7 @@ class TestComputeTasks(base.TestCase):
image_tag=AMP_IMAGE_TAG,
key_name=None,
sec_groups=AMP_SEC_GROUPS,
network_ids=[AMP_NET],
network_ids=AMP_NET,
port_ids=[PORT_ID],
config_drive_files={'/etc/octavia/'
'amphora-agent.conf': 'test_conf'},
@ -276,7 +276,7 @@ class TestComputeTasks(base.TestCase):
image_tag=AMP_IMAGE_TAG,
key_name=AMP_SSH_KEY_NAME,
sec_groups=AMP_SEC_GROUPS,
network_ids=[AMP_NET],
network_ids=AMP_NET,
port_ids=[],
user_data=None,
config_drive_files={

View File

@ -65,7 +65,7 @@ class TestNetworkTasks(base.TestCase):
self.amphora_mock.compute_id = COMPUTE_ID
self.amphora_mock.status = constants.AMPHORA_ALLOCATED
conf = oslo_fixture.Config(cfg.CONF)
conf.config(group="controller_worker", amp_network='netid')
conf.config(group="controller_worker", amp_boot_network_list=['netid'])
super(TestNetworkTasks, self).setUp()