Updated unit_tests
This commit is contained in:
parent
81ddbe68d7
commit
eec17b49e8
@ -30,16 +30,17 @@ def _edge_settings():
|
||||
|
||||
|
||||
def _identity_context():
|
||||
ctxs = [ { "auth_host": gethostbyname(hostname),
|
||||
"auth_port": relation_get("service_port", unit, rid),
|
||||
"admin_user": relation_get("service_username", unit, rid),
|
||||
"admin_password": relation_get("service_password", unit, rid),
|
||||
"service_protocol": relation_get("auth_protocol", unit, rid) or 'http',
|
||||
"admin_tenant_name": relation_get("service_tenant_name", unit, rid) }
|
||||
for rid in relation_ids("identity-admin")
|
||||
for unit, hostname in
|
||||
((unit, relation_get("service_hostname", unit, rid)) for unit in related_units(rid))
|
||||
if hostname ]
|
||||
ctxs = [{
|
||||
'auth_host': gethostbyname(hostname),
|
||||
'auth_port': relation_get('service_port', unit, rid),
|
||||
'admin_user': relation_get('service_username', unit, rid),
|
||||
'admin_password': relation_get('service_password', unit, rid),
|
||||
'service_protocol': relation_get('auth_protocol', unit, rid) or 'http',
|
||||
'admin_tenant_name': relation_get('service_tenant_name', unit,
|
||||
rid),
|
||||
} for rid in relation_ids('identity-admin') for (unit, hostname) in
|
||||
((unit, relation_get('service_hostname', unit, rid))
|
||||
for unit in related_units(rid)) if hostname]
|
||||
return ctxs[0] if ctxs else {}
|
||||
|
||||
|
||||
@ -104,7 +105,8 @@ class NeutronPGPluginContext(context.NeutronContext):
|
||||
identity_context = _identity_context()
|
||||
pg_ctxt['admin_user'] = identity_context['admin_user']
|
||||
pg_ctxt['admin_password'] = identity_context['admin_password']
|
||||
pg_ctxt['admin_tenant_name'] = identity_context['admin_tenant_name']
|
||||
pg_ctxt['admin_tenant_name'] = \
|
||||
identity_context['admin_tenant_name']
|
||||
pg_ctxt['service_protocol'] = identity_context['service_protocol']
|
||||
pg_ctxt['auth_port'] = identity_context['auth_port']
|
||||
pg_ctxt['auth_host'] = identity_context['auth_host']
|
||||
|
@ -27,8 +27,7 @@ from charmhelpers.contrib.openstack.utils import (
|
||||
TEMPLATES = 'templates/'
|
||||
|
||||
PG_PACKAGES = [
|
||||
'plumgrid-pythonlib',
|
||||
#'neutron-plugin-plumgrid'
|
||||
'plumgrid-pythonlib'
|
||||
]
|
||||
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
@ -76,8 +75,6 @@ def determine_packages():
|
||||
"Build version '%s' for package '%s' not available" \
|
||||
% (tag, pkg)
|
||||
raise ValueError(error_msg)
|
||||
# if subordinate
|
||||
#pkgs.append('neutron-plugin-plumgrid')
|
||||
cmd = ['mkdir', '-p', '/etc/neutron/plugins/plumgrid']
|
||||
check_call(cmd)
|
||||
cmd = ['touch', '/etc/neutron/plugins/plumgrid/plumgrid.ini']
|
||||
@ -154,15 +151,14 @@ def migrate_neutron_db():
|
||||
|
||||
|
||||
def set_neutron_relation():
|
||||
#release = os_release('neutron-common', base='kilo')
|
||||
#plugin = "neutron.plugins.plumgrid.plumgrid_plugin.plumgrid_plugin.NeutronPluginPLUMgridV2" \
|
||||
# if release == 'kilo'\
|
||||
# else "networking_plumgrid.neutron.plugins.plugin.NeutronPluginPLUMgridV2"
|
||||
print "#### core-plugin: %s" % neutron_plugin_attribute('plumgrid','driver','neutron')
|
||||
print "#### neutron-plugin-config %s" % neutron_plugin_attribute('plumgrid','config','neutron')
|
||||
settings = { "neutron-plugin": "plumgrid",
|
||||
"core-plugin": neutron_plugin_attribute('plumgrid','driver','neutron'),
|
||||
"neutron-plugin-config": neutron_plugin_attribute('plumgrid','config','neutron'),
|
||||
"service-plugins": " ",
|
||||
"quota-driver": "neutron.db.quota_db.DbQuotaDriver"}
|
||||
settings = {
|
||||
'neutron-plugin': 'plumgrid',
|
||||
'core-plugin': neutron_plugin_attribute('plumgrid', 'driver',
|
||||
'neutron'),
|
||||
'neutron-plugin-config': neutron_plugin_attribute('plumgrid',
|
||||
'config', 'neutron'),
|
||||
'service-plugins': ' ',
|
||||
'quota-driver': 'neutron.db.quota_db.DbQuotaDriver',
|
||||
}
|
||||
|
||||
relation_set(relation_settings=settings)
|
||||
|
@ -15,6 +15,3 @@ username={{ pg_username }}
|
||||
password={{ pg_password }}
|
||||
servertimeout=70
|
||||
|
||||
{% if database_host -%}
|
||||
connection = {{ database_type }}://{{ database_user }}:{{ database_password }}@{{ database_host }}/{{ database }}{% if database_ssl_ca %}?ssl_ca={{ database_ssl_ca }}{% if database_ssl_cert %}&ssl_cert={{ database_ssl_cert }}&ssl_key={{ database_ssl_key }}{% endif %}{% endif %}
|
||||
{% endif -%}
|
||||
|
@ -5,6 +5,7 @@ import charmhelpers
|
||||
|
||||
TO_PATCH = [
|
||||
'config',
|
||||
'relation_get'
|
||||
]
|
||||
|
||||
|
||||
@ -20,16 +21,20 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
|
||||
def setUp(self):
|
||||
super(NeutronPGContextTest, self).setUp(context, TO_PATCH)
|
||||
self.relation_get.side_effect = self.test_relation.get
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.test_config.set('enable-metadata', False)
|
||||
self.test_config.set('plumgrid-username', 'plumgrid')
|
||||
self.test_config.set('plumgrid-password', 'plumgrid')
|
||||
self.test_config.set('plumgrid-virtual-ip', '192.168.100.250')
|
||||
|
||||
def tearDown(self):
|
||||
super(NeutronPGContextTest, self).tearDown()
|
||||
|
||||
@patch.object(context, '_container_settings')
|
||||
@patch.object(context, '_identity_context')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'config',
|
||||
lambda *args: None)
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'relation_get')
|
||||
@patch.object(charmhelpers.core.hookenv, 'relation_get')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'relation_ids')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'related_units')
|
||||
@patch.object(charmhelpers.contrib.openstack.context, 'config')
|
||||
@ -44,14 +49,19 @@ 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,
|
||||
_con_settings):
|
||||
_iden_settings):
|
||||
def mock_npa(plugin, section, manager):
|
||||
if section == "driver":
|
||||
return "neutron.randomdriver"
|
||||
if section == "config":
|
||||
return "neutron.randomconfig"
|
||||
|
||||
config = {'enable-metadata': False}
|
||||
config = {
|
||||
'enable-metadata': False,
|
||||
'plumgrid-username': 'plumgrid',
|
||||
'plumgrid-password': 'plumgrid',
|
||||
'plumgrid-virtual-ip': '192.168.100.250'
|
||||
}
|
||||
|
||||
def mock_config(key=None):
|
||||
if key:
|
||||
@ -62,7 +72,7 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
self.maxDiff = None
|
||||
self.config.side_effect = mock_config
|
||||
_npa.side_effect = mock_npa
|
||||
_con_settings.return_value = {
|
||||
_iden_settings.return_value = {
|
||||
'auth_host': '10.0.0.1',
|
||||
'auth_port': '35357',
|
||||
'auth_protocol': 'http',
|
||||
@ -75,6 +85,9 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
napi_ctxt = context.NeutronPGPluginContext()
|
||||
expect = {
|
||||
'enable_metadata': False,
|
||||
'pg_username': 'plumgrid',
|
||||
'pg_password': 'plumgrid',
|
||||
'virtual_ip': '192.168.100.250',
|
||||
'config': 'neutron.randomconfig',
|
||||
'core_plugin': 'neutron.randomdriver',
|
||||
'local_ip': '192.168.100.201',
|
||||
@ -82,12 +95,12 @@ class NeutronPGContextTest(CharmTestCase):
|
||||
'neutron_plugin': 'plumgrid',
|
||||
'neutron_security_groups': None,
|
||||
'neutron_url': 'https://None:9696',
|
||||
'admin_user': 'admin',
|
||||
'admin_password': 'admin',
|
||||
'admin_tenant_name': 'admin',
|
||||
'service_protocol': 'http',
|
||||
'auth_port': '35357',
|
||||
'auth_host': '10.0.0.1',
|
||||
#'admin_user': 'admin',
|
||||
#'admin_password': 'admin',
|
||||
#'admin_tenant_name': 'admin',
|
||||
#'service_protocol': 'http',
|
||||
#'auth_port': '35357',
|
||||
#'auth_host': '10.0.0.1',
|
||||
'metadata_mode': 'tunnel',
|
||||
'nova_metadata_proxy_secret': 'plumgrid',
|
||||
'pg_metadata_ip': '169.254.169.254',
|
||||
|
@ -24,6 +24,7 @@ TO_PATCH = [
|
||||
'ensure_files',
|
||||
'stop',
|
||||
'determine_packages',
|
||||
'status_set'
|
||||
]
|
||||
NEUTRON_CONF_DIR = "/etc/neutron"
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user