コード例 #1
0
 def setUp(self):
     '''
     Create multiple top files for use in each test
     '''
     self.env1 = {'base': {'*': ['e1_a', 'e1_b', 'e1_c']}}
     self.env2 = {'base': {'*': ['e2_a', 'e2_b', 'e2_c']}}
     self.env3 = {'base': {'*': ['e3_a', 'e3_b', 'e3_c']}}
     self.config = self._make_default_config()
     self.highstate = HighState(self.config)
コード例 #2
0
 def test_merge_strategy_same(self):
     '''
     Test to see if the top file that corresponds
     to the requested env is the one that is used
     by the state system
     '''
     config = self._make_default_config()
     config['top_file_merging_strategy'] = 'same'
     config['environment'] = 'b'
     highstate = HighState(config)
     ret = highstate.get_tops()
     self.assertEqual(ret, OrderedDict([('b', [{}])]))
コード例 #3
0
 def test_ordered_merge(self):
     '''
     Test to see if the merger respects environment
     ordering
     '''
     config = self._make_default_config()
     config['top_file_merging_strategy'] = 'merge'
     config['env_order'] = ['b', 'a', 'c']
     with patch('salt.fileclient.FSClient.envs',
                MagicMock(return_value=['a', 'b', 'c'])):
         highstate = HighState(config)
         ret = highstate.get_tops()
     self.assertEqual(ret,
                      OrderedDict([('a', [{}]), ('c', [{}]), ('b', [{}])]))
コード例 #4
0
def state_highstate(state, dirpath):
    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()
コード例 #5
0
ファイル: test_pydsl.py プロジェクト: fake-name/salt
    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()
コード例 #6
0
    def setUp(self):
        self.root_dir = tempfile.mkdtemp(dir=integration.TMP)
        self.state_tree_dir = os.path.join(self.root_dir, 'state_tree')
        self.cache_dir = os.path.join(self.root_dir, 'cachedir')
        if not os.path.isdir(self.root_dir):
            os.makedirs(self.root_dir)

        if not os.path.isdir(self.state_tree_dir):
            os.makedirs(self.state_tree_dir)

        if not os.path.isdir(self.cache_dir):
            os.makedirs(self.cache_dir)
        self.config = salt.config.minion_config(None)
        self.config['root_dir'] = self.root_dir
        self.config['state_events'] = False
        self.config['id'] = 'match'
        self.config['file_client'] = 'local'
        self.config['file_roots'] = dict(base=[self.state_tree_dir])
        self.config['cachedir'] = self.cache_dir
        self.config['test'] = False
        self.highstate = HighState(self.config)
        self.highstate.push_active()
コード例 #7
0
ファイル: test_pydsl.py プロジェクト: fake-name/salt
    def setUp(self):
        self.root_dir = tempfile.mkdtemp(dir=RUNTIME_VARS.TMP)
        self.addCleanup(shutil.rmtree, self.root_dir, ignore_errors=True)
        self.state_tree_dir = os.path.join(self.root_dir, "state_tree")
        self.cache_dir = os.path.join(self.root_dir, "cachedir")
        if not os.path.isdir(self.root_dir):
            os.makedirs(self.root_dir)

        if not os.path.isdir(self.state_tree_dir):
            os.makedirs(self.state_tree_dir)

        if not os.path.isdir(self.cache_dir):
            os.makedirs(self.cache_dir)
        self.config = salt.config.minion_config(None)
        self.config["root_dir"] = self.root_dir
        self.config["state_events"] = False
        self.config["id"] = "match"
        self.config["file_client"] = "local"
        self.config["file_roots"] = dict(base=[self.state_tree_dir])
        self.config["cachedir"] = self.cache_dir
        self.config["test"] = False
        self.config["grains"] = salt.loader.grains(self.config)
        self.HIGHSTATE = HighState(self.config)
        self.HIGHSTATE.push_active()
コード例 #8
0
ファイル: test_pydsl.py プロジェクト: morinap/salt-1
    def setUp(self):
        self.root_dir = tempfile.mkdtemp(dir=RUNTIME_VARS.TMP)
        self.addCleanup(shutil.rmtree, self.root_dir, ignore_errors=True)
        self.state_tree_dir = os.path.join(self.root_dir, 'state_tree')
        self.cache_dir = os.path.join(self.root_dir, 'cachedir')
        if not os.path.isdir(self.root_dir):
            os.makedirs(self.root_dir)

        if not os.path.isdir(self.state_tree_dir):
            os.makedirs(self.state_tree_dir)

        if not os.path.isdir(self.cache_dir):
            os.makedirs(self.cache_dir)
        self.config = salt.config.minion_config(None)
        self.config['root_dir'] = self.root_dir
        self.config['state_events'] = False
        self.config['id'] = 'match'
        self.config['file_client'] = 'local'
        self.config['file_roots'] = dict(base=[self.state_tree_dir])
        self.config['cachedir'] = self.cache_dir
        self.config['test'] = False
        self.config['grains'] = salt.loader.grains(self.config)
        self.HIGHSTATE = HighState(self.config)
        self.HIGHSTATE.push_active()
コード例 #9
0
 def setUp(self):
     self.HIGHSTATE = HighState(OPTS)
     self.HIGHSTATE.push_active()
コード例 #10
0
 def setUp(self):
     self.highstate = HighState(OPTS)
     self.highstate.push_active()