本文整理汇总了Python中salt.state.HighState.top_matches方法的典型用法代码示例。如果您正苦于以下问题:Python HighState.top_matches方法的具体用法?Python HighState.top_matches怎么用?Python HighState.top_matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类salt.state.HighState
的用法示例。
在下文中一共展示了HighState.top_matches方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: HighStateTestCase
# 需要导入模块: from salt.state import HighState [as 别名]
# 或者: from salt.state.HighState import top_matches [as 别名]
class HighStateTestCase(TestCase):
def setUp(self):
self.highstate = HighState(OPTS)
self.highstate.push_active()
def tearDown(self):
self.highstate.pop_active()
def test_top_matches_with_list(self):
top = {'env': {'match': ['state1', 'state2'], 'nomatch': ['state3']}}
matches = self.highstate.top_matches(top)
self.assertEqual(matches, {'env': ['state1', 'state2']})
def test_top_matches_with_string(self):
top = {'env': {'match': 'state1', 'nomatch': 'state2'}}
matches = self.highstate.top_matches(top)
self.assertEqual(matches, {'env': ['state1']})
def test_matches_whitelist(self):
matches = {'env': ['state1', 'state2', 'state3']}
matches = self.highstate.matches_whitelist(matches, ['state2'])
self.assertEqual(matches, {'env': ['state2']})
def test_matches_whitelist_with_string(self):
matches = {'env': ['state1', 'state2', 'state3']}
matches = self.highstate.matches_whitelist(matches,
'state2,state3')
self.assertEqual(matches, {'env': ['state2', 'state3']})
示例2: HighStateTestCase
# 需要导入模块: from salt.state import HighState [as 别名]
# 或者: from salt.state.HighState import top_matches [as 别名]
class HighStateTestCase(TestCase):
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()
def tearDown(self):
self.highstate.pop_active()
def test_top_matches_with_list(self):
top = {'env': {'match': ['state1', 'state2'], 'nomatch': ['state3']}}
matches = self.highstate.top_matches(top)
self.assertEqual(matches, {'env': ['state1', 'state2']})
def test_top_matches_with_string(self):
top = {'env': {'match': 'state1', 'nomatch': 'state2'}}
matches = self.highstate.top_matches(top)
self.assertEqual(matches, {'env': ['state1']})
def test_matches_whitelist(self):
matches = {'env': ['state1', 'state2', 'state3']}
matches = self.highstate.matches_whitelist(matches, ['state2'])
self.assertEqual(matches, {'env': ['state2']})
def test_matches_whitelist_with_string(self):
matches = {'env': ['state1', 'state2', 'state3']}
matches = self.highstate.matches_whitelist(matches,
'state2,state3')
self.assertEqual(matches, {'env': ['state2', 'state3']})