Updating functions names and code comments
This commit is contained in:
parent
a8be08ad7e
commit
21f96b3aba
@ -1,7 +1,7 @@
|
||||
options:
|
||||
enable-metadata:
|
||||
type: boolean
|
||||
default: False
|
||||
default: True
|
||||
description: "Set as True to enable metadata support"
|
||||
install_sources:
|
||||
default: 'ppa:plumgrid-team/stable'
|
||||
|
@ -13,9 +13,9 @@ from charmhelpers.contrib.openstack import context
|
||||
from socket import gethostbyname
|
||||
|
||||
|
||||
def _edge_settings():
|
||||
def _edge_context():
|
||||
'''
|
||||
Inspects plumgrid-edge relation to get metadata shared secret.
|
||||
Inspects plumgrid-plugin relation to get metadata shared secret.
|
||||
'''
|
||||
ctxt = {
|
||||
'metadata_shared_secret': 'plumgrid',
|
||||
@ -29,9 +29,10 @@ def _edge_settings():
|
||||
return ctxt
|
||||
|
||||
|
||||
def _plumgrid_configs():
|
||||
def _plumgrid_context():
|
||||
'''
|
||||
Inspects plumgrid-director relation to get plumgrid virtup ip, username and password.
|
||||
Inspects plumgrid-configs relation to get plumgrid virtual ip,
|
||||
username and password.
|
||||
'''
|
||||
ctxt = {}
|
||||
for rid in relation_ids('plumgrid-configs'):
|
||||
@ -49,7 +50,7 @@ def _plumgrid_configs():
|
||||
|
||||
def _identity_context():
|
||||
'''
|
||||
Inspects keystone relation to get keystone credentials.
|
||||
Inspects identity-admin relation to get keystone credentials.
|
||||
'''
|
||||
ctxs = [{
|
||||
'auth_host': gethostbyname(hostname),
|
||||
@ -117,9 +118,9 @@ class NeutronPGPluginContext(context.NeutronContext):
|
||||
pg_ctxt['pg_metadata_port'] = '8775'
|
||||
pg_ctxt['metadata_mode'] = 'tunnel'
|
||||
if enable_metadata:
|
||||
plumgrid_edge_settings = _edge_settings()
|
||||
plumgrid_edge_ctxt = _edge_context()
|
||||
pg_ctxt['nova_metadata_proxy_secret'] = \
|
||||
plumgrid_edge_settings['metadata_shared_secret']
|
||||
plumgrid_edge_ctxt['metadata_shared_secret']
|
||||
else:
|
||||
pg_ctxt['nova_metadata_proxy_secret'] = 'plumgrid'
|
||||
identity_context = _identity_context()
|
||||
@ -131,10 +132,10 @@ class NeutronPGPluginContext(context.NeutronContext):
|
||||
pg_ctxt['service_protocol'] = identity_context['service_protocol']
|
||||
pg_ctxt['auth_port'] = identity_context['auth_port']
|
||||
pg_ctxt['auth_host'] = identity_context['auth_host']
|
||||
plumgrid_configs = _plumgrid_configs()
|
||||
if plumgrid_configs:
|
||||
pg_ctxt['pg_username'] = plumgrid_configs['plumgrid_username']
|
||||
pg_ctxt['pg_password'] = plumgrid_configs['plumgrid_password']
|
||||
pg_ctxt['virtual_ip'] = plumgrid_configs['plumgrid_virtual_ip']
|
||||
plumgrid_context = _plumgrid_context()
|
||||
if plumgrid_context:
|
||||
pg_ctxt['pg_username'] = plumgrid_context['plumgrid_username']
|
||||
pg_ctxt['pg_password'] = plumgrid_context['plumgrid_password']
|
||||
pg_ctxt['virtual_ip'] = plumgrid_context['plumgrid_virtual_ip']
|
||||
print pg_ctxt
|
||||
return pg_ctxt
|
||||
|
@ -167,10 +167,10 @@ def install_networking_plumgrid():
|
||||
|
||||
def migrate_neutron_db():
|
||||
release = os_release('neutron-common', base='kilo')
|
||||
neutron_db_cmd = [('plumgrid-db-manage' if release == 'kilo'
|
||||
else 'neutron-db-manage'), 'upgrade', 'heads']
|
||||
_exec_cmd(cmd=neutron_db_cmd,
|
||||
error_msg="neutron-db-manage executed with errors", fatal=False)
|
||||
_exec_cmd(cmd=[('plumgrid-db-manage' if release == 'kilo'
|
||||
else 'neutron-db-manage'), 'upgrade', 'heads'],
|
||||
error_msg="neutron-db-manage executed with errors",
|
||||
fatal=False)
|
||||
|
||||
|
||||
def set_neutron_relation():
|
||||
|
@ -27,8 +27,6 @@ requires:
|
||||
container:
|
||||
interface: neutron-plugin-api
|
||||
scope: container
|
||||
plumgrid:
|
||||
interface: plumgrid
|
||||
identity-admin:
|
||||
interface: keystone-admin
|
||||
plumgrid-configs:
|
||||
|
@ -27,7 +27,8 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
|
||||
def tearDown(self):
|
||||
super(NeutronPGContextTest, self).tearDown()
|
||||
@patch.object(context, '_plumgrid_configs')
|
||||
|
||||
@patch.object(context, '_plumgrid_context')
|
||||
@patch.object(context, '_identity_context')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'config',
|
||||
lambda *args: None)
|
||||
@ -46,7 +47,7 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
def test_neutroncc_context_api_rel(self, _unit_priv_ip, _npa, _ens_pkgs,
|
||||
_save_ff, _https, _is_clus, _unit_get,
|
||||
_config, _runits, _rids, _rget,
|
||||
_iden_context, _plum_configs):
|
||||
_iden_context, _plum_context):
|
||||
def mock_npa(plugin, section, manager):
|
||||
if section == "driver":
|
||||
return "neutron.randomdriver"
|
||||
@ -55,9 +56,6 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
|
||||
config = {
|
||||
'enable-metadata': False,
|
||||
#'plumgrid-username': 'plumgrid',
|
||||
#'plumgrid-password': 'plumgrid',
|
||||
#'plumgrid-virtual-ip': '192.168.100.250',
|
||||
'hardware-vendor-name': 'vendor_name',
|
||||
'switch-username': 'plumgrid',
|
||||
'switch-password': 'plumgrid',
|
||||
@ -73,7 +71,7 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
self.config.side_effect = mock_config
|
||||
_npa.side_effect = mock_npa
|
||||
_iden_context.return_value = None
|
||||
_plum_configs.return_value = None
|
||||
_plum_context.return_value = None
|
||||
_unit_get.return_value = '192.168.100.201'
|
||||
_unit_priv_ip.return_value = '192.168.100.201'
|
||||
napi_ctxt = context.NeutronPGPluginContext()
|
||||
|
Loading…
x
Reference in New Issue
Block a user