本文整理汇总了Python中MilkCheck.Engine.BaseEntity.BaseEntity类的典型用法代码示例。如果您正苦于以下问题:Python BaseEntity类的具体用法?Python BaseEntity怎么用?Python BaseEntity使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BaseEntity类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
开发者ID:pombredanne,项目名称:milkcheck,代码行数:7,代码来源:Service.py
示例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))
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py
示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py
示例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'))
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py
示例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'))
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py
示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py
示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py
示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py
示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:9,代码来源:ServiceGroup.py
示例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
开发者ID:mdlx,项目名称:milkcheck,代码行数:9,代码来源:Action.py
示例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)
开发者ID:pombredanne,项目名称:milkcheck,代码行数:56,代码来源:ServiceGroup.py
示例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')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:10,代码来源:BaseEntityTest.py
示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:10,代码来源:BaseEntityTest.py
示例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']))
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:11,代码来源:BaseEntityTest.py
示例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)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:12,代码来源:BaseEntityTest.py
示例16: test_lookup_variables2
def test_lookup_variables2(self):
'''Test variables resolution through multiple entities'''
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('VAR'), 'test')
self.assertEqual(service._lookup_variable('GVAR'), 'group')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:9,代码来源:BaseEntityTest.py
示例17: __init__
def __init__(self, name, target=None):
BaseEntity.__init__(self, name, target)
# Define a flag allowing us to specify that this service is the
# original caller so we do not have to start his children.
self.origin = False
# Used for ghost services or services that you do not want to execute.
self.simulate = False
# Actions of the service
self._actions = {}
self._last_action = None
开发者ID:pombredanne,项目名称:milkcheck,代码行数:13,代码来源:Service.py
示例18: test_resolve_all_variables
def test_resolve_all_variables(self):
"""resolve_all() resolves variables only once"""
entity = BaseEntity('entity')
entity.add_var('foo', 'cool')
entity.add_var('bar', '%foo')
entity.add_var('baz', '%foo')
entity.fromdict({'desc': 'New %bar'})
entity.resolve_all()
self.assertEqual(entity.variables['foo'], entity.variables['bar'])
self.assertEqual(entity.variables['foo'], entity.variables['baz'])
self.assertEqual(entity.desc, 'New cool')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:11,代码来源:BaseEntityTest.py
示例19: test_eval_deps_waiting
def test_eval_deps_waiting(self):
"""Test that eval_deps_status return WAITING_STATUS"""
service = BaseEntity("test_service")
serv_a = BaseEntity("A")
serv_b = BaseEntity("B")
service.add_dep(serv_a)
service.add_dep(serv_b, CHECK)
serv_a.status = WAITING_STATUS
self.assertEqual(service.eval_deps_status(), WAITING_STATUS)
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:9,代码来源:BaseEntityTest.py
示例20: test_resolve_property1
def test_resolve_property1(self):
'''Test replacement of symbols within a property'''
service = BaseEntity('test_service')
service.add_var('NODES', 'localhost,127.0.0.1')
service.desc = 'start %NAME on %TARGET'
service.target = '%NODES'
self.assertEqual(service.resolve_property('target'),
NodeSet('localhost,127.0.0.1'))
self.assertEqual(service.resolve_property('name'),
'test_service')
self.assertEqual(service.resolve_property('desc'),
'start test_service on 127.0.0.1,localhost')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:12,代码来源:BaseEntityTest.py
注:本文中的MilkCheck.Engine.BaseEntity.BaseEntity类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论