Remove amp_image_id option

This option entered deprecation in Mitaka and is long due to be removed.

Change-Id: Ide048da1c87a4e9bc6574b39e2cf6b96b4dfaf95
This commit is contained in:
Carlos Goncalves 2020-06-23 19:54:20 +02:00
parent e475734b2a
commit 33d28b07c2
12 changed files with 46 additions and 106 deletions

View File

@ -281,7 +281,6 @@
# amp_active_wait_sec = 10
# Glance parameters to extract image ID to use for amphora. Only one of
# parameters is needed. Using tags is the recommended way to refer to images.
# amp_image_id =
# amp_image_tag =
# Optional owner ID used to restrict glance images to one owner ID.
# This is a recommended security setting.

View File

@ -437,13 +437,7 @@ controller_worker_opts = [
default='',
help=_('Glance image tag for the Amphora image to boot. '
'Use this option to be able to update the image '
'without reconfiguring Octavia. '
'Ignored if amp_image_id is defined.')),
cfg.StrOpt('amp_image_id',
default='',
deprecated_for_removal=True,
deprecated_reason='Superseded by amp_image_tag option.',
help=_('Glance image id for the Amphora image to boot')),
'without reconfiguring Octavia.')),
cfg.StrOpt('amp_image_owner_id',
default='',
help=_('Restrict glance image selection to a specific '

View File

@ -19,15 +19,13 @@ class ComputeBase(object, metaclass=abc.ABCMeta):
@abc.abstractmethod
def build(self, name="amphora_name", amphora_flavor=None,
image_id=None, image_tag=None, image_owner=None,
key_name=None, sec_groups=None, network_ids=None,
config_drive_files=None, user_data=None, server_group_id=None,
availability_zone=None):
image_tag=None, image_owner=None, key_name=None, sec_groups=None,
network_ids=None, config_drive_files=None, user_data=None,
server_group_id=None, availability_zone=None):
"""Build a new amphora.
:param name: Optional name for Amphora
:param amphora_flavor: Optionally specify a flavor
:param image_id: ID of the base image for the amphora instance
:param image_tag: tag of the base image for the amphora instance
:param key_name: Optionally specify a keypair
:param sec_groups: Optionally specify list of security groups

View File

@ -29,24 +29,22 @@ class NoopManager(object):
self.computeconfig = {}
def build(self, name="amphora_name", amphora_flavor=None,
image_id=None, image_tag=None, image_owner=None,
key_name=None, sec_groups=None, network_ids=None,
config_drive_files=None, user_data=None, port_ids=None,
server_group_id=None, availability_zone=None):
image_tag=None, image_owner=None, key_name=None, sec_groups=None,
network_ids=None, config_drive_files=None, user_data=None,
port_ids=None, server_group_id=None, availability_zone=None):
LOG.debug("Compute %s no-op, build name %s, amphora_flavor %s, "
"image_id %s, image_tag %s, image_owner %s, key_name %s, "
"sec_groups %s, network_ids %s, config_drive_files %s, "
"user_data %s, port_ids %s, server_group_id %s, "
"availability_zone %s",
"image_tag %s, image_owner %s, key_name %s, sec_groups %s, "
"network_ids %s, config_drive_files %s, user_data %s, "
"port_ids %s, server_group_id %s, availability_zone %s",
self.__class__.__name__,
name, amphora_flavor, image_id, image_tag, image_owner,
name, amphora_flavor, image_tag, image_owner,
key_name, sec_groups, network_ids, config_drive_files,
user_data, port_ids, server_group_id, availability_zone)
self.computeconfig[(name, amphora_flavor, image_id, image_tag,
self.computeconfig[(name, amphora_flavor, image_tag,
image_owner, key_name, user_data,
server_group_id)] = (
name, amphora_flavor,
image_id, image_tag, image_owner, key_name, sec_groups,
image_tag, image_owner, key_name, sec_groups,
network_ids, config_drive_files, user_data, port_ids,
server_group_id, 'build')
compute_id = uuidutils.generate_uuid()
@ -126,13 +124,12 @@ class NoopComputeDriver(driver_base.ComputeBase):
self.driver = NoopManager()
def build(self, name="amphora_name", amphora_flavor=None,
image_id=None, image_tag=None, image_owner=None,
key_name=None, sec_groups=None, network_ids=None,
config_drive_files=None, user_data=None, port_ids=None,
server_group_id=None, availability_zone=None):
image_tag=None, image_owner=None, key_name=None, sec_groups=None,
network_ids=None, config_drive_files=None, user_data=None,
port_ids=None, server_group_id=None, availability_zone=None):
compute_id = self.driver.build(name, amphora_flavor,
image_id, image_tag, image_owner,
image_tag, image_owner,
key_name, sec_groups, network_ids,
config_drive_files, user_data, port_ids,
server_group_id, availability_zone)

View File

@ -57,16 +57,6 @@ def _extract_amp_image_id_by_tag(client, image_tag, image_owner):
return image_id
def _get_image_uuid(client, image_id, image_tag, image_owner):
if image_id:
if image_tag:
LOG.warning("Both amp_image_id and amp_image_tag options defined. "
"Using the amp_image_id.")
return image_id
return _extract_amp_image_id_by_tag(client, image_tag, image_owner)
class VirtualMachineManager(compute_base.ComputeBase):
'''Compute implementation of virtual machines via nova.'''
@ -97,15 +87,13 @@ class VirtualMachineManager(compute_base.ComputeBase):
).driver
def build(self, name="amphora_name", amphora_flavor=None,
image_id=None, image_tag=None, image_owner=None,
key_name=None, sec_groups=None, network_ids=None,
port_ids=None, config_drive_files=None, user_data=None,
server_group_id=None, availability_zone=None):
image_tag=None, image_owner=None, key_name=None, sec_groups=None,
network_ids=None, port_ids=None, config_drive_files=None,
user_data=None, server_group_id=None, availability_zone=None):
'''Create a new virtual machine.
:param name: optional name for amphora
:param amphora_flavor: image flavor for virtual machine
:param image_id: image ID for virtual machine
:param image_tag: image tag for virtual machine
:param key_name: keypair to add to the virtual machine
:param sec_groups: Security group IDs for virtual machine
@ -144,8 +132,8 @@ class VirtualMachineManager(compute_base.ComputeBase):
"group": server_group_id}
az_name = availability_zone or CONF.nova.availability_zone
image_id = _get_image_uuid(
self._glance_client, image_id, image_tag, image_owner)
image_id = _extract_amp_image_id_by_tag(
self._glance_client, image_tag, image_owner)
if CONF.nova.random_amphora_name_length:
r = random.SystemRandom()

View File

@ -108,7 +108,6 @@ class ComputeCreate(BaseComputeTask):
compute_id = self.compute.build(
name="amphora-" + amphora_id,
amphora_flavor=amp_compute_flavor,
image_id=CONF.controller_worker.amp_image_id,
image_tag=CONF.controller_worker.amp_image_tag,
image_owner=CONF.controller_worker.amp_image_owner_id,
key_name=key_name,

View File

@ -113,7 +113,6 @@ class ComputeCreate(BaseComputeTask):
compute_id = self.compute.build(
name="amphora-" + amphora_id,
amphora_flavor=amp_compute_flavor,
image_id=CONF.controller_worker.amp_image_id,
image_tag=CONF.controller_worker.amp_image_tag,
image_owner=CONF.controller_worker.amp_image_owner_id,
key_name=key_name,

View File

@ -32,7 +32,6 @@ class TestNoopComputeDriver(base.TestCase):
self.name = "amphora_name"
self.amphora_flavor = "m1.tiny"
self.image_id = self.FAKE_UUID_1
self.image_tag = "faketag"
self.image_owner = self.FAKE_UUID_2
self.key_name = "key_name"
@ -54,20 +53,19 @@ class TestNoopComputeDriver(base.TestCase):
def test_build(self):
self.driver.build(self.name, self.amphora_flavor,
self.image_id, self.image_tag, self.image_owner,
self.image_tag, self.image_owner,
self.key_name, self.sec_groups, self.network_ids,
self.confdrivefiles, self.user_data, self.port_ids,
self.server_group_id)
self.assertEqual((self.name, self.amphora_flavor,
self.image_id, self.image_tag, self.image_owner,
self.image_tag, self.image_owner,
self.key_name, self.sec_groups, self.network_ids,
self.confdrivefiles, self.user_data, self.port_ids,
self.server_group_id, 'build'),
self.driver.driver.computeconfig[(
self.name,
self.amphora_flavor,
self.image_id,
self.image_tag,
self.image_owner,
self.key_name,

View File

@ -29,29 +29,6 @@ import octavia.tests.unit.base as base
CONF = cfg.CONF
class Test_GetImageUuid(base.TestCase):
def test__get_image_uuid_tag(self):
client = mock.Mock()
with mock.patch.object(nova_common,
'_extract_amp_image_id_by_tag',
return_value='fakeid') as extract:
image_id = nova_common._get_image_uuid(client, '', 'faketag', None)
self.assertEqual('fakeid', image_id)
extract.assert_called_with(client, 'faketag', None)
def test__get_image_uuid_notag(self):
client = mock.Mock()
image_id = nova_common._get_image_uuid(client, 'fakeid', '', None)
self.assertEqual('fakeid', image_id)
def test__get_image_uuid_id_beats_tag(self):
client = mock.Mock()
image_id = nova_common._get_image_uuid(client, 'fakeid',
'faketag', None)
self.assertEqual('fakeid', image_id)
class Test_ExtractAmpImageIdByTag(base.TestCase):
def setUp(self):
@ -158,10 +135,16 @@ class TestNovaClient(base.TestCase):
self.flavor_id = uuidutils.generate_uuid()
self.availability_zone = 'my_test_az'
self.mock_image_tag = mock.patch(
'octavia.compute.drivers.nova_driver.'
'_extract_amp_image_id_by_tag').start()
self.mock_image_tag.return_value = 1
self.addCleanup(self.mock_image_tag.stop)
super(TestNovaClient, self).setUp()
def test_build(self):
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='stout',
key_name=1,
sec_groups=1,
network_ids=[1],
@ -192,7 +175,7 @@ class TestNovaClient(base.TestCase):
volume_driver='volume_cinder_driver')
self.manager.volume_driver = mock_driver
mock_driver.create_volume_from_image.return_value = 1
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='pilsner',
key_name=1,
sec_groups=1,
network_ids=[1],
@ -220,7 +203,7 @@ class TestNovaClient(base.TestCase):
def test_build_with_availability_zone(self):
FAKE_AZ = "my_availability_zone"
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='malt',
key_name=1,
sec_groups=1,
network_ids=[1],
@ -250,7 +233,7 @@ class TestNovaClient(base.TestCase):
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,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='ipa',
key_name=1,
sec_groups=1,
network_ids=[1],
@ -280,14 +263,14 @@ class TestNovaClient(base.TestCase):
self.addCleanup(self.conf.config,
group='nova', random_amphora_name_length=0)
self.manager.build(name="b" * 50, image_id=1)
self.manager.build(name="b" * 50)
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,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='porter',
key_name=1,
sec_groups=1,
network_ids=None,
@ -317,16 +300,11 @@ class TestNovaClient(base.TestCase):
self.assertRaises(exceptions.ComputeBuildException, self.manager.build)
def test_build_extracts_image_id_by_tag(self):
expected_id = 'fakeid-by-tag'
with mock.patch.object(nova_common, '_get_image_uuid',
return_value=expected_id):
self.manager.build(image_id='fakeid', image_tag='tag')
self.assertEqual(expected_id,
self.manager.manager.create.call_args[1]['image'])
self.manager.build(image_tag='tag')
self.assertEqual(1, self.manager.manager.create.call_args[1]['image'])
def test_delete(self):
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='pale_ale',
key_name=1, sec_groups=1,
network_ids=[1])
self.manager.delete(amphora_id)
@ -334,7 +312,7 @@ class TestNovaClient(base.TestCase):
def test_bad_delete(self):
self.manager.manager.delete.side_effect = Exception
amphora_id = self.manager.build(amphora_flavor=1, image_id=1,
amphora_id = self.manager.build(amphora_flavor=1, image_tag='lager',
key_name=1, sec_groups=1,
network_ids=[1])
self.assertRaises(exceptions.ComputeDeleteException,

View File

@ -29,7 +29,6 @@ import octavia.tests.unit.base as base
AMP_FLAVOR_ID = '10'
AMP_IMAGE_ID = '11'
AMP_IMAGE_TAG = 'glance_tag'
AMP_SSH_KEY_NAME = None
AMP_NET = [uuidutils.generate_uuid()]
@ -66,8 +65,6 @@ class TestComputeTasks(base.TestCase):
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
self.conf.config(
group="controller_worker", amp_flavor_id=AMP_FLAVOR_ID)
self.conf.config(
group="controller_worker", amp_image_id=AMP_IMAGE_ID)
self.conf.config(
group="controller_worker", amp_image_tag=AMP_IMAGE_TAG)
self.conf.config(
@ -114,7 +111,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner=image_owner_id,
key_name=AMP_SSH_KEY_NAME,
@ -178,7 +174,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner='',
key_name=AMP_SSH_KEY_NAME,
@ -245,7 +240,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner=image_owner_id,
key_name=AMP_SSH_KEY_NAME,
@ -311,7 +305,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner='',
key_name=None,
@ -378,7 +371,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner='',
key_name=AMP_SSH_KEY_NAME,

View File

@ -28,7 +28,6 @@ import octavia.tests.unit.base as base
AMP_FLAVOR_ID = '10'
AMP_IMAGE_ID = '11'
AMP_IMAGE_TAG = 'glance_tag'
AMP_SSH_KEY_NAME = None
AMP_NET = [uuidutils.generate_uuid()]
@ -76,8 +75,6 @@ class TestComputeTasks(base.TestCase):
self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
self.conf.config(
group="controller_worker", amp_flavor_id=AMP_FLAVOR_ID)
self.conf.config(
group="controller_worker", amp_image_id=AMP_IMAGE_ID)
self.conf.config(
group="controller_worker", amp_image_tag=AMP_IMAGE_TAG)
self.conf.config(
@ -124,7 +121,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _db_amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner=image_owner_id,
key_name=AMP_SSH_KEY_NAME,
@ -188,7 +184,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _db_amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner='',
key_name=AMP_SSH_KEY_NAME,
@ -255,7 +250,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _db_amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner=image_owner_id,
key_name=AMP_SSH_KEY_NAME,
@ -321,7 +315,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _db_amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner='',
key_name=None,
@ -388,7 +381,6 @@ class TestComputeTasks(base.TestCase):
mock_driver.build.assert_called_once_with(
name="amphora-" + _db_amphora_mock.id,
amphora_flavor=AMP_FLAVOR_ID,
image_id=AMP_IMAGE_ID,
image_tag=AMP_IMAGE_TAG,
image_owner='',
key_name=AMP_SSH_KEY_NAME,

View File

@ -0,0 +1,6 @@
---
upgrade:
- |
The option ``[controller_worker]/amp_image_id`` has been deprecated since
Mitaka release and is now removed. This option was superseded by
``[controller_worker]/amp_image_tag`` option.