Revert "Changed the way charmhelpers.core.hookenv.config is imported"
This commit is contained in:
parent
8bd46bd629
commit
3b26fda2c5
@ -1,7 +1,7 @@
|
||||
from charmhelpers.core.hookenv import (
|
||||
relation_ids, relation_set, log, ERROR,
|
||||
config, relation_ids, relation_set, log, ERROR,
|
||||
unit_get, related_units, relation_get, relations_for_id)
|
||||
from charmhelpers.core import hookenv
|
||||
|
||||
from charmhelpers.fetch import apt_install, filter_installed_packages
|
||||
from charmhelpers.contrib.openstack import context, neutron, utils
|
||||
|
||||
@ -181,14 +181,14 @@ def canonical_url(vip_setting='vip'):
|
||||
if https():
|
||||
scheme = 'https'
|
||||
|
||||
if hookenv.config('prefer-ipv6'):
|
||||
if config('prefer-ipv6'):
|
||||
if is_clustered():
|
||||
addr = '[%s]' % hookenv.config(vip_setting)
|
||||
addr = '[%s]' % config(vip_setting)
|
||||
else:
|
||||
addr = '[%s]' % get_ipv6_addr(exc_list=[hookenv.config('vip')])[0]
|
||||
addr = '[%s]' % get_ipv6_addr(exc_list=[config('vip')])[0]
|
||||
else:
|
||||
if is_clustered():
|
||||
addr = hookenv.config(vip_setting)
|
||||
addr = config(vip_setting)
|
||||
else:
|
||||
addr = unit_get('private-address')
|
||||
|
||||
@ -209,8 +209,8 @@ class NeutronCCContext(context.NeutronContext):
|
||||
|
||||
@property
|
||||
def neutron_security_groups(self):
|
||||
sec_groups = (hookenv.config('neutron-security-groups') or
|
||||
hookenv.config('quantum-security-groups'))
|
||||
sec_groups = (config('neutron-security-groups') or
|
||||
config('quantum-security-groups'))
|
||||
return sec_groups.lower() == 'yes'
|
||||
|
||||
def _ensure_packages(self):
|
||||
@ -220,9 +220,9 @@ class NeutronCCContext(context.NeutronContext):
|
||||
|
||||
def __call__(self):
|
||||
ctxt = super(NeutronCCContext, self).__call__()
|
||||
ctxt['external_network'] = hookenv.config('neutron-external-network')
|
||||
if hookenv.config('quantum-plugin') in ['nvp', 'nsx']:
|
||||
_config = hookenv.config()
|
||||
ctxt['external_network'] = config('neutron-external-network')
|
||||
if config('quantum-plugin') in ['nvp', 'nsx']:
|
||||
_config = config()
|
||||
for k, v in _config.iteritems():
|
||||
if k.startswith('nvp'):
|
||||
ctxt[k.replace('-', '_')] = v
|
||||
@ -251,7 +251,7 @@ class IdentityServiceContext(context.IdentityServiceContext):
|
||||
ctxt['service_port']
|
||||
)
|
||||
ctxt['keystone_ec2_url'] = ec2_tokens
|
||||
ctxt['region'] = hookenv.config('region')
|
||||
ctxt['region'] = config('region')
|
||||
|
||||
return ctxt
|
||||
|
||||
@ -265,21 +265,21 @@ class NeutronPostgresqlDBContext(context.PostgresqlDBContext):
|
||||
|
||||
def __init__(self):
|
||||
super(NeutronPostgresqlDBContext,
|
||||
self).__init__(hookenv.config('neutron-database'))
|
||||
self).__init__(config('neutron-database'))
|
||||
|
||||
|
||||
class NovaConfigContext(context.WorkerConfigContext):
|
||||
def __call__(self):
|
||||
ctxt = super(NovaConfigContext, self).__call__()
|
||||
ctxt['cpu_allocation_ratio'] = hookenv.config('cpu-allocation-ratio')
|
||||
ctxt['ram_allocation_ratio'] = hookenv.config('ram-allocation-ratio')
|
||||
ctxt['cpu_allocation_ratio'] = config('cpu-allocation-ratio')
|
||||
ctxt['ram_allocation_ratio'] = config('ram-allocation-ratio')
|
||||
return ctxt
|
||||
|
||||
|
||||
class NovaIPv6Context(context.BindHostContext):
|
||||
def __call__(self):
|
||||
ctxt = super(NovaIPv6Context, self).__call__()
|
||||
ctxt['use_ipv6'] = hookenv.config('prefer-ipv6')
|
||||
ctxt['use_ipv6'] = config('prefer-ipv6')
|
||||
return ctxt
|
||||
|
||||
|
||||
|
@ -14,6 +14,7 @@ TO_PATCH = [
|
||||
'relation_ids',
|
||||
'relation_get',
|
||||
'related_units',
|
||||
'config',
|
||||
'log',
|
||||
'unit_get',
|
||||
'relations_for_id',
|
||||
@ -29,6 +30,7 @@ class NovaComputeContextTests(CharmTestCase):
|
||||
def setUp(self):
|
||||
super(NovaComputeContextTests, self).setUp(context, TO_PATCH)
|
||||
self.relation_get.side_effect = self.test_relation.get
|
||||
self.config.side_effect = self.test_config.get
|
||||
self.log.side_effect = fake_log
|
||||
|
||||
@mock.patch.object(utils, 'os_release')
|
||||
|
@ -155,9 +155,8 @@ class NovaCCUtilsTests(CharmTestCase):
|
||||
_map = utils.resource_map()
|
||||
return _map
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_resource_map_quantum(self, subcontext, config_):
|
||||
def test_resource_map_quantum(self, subcontext):
|
||||
self.is_relation_made.return_value = False
|
||||
self._resource_map(network_manager='quantum')
|
||||
_map = utils.resource_map()
|
||||
@ -168,9 +167,8 @@ class NovaCCUtilsTests(CharmTestCase):
|
||||
]
|
||||
[self.assertIn(q_conf, _map.keys()) for q_conf in confs]
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_resource_map_neutron(self, subcontext, config_):
|
||||
def test_resource_map_neutron(self, subcontext):
|
||||
self.is_relation_made.return_value = False
|
||||
self._resource_map(network_manager='neutron')
|
||||
_map = utils.resource_map()
|
||||
@ -261,11 +259,9 @@ class NovaCCUtilsTests(CharmTestCase):
|
||||
for service in console_services:
|
||||
self.assertIn(service, _map['/etc/nova/nova.conf']['services'])
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch('os.path.exists')
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_restart_map_api_before_frontends(self, subcontext, _exists,
|
||||
config_):
|
||||
def test_restart_map_api_before_frontends(self, subcontext, _exists):
|
||||
self.is_relation_made.return_value = False
|
||||
_exists.return_value = False
|
||||
self._resource_map(network_manager='neutron')
|
||||
@ -307,9 +303,8 @@ class NovaCCUtilsTests(CharmTestCase):
|
||||
pkgs = utils.determine_packages()
|
||||
self.assertIn('quantum-server', pkgs)
|
||||
|
||||
@patch('charmhelpers.core.hookenv.config')
|
||||
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
|
||||
def test_determine_packages_neutron(self, subcontext, config_):
|
||||
def test_determine_packages_neutron(self, subcontext):
|
||||
self.is_relation_made.return_value = False
|
||||
self._resource_map(network_manager='neutron')
|
||||
pkgs = utils.determine_packages()
|
||||
|
Loading…
Reference in New Issue
Block a user