• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python config.minion_config函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中salt.config.minion_config函数的典型用法代码示例。如果您正苦于以下问题:Python minion_config函数的具体用法?Python minion_config怎么用?Python minion_config使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了minion_config函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_load_minion_config_from_environ_var

    def test_load_minion_config_from_environ_var(self):
        original_environ = os.environ.copy()

        tempdir = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
        try:
            env_root_dir = os.path.join(tempdir, "foo", "env")
            os.makedirs(env_root_dir)
            env_fpath = os.path.join(env_root_dir, "config-env")

            salt.utils.fopen(env_fpath, "w").write("root_dir: {0}\n" "log_file: {1}\n".format(env_root_dir, env_fpath))

            os.environ["SALT_MINION_CONFIG"] = env_fpath
            # Should load from env variable, not the default configuration file
            config = sconfig.minion_config("/etc/salt/minion")
            self.assertEqual(config["log_file"], env_fpath)
            os.environ.clear()
            os.environ.update(original_environ)

            root_dir = os.path.join(tempdir, "foo", "bar")
            os.makedirs(root_dir)
            fpath = os.path.join(root_dir, "config")
            salt.utils.fopen(fpath, "w").write("root_dir: {0}\n" "log_file: {1}\n".format(root_dir, fpath))
            # Let's set the environment variable, yet, since the configuration
            # file path is not the default one, ie, the user has passed an
            # alternative configuration file form the CLI parser, the
            # environment variable will be ignored.
            os.environ["SALT_MINION_CONFIG"] = env_fpath
            config = sconfig.minion_config(fpath)
            self.assertEqual(config["log_file"], fpath)
            os.environ.clear()
            os.environ.update(original_environ)
        finally:
            if os.path.isdir(tempdir):
                shutil.rmtree(tempdir)
开发者ID:joehealy,项目名称:pkg-salt,代码行数:34,代码来源:config_test.py


示例2: test_check_dns_deprecation_warning

    def test_check_dns_deprecation_warning(self):
        helium_version = SaltStackVersion.from_name('Helium')
        if salt_version.__version_info__ >= helium_version:
            raise AssertionError(
                'Failing this test on purpose! Please delete this test case, '
                'the \'check_dns\' keyword argument and the deprecation '
                'warnings in `salt.config.minion_config` and '
                'salt.config.apply_minion_config`'
            )

        # Let's force the warning to always be thrown
        warnings.resetwarnings()
        warnings.filterwarnings(
            'always', '(.*)check_dns(.*)', DeprecationWarning, 'salt.config'
        )
        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=True)
            self.assertEqual(
                'The functionality behind the \'check_dns\' keyword argument '
                'is no longer required, as such, it became unnecessary and is '
                'now deprecated. \'check_dns\' will be removed in Salt '
                '{0}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(
                overrides=None, defaults=None, check_dns=True
            )
            self.assertEqual(
                'The functionality behind the \'check_dns\' keyword argument '
                'is no longer required, as such, it became unnecessary and is '
                'now deprecated. \'check_dns\' will be removed in Salt '
                '{0}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=False)
            self.assertEqual(
                'The functionality behind the \'check_dns\' keyword argument '
                'is no longer required, as such, it became unnecessary and is '
                'now deprecated. \'check_dns\' will be removed in Salt '
                '{0}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(
                overrides=None, defaults=None, check_dns=False
            )
            self.assertEqual(
                'The functionality behind the \'check_dns\' keyword argument '
                'is no longer required, as such, it became unnecessary and is '
                'now deprecated. \'check_dns\' will be removed in Salt '
                '{0}.'.format(helium_version.formatted_version),
                str(w[-1].message)
            )
开发者ID:AccelerationNet,项目名称:salt,代码行数:58,代码来源:config_test.py


示例3: test_check_dns_deprecation_warning

    def test_check_dns_deprecation_warning(self):
        if salt_version.__version_info__ >= (0, 19):
            raise AssertionError(
                "Failing this test on purpose! Please delete this test case, "
                "the 'check_dns' keyword argument and the deprecation "
                "warnings in `salt.config.minion_config` and "
                "salt.config.apply_minion_config`"
            )

        # Let's force the warning to always be thrown
        warnings.resetwarnings()
        warnings.filterwarnings("always", "(.*)check_dns(.*)", DeprecationWarning, "salt.config")
        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=True)
            self.assertEqual(
                "The functionality behind the 'check_dns' keyword argument "
                "is no longer required, as such, it became unnecessary and is "
                "now deprecated. 'check_dns' will be removed in salt > "
                "0.18.0",
                str(w[-1].message),
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(overrides=None, defaults=None, check_dns=True)
            self.assertEqual(
                "The functionality behind the 'check_dns' keyword argument "
                "is no longer required, as such, it became unnecessary and is "
                "now deprecated. 'check_dns' will be removed in salt > "
                "0.18.0",
                str(w[-1].message),
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.minion_config(None, None, check_dns=False)
            self.assertEqual(
                "The functionality behind the 'check_dns' keyword argument "
                "is no longer required, as such, it became unnecessary and is "
                "now deprecated. 'check_dns' will be removed in salt > "
                "0.18.0",
                str(w[-1].message),
            )

        with warnings.catch_warnings(record=True) as w:
            sconfig.apply_minion_config(overrides=None, defaults=None, check_dns=False)
            self.assertEqual(
                "The functionality behind the 'check_dns' keyword argument "
                "is no longer required, as such, it became unnecessary and is "
                "now deprecated. 'check_dns' will be removed in salt > "
                "0.18.0",
                str(w[-1].message),
            )
开发者ID:joehealy,项目名称:pkg-salt,代码行数:51,代码来源:config_test.py


示例4: setup_config

    def setup_config(self):
        opts = config.master_config(self.get_config_file_path('master'))
        user = opts.get('user', 'root')
        opts['_minion_conf_file'] = opts['conf_file']
        opts.update(config.minion_config(self.get_config_file_path('minion')))
        # Over ride the user from the master config file
        opts['user'] = user

        if 'syndic_master' not in opts:
            self.error(
                "The syndic_master needs to be configured in the salt master "
                "config, EXITING!"
            )

        from salt import utils
        # Some of the opts need to be changed to match the needed opts
        # in the minion class.
        opts['master'] = opts['syndic_master']
        opts['master_ip'] = utils.dns_check(opts['master'])

        opts['master_uri'] = 'tcp://{0}:{1}'.format(
            opts['master_ip'], str(opts['master_port'])
        )
        opts['_master_conf_file'] = opts['conf_file']
        opts.pop('conf_file')
        return opts
开发者ID:11craft,项目名称:salt,代码行数:26,代码来源:parsers.py


示例5: setUp

    def setUp(self, *args, **kwargs):
        super(RendererMixin, self).setUp(*args, **kwargs)

        self.root_dir = tempfile.mkdtemp("pyobjects_test_root")

        self.config = minion_config(None)
        self.config.update({"file_client": "local", "file_roots": {"base": [self.root_dir]}})
开发者ID:AccelerationNet,项目名称:salt,代码行数:7,代码来源:pyobjects_test.py


示例6: returner

def returner(ret):
    '''
    Send the return data to the Salt Master over the encrypted
    0MQ bus with custom tag for 3rd party script filtering.
    '''

    # get opts from minion config file, supports minion.d drop dir!
    opts = minion_config(os.path.join(syspaths.CONFIG_DIR, 'minion'))

    # TODO: this needs to be customizable!
    tag = 'third-party'

    # add custom tag to return data for filtering
    ret['tag'] = tag

    # multi event example, supports a list of event ret objects.
    # single event does not currently expand/filter properly on Master side.
    package = {
      #'id': opts['id'],
      'events': [ ret ],
      'tag': None,
      'pretag': None,
      'data': None
    }

    # opts must contain valid minion ID else it binds to invalid 0MQ socket.
    event = salt.utils.event.SaltEvent('minion', **opts)

    # Fire event payload with 'fire_master' tag which triggers the
    # salt-minion daemon to forward payload to the master event bus!
    event.fire_event(package, 'fire_master')
开发者ID:27escape,项目名称:bin,代码行数:31,代码来源:zeromq_return.py


示例7: test_issue_5970_minion_confd_inclusion

    def test_issue_5970_minion_confd_inclusion(self):
        try:
            tempdir = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
            minion_config = os.path.join(tempdir, 'minion')
            minion_confd = os.path.join(tempdir, 'minion.d')
            os.makedirs(minion_confd)

            # Let's populate a minion configuration file with some basic
            # settings
            salt.utils.fopen(minion_config, 'w').write(
                'blah: false\n'
                'root_dir: {0}\n'
                'log_file: {1}\n'.format(tempdir, minion_config)
            )

            # Now, let's populate an extra configuration file under minion.d
            # Notice that above we've set blah as False and bellow as True.
            # Since the minion.d files are loaded after the main configuration
            # file so overrides can happen, the final value of blah should be
            # True.
            extra_config = os.path.join(minion_confd, 'extra.conf')
            salt.utils.fopen(extra_config, 'w').write(
                'blah: true\n'
            )

            # Let's load the configuration
            config = sconfig.minion_config(minion_config)

            self.assertEqual(config['log_file'], minion_config)
            # As proven by the assertion below, blah is True
            self.assertTrue(config['blah'])
        finally:
            if os.path.isdir(tempdir):
                shutil.rmtree(tempdir)
开发者ID:AccelerationNet,项目名称:salt,代码行数:34,代码来源:config_test.py


示例8: setUp

 def setUp(self):
     self.opts = _config = minion_config(None)
     self.opts['grains'] = grains(self.opts)
     self.loader = LazyLoader(_module_dirs(self.opts, 'modules', 'module'),
                              self.opts,
                              tag='module',
                              virtual_enable=False)
开发者ID:bryson,项目名称:salt,代码行数:7,代码来源:loader.py


示例9: setUp

    def setUp(self):
        self.opts = _config = minion_config(None)
        self.tmp_dir = tempfile.mkdtemp(dir=integration.TMP)
        os.makedirs(self.module_dir)

        self.lib_count = collections.defaultdict(int)  # mapping of path -> count

        # bootstrap libs
        with open(os.path.join(self.module_dir, '__init__.py'), 'w') as fh:
            fh.write(deep_init_base)
            fh.flush()
            os.fsync(fh.fileno())  # flush to disk

        self.lib_paths = {}
        dir_path = self.module_dir
        for lib_name in self.libs:
            dir_path = os.path.join(dir_path, lib_name)
            self.lib_paths[lib_name] = dir_path
            os.makedirs(dir_path)
            self.update_lib(lib_name)

        dirs = _module_dirs(self.opts, 'modules', 'module')
        dirs.append(self.tmp_dir)
        self.loader = LazyLoader(dirs,
                                 self.opts,
                                 tag='module')
开发者ID:shineforever,项目名称:ops,代码行数:26,代码来源:loader.py


示例10: _init_env

 def _init_env(self):
     '''
     Initialize some Salt environment.
     '''
     from salt.config import minion_config
     from salt.grains import core as g_core
     g_core.__opts__ = minion_config(self.DEFAULT_MINION_CONFIG_PATH)
     self.grains_core = g_core
开发者ID:DaveQB,项目名称:salt,代码行数:8,代码来源:collector.py


示例11: render

 def render(self, template, opts=None):
     _config = minion_config(None)
     _config['file_client'] = 'local'
     if opts:
         _config.update(opts)
     _state = salt.state.State(_config)
     return compile_template_str(template,
                                 _state.rend,
                                 _state.opts['renderer'])
开发者ID:DaveQB,项目名称:salt,代码行数:9,代码来源:yamlex_test.py


示例12: _minion_opts

def _minion_opts(cfg='minion'):
    if 'conf_file' in __opts__:
        default_dir = os.path.dirname(__opts__['conf_file'])
    else:
        default_dir = salt.syspaths.CONFIG_DIR,
    cfg = os.environ.get(
        'SALT_MINION_CONFIG', os.path.join(default_dir, cfg))
    opts = config.minion_config(cfg)
    return opts
开发者ID:AccelerationNet,项目名称:salt,代码行数:9,代码来源:lxc.py


示例13: test_load_minion_config_from_environ_var

    def test_load_minion_config_from_environ_var(self):
        original_environ = os.environ.copy()

        tempdir = tempfile.mkdtemp(dir=integration.SYS_TMP_DIR)
        try:
            env_root_dir = os.path.join(tempdir, 'foo', 'env')
            os.makedirs(env_root_dir)
            env_fpath = os.path.join(env_root_dir, 'config-env')

            with salt.utils.fopen(env_fpath, 'w') as fp_:
                fp_.write(
                    'root_dir: {0}\n'
                    'log_file: {1}\n'.format(env_root_dir, env_fpath)
                )

            os.environ['SALT_MINION_CONFIG'] = env_fpath
            # Should load from env variable, not the default configuration file
            config = sconfig.minion_config('/etc/salt/minion')
            self.assertEqual(config['log_file'], env_fpath)
            os.environ.clear()
            os.environ.update(original_environ)

            root_dir = os.path.join(tempdir, 'foo', 'bar')
            os.makedirs(root_dir)
            fpath = os.path.join(root_dir, 'config')
            with salt.utils.fopen(fpath, 'w') as fp_:
                fp_.write(
                    'root_dir: {0}\n'
                    'log_file: {1}\n'.format(root_dir, fpath)
                )
            # Let's set the environment variable, yet, since the configuration
            # file path is not the default one, i.e., the user has passed an
            # alternative configuration file form the CLI parser, the
            # environment variable will be ignored.
            os.environ['SALT_MINION_CONFIG'] = env_fpath
            config = sconfig.minion_config(fpath)
            self.assertEqual(config['log_file'], fpath)
            os.environ.clear()
            os.environ.update(original_environ)
        finally:
            if os.path.isdir(tempdir):
                shutil.rmtree(tempdir)
开发者ID:bryson,项目名称:salt,代码行数:42,代码来源:config_test.py


示例14: test_get_opts

 def test_get_opts(self):
     '''
     test.get_opts
     '''
     opts = config.minion_config(
         self.get_config_file_path('minion')
     )
     self.assertEqual(
         self.run_function('test.get_opts')['cachedir'],
         opts['cachedir']
     )
开发者ID:shineforever,项目名称:ops,代码行数:11,代码来源:test.py


示例15: test_sha256_is_default_for_minion

 def test_sha256_is_default_for_minion(self):
     fpath = tempfile.mktemp()
     try:
         salt.utils.fopen(fpath, 'w').write(
             "root_dir: /\n"
             "key_logfile: key\n"
         )
         config = sconfig.minion_config(fpath)
         self.assertEqual(config['hash_type'], 'sha256')
     finally:
         if os.path.isfile(fpath):
             os.unlink(fpath)
开发者ID:bryson,项目名称:salt,代码行数:12,代码来源:config_test.py


示例16: setup_config

    def setup_config(self):
        opts = config.master_config(self.get_config_file_path("master"))
        opts["_minion_conf_file"] = opts["conf_file"]
        opts.update(config.minion_config(self.get_config_file_path("minion")))

        if "syndic_master" not in opts:
            self.error("The syndic_master needs to be configured in the salt master " "config, EXITING!")

        from salt import utils

        # Some of the opts need to be changed to match the needed opts
        # in the minion class.
        opts["master"] = opts["syndic_master"]
        opts["master_ip"] = utils.dns_check(opts["master"])

        opts["master_uri"] = "tcp://{0}:{1}".format(opts["master_ip"], str(opts["master_port"]))
        opts["_master_conf_file"] = opts["conf_file"]
        opts.pop("conf_file")
        return opts
开发者ID:rrada,项目名称:salt,代码行数:19,代码来源:parsers.py


示例17: setup_config

    def setup_config(self):
        opts = config.master_config(self.get_config_file_path())
        user = opts.get('user', 'root')
        opts['_minion_conf_file'] = opts['conf_file']
        opts.update(config.minion_config(self.get_config_file_path('minion')))
        # Override the user from the master config file
        opts['user'] = user
        # Override the name of the PID file.
        opts['pidfile'] = '/var/run/salt-syndic.pid'

        if not opts.get('syndic_master', None):
            self.error(
                'The syndic_master needs to be configured in the salt master '
                'config, EXITING!'
            )

        # Some of the opts need to be changed to match the needed opts
        # in the minion class.
        opts['master'] = opts.get('syndic_master', opts['master'])
        try:
            opts['master_ip'] = utils.dns_check(
                opts['master'],
                ipv6=opts['ipv6']
            )
        except exceptions.SaltSystemExit as exc:
            self.exit(
                status=exc.code,
                msg='{0}: {1}\n'.format(self.get_prog_name(), exc.message)
            )

        opts['master_uri'] = 'tcp://{0}:{1}'.format(
            opts['master_ip'], str(opts['master_port'])
        )
        opts['_master_conf_file'] = opts['conf_file']
        opts.pop('conf_file')
        return opts
开发者ID:herlo,项目名称:salt,代码行数:36,代码来源:parsers.py


示例18: test_bad_name

 def test_bad_name(self):
     self.opts = minion_config(None)
     testmod = salt.loader.raw_mod(self.opts, 'module_we_do_not_have', None)
     self.assertEqual(testmod, {})
开发者ID:bryson,项目名称:salt,代码行数:4,代码来源:interfaces.py


示例19: test_basic

 def test_basic(self):
     self.opts = minion_config(None)
     testmod = salt.loader.raw_mod(self.opts, 'test', None)
     for k, v in six.iteritems(testmod):
         self.assertEqual(k.split('.')[0], 'test')
开发者ID:bryson,项目名称:salt,代码行数:5,代码来源:interfaces.py


示例20: _mixin_setup

    def _mixin_setup(self):
        group = self.output_options_group = optparse.OptionGroup(
            self, "Output Options", "Configure your preferred output format"
        )
        self.add_option_group(group)
        group.add_option(
            '--raw-out',
            default=False,
            action='store_true',
            help=('DEPRECATED. Print the output from the \'{0}\' command in '
                  'raw python form, this is suitable for re-reading the '
                  'output into an executing python script with eval.'.format(
                      self.get_prog_name()
                  ))
        )
        group.add_option(
            '--yaml-out',
            default=False,
            action='store_true',
            help=('DEPRECATED. Print the output from the \'{0}\' command in '
                  'yaml.'.format(self.get_prog_name()))
        )
        group.add_option(
            '--json-out',
            default=False,
            action='store_true',
            help=('DEPRECATED. Print the output from the \'{0}\' command in '
                  'json.'.format(self.get_prog_name()))
        )

        if self._include_text_out_:
            group.add_option(
                '--text-out',
                default=False,
                action='store_true',
                help=('DEPRECATED. Print the output from the \'{0}\' command '
                      'in the same form the shell would.'.format(
                          self.get_prog_name()
                      ))
            )

        outputters = loader.outputters(
            config.minion_config(
                '/etc/salt/minion', check_dns=False
            )
        )

        group.add_option(
            '--out', '--output',
            dest='output',
            choices=outputters.keys(),
            help=(
                'Print the output from the \'{0}\' command using the '
                'specified outputter. One of {1}.'.format(
                    self.get_prog_name(),
                    ', '.join([repr(k) for k in outputters])
                )
            )
        )
        group.add_option(
            '--out-indent', '--output-indent',
            dest='output_indent',
            default=None,
            type=int,
            help=('Print the output indented by the provided value in spaces. '
                  'Negative values disables indentation. Only applicable in '
                  'outputters that support indentation.')
        )
        group.add_option(
            '--no-color',
            default=False,
            action='store_true',
            help='Disable all colored output'
        )

        for option in self.output_options_group.option_list:
            def process(opt):
                default = self.defaults.get(opt.dest)
                if getattr(self.options, opt.dest, default) is False:
                    return

                if opt.dest not in ('out', 'output_indent', 'no_color'):
                    msg = (
                        'The option {0} is deprecated. Please consider using '
                        '\'--out {1}\' instead.'.format(
                            opt.get_opt_string(),
                            opt.dest.split('_', 1)[0]
                        )
                    )
                    if version.__version_info__ >= (0, 10, 7):
                        # XXX: CLEAN THIS CODE WHEN 0.10.8 is about to come out
                        self.error(msg)
                    elif log.is_console_configured():
                        logging.getLogger(__name__).warning(msg)
                    else:
                        sys.stdout.write('WARNING: {0}\n'.format(msg))

                self.selected_output_option = opt.dest

            funcname = 'process_{0}'.format(option.dest)
#.........这里部分代码省略.........
开发者ID:tristanhands,项目名称:salt,代码行数:101,代码来源:parsers.py



注:本文中的salt.config.minion_config函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python six.iteritems函数代码示例发布时间:2022-05-27
下一篇:
Python config.master_config函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap