本文整理汇总了Python中salt.utils.verify.verify_env函数的典型用法代码示例。如果您正苦于以下问题:Python verify_env函数的具体用法?Python verify_env怎么用?Python verify_env使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了verify_env函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
"""
Execute the salt call!
"""
self.parse_args()
if self.config["verify_env"]:
verify_env(
[self.config["pki_dir"], self.config["cachedir"], os.path.dirname(self.config["log_file"])],
self.config["user"],
permissive=self.config["permissive_pki_access"],
pki_dir=self.config["pki_dir"],
)
if self.options.local:
self.config["file_client"] = "local"
# Setup file logging!
self.setup_logfile_logger()
caller = salt.cli.caller.Caller(self.config)
if self.options.doc:
caller.print_docs()
self.exit(0)
if self.options.grains_run:
caller.print_grains()
self.exit(0)
caller.run()
开发者ID:rizumu,项目名称:salt,代码行数:31,代码来源:__init__.py
示例2: start
def start(self):
'''
Execute this method to start up a syndic.
'''
verify_env([self.opts['pki_dir'], self.opts['cachedir'],
os.path.dirname(self.opts['log_file']),
],
self.opts['user'])
import salt.log
salt.log.setup_logfile_logger(
self.opts['log_file'], self.opts['log_level']
)
for name, level in self.opts['log_granular_levels'].items():
salt.log.set_logger_level(name, level)
import logging
# Late import so logging works correctly
import salt.minion
log = logging.getLogger(__name__)
if self.cli['daemon']:
# Late import so logging works correctly
import salt.utils
salt.utils.daemonize()
set_pidfile(self.cli['pidfile'])
if check_user(self.opts['user'], log):
try:
syndic = salt.minion.Syndic(self.opts)
syndic.tune_in()
except KeyboardInterrupt:
log.warn('Stopping the Salt Syndic Minion')
raise SystemExit('\nExiting on Ctrl-c')
开发者ID:Adapptor,项目名称:salt,代码行数:32,代码来源:__init__.py
示例3: run
def run(self):
"""
Execute salt-run
"""
self.parse_args()
if self.config["verify_env"]:
verify_env(
[self.config["pki_dir"], self.config["cachedir"]],
self.config["user"],
permissive=self.config["permissive_pki_access"],
pki_dir=self.config["pki_dir"],
)
if not self.config["log_file"].startswith(("tcp://", "udp://", "file://")):
# Logfile is not using Syslog, verify
verify_files([self.config["log_file"]], self.config["user"])
# Setup file logging!
self.setup_logfile_logger()
runner = salt.runner.Runner(self.config)
if self.options.doc:
runner._print_docs()
self.exit(salt.exitcodes.EX_OK)
# Run this here so SystemExit isn't raised anywhere else when
# someone tries to use the runners via the python API
try:
if check_user(self.config["user"]):
runner.run()
except SaltClientError as exc:
raise SystemExit(str(exc))
开发者ID:wikimedia,项目名称:operations-debs-salt,代码行数:32,代码来源:__init__.py
示例4: start
def start(self):
'''
Execute this method to start up a minion.
'''
verify_env([self.opts['pki_dir'],
self.opts['cachedir'],
self.opts['extension_modules'],
os.path.dirname(self.opts['log_file']),
])
import salt.log
salt.log.setup_logfile_logger(
self.opts['log_file'], self.opts['log_level']
)
for name, level in self.opts['log_granular_levels'].iteritems():
salt.log.set_logger_level(name, level)
import logging
# Late import so logging works correctly
import salt.minion
log = logging.getLogger(__name__)
if self.cli['daemon']:
# Late import so logging works correctly
import salt.utils
# If the minion key has not been accepted, then Salt enters a loop
# waiting for it, if we daemonize later then the minion cound halt
# the boot process waiting for a key to be accepted on the master.
# This is the latest safe place to daemonize
salt.utils.daemonize()
minion = salt.minion.Minion(self.opts)
set_pidfile(self.cli['pidfile'])
if check_user(self.opts['user'], log):
try:
minion.tune_in()
except KeyboardInterrupt:
log.warn('Stopping the Salt Minion')
raise SystemExit('\nExiting on Ctrl-c')
开发者ID:LinuxJedi,项目名称:salt,代码行数:35,代码来源:__init__.py
示例5: start
def start(self):
'''
Run the sequence to start a salt master server
'''
self.parse_args()
try:
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.dirname(self.config['log_file']),
self.config['sock_dir'],
self.config['token_dir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
except OSError, err:
sys.exit(err.errno)
开发者ID:BackSeat,项目名称:salt,代码行数:25,代码来源:__init__.py
示例6: prepare
def prepare(self):
'''
Run the preparation sequence required to start a salt syndic minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Syndic, self).prepare()
try:
if self.config['verify_env']:
verify_env(
[
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
except OSError as error:
self.environment_failure(error)
self.setup_logfile_logger()
verify_log(self.config)
self.action_log_info('Setting up "{0}"'.format(self.config['id']))
# Late import so logging works correctly
import salt.minion
self.daemonize_if_required()
self.syndic = salt.minion.SyndicManager(self.config)
self.set_pidfile()
开发者ID:bryson,项目名称:salt,代码行数:34,代码来源:daemons.py
示例7: __enter__
def __enter__(self):
'''
Start a master and minion
'''
self.master_opts = salt.config.master_config(
os.path.join(INTEGRATION_TEST_DIR, 'files/conf/master'))
self.minion_opts = salt.config.minion_config(
os.path.join(INTEGRATION_TEST_DIR, 'files/conf/minion'))
self.master_opts['file_roots'] = FILES
self.master_opts['hosts.file'] = os.path.join(TMP, 'hosts')
self.minion_opts['file_roots'] = FILES
self.minion_opts['hosts.file'] = os.path.join(TMP, 'hosts')
verify_env([os.path.join(self.master_opts['pki_dir'], 'minions'),
os.path.join(self.master_opts['pki_dir'], 'minions_pre'),
os.path.join(self.master_opts['pki_dir'], 'minions_rejected'),
os.path.join(self.master_opts['cachedir'], 'jobs'),
os.path.dirname(self.master_opts['log_file']),
self.minion_opts['extension_modules'],
self.master_opts['sock_dir'],
])
master = salt.master.Master(self.master_opts)
self.master_process = multiprocessing.Process(target=master.start)
self.master_process.start()
minion = salt.minion.Minion(self.minion_opts)
self.minion_process = multiprocessing.Process(target=minion.tune_in)
self.minion_process.start()
return self
开发者ID:cmek,项目名称:salt,代码行数:30,代码来源:__init__.py
示例8: run
def run(self):
'''
Execute salt-key
'''
self.parse_args()
if self.config['verify_env']:
verify_env_dirs = []
if not self.config['gen_keys']:
verify_env_dirs.extend([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
])
verify_env(
verify_env_dirs,
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
if (not self.config['key_logfile'].startswith('tcp://') or
not self.config['key_logfile'].startswith('udp://') or
not self.config['key_logfile'].startswith('file://')):
# Logfile is not using Syslog, verify
verify_files(
[self.config['key_logfile']],
self.config['user']
)
self.setup_logfile_logger()
key = salt.key.KeyCLI(self.config)
key.run()
开发者ID:sitepoint,项目名称:salt,代码行数:35,代码来源:__init__.py
示例9: run
def run(self):
'''
Execute the salt call!
'''
self.parse_args()
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
os.path.dirname(self.config['log_file'])
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
caller = salt.cli.caller.Caller(self.config)
if self.options.doc:
caller.print_docs()
self.exit(0)
if self.options.grains_run:
caller.print_grains()
self.exit(0)
caller.run()
开发者ID:BackSeat,项目名称:salt,代码行数:28,代码来源:__init__.py
示例10: test_verify_env
def test_verify_env(self):
root_dir = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
var_dir = os.path.join(root_dir, "var", "log", "salt")
verify_env([var_dir], getpass.getuser())
self.assertTrue(os.path.exists(var_dir))
dir_stat = os.stat(var_dir)
self.assertEqual(dir_stat.st_uid, os.getuid())
self.assertEqual(dir_stat.st_mode & stat.S_IRWXU, stat.S_IRWXU)
self.assertEqual(dir_stat.st_mode & stat.S_IRWXG, 40)
self.assertEqual(dir_stat.st_mode & stat.S_IRWXO, 5)
开发者ID:bryson,项目名称:salt,代码行数:10,代码来源:verify_test.py
示例11: test_verify_env
def test_verify_env(self):
root_dir = tempfile.mkdtemp()
var_dir = os.path.join(root_dir, 'var', 'log', 'salt')
verify_env([var_dir], getpass.getuser())
self.assertTrue(os.path.exists(var_dir))
dir_stat = os.stat(var_dir)
self.assertEqual(dir_stat.st_uid, os.getuid())
self.assertEqual(dir_stat.st_gid, os.getgid())
self.assertEqual(dir_stat.st_mode & stat.S_IRWXU, stat.S_IRWXU)
self.assertEqual(dir_stat.st_mode & stat.S_IRWXG, 40)
self.assertEqual(dir_stat.st_mode & stat.S_IRWXO, 5)
开发者ID:herlo,项目名称:salt,代码行数:11,代码来源:verify_test.py
示例12: start
def start(self):
'''
Execute this method to start up a syndic.
'''
try:
verify_env([
self.opts['pki_dir'], self.opts['cachedir'],
os.path.dirname(self.opts['log_file']),
], self.opts['user'])
except OSError, err:
sys.exit(err.errno)
开发者ID:lixmgl,项目名称:Intern_OpenStack_Swift,代码行数:11,代码来源:__init__.py
示例13: run
def run(self):
'''
Execute the salt call!
'''
self.parse_args()
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
self.config['cachedir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
if not self.config['log_file'].startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
verify_files(
[self.config['log_file']],
self.config['user']
)
if self.options.file_root:
# check if the argument is pointing to a file on disk
file_root = os.path.abspath(self.options.file_root)
self.config['file_roots'] = {'base': [file_root]}
if self.options.pillar_root:
# check if the argument is pointing to a file on disk
pillar_root = os.path.abspath(self.options.pillar_root)
self.config['pillar_roots'] = {'base': [pillar_root]}
if self.options.local:
self.config['file_client'] = 'local'
if self.options.master:
self.config['master'] = self.options.master
# Setup file logging!
self.setup_logfile_logger()
caller = salt.cli.caller.Caller(self.config)
if self.options.doc:
caller.print_docs()
self.exit(0)
if self.options.grains_run:
caller.print_grains()
self.exit(0)
caller.run()
开发者ID:1mentat,项目名称:salt,代码行数:53,代码来源:__init__.py
示例14: prepare
def prepare(self):
'''
Run the preparation sequence required to start a salt master server.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
self.parse_args()
try:
if self.config['verify_env']:
verify_env(
[
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'],
'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.join(self.config['cachedir'], 'proc'),
self.config['sock_dir'],
self.config['token_dir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
logfile = self.config['log_file']
if logfile is not None and not logfile.startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
verify_files([logfile], self.config['user'])
except OSError as err:
sys.exit(err.errno)
self.setup_logfile_logger()
logger.info('Setting up the Salt Master')
if not verify_socket(self.config['interface'],
self.config['publish_port'],
self.config['ret_port']):
self.exit(4, 'The ports are not available to bind\n')
self.config['interface'] = ip_bracket(self.config['interface'])
migrations.migrate_paths(self.config)
# Late import so logging works correctly
import salt.master
self.master = salt.master.Master(self.config)
self.daemonize_if_required()
self.set_pidfile()
开发者ID:1mentat,项目名称:salt,代码行数:53,代码来源:__init__.py
示例15: prepare
def prepare(self):
'''
Run the preparation sequence required to start a salt syndic minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
super(Syndic, self).prepare()
try:
if self.config['verify_env']:
verify_env(
[
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
logfile = self.config['log_file']
if logfile is not None and not logfile.startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
current_umask = os.umask(0o027)
verify_files([logfile], self.config['user'])
os.umask(current_umask)
except OSError as err:
log.exception('Failed to prepare salt environment')
self.shutdown(err.errno)
self.setup_logfile_logger()
verify_log(self.config)
log.info(
'Setting up the Salt Syndic Minion "{0}"'.format(
self.config['id']
)
)
# Late import so logging works correctly
import salt.minion
self.daemonize_if_required()
# if its a multisyndic, do so
if isinstance(self.config.get('master'), list):
self.syndic = salt.minion.MultiSyndic(self.config)
else:
self.syndic = salt.minion.Syndic(self.config)
self.set_pidfile()
开发者ID:HowardMei,项目名称:saltstack,代码行数:51,代码来源:daemons.py
示例16: run
def run(self):
'''
Execute saltkey
'''
verify_env([
os.path.join(self.opts['pki_dir'], 'minions'),
os.path.join(self.opts['pki_dir'], 'minions_pre'),
os.path.join(self.opts['pki_dir'], 'minions_rejected'),
os.path.dirname(self.opts['log_file']),
],
self.opts['user'])
import salt.log
salt.log.setup_logfile_logger(self.opts['key_logfile'],
self.opts['loglevel'])
key = salt.cli.key.Key(self.opts)
key.run()
开发者ID:Adapptor,项目名称:salt,代码行数:16,代码来源:__init__.py
示例17: run
def run(self):
'''
Execute salt-key
'''
import salt.key
self.parse_args()
if self.config['verify_env']:
verify_env_dirs = []
if not self.config['gen_keys']:
if self.config['transport'] == 'raet':
verify_env_dirs.extend([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'accepted'),
os.path.join(self.config['pki_dir'], 'pending'),
os.path.join(self.config['pki_dir'], 'rejected'),
])
elif self.config['transport'] == 'zeromq':
verify_env_dirs.extend([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
])
verify_env(
verify_env_dirs,
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
if not self.config['log_file'].startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
verify_files(
[self.config['key_logfile']],
self.config['user']
)
self.setup_logfile_logger()
key = salt.key.KeyCLI(self.config)
if check_user(self.config['user']):
key.run()
开发者ID:qzchenwl,项目名称:saltstack-verify,代码行数:46,代码来源:key.py
示例18: start
def start(self):
'''
Execute this method to start up a syndic.
'''
self.parse_args()
try:
if self.config['verify_env']:
verify_env([
self.config['pki_dir'], self.config['cachedir'],
os.path.dirname(self.config['log_file']),
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
except OSError, err:
sys.exit(err.errno)
开发者ID:conceptho,项目名称:salt,代码行数:17,代码来源:__init__.py
示例19: start
def start(self):
'''
Run the sequence to start a salt master server
'''
self.parse_args()
try:
if self.config['verify_env']:
verify_env([
self.config['pki_dir'],
os.path.join(self.config['pki_dir'], 'minions'),
os.path.join(self.config['pki_dir'], 'minions_pre'),
os.path.join(self.config['pki_dir'], 'minions_rejected'),
self.config['cachedir'],
os.path.join(self.config['cachedir'], 'jobs'),
os.path.join(self.config['cachedir'], 'proc'),
os.path.dirname(self.config['log_file']),
self.config['sock_dir'],
self.config['token_dir'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
except OSError as err:
sys.exit(err.errno)
self.setup_logfile_logger()
logging.getLogger(__name__).warn('Setting up the Salt Master')
# Late import so logging works correctly
if not verify_socket(self.config['interface'],
self.config['publish_port'],
self.config['ret_port']):
self.exit(4, 'The ports are not available to bind\n')
migrations.migrate_paths(self.config)
import salt.master
master = salt.master.Master(self.config)
self.daemonize_if_required()
self.set_pidfile()
if check_user(self.config['user']):
try:
master.start()
except salt.master.MasterExit:
sys.exit()
开发者ID:gspradeep,项目名称:salt,代码行数:45,代码来源:__init__.py
示例20: prepare
def prepare(self):
'''
Run the preparation sequence required to start a salt syndic minion.
If sub-classed, don't **ever** forget to run:
super(YourSubClass, self).prepare()
'''
self.parse_args()
try:
if self.config['verify_env']:
verify_env(
[
self.config['pki_dir'],
self.config['cachedir'],
self.config['sock_dir'],
self.config['extension_modules'],
],
self.config['user'],
permissive=self.config['permissive_pki_access'],
pki_dir=self.config['pki_dir'],
)
logfile = self.config['log_file']
if logfile is not None and not logfile.startswith(('tcp://',
'udp://',
'file://')):
# Logfile is not using Syslog, verify
verify_files([logfile], self.config['user'])
except OSError as err:
logger.exception('Failed to prepare salt environment')
sys.exit(err.errno)
self.setup_logfile_logger()
logger.info(
'Setting up the Salt Syndic Minion "{0}"'.format(
self.config['id']
)
)
# Late import so logging works correctly
import salt.minion
self.daemonize_if_required()
self.syndic = salt.minion.Syndic(self.config)
self.set_pidfile()
开发者ID:bemehow,项目名称:salt,代码行数:44,代码来源:__init__.py
注:本文中的salt.utils.verify.verify_env函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论