[billy-olsen,r=] Add region information to the conf files, relations.

This change adds the appropriate region information to the conf files
and to the cloud-compute relations in order to ensure that the region
can be configured on all nova components.

Closes-Bug: #1468306
This commit is contained in:
billy.olsen@canonical.com 2016-02-12 10:38:21 -07:00
parent 00791f3f9d
commit 19df3b6430
8 changed files with 49 additions and 10 deletions

View File

@ -259,6 +259,12 @@ def config_changed():
[cluster_joined(rid) for rid in relation_ids('cluster')]
update_nrpe_config()
# If the region value has changed, notify the cloud-compute relations
# to ensure the value is propagated to the compute nodes.
if config_value_changed('region'):
for rid in relation_ids('cloud-compute'):
compute_changed(rid)
update_nova_consoleauth_config()
@ -598,6 +604,7 @@ def compute_joined(rid=None, remote_restart=False):
# (comment from bash vers) XXX Should point to VIP if clustered, or
# this may not even be needed.
'ec2_host': unit_get('private-address'),
'region': config('region')
}
# update relation setting if we're attempting to restart remote
# services
@ -611,6 +618,8 @@ def compute_joined(rid=None, remote_restart=False):
@hooks.hook('cloud-compute-relation-changed')
def compute_changed(rid=None, unit=None):
rel_settings = relation_get(rid=rid, unit=unit)
if not rel_settings.get('region', None) == config('region'):
relation_set(relation_id=rid, region=config('region'))
if 'migration_auth_type' not in rel_settings:
return
if rel_settings['migration_auth_type'] == 'ssh':
@ -1061,8 +1070,8 @@ def update_nova_consoleauth_config():
fp.write('manual\n')
fp.flush()
elif (not config('single-nova-consoleauth')
and console_attributes('protocol')):
elif (not config('single-nova-consoleauth') and
console_attributes('protocol')):
for item in ['vip_consoleauth', 'res_nova_consoleauth']:
if item not in data['delete_resources']:
data['delete_resources'].append(item)

View File

@ -348,8 +348,8 @@ def resource_map():
if plugin:
conf = neutron_plugin_attribute(plugin, 'config', net_manager)
ctxts = (neutron_plugin_attribute(plugin, 'contexts',
net_manager)
or [])
net_manager) or
[])
services = neutron_plugin_attribute(plugin, 'server_services',
net_manager)
resource_map[conf] = {}

View File

@ -130,6 +130,9 @@ default_floating_pool = {{ default_floating_pool }}
{% if volume_service -%}
volume_api_class=nova.volume.cinder.API
{% if volume_service == 'cinder' -%}
os_region_name = {{ region }}
{% endif -%}
{% endif -%}
{% if user_config_flags -%}

View File

@ -163,6 +163,8 @@ admin_user = {{ admin_user }}
admin_password = {{ admin_password }}
{% endif -%}
{% include "parts/cinder" %}
[osapi_v3]
enabled=True

View File

@ -148,6 +148,8 @@ admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
{% include "section-keystone-authtoken" %}
{% include "parts/cinder" %}
[osapi_v3]
enabled=True

5
templates/parts/cinder Normal file
View File

@ -0,0 +1,5 @@
{% if volume_service and volume_service == 'cinder' -%}
[cinder]
os_region_name = {{ region }}
{% endif -%}

View File

@ -153,6 +153,7 @@ class NovaComputeContextTests(CharmTestCase):
@mock.patch.object(neutron, 'network_manager')
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
@mock.patch('charmhelpers.contrib.openstack.context.kv')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_address_in_network')
@mock.patch('charmhelpers.contrib.openstack.context.'
@ -162,7 +163,7 @@ class NovaComputeContextTests(CharmTestCase):
@mock.patch('charmhelpers.contrib.openstack.context.relation_ids')
def test_haproxy_context(self, mock_relation_ids, mock_get_ipv6_addr,
mock_local_unit, mock_get_netmask_for_address,
mock_get_address_in_network, mock_https,
mock_get_address_in_network, mock_kv, mock_https,
mock_network_manager):
mock_network_manager.return_value = 'neutron'
mock_https.return_value = False
@ -172,6 +173,7 @@ class NovaComputeContextTests(CharmTestCase):
@mock.patch.object(neutron, 'network_manager')
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
@mock.patch('charmhelpers.contrib.openstack.context.kv')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_address_in_network')
@mock.patch('charmhelpers.contrib.openstack.context.'
@ -183,7 +185,8 @@ class NovaComputeContextTests(CharmTestCase):
mock_get_ipv6_addr, mock_local_unit,
mock_get_netmask_for_address,
mock_get_address_in_network,
mock_https, mock_network_manager):
mock_kv, mock_https,
mock_network_manager):
mock_network_manager.return_value = 'neutron'
mock_https.return_value = False
self.is_relation_made.return_value = True

View File

@ -33,6 +33,7 @@ TO_PATCH = [
'openstack_upgrade_available',
'cmd_all_services',
'config',
'config_value_changed',
'determine_endpoints',
'determine_packages',
'determine_ports',
@ -155,9 +156,8 @@ class NovaCCHooksTests(CharmTestCase):
self.assertTrue(self.save_script_rc.called)
mock_filter_packages.assert_called_with([])
@patch.object(hooks, 'config_value_changed')
@patch.object(hooks, 'configure_https')
def test_config_changed_git(self, configure_https, config_val_changed):
def test_config_changed_git(self, configure_https):
self.git_install_requested.return_value = True
repo = 'cloud:trusty-juno'
openstack_origin_git = {
@ -202,10 +202,24 @@ class NovaCCHooksTests(CharmTestCase):
self.assertTrue(self.save_script_rc.called)
mock_filter_packages.assert_called_with([])
@patch.object(hooks, 'filter_installed_packages')
@patch.object(hooks, 'configure_https')
@patch.object(hooks, 'compute_changed')
def test_config_changed_region_change(self, mock_compute_changed,
mock_config_https,
mock_filter_packages):
self.git_install_requested.return_value = False
self.openstack_upgrade_available.return_value = False
self.config_value_changed.return_value = True
self.relation_ids.side_effect = \
lambda x: ['generic_rid'] if x == 'cloud-compute' else []
hooks.config_changed()
mock_compute_changed.assert_has_calls([call('generic_rid')])
def test_compute_changed_ssh_migration(self):
self.test_relation.set({
'migration_auth_type': 'ssh', 'ssh_public_key': 'fookey',
'private-address': '10.0.0.1'})
'private-address': '10.0.0.1', 'region': 'RegionOne'})
self.ssh_known_hosts_lines.return_value = [
'k_h_0', 'k_h_1', 'k_h_2']
self.ssh_authorized_keys_lines.return_value = [
@ -233,7 +247,7 @@ class NovaCCHooksTests(CharmTestCase):
def test_compute_changed_nova_public_key(self):
self.test_relation.set({
'migration_auth_type': 'sasl', 'nova_ssh_public_key': 'fookey',
'private-address': '10.0.0.1'})
'private-address': '10.0.0.1', 'region': 'RegionOne'})
self.ssh_known_hosts_lines.return_value = [
'k_h_0', 'k_h_1', 'k_h_2']
self.ssh_authorized_keys_lines.return_value = [
@ -861,6 +875,7 @@ class NovaCCHooksTests(CharmTestCase):
def test_config_changed_single_consoleauth(self, mock_config,
mock_configure_https,
mock_filter_packages):
self.config_value_changed.return_value = False
self.git_install_requested.return_value = False
config.return_value = 'novnc'
rids = {'ha': ['ha:1']}