本文整理汇总了Python中MilkCheck.Engine.BaseEntity.BaseEntity类的典型用法代码示例。如果您正苦于以下问题:Python BaseEntity类的具体用法?Python BaseEntity怎么用?Python BaseEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: reset
def reset(self):
"""Reset values of attributes in order to perform multiple exec"""
BaseEntity.reset(self)
self.origin = False
self._last_action = None
for action in self._actions.values():
action.reset()
示例2: test_resolve_property5
def test_resolve_property5(self):
'''Test resolution with a property containing special characters'''
service = BaseEntity('test_service')
service.add_var('NODES', HOSTNAME)
service.target = '%NODES'
self.assertEqual(service.resolve_property('target'),
NodeSet(HOSTNAME))
示例3: test_clear_deps
def test_clear_deps(self):
"""Test method clear_deps"""
ent = BaseEntity('foo')
ent_dep = BaseEntity('parent')
ent.add_dep(ent_dep)
self.assertEqual(len(ent.parents), 1)
ent.clear_deps()
self.assertEqual(len(ent.parents), 0)
示例4: test_has_parent_dep
def test_has_parent_dep(self):
"""Test method has_parent_dep"""
ent = BaseEntity('foo')
ent_dep = BaseEntity('parent')
ent.parents['parent'] = Dependency(ent_dep)
self.assertTrue(ent.has_parent_dep('parent'))
del ent.parents['parent']
self.assertFalse(ent.has_parent_dep('parent'))
示例5: test_has_child_dep
def test_has_child_dep(self):
"""Test method has_child_dep"""
ent = BaseEntity('foo')
ent_dep = BaseEntity('child')
ent.children['child'] = Dependency(ent_dep)
self.assertTrue(ent.has_child_dep('child'))
del ent.children['child']
self.assertFalse(ent.has_child_dep('child'))
示例6: test_reset_entity
def test_reset_entity(self):
'''Test reset entity'''
ent = BaseEntity(name='foo', target='fortoy5')
ent.status = NO_STATUS
ent.algo_reverse = True
ent.reset()
self.assertEqual(ent._algo_reversed, False)
self.assertEqual(ent.status, NO_STATUS)
示例7: test_resolve_2_command_substitutions
def test_resolve_2_command_substitutions(self):
'''Test 2 command substitutions'''
service = BaseEntity('test_service')
service.add_var('EXCLUDED_NODES', 'foo')
service.add_var('SELECTED_NODES', 'bar')
expr = '%([ -n "%SELECTED_NODES" ] && echo "-n %SELECTED_NODES")' + \
' %([ -n "%EXCLUDED_NODES" ] && echo "-x %EXCLUDED_NODES")'
self.assertEqual(service._resolve(expr), '-n bar -x foo')
示例8: test_remote
def test_remote(self):
"""Test the remote property"""
ent1 = BaseEntity('father')
self.assertTrue(ent1.remote)
ent1.remote = False
ent2 = BaseEntity('child')
ent2.inherits_from(ent1)
self.assertFalse(ent2.remote)
示例9: filter_nodes
def filter_nodes(self, nodes):
"""
Add error nodes to skip list.
Nodes in this list will not be used when launching actions.
"""
BaseEntity.filter_nodes(self, nodes)
for service in self._subservices.values():
service.filter_nodes(nodes)
示例10: reset
def reset(self):
'''
Reset values of attributes in order to used the action multiple time.
'''
BaseEntity.reset(self)
self.start_time = None
self.stop_time = None
self.worker = None
self.tries = 0
示例11: fromdict
def fromdict(self, grpdict):
"""Populate group attributes from dict."""
BaseEntity.fromdict(self, grpdict)
if 'services' in grpdict:
dep_mapping = {}
# Wrap dependencies from YAML and build the service
for names, props in grpdict['services'].items():
for subservice in NodeSet(names):
# Parsing dependencies
wrap = DepWrapper()
for prop in ('require', 'require_weak',
'before', 'after', 'check'):
if prop in props:
if prop in ('before', 'after'):
props['require_weak'] = props[prop]
prop = 'require_weak'
wrap.deps[prop] = props[prop]
# Get subservices which might be Service or ServiceGroup
service = None
if 'services' in props:
service = ServiceGroup(subservice)
service.fromdict(props)
else:
service = Service(subservice)
service.fromdict(props)
# Link the group and its new subservice together
self._subservices[subservice] = service
service.parent = self
wrap.source = service
dep_mapping[subservice] = wrap
# Generate dependency links of the service
for wrap in dep_mapping.values():
# Not any dependencies so just attach
for dtype in wrap.deps:
for dep in wrap.deps[dtype]:
if dep not in self._subservices:
raise UnknownDependencyError(dep)
wrap.source.add_dep(self._subservices[dep],
sgth=dtype.upper())
# Bind subgraph to the service group
for service in self.iter_subservices():
if not service.children:
service.add_dep(self._source, parent=False)
if not service.parents:
service.add_dep(self._sink)
for subser in self.iter_subservices():
subser.inherits_from(self)
示例12: test_lookup_variables4
def test_lookup_variables4(self):
'''Test variables resolution with a var referencing a property'''
service = BaseEntity('test_service')
service.add_var('VAR', 'test')
group = BaseEntity('group_service')
group.add_var('GVAR', 'group')
service.parent = group
self.assertEqual(service._lookup_variable('GVAR'), 'group')
self.assertEqual(service._lookup_variable('TARGET'), None)
self.assertEqual(service._lookup_variable('NAME'), 'test_service')
示例13: test_eval_deps_error
def test_eval_deps_error(self):
"""Test that eval_deps_status return DEP_ERROR"""
service = BaseEntity("test_service")
serv_a = BaseEntity("A")
serv_b = BaseEntity("B")
service.add_dep(serv_a)
service.add_dep(serv_b, CHECK)
serv_b.status = DONE
serv_a.status = TIMEOUT
self.assertEqual(service.eval_deps_status(), DEP_ERROR)
示例14: test_tags
def test_tags(self):
"""Test tags property"""
ent1 = BaseEntity(name='parent')
self.assertEqual(ent1.tags, set())
ent1.tags.add('foo')
ent2 = BaseEntity(name='child')
ent2.inherits_from(ent1)
self.assertEqual(ent2.tags, set(['foo']))
ent2.tags = set(['bar'])
self.assertEqual(ent2.tags, set(['bar']))
示例15: test_search_node_graph
def test_search_node_graph(self):
"""Test the research of a node through a graph"""
ent1 = BaseEntity('E1')
ent2 = BaseEntity('E2')
ent3 = BaseEntity('E3')
ent4 = BaseEntity('E4')
ent1.add_dep(ent2)
ent1.add_dep(ent3)
ent2.add_dep(ent4)
ent3.add_dep(ent4)
self.assertTrue(ent1.search('E3') is ent3)
self.assertTrue(ent1.search('E5') is None)