Remove support for nova cells v1

This change removes support for nova cells v1.

Change-Id: Id86697b6a2e893e023769ea214671e958e7166ca
This commit is contained in:
Liam Young 2018-06-13 11:05:35 +00:00
parent ba0b7f7e91
commit 21b17020d8
6 changed files with 7 additions and 102 deletions

View File

@ -70,24 +70,6 @@ class ApacheSSLContext(context.ApacheSSLContext):
return super(ApacheSSLContext, self).__call__()
class NovaCellContext(context.OSContextGenerator):
interfaces = ['nova-cell']
def __call__(self):
log('Generating template context for cell')
ctxt = {}
for rid in relation_ids('cell'):
for unit in related_units(rid):
rdata = relation_get(rid=rid, unit=unit)
ctxt = {
'cell_type': rdata.get('cell_type'),
'cell_name': rdata.get('cell_name'),
}
if context.context_complete(ctxt):
return ctxt
return {}
class NovaCellV2SharedDBContext(context.OSContextGenerator):
interfaces = ['shared-db']

View File

@ -74,7 +74,6 @@ from charmhelpers.contrib.openstack.neutron import (
from nova_cc_context import (
NeutronAPIContext,
NovaCellContext,
)
from charmhelpers.contrib.peerstorage import (
@ -164,8 +163,7 @@ AGENT_CONSOLEAUTH = 'ocf:openstack:nova-consoleauth'
AGENT_CA_PARAMS = 'op monitor interval="5s"'
def leader_init_db_if_ready(skip_acl_check=False, skip_cells_restarts=False,
db_rid=None, unit=None):
def leader_init_db_if_ready(skip_acl_check=False, db_rid=None, unit=None):
"""Initialise db if leader and db not yet intialised.
NOTE: must be called from database context.
@ -192,10 +190,6 @@ def leader_init_db_if_ready(skip_acl_check=False, skip_cells_restarts=False,
log('Triggering remote neutron-network-service restarts.')
[quantum_joined(rid=rid, remote_restart=True)
for rid in relation_ids('quantum-network-service')]
if not skip_cells_restarts:
log('Triggering remote cell restarts.')
[nova_cell_relation_joined(rid=rid, remote_restart=True)
for rid in relation_ids('cell')]
else:
log('allowed_units either not presented, or local unit '
'not in acl list: %s' % repr(allowed_units))
@ -367,8 +361,6 @@ def amqp_changed():
# to be set in nova.conf, so we attempt db init in here as well as the
# db relation-changed hooks.
update_cell_db_if_ready_allowed_units()
[nova_cell_relation_joined(rid=rid)
for rid in relation_ids('cell')]
for r_id in relation_ids('nova-api'):
nova_api_relation_joined(rid=r_id)
@ -909,8 +901,6 @@ def db_departed():
active=config('service-guard'))
def relation_broken():
CONFIGS.write_all()
[nova_cell_relation_joined(rid=rid)
for rid in relation_ids('cell')]
def configure_https():
@ -978,32 +968,6 @@ def upgrade_charm():
update_nova_consoleauth_config()
# remote_restart is defaulted to true as nova-cells may have started the
# nova-cell process before the db migration was run so it will need a
# kick
@hooks.hook('cell-relation-joined')
def nova_cell_relation_joined(rid=None, remote_restart=True):
rel_settings = {
'nova_url': "%s:8774/v2" % canonical_url(CONFIGS, INTERNAL)
}
if remote_restart:
rel_settings['restart_trigger'] = str(uuid.uuid4())
relation_set(relation_id=rid, **rel_settings)
@hooks.hook('cell-relation-changed')
@restart_on_change(restart_map())
def nova_cell_relation_changed():
CONFIGS.write(NOVA_CONF)
def get_cell_type():
cell_info = NovaCellContext()()
if 'cell_type' in cell_info:
return cell_info['cell_type']
return None
@hooks.hook('neutron-api-relation-joined')
def neutron_api_relation_joined(rid=None, remote_restart=False):
for id_rid in relation_ids('identity-service'):
@ -1011,8 +975,6 @@ def neutron_api_relation_joined(rid=None, remote_restart=False):
rel_settings = {
'nova_url': canonical_url(CONFIGS, INTERNAL) + ":8774/v2"
}
if get_cell_type():
rel_settings['cell_type'] = get_cell_type()
if remote_restart:
rel_settings['restart_trigger'] = str(uuid.uuid4())
relation_set(relation_id=rid, **rel_settings)

View File

@ -189,7 +189,6 @@ BASE_RESOURCE_MAP = OrderedDict([
interface='nova-vmware',
service='nova',
config_file=NOVA_CONF),
nova_cc_context.NovaCellContext(),
context.SyslogContext(),
context.LogLevelContext(),
nova_cc_context.HAProxyContext(),

View File

@ -47,8 +47,6 @@ requires:
interface: quantum
neutron-api:
interface: neutron-api
cell:
interface: nova-cell
ha:
interface: hacluster
scope: container

View File

@ -886,6 +886,7 @@ class NovaCCBasicDeployment(OpenStackAmuletDeployment):
ret)
amulet.raise_status(amulet.FAIL, msg=message)
self.d.configure('nova-cloud-controller', {'pci-alias': ''})
self.d.sentry.wait()
def test_400_image_instance_create(self):
"""Create an image/instance, verify they exist, and delete them."""

View File

@ -53,7 +53,6 @@ TO_PATCH = [
'determine_endpoints',
'determine_packages',
'determine_ports',
'NovaCellContext',
'open_port',
'is_relation_made',
'is_unit_paused_set',
@ -626,11 +625,10 @@ class NovaCCHooksTests(CharmTestCase):
@patch.object(utils, 'os_release')
@patch.object(hooks, 'quantum_joined')
@patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'nova_cell_relation_joined')
@patch.object(hooks, 'compute_joined')
@patch.object(hooks, 'CONFIGS')
def test_db_changed_remote_restarts(self, configs, comp_joined,
cell_joined, mock_is_db_initialised,
mock_is_db_initialised,
quantum_joined, utils_os_release,
utils_is_leader):
mock_is_db_initialised.return_value = False
@ -655,33 +653,27 @@ class NovaCCHooksTests(CharmTestCase):
self._shared_db_test(configs)
comp_joined.assert_called_with(remote_restart=True,
rid='nova-compute/0')
cell_joined.assert_called_with(remote_restart=True,
rid='nova-cell-api/0')
quantum_joined.assert_called_with(remote_restart=True,
rid='neutron-gateway/0')
self.migrate_nova_databases.assert_called_with()
@patch.object(hooks, 'nova_cell_relation_joined')
@patch.object(hooks, 'CONFIGS')
def test_amqp_relation_broken(self, configs, cell_joined):
def test_amqp_relation_broken(self, configs):
configs.write = MagicMock()
self.relation_ids.return_value = ['nova-cell-api/0']
hooks.relation_broken()
self.assertTrue(configs.write_all.called)
cell_joined.assert_called_with(rid='nova-cell-api/0')
@patch.object(hooks, 'leader_init_db_if_ready_allowed_units')
@patch.object(hooks, 'update_cell_db_if_ready_allowed_units')
@patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'quantum_joined')
@patch.object(hooks, 'nova_api_relation_joined')
@patch.object(hooks, 'nova_cell_relation_joined')
@patch.object(hooks, 'CONFIGS')
def test_amqp_changed_api_rel(self, configs, cell_joined, api_joined,
def test_amqp_changed_api_rel(self, configs, api_joined,
quantum_joined, mock_is_db_initialised,
update_db_allowed, init_db_allowed):
self.relation_ids.side_effect = [
['nova-cell-api/0'],
['nova-api/0'],
['quantum-service/0'],
]
@ -694,7 +686,6 @@ class NovaCCHooksTests(CharmTestCase):
hooks.amqp_changed()
self.assertEqual(configs.write.call_args_list,
[call('/etc/nova/nova.conf')])
cell_joined.assert_called_with(rid='nova-cell-api/0')
api_joined.assert_called_with(rid='nova-api/0')
quantum_joined.assert_called_with(rid='quantum-service/0',
remote_restart=True)
@ -704,9 +695,8 @@ class NovaCCHooksTests(CharmTestCase):
@patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'quantum_joined')
@patch.object(hooks, 'nova_api_relation_joined')
@patch.object(hooks, 'nova_cell_relation_joined')
@patch.object(hooks, 'CONFIGS')
def test_amqp_changed_noapi_rel(self, configs, cell_joined, api_joined,
def test_amqp_changed_noapi_rel(self, configs, api_joined,
quantum_joined, mock_is_db_initialised,
update_db_allowed, init_db_allowed):
mock_is_db_initialised.return_value = False
@ -714,7 +704,6 @@ class NovaCCHooksTests(CharmTestCase):
configs.complete_contexts.return_value = ['amqp']
configs.write = MagicMock()
self.relation_ids.side_effect = [
['nova-cell-api/0'],
['nova-api/0'],
['quantum-service/0'],
]
@ -724,51 +713,25 @@ class NovaCCHooksTests(CharmTestCase):
hooks.amqp_changed()
self.assertEqual(configs.write.call_args_list,
[call('/etc/nova/nova.conf')])
cell_joined.assert_called_with(rid='nova-cell-api/0')
api_joined.assert_called_with(rid='nova-api/0')
quantum_joined.assert_called_with(rid='quantum-service/0',
remote_restart=True)
@patch.object(hooks, 'canonical_url')
def test_nova_cell_relation_joined(self, _canonical_url):
self.uuid.uuid4.return_value = 'bob'
_canonical_url.return_value = 'http://novaurl'
hooks.nova_cell_relation_joined(rid='rid',
remote_restart=True)
self.relation_set.assert_called_with(restart_trigger='bob',
nova_url='http://novaurl:8774/v2',
relation_id='rid')
@patch.object(hooks, 'CONFIGS')
def test_nova_cell_relation_changed(self, configs):
hooks.nova_cell_relation_changed()
configs.write.assert_called_with('/etc/nova/nova.conf')
def test_get_cell_type(self):
self.NovaCellContext().return_value = {
'cell_type': 'parent',
'cell_name': 'api',
}
self.assertEqual(hooks.get_cell_type(), 'parent')
@patch.object(hooks, 'canonical_url')
@patch.object(os, 'rename')
@patch.object(os.path, 'isfile')
@patch.object(hooks, 'CONFIGS')
@patch.object(hooks, 'get_cell_type')
def test_neutron_api_relation_joined(self, get_cell_type, configs, isfile,
def test_neutron_api_relation_joined(self, configs, isfile,
rename, _canonical_url):
nova_url = 'http://novaurl:8774/v2'
isfile.return_value = True
_identity_joined = self.patch('identity_joined')
self.relation_ids.return_value = ['relid']
_canonical_url.return_value = 'http://novaurl'
get_cell_type.return_value = 'parent'
self.uuid.uuid4.return_value = 'bob'
hooks.neutron_api_relation_joined(remote_restart=True)
self.assertTrue(_identity_joined.called)
self.relation_set.assert_called_with(relation_id=None,
cell_type='parent',
nova_url=nova_url,
restart_trigger='bob')