本文整理汇总了Python中salt.utils.namespaced_function函数的典型用法代码示例。如果您正苦于以下问题:Python namespaced_function函数的具体用法?Python namespaced_function怎么用?Python namespaced_function使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了namespaced_function函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __virtual__
def __virtual__():
'''
Set up the libcloud functions and check for JOYENT configs
'''
if get_configured_provider() is False:
return False
global script
conn = None
script = namespaced_function(script, globals(), (conn,))
return True
开发者ID:dmyerscough,项目名称:salt,代码行数:11,代码来源:joyent.py
示例2: __virtual__
def __virtual__():
"""
Set up the libcloud functions and check for JOYENT configs
"""
if get_configured_provider() is False:
log.debug("There is no Joyent cloud provider configuration available. Not " "loading module.")
return False
log.debug("Loading Joyent cloud module")
global script
conn = None
script = namespaced_function(script, globals(), (conn,))
return True
开发者ID:bemehow,项目名称:salt,代码行数:14,代码来源:joyent.py
示例3: __virtual__
def __virtual__():
'''
Only works on Windows systems
'''
if salt.utils.is_windows():
if HAS_WINDOWS_MODULES:
global check_perms, get_managed, makedirs_perms, manage_file
global source_list, mkdir, __clean_tmp, makedirs, _is_bin
check_perms = namespaced_function(check_perms, globals())
get_managed = namespaced_function(get_managed, globals())
makedirs_perms = namespaced_function(makedirs_perms, globals())
makedirs = namespaced_function(makedirs, globals())
manage_file = namespaced_function(manage_file, globals())
source_list = namespaced_function(source_list, globals())
mkdir = namespaced_function(mkdir, globals())
__clean_tmp = namespaced_function(__clean_tmp, globals())
_is_bin = namespaced_function(_is_bin, globals())
return 'file'
log.warn(salt.utils.required_modules_error(__file__, __doc__))
return False
开发者ID:herlo,项目名称:salt,代码行数:22,代码来源:win_file.py
示例4: parse_rpm
def parse_rpm(path):
try:
from salt.modules.yumpkg5 import __QUERYFORMAT, _parse_pkginfo
from salt.utils import namespaced_function
_parse_pkginfo = namespaced_function(_parse_pkginfo, globals())
except ImportError:
log.critical('Error importing helper functions. This is almost '
'certainly a bug.')
return '', ''
pkginfo = __salt__['cmd.run_all'](
'rpm -qp --queryformat {0!r} {1!r}'.format(__QUERYFORMAT, path)
).get('stdout', '').strip()
pkginfo = _parse_pkginfo(pkginfo)
if pkginfo is None:
return '', ''
else:
return pkginfo.name, pkginfo.version
开发者ID:sitepoint,项目名称:salt,代码行数:17,代码来源:pkg_resource.py
示例5: __virtual__
def __virtual__():
'''
Confine this module to yum based systems
'''
# Work only on RHEL/Fedora based distros with python 2.5 and below
try:
os_grain = __grains__['os']
os_family = __grains__['os_family']
os_major_version = int(__grains__['osrelease'].split('.')[0])
except Exception:
return False
valid = False
# Fedora <= 10 need to use this module
if os_grain == 'Fedora' and os_major_version < 11:
valid = True
# XCP == 1.x uses a CentOS 5 base
elif os_grain == 'XCP':
if os_major_version == 1:
valid = True
# XenServer 6 and earlier uses a CentOS 5 base
elif os_grain == 'XenServer':
if os_major_version <= 6:
valid = True
else:
# RHEL <= 5 and all variants need to use this module
if os_family == 'RedHat' and os_major_version <= 5:
valid = True
if valid:
global mod_repo, _parse_repo_file, list_repos, get_repo
global expand_repo_def, del_repo
mod_repo = namespaced_function(mod_repo, globals())
_parse_repo_file = namespaced_function(_parse_repo_file, globals())
list_repos = namespaced_function(list_repos, globals())
get_repo = namespaced_function(get_repo, globals())
expand_repo_def = namespaced_function(expand_repo_def, globals())
del_repo = namespaced_function(del_repo, globals())
return 'pkg'
return False
开发者ID:jaypei,项目名称:salt,代码行数:39,代码来源:yumpkg5.py
示例6: import
from salt.utils.cloud import is_public_ip
from salt.exceptions import (
SaltCloudSystemExit,
SaltCloudExecutionFailure,
SaltCloudExecutionTimeout
)
# Import 3rd-party libs
import salt.ext.six as six
from salt.ext.six.moves import http_client # pylint: disable=import-error,no-name-in-module
# Get logging started
log = logging.getLogger(__name__)
# namespace libcloudfuncs
get_salt_interface = namespaced_function(get_salt_interface, globals())
JOYENT_API_HOST_SUFFIX = '.api.joyentcloud.com'
JOYENT_API_VERSION = '~7.2'
JOYENT_LOCATIONS = {
'us-east-1': 'North Virginia, USA',
'us-west-1': 'Bay Area, California, USA',
'us-sw-1': 'Las Vegas, Nevada, USA',
'eu-ams-1': 'Amsterdam, Netherlands'
}
DEFAULT_LOCATION = 'us-east-1'
# joyent no longer reports on all data centers, so setting this value to true
# causes the list_nodes function to get information on machines from all
# data centers
开发者ID:dmyerscough,项目名称:salt,代码行数:31,代码来源:joyent.py
示例7: __virtual__
def __virtual__():
'''
Set up the libcloud funcstions and check for AWS configs
'''
if not HAS_LIBCLOUD:
return False
try:
# Import botocore
import botocore.session
except ImportError:
# Botocore is not available, the Libcloud AWS module will be loaded
# instead.
return False
# "Patch" the imported libcloud_aws to have the current __opts__
libcloud_aws.__opts__ = __opts__
libcloudfuncs.__opts__ = __opts__
if get_configured_provider() is False:
return False
for provider, details in six.iteritems(__opts__['providers']):
if 'provider' not in details or details['provider'] != 'aws':
continue
if not os.path.exists(details['private_key']):
raise SaltCloudException(
'The AWS key file {0!r} used in the {1!r} provider '
'configuration does not exist\n'.format(
details['private_key'],
provider
)
)
keymode = str(
oct(stat.S_IMODE(os.stat(details['private_key']).st_mode))
)
if keymode not in ('0400', '0600'):
raise SaltCloudException(
'The AWS key file {0!r} used in the {1!r} provider '
'configuration needs to be set to mode 0400 or 0600\n'.format(
details['private_key'],
provider
)
)
# Let's bring the functions imported from libcloud_aws to the current
# namespace.
keysdiff = set(POST_IMPORT_LOCALS_KEYS).difference(
PRE_IMPORT_LOCALS_KEYS
)
for key in keysdiff:
# only import callables that actually have __code__ (this includes
# functions but excludes Exception classes)
if (callable(POST_IMPORT_LOCALS_KEYS[key]) and
hasattr(POST_IMPORT_LOCALS_KEYS[key], "__code__")):
globals().update(
{
key: namespaced_function(
POST_IMPORT_LOCALS_KEYS[key], globals(), ()
)
}
)
global avail_images, avail_sizes, avail_locations, script
global list_nodes, list_nodes_full, list_nodes_select
# open a connection in a specific region
conn = get_conn(**{'location': get_location()})
# Init the libcloud functions
avail_locations = namespaced_function(avail_locations, globals(), (conn,))
avail_images = namespaced_function(avail_images, globals(), (conn,))
avail_sizes = namespaced_function(avail_sizes, globals(), (conn,))
script = namespaced_function(script, globals(), (conn,))
list_nodes = namespaced_function(list_nodes, globals(), (conn,))
list_nodes_full = namespaced_function(list_nodes_full, globals(), (conn,))
list_nodes_select = namespaced_function(
list_nodes_select, globals(), (conn,)
)
return 'aws'
开发者ID:DavideyLee,项目名称:salt,代码行数:83,代码来源:botocore_aws.py
示例8: namespaced_function
# Import netaddr IP matching
try:
from netaddr import all_matching_cidrs
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
# Get logging started
log = logging.getLogger(__name__)
request_log = logging.getLogger('requests')
# Some of the libcloud functions need to be in the same namespace as the
# functions defined in the module, so we create new function objects inside
# this module namespace
script = namespaced_function(script, globals())
reboot = namespaced_function(reboot, globals())
# Only load in this module is the OPENSTACK configurations are in place
def __virtual__():
'''
Check for Nova configurations
'''
request_log.setLevel(getattr(logging, __opts__.get('requests_log_level', 'warning').upper()))
return nova.HAS_NOVA
def get_configured_provider():
'''
Return the first configured instance.
开发者ID:ricardoheyn,项目名称:forzen-salt,代码行数:31,代码来源:nova.py
示例9: namespaced_function
vm_['name']
)
)
log.info('Created Cloud VM {0[name]!r}'.format(vm_))
log.debug(
'{0[name]!r} VM creation details:\n{1}'.format(
vm_, pprint.pformat(node.__dict__)
)
)
ret.update(node.__dict__)
salt.utils.cloud.fire_event(
'event',
'created instance',
'salt/cloud/{0}/created'.format(vm_['name']),
{
'name': vm_['name'],
'profile': vm_['profile'],
'provider': vm_['provider'],
},
)
return ret
list_nodes = namespaced_function(list_nodes, globals())
script = namespaced_function(script, globals())
开发者ID:dougmbaya,项目名称:salt-cloud-provider-vcloud,代码行数:29,代码来源:vcloud.py
示例10: namespaced_function
# Import libcloud
from libcloud.compute.base import NodeAuthPassword
# Import salt cloud libs
import salt.config as config
from salt.cloud.libcloudfuncs import * # pylint: disable=W0614,W0401
from salt.utils import namespaced_function
# Get logging started
log = logging.getLogger(__name__)
# Redirect linode functions to this module namespace
get_size = namespaced_function(get_size, globals())
get_image = namespaced_function(get_image, globals())
avail_locations = namespaced_function(avail_locations, globals())
avail_images = namespaced_function(avail_images, globals())
avail_sizes = namespaced_function(avail_sizes, globals())
script = namespaced_function(script, globals())
destroy = namespaced_function(destroy, globals())
list_nodes = namespaced_function(list_nodes, globals())
list_nodes_full = namespaced_function(list_nodes_full, globals())
list_nodes_select = namespaced_function(list_nodes_select, globals())
show_instance = namespaced_function(show_instance, globals())
# Only load in this module if the LINODE configurations are in place
def __virtual__():
'''
开发者ID:MadeiraCloud,项目名称:salt,代码行数:30,代码来源:linode.py
示例11: namespaced_function
# Import python libs
import logging
import os
import re
# Import salt libs
import salt.utils
if salt.utils.is_windows():
from salt.utils import namespaced_function
from salt.modules.win_pkg import _get_package_info
from salt.modules.win_pkg import get_repo_data
from salt.modules.win_pkg import _get_latest_pkg_version
from salt.modules.win_pkg import _reverse_cmp_pkg_versions
_get_package_info = namespaced_function(_get_package_info, globals())
get_repo_data = namespaced_function(get_repo_data, globals())
_get_latest_pkg_version = namespaced_function(_get_latest_pkg_version, globals())
_reverse_cmp_pkg_versions = namespaced_function(_reverse_cmp_pkg_versions, globals())
# The following imports are used by the namespaced win_pkg funcs
# and need to be included in their globals.
import msgpack
from distutils.version import LooseVersion
log = logging.getLogger(__name__)
def __gen_rtag():
'''
Return the location of the refresh tag
'''
开发者ID:jaypei,项目名称:salt,代码行数:30,代码来源:pkg.py
示例12: namespaced_function
# Import netaddr IP matching
try:
from netaddr import all_matching_cidrs
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
# Get logging started
log = logging.getLogger(__name__)
# Some of the libcloud functions need to be in the same namespace as the
# functions defined in the module, so we create new function objects inside
# this module namespace
get_size = namespaced_function(get_size, globals())
get_image = namespaced_function(get_image, globals())
avail_locations = namespaced_function(avail_locations, globals())
script = namespaced_function(script, globals())
destroy = namespaced_function(destroy, globals())
reboot = namespaced_function(reboot, globals())
# Only load in this module is the OPENSTACK configurations are in place
def __virtual__():
"""
Check for Nova configurations
"""
if get_configured_provider() is False:
log.debug("There is no Nova cloud provider configuration available. " "Not loading module.")
return False
开发者ID:ckraemer,项目名称:salt,代码行数:31,代码来源:nova.py
示例13: __virtual__
def __virtual__():
"""
Set up the libcloud funcstions and check for AWS configs
"""
try:
# Import botocore
import botocore.session
except ImportError:
# Botocore is not available, the Libcloud AWS module will be loaded
# instead.
log.debug("The 'botocore' library is not installed. The libcloud AWS " "support will be loaded instead.")
return False
# "Patch" the imported libcloud_aws to have the current __opts__
libcloud_aws.__opts__ = __opts__
libcloudfuncs.__opts__ = __opts__
if get_configured_provider() is False:
log.debug("There is no AWS cloud provider configuration available. Not " "loading module")
return False
for provider, details in __opts__["providers"].iteritems():
if "provider" not in details or details["provider"] != "aws":
continue
if not os.path.exists(details["private_key"]):
raise SaltCloudException(
"The AWS key file {0!r} used in the {1!r} provider "
"configuration does not exist\n".format(details["private_key"], provider)
)
keymode = str(oct(stat.S_IMODE(os.stat(details["private_key"]).st_mode)))
if keymode not in ("0400", "0600"):
raise SaltCloudException(
"The AWS key file {0!r} used in the {1!r} provider "
"configuration needs to be set to mode 0400 or 0600\n".format(details["private_key"], provider)
)
# Let's bring the functions imported from libcloud_aws to the current
# namespace.
keysdiff = set(POST_IMPORT_LOCALS_KEYS.keys()).difference(PRE_IMPORT_LOCALS_KEYS)
for key in keysdiff:
# only import callables that actually have __code__ (this includes
# functions but excludes Exception classes)
if callable(POST_IMPORT_LOCALS_KEYS[key]) and hasattr(POST_IMPORT_LOCALS_KEYS[key], "__code__"):
globals().update({key: namespaced_function(POST_IMPORT_LOCALS_KEYS[key], globals(), ())})
global avail_images, avail_sizes, avail_locations, script
global list_nodes, list_nodes_full, list_nodes_select
# open a connection in a specific region
conn = get_conn(**{"location": get_location()})
# Init the libcloud functions
avail_locations = namespaced_function(avail_locations, globals(), (conn,))
avail_images = namespaced_function(avail_images, globals(), (conn,))
avail_sizes = namespaced_function(avail_sizes, globals(), (conn,))
script = namespaced_function(script, globals(), (conn,))
list_nodes = namespaced_function(list_nodes, globals(), (conn,))
list_nodes_full = namespaced_function(list_nodes_full, globals(), (conn,))
list_nodes_select = namespaced_function(list_nodes_select, globals(), (conn,))
log.debug("Loading AWS botocore cloud module")
return "aws"
开发者ID:ckraemer,项目名称:salt,代码行数:64,代码来源:botocore_aws.py
示例14: import
# Import saltcloud libs
import salt.utils.cloud
import salt.config as config
from salt.cloud.libcloudfuncs import * # pylint: disable=W0401,W0614
from salt.cloud.exceptions import (
SaltCloudException,
SaltCloudSystemExit,
)
# pylint: disable=C0103,E0602,E0102
# Get logging started
log = logging.getLogger(__name__)
# Redirect GCE functions to this module namespace
avail_locations = namespaced_function(avail_locations, globals())
script = namespaced_function(script, globals())
destroy = namespaced_function(destroy, globals())
list_nodes = namespaced_function(list_nodes, globals())
list_nodes_full = namespaced_function(list_nodes_full, globals())
list_nodes_select = namespaced_function(list_nodes_select, globals())
# Only load in this module if the GCE configurations are in place
def __virtual__():
'''
Set up the libcloud functions and check for GCE configurations.
'''
if get_configured_provider() is False:
log.debug(
'There is no GCE cloud provider configuration available. Not '
开发者ID:penta-srl,项目名称:salt,代码行数:31,代码来源:gce.py
示例15: __virtual__
def __virtual__():
'''
Set up the libcloud funcstions and check for AWS configs
'''
try:
# Import botocore
import botocore.session
except ImportError:
# Botocore is not available, the Libcloud AWS module will be loaded
# instead.
return False
# "Patch" the imported libcloud_aws to have the current __opts__
libcloud_aws.__opts__ = __opts__
libcloudfuncs.__opts__ = __opts__
if get_configured_provider() is False:
return False
if get_dependencies() is False:
return False
for provider, details in six.iteritems(__opts__['providers']):
if 'aws' not in details:
continue
parameters = details['aws']
if salt.utils.cloud.check_key_path_and_mode(
provider, parameters['private_key']
) is False:
return False
# Let's bring the functions imported from libcloud_aws to the current
# namespace.
keysdiff = set(POST_IMPORT_LOCALS_KEYS).difference(
PRE_IMPORT_LOCALS_KEYS
)
for key in keysdiff:
# only import callables that actually have __code__ (this includes
# functions but excludes Exception classes)
if (callable(POST_IMPORT_LOCALS_KEYS[key]) and
hasattr(POST_IMPORT_LOCALS_KEYS[key], "__code__")):
globals().update(
{
key: namespaced_function(
POST_IMPORT_LOCALS_KEYS[key], globals(), ()
)
}
)
global avail_images, avail_sizes, avail_locations, script
global list_nodes, list_nodes_full, list_nodes_select
# open a connection in a specific region
conn = get_conn(**{'location': get_location()})
# Init the libcloud functions
avail_locations = namespaced_function(avail_locations, globals(), (conn,))
avail_images = namespaced_function(avail_images, globals(), (conn,))
avail_sizes = namespaced_function(avail_sizes, globals(), (conn,))
script = namespaced_function(script, globals(), (conn,))
list_nodes = namespaced_function(list_nodes, globals(), (conn,))
list_nodes_full = namespaced_function(list_nodes_full, globals(), (conn,))
list_nodes_select = namespaced_function(
list_nodes_select, globals(), (conn,)
)
log.warning('This driver has been deprecated and will be removed in the '
'Boron release of Salt. Please use the ec2 driver instead.')
return __virtualname__
开发者ID:HowardMei,项目名称:saltstack,代码行数:71,代码来源:botocore_aws.py
示例16: namespaced_function
SaltCloudExecutionTimeout
)
# Import netaddr IP matching
try:
from netaddr import all_matching_cidrs
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
# Get logging started
log = logging.getLogger(__name__)
request_log = logging.getLogger('requests')
# namespace libcloudfuncs
get_salt_interface = namespaced_function(get_salt_interface, globals())
# Some of the libcloud functions need to be in the same namespace as the
# functions defined in the module, so we create new function objects inside
# this module namespace
script = namespaced_function(script, globals())
reboot = namespaced_function(reboot, globals())
# Only load in this module is the OPENSTACK configurations are in place
def __virtual__():
'''
Check for Nova configurations
'''
request_log.setLevel(getattr(logging, __opts__.get('requests_log_level', 'warning').upper()))
开发者ID:dmyerscough,项目名称:salt,代码行数:31,代码来源:nova.py
示例17: namespaced_function
from salt.cloud.libcloudfuncs import * # pylint: disable=W0614,W0401
from salt.utils import namespaced_function
# Attempt to import softlayer lib
try:
import SoftLayer
HAS_SLLIBS = True
except ImportError:
HAS_SLLIBS = False
# Get logging started
log = logging.getLogger(__name__)
# Redirect SoftLayer functions to this module namespace
script = namespaced_function(script, globals())
# Only load in this module if the SoftLayer configurations are in place
def __virtual__():
'''
Set up the libcloud functions and check for SoftLayer configurations.
'''
if not HAS_SLLIBS:
log.debug(
'The SoftLayer Python Library needs to be installed in ordere to '
'use the SoftLayer HW salt.cloud module. See: '
'https://pypi.python.org/pypi/SoftLayer'
)
return False
开发者ID:MadeiraCloud,项目名称:salt,代码行数:30,代码来源:softlayer-hw.py
示例18: import
import salt.config as config
from salt.ext.six.moves import range
from salt.exceptions import (
SaltCloudException,
SaltCloudSystemExit
)
# Import Salt-Cloud Libs
import salt.utils.cloud
from salt.cloud.libcloudfuncs import get_size, get_image, script, show_instance
from salt.utils import namespaced_function
get_size = namespaced_function(get_size, globals())
get_image = namespaced_function(get_image, globals())
script = namespaced_function(script, globals())
show_instance = namespaced_function(show_instance, globals())
# Get logging started
log = logging.getLogger(__name__)
__virtualname__ = 'packet'
# Only load this module if the Packet configuration is in place.
def __virtual__():
'''
开发者ID:bryson,项目名称:salt,代码行数:31,代码来源:packet.py
示例19: __virtual__
def __virtual__():
'''
Set up the libcloud funcstions and check for AWS configs
'''
try:
import botocore
# Since we have botocore, we won't load the libcloud AWS module
return False
except ImportError:
pass
if get_configured_provider() is False:
return False
for provider, details in __opts__['providers'].iteritems():
if 'provider' not in details or details['provider'] != 'aws':
continue
if not os.path.exists(details['private_key']):
raise SaltCloudException(
'The AWS key file {0!r} used in the {1!r} provider '
'configuration does not exist\n'.format(
details['private_key'],
provider
)
)
keymode = str(
oct(stat.S_IMODE(os.stat(details['private_key']).st_mode))
)
if keymode not in ('0400', '0600'):
raise SaltCloudException(
'The AWS key file {0!r} used in the {1!r} provider '
'configuration needs to be set to mode 0400 or 0600\n'.format(
details['private_key'],
provider
)
)
global avail_images, avail_sizes, script, list_nodes
global avail_locations, list_nodes_full, list_nodes_select, get_image
global get_size, libcloudfuncs_destroy, show_instance
# open a connection in a specific region
conn = get_conn(**{'location': get_location()})
# Init the libcloud functions
get_size = namespaced_function(get_size, globals(), (conn,))
get_image = namespaced_function(get_image, globals(), (conn,))
avail_locations = namespaced_function(avail_locations, globals(), (conn,))
avail_images = namespaced_function(avail_images, globals(), (conn,))
avail_sizes = namespaced_function(avail_sizes, globals(), (conn,))
script = namespaced_function(script, globals(), (conn,))
list_nodes = namespaced_function(list_nodes, globals(), (conn,))
list_nodes_full = namespaced_function(list_nodes_full, globals(), (conn,))
list_nodes_select = namespaced_function(
list_nodes_select, globals(), (conn,)
)
libcloudfuncs_destroy = namespaced_function(
libcloudfuncs_destroy, globals(), (conn,)
)
show_instance = namespaced_function(show_instance, globals())
return __virtualname__
开发者ID:Anbcorp,项目名称:salt,代码行数:64,代码来源:libcloud_aws.py
示例20: namespaced_function
# Import netaddr IP matching
try:
from netaddr import all_matching_cidrs
HAS_NETADDR = True
except ImportError:
HAS_NETADDR = False
# Get logging started
log = logging.getLogger(__name__)
# Some of the libcloud functions need to be in the same namespace as the
# functions defined in the module, so we create new function objects inside
# this module namespace
avail_locations = namespaced_function(avail_locations, globals())
script = namespaced_function(script, globals())
destroy = namespaced_function(destroy, globals())
reboot = namespaced_function(reboot, globals())
# Only load in this module is the OPENSTACK configurations are in place
def __virtual__():
'''
Check for Nova configurations
'''
if get_configured_provider() is False:
log.debug(
'There is no Nova cloud provider configuration available. '
'Not loading module.'
)
开发者ID:bemehow,项目名称:salt,代码行数:30,代码来源:nova.py
注:本文中的salt.utils.namespaced_function函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论