当前位置: 首页>>代码示例>>Python>>正文


Python HighState.render_highstate方法代码示例

本文整理汇总了Python中salt.state.HighState.render_highstate方法的典型用法代码示例。如果您正苦于以下问题:Python HighState.render_highstate方法的具体用法?Python HighState.render_highstate怎么用?Python HighState.render_highstate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在salt.state.HighState的用法示例。


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

示例1: state_highstate

# 需要导入模块: from salt.state import HighState [as 别名]
# 或者: from salt.state.HighState import render_highstate [as 别名]
def state_highstate(matches, dirpath):
    OPTS['file_roots'] = dict(base=[dirpath])
    HIGHSTATE = HighState(OPTS)
    HIGHSTATE.push_active()
    try:
        high, errors = HIGHSTATE.render_highstate({'base': ['aaa']})
        if errors:
            import pprint
            pprint.pprint('\n'.join(errors))
            pprint.pprint(high)

        out = HIGHSTATE.state.call_high(high)
        # pprint.pprint(out)
    finally:
        HIGHSTATE.pop_active()
开发者ID:jslatts,项目名称:salt,代码行数:17,代码来源:pydsl_test.py

示例2: state_highstate

# 需要导入模块: from salt.state import HighState [as 别名]
# 或者: from salt.state.HighState import render_highstate [as 别名]
    def state_highstate(self, state, dirpath):
        opts = copy.copy(self.config)
        opts['file_roots'] = dict(base=[dirpath])
        HIGHSTATE = HighState(opts)
        HIGHSTATE.push_active()
        try:
            high, errors = HIGHSTATE.render_highstate(state)
            if errors:
                import pprint
                pprint.pprint('\n'.join(errors))
                pprint.pprint(high)

            out = HIGHSTATE.state.call_high(high)
            # pprint.pprint(out)
        finally:
            HIGHSTATE.pop_active()
开发者ID:DaveQB,项目名称:salt,代码行数:18,代码来源:pydsl_test.py

示例3: test_pipe_through_stateconf

# 需要导入模块: from salt.state import HighState [as 别名]
# 或者: from salt.state.HighState import render_highstate [as 别名]
    def test_pipe_through_stateconf(self):
        if sys.version_info < (2, 7) and not HAS_ORDERED_DICT:
            self.skipTest('OrderedDict is not available')
        dirpath = tempfile.mkdtemp()
        output = os.path.join(dirpath, 'output')
        try:
            xxx = os.path.join(dirpath, 'xxx.sls')
            with open(xxx, 'w') as xxx:
                xxx.write('''#!stateconf -os yaml . jinja
.X:
  cmd.run:
    - name: echo X >> {0}
    - cwd: /
.Y:
  cmd.run:
    - name: echo Y >> {1}
    - cwd: /
.Z:
  cmd.run:
    - name: echo Z >> {2}
    - cwd: /
'''.format(output, output, output))
            yyy = os.path.join(dirpath, 'yyy.sls')
            with open(yyy, 'w') as yyy:
                yyy.write('''#!pydsl|stateconf -ps
state('.D').cmd.run('echo D >> {0}', cwd='/')
state('.E').cmd.run('echo E >> {1}', cwd='/')
state('.F').cmd.run('echo F >> {2}', cwd='/')
'''.format(output, output, output))

            aaa = os.path.join(dirpath, 'aaa.sls')
            with open(aaa, 'w') as aaa:
                aaa.write('''#!pydsl|stateconf -ps
include('xxx', 'yyy')

# make all states in yyy run BEFORE states in this sls.
extend(state('.start').stateconf.require(stateconf='xxx::goal'))

# make all states in xxx run AFTER this sls.
extend(state('.goal').stateconf.require_in(stateconf='yyy::start'))

__pydsl__.set(ordered=True)

state('.A').cmd.run('echo A >> {0}', cwd='/')
state('.B').cmd.run('echo B >> {1}', cwd='/')
state('.C').cmd.run('echo C >> {2}', cwd='/')
'''.format(output, output, output))

            OPTS['file_roots'] = dict(base=[dirpath])
            HIGHSTATE = HighState(OPTS)
            HIGHSTATE.state.load_modules()
            sys.modules['salt.loaded.int.render.pydsl'].__salt__ = HIGHSTATE.state.functions

            high, errors = HIGHSTATE.render_highstate({'base': ['aaa']})
#            import pprint
#            pprint.pprint(errors)
#            pprint.pprint(high)
            out = HIGHSTATE.state.call_high(high)
#            pprint.pprint(out)
            with open(output, 'r') as f:
                self.assertEqual(''.join(f.read().split()), "XYZABCDEF")

        finally:
            shutil.rmtree(dirpath, ignore_errors=True)
开发者ID:inthecloud247,项目名称:salt,代码行数:66,代码来源:pydsl_test.py


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