mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Allow modules to be packed into boto utils
A workaround to allow modules to be packed into the namespace for the boto utils.
This commit is contained in:
parent
54b9641330
commit
36d55ea0ad
3 changed files with 9 additions and 7 deletions
|
@ -125,10 +125,10 @@ def __virtual__():
|
|||
return True
|
||||
|
||||
|
||||
def __init__(opts):
|
||||
def __init__(opts, pack=None):
|
||||
salt.utils.compat.pack_dunder(__name__)
|
||||
if HAS_BOTO:
|
||||
__utils__['boto.assign_funcs'](__name__, 'vpc')
|
||||
__utils__['boto.assign_funcs'](__name__, 'vpc', pack=pack)
|
||||
|
||||
|
||||
def _check_vpc(vpc_id, vpc_name, region, key, keyid, profile):
|
||||
|
|
|
@ -88,13 +88,11 @@ def _get_profile(service, region, key, keyid, profile):
|
|||
key = _profile.get('key', None)
|
||||
keyid = _profile.get('keyid', None)
|
||||
region = _profile.get('region', None)
|
||||
|
||||
if not region and __salt__['config.option'](service + '.region'):
|
||||
region = __salt__['config.option'](service + '.region')
|
||||
|
||||
if not region:
|
||||
region = 'us-east-1'
|
||||
|
||||
if not key and __salt__['config.option'](service + '.key'):
|
||||
key = __salt__['config.option'](service + '.key')
|
||||
if not keyid and __salt__['config.option'](service + '.keyid'):
|
||||
|
@ -247,7 +245,7 @@ def exactly_one(l):
|
|||
return exactly_n(l)
|
||||
|
||||
|
||||
def assign_funcs(modname, service, module=None):
|
||||
def assign_funcs(modname, service, module=None, pack=None):
|
||||
'''
|
||||
Assign _get_conn and _cache_id functions to the named module.
|
||||
|
||||
|
@ -255,6 +253,9 @@ def assign_funcs(modname, service, module=None):
|
|||
|
||||
_utils__['boto.assign_partials'](__name__, 'ec2')
|
||||
'''
|
||||
if pack:
|
||||
global __salt__
|
||||
__salt__ = pack
|
||||
mod = sys.modules[modname]
|
||||
setattr(mod, '_get_conn', get_connection_func(service, module=module))
|
||||
setattr(mod, '_cache_id', cache_id_func(service))
|
||||
|
|
|
@ -9,7 +9,7 @@ from distutils.version import LooseVersion # pylint: disable=import-error,no-na
|
|||
|
||||
# Import Salt Testing libs
|
||||
from salttesting.unit import skipIf, TestCase
|
||||
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch
|
||||
from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch, MagicMock
|
||||
from salttesting.helpers import ensure_in_syspath
|
||||
|
||||
ensure_in_syspath('../../')
|
||||
|
@ -70,9 +70,10 @@ dhcp_options_parameters.update(conn_parameters)
|
|||
|
||||
opts = salt.config.DEFAULT_MINION_OPTS
|
||||
utils = salt.loader.utils(opts, whitelist=['boto'])
|
||||
mods = salt.loader.minion_mods(opts)
|
||||
|
||||
boto_vpc.__utils__ = utils
|
||||
boto_vpc.__init__(opts)
|
||||
boto_vpc.__init__(opts, pack=mods)
|
||||
|
||||
|
||||
def _has_required_boto():
|
||||
|
|
Loading…
Add table
Reference in a new issue