Pass neutron data to vmw subordinte.
This commit is contained in:
parent
028ff2ed69
commit
8550db788a
@ -25,7 +25,7 @@ from charmhelpers.core.host import (
|
||||
)
|
||||
|
||||
from charmhelpers.fetch import (
|
||||
apt_install, apt_update, filter_installed_packages
|
||||
apt_install, apt_update
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
@ -229,19 +229,9 @@ def save_novarc():
|
||||
out.write('export OS_REGION_NAME=%s\n' % config('region'))
|
||||
|
||||
|
||||
@hooks.hook('cloud-compute-relation-joined')
|
||||
def compute_joined(rid=None):
|
||||
if not eligible_leader(CLUSTER_RES):
|
||||
return
|
||||
rel_settings = {
|
||||
'network_manager': network_manager(),
|
||||
'volume_service': volume_service(),
|
||||
# (comment from bash vers) XXX Should point to VIP if clustered, or
|
||||
# this may not even be needed.
|
||||
'ec2_host': unit_get('private-address'),
|
||||
}
|
||||
|
||||
def keystone_compute_settings():
|
||||
ks_auth_config = _auth_config()
|
||||
rel_settings = {}
|
||||
|
||||
if network_manager() in ['quantum', 'neutron']:
|
||||
if ks_auth_config:
|
||||
@ -259,6 +249,22 @@ def compute_joined(rid=None):
|
||||
ks_ca = keystone_ca_cert_b64()
|
||||
if ks_auth_config and ks_ca:
|
||||
rel_settings['ca_cert'] = ks_ca
|
||||
|
||||
return rel_settings
|
||||
|
||||
|
||||
@hooks.hook('cloud-compute-relation-joined')
|
||||
def compute_joined(rid=None):
|
||||
if not eligible_leader(CLUSTER_RES):
|
||||
return
|
||||
rel_settings = {
|
||||
'network_manager': network_manager(),
|
||||
'volume_service': volume_service(),
|
||||
# (comment from bash vers) XXX Should point to VIP if clustered, or
|
||||
# this may not even be needed.
|
||||
'ec2_host': unit_get('private-address'),
|
||||
}
|
||||
rel_settings.update(keystone_compute_settings())
|
||||
relation_set(relation_id=rid, **rel_settings)
|
||||
|
||||
|
||||
@ -389,7 +395,18 @@ def configure_https():
|
||||
|
||||
@hooks.hook()
|
||||
def nova_vmware_relation_joined():
|
||||
relation_set(network_manager=network_manager())
|
||||
rel_settings = {'network_manager': network_manager()}
|
||||
|
||||
ks_auth = _auth_config()
|
||||
if ks_auth:
|
||||
rel_settings.update(ks_auth)
|
||||
rel_settings.update({
|
||||
'quantum_plugin': neutron_plugin(),
|
||||
'quantum_security_groups': config('quantum-security-groups'),
|
||||
'quantum_url': (canonical_url(CONFIGS) + ':' +
|
||||
str(api_port('neutron-server')))})
|
||||
|
||||
relation_set(**rel_settings)
|
||||
|
||||
|
||||
@hooks.hook('nova-vmware-relation-changed')
|
||||
|
2
revision
2
revision
@ -1 +1 @@
|
||||
308
|
||||
309
|
||||
|
@ -17,8 +17,10 @@ utils.restart_map = _map
|
||||
|
||||
|
||||
TO_PATCH = [
|
||||
'api_port',
|
||||
'apt_update',
|
||||
'apt_install',
|
||||
'canonical_url',
|
||||
'configure_installation_source',
|
||||
'charm_dir',
|
||||
'do_openstack_upgrade',
|
||||
@ -33,10 +35,30 @@ TO_PATCH = [
|
||||
'ssh_known_hosts_b64',
|
||||
'ssh_authorized_keys_b64',
|
||||
'save_script_rc',
|
||||
'execd_preinstall'
|
||||
'execd_preinstall',
|
||||
'network_manager',
|
||||
'volume_service',
|
||||
'unit_get',
|
||||
'eligible_leader',
|
||||
'keystone_ca_cert_b64',
|
||||
'neutron_plugin',
|
||||
]
|
||||
|
||||
|
||||
FAKE_KS_AUTH_CFG = {
|
||||
'auth_host': 'kshost',
|
||||
'auth_port': '5000',
|
||||
'service_port': 'token',
|
||||
'service_username': 'admin_user',
|
||||
'service_password': 'admin_passwd',
|
||||
'service_tenant_name': 'admin_tenant',
|
||||
'auth_uri': 'http://kshost:5000/v2',
|
||||
# quantum-gateway interface deviates a bit.
|
||||
'keystone_host': 'kshost',
|
||||
'service_tenant': 'service_tenant',
|
||||
}
|
||||
|
||||
|
||||
class NovaCCHooksTests(CharmTestCase):
|
||||
def setUp(self):
|
||||
super(NovaCCHooksTests, self).setUp(hooks, TO_PATCH)
|
||||
@ -76,3 +98,41 @@ class NovaCCHooksTests(CharmTestCase):
|
||||
self.ssh_compute_add.assert_called_with('fookey')
|
||||
self.relation_set.assert_called_with(known_hosts='hosts',
|
||||
authorized_keys='keys')
|
||||
|
||||
@patch.object(hooks, '_auth_config')
|
||||
def test_compute_joined_neutron(self, auth_config):
|
||||
self.network_manager.return_value = 'neutron'
|
||||
self.eligible_leader = True
|
||||
self.keystone_ca_cert_b64.return_value = 'foocert64'
|
||||
self.volume_service.return_value = 'cinder'
|
||||
self.unit_get.return_value = 'nova-cc-host1'
|
||||
self.canonical_url.return_value = 'http://nova-cc-host1'
|
||||
self.api_port.return_value = '9696'
|
||||
self.neutron_plugin.return_value = 'nvp'
|
||||
auth_config.return_value = FAKE_KS_AUTH_CFG
|
||||
hooks.compute_joined()
|
||||
|
||||
self.relation_set.assert_called_with(
|
||||
relation_id=None,
|
||||
quantum_url='http://nova-cc-host1:9696',
|
||||
ca_cert='foocert64',
|
||||
quantum_security_groups='no',
|
||||
region='RegionOne',
|
||||
volume_service='cinder',
|
||||
ec2_host='nova-cc-host1',
|
||||
quantum_plugin='nvp',
|
||||
network_manager='neutron', **FAKE_KS_AUTH_CFG)
|
||||
|
||||
@patch.object(hooks, '_auth_config')
|
||||
def test_nova_vmware_joined(self, auth_config):
|
||||
auth_config.return_value = FAKE_KS_AUTH_CFG
|
||||
# quantum-security-groups, plugin
|
||||
self.neutron_plugin.return_value = 'nvp'
|
||||
self.network_manager.return_value = 'neutron'
|
||||
self.canonical_url.return_value = 'http://nova-cc-host1'
|
||||
self.api_port.return_value = '9696'
|
||||
hooks.nova_vmware_relation_joined()
|
||||
self.relation_set.assert_called_with(
|
||||
network_manager='neutron', quantum_security_groups='no',
|
||||
quantum_url='http://nova-cc-host1:9696', quantum_plugin='nvp',
|
||||
**FAKE_KS_AUTH_CFG)
|
||||
|
Loading…
x
Reference in New Issue
Block a user