本文整理汇总了Python中MilkCheck.Engine.ServiceGroup.ServiceGroup.has_subservice方法的典型用法代码示例。如果您正苦于以下问题:Python ServiceGroup.has_subservice方法的具体用法?Python ServiceGroup.has_subservice怎么用?Python ServiceGroup.has_subservice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MilkCheck.Engine.ServiceGroup.ServiceGroup
的用法示例。
在下文中一共展示了ServiceGroup.has_subservice方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_has_subservice
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_has_subservice(self):
'''Test whether a service is an internal dependency of a group'''
group = ServiceGroup('group')
serv = Service('intern_service')
self.assertFalse(group.has_subservice(serv.name))
group.add_inter_dep(target=serv)
self.assertTrue(group.has_subservice(serv.name))
示例2: test_create_service_imbrications
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_create_service_imbrications(self):
'''Test create service with mutliple level of subservices'''
sergrp = ServiceGroup('groupinit')
sergrp.fromdict(
{'services':
{'svcA':
{'require': ['subgroup'],
'actions':
{'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': 'I am the subservice $NAME'},
'subgroup':
{'services':
{'svcB':
{'require_weak':['svcC'],
'actions':
{'start': {'cmd': '/bin/True'},
' stop': {'cmd': '/bin/False'}},
'desc': 'I am the subservice $NAME'},
'svcC':
{'actions':
{'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': 'I am the subservice $NAME'}},
'target': '127.0.0.1',
'desc': "I'm the service $NAME"}},
'desc': 'I am a group',
'target': 'localhost',
})
for subservice in ('svcA', 'subgroup'):
if isinstance(sergrp._subservices[subservice], ServiceGroup):
for subsubser in ('svcB', 'svcC'):
self.assertTrue(
sergrp._subservices[subservice].has_subservice(subsubser))
self.assertTrue(sergrp.has_subservice(subservice))
示例3: test_servicegroup_with_nodeset_like_actions_with_one_decl
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_servicegroup_with_nodeset_like_actions_with_one_decl(self):
'''Test a service group with several group with nodeset-like names'''
sergrp = ServiceGroup('group1')
sergrp.fromdict({
'services': {
'da[1-3]': {
'actions': {'start': {'cmd': '/bin/True'}}
},
}})
self.assertEqual(len(sergrp._subservices), 3)
self.assertTrue(sergrp.has_subservice('da1'))
self.assertTrue(sergrp.has_subservice('da2'))
self.assertTrue(sergrp.has_subservice('da3'))
self.assertEqual(len(sergrp._subservices['da1']._actions), 1)
self.assertEqual(len(sergrp._subservices['da2']._actions), 1)
self.assertEqual(len(sergrp._subservices['da3']._actions), 1)
示例4: test_fromdict2
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_fromdict2(self):
'''
Test instanciation of a service group with dependencies between
subservices.
'''
sergrp = ServiceGroup('S1')
sergrp.fromdict(
{'services':
{'hpss_nfs':
{'target': 'localhost',
'require': ['lustre', 'test'],
'actions':
{'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': "I'm the service hpss_nfs"
},
'lustre':
{'target': 'localhost',
'actions':
{'start': {'cmd':'/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': "I'm the service lustre"},
'test':
{'target': 'localhost',
'actions':
{'start': {'cmd':'/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': "I'm a test suite"}},
'variables':{'LUSTRE_FS_LIST': 'store0,work0'},
'desc': "I'm the service S1",
'target': 'localhost',
})
self.assertTrue(sergrp.has_subservice('hpss_nfs'))
self.assertTrue(sergrp.has_subservice('lustre'))
self.assertTrue(sergrp.has_subservice('test'))
self.assertFalse(
sergrp._subservices['hpss_nfs'].has_parent_dep('sink'))
self.assertTrue(
sergrp._subservices['hpss_nfs'].has_child_dep('source'))
self.assertTrue(
sergrp._subservices['lustre'].has_parent_dep('sink'))
self.assertFalse(
sergrp._subservices['test'].has_child_dep('source'))
self.assertTrue(
sergrp._subservices['test'].has_parent_dep('sink'))
示例5: test_add_inter_dep_service_group_first
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_add_inter_dep_service_group_first(self):
'''Test ability to add dependencies to the subgraph N1'''
group = ServiceGroup('GROUP')
s1 = Service('alpha')
s2 = Service('beta')
s3 = Service('lambda')
group.add_inter_dep(target=s1)
group.add_inter_dep(base=s1, target=s2)
group.add_inter_dep(target=s3)
self.assertTrue(group.has_subservice('alpha'))
self.assertTrue(group.has_subservice('beta'))
self.assertTrue(group.has_subservice('lambda'))
self.assertTrue(s2.has_parent_dep('sink'))
self.assertFalse(s2.has_child_dep('source'))
self.assertFalse(s1.has_parent_dep('sink'))
self.assertTrue(s1.has_child_dep('source'))
self.assertTrue(s3.has_child_dep('source'))
self.assertTrue(s3.has_parent_dep('sink'))
示例6: test_fromdict1
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_fromdict1(self):
'''Test instanciation of a service group from a dictionnary'''
sergrp = ServiceGroup('S1')
sergrp.fromdict(
{'services':
{'hpss_nfs':
{'target': 'localhost',
'actions':
{'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': "I'm the service hpss_nfs"
},
'lustre':
{'target': 'localhost',
'actions':
{'start': {'cmd':'/bin/True'},
'stop': {'cmd': '/bin/False'}},
'desc': "I'm the service lustre"}},
'desc': "I'm the service S1",
'target': 'localhost',
'variables':{
'var1': 'toto',
'var2': 'titi'
},
})
self.assertEqual(len(sergrp.variables), 2)
self.assertTrue('var1' in sergrp.variables)
self.assertTrue('var2' in sergrp.variables)
self.assertTrue(sergrp.has_subservice('hpss_nfs'))
self.assertTrue(sergrp.has_subservice('lustre'))
self.assertTrue(
sergrp._subservices['hpss_nfs'].has_parent_dep('sink'))
self.assertTrue(
sergrp._subservices['hpss_nfs'].has_child_dep('source'))
self.assertTrue(
sergrp._subservices['lustre'].has_parent_dep('sink'))
self.assertTrue(
sergrp._subservices['lustre'].has_child_dep('source'))
示例7: test_subservices_with_different_actions
# 需要导入模块: from MilkCheck.Engine.ServiceGroup import ServiceGroup [as 别名]
# 或者: from MilkCheck.Engine.ServiceGroup.ServiceGroup import has_subservice [as 别名]
def test_subservices_with_different_actions(self):
'''Test a service group with subservices with different actions'''
sergrp = ServiceGroup('group1')
sergrp.fromdict(
{
'services': {
'svc1': {
'actions': {
'start': {'cmd': '/bin/True'},
'status': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/True'},
}
},
'svc2': {
'require': [ 'svc1' ],
'actions': {
'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/True'},
'status': {'cmd': '/bin/True'},
}
},
'svc3': {
'require': [ 'svc1' ],
'actions': {
'start': {'cmd': '/bin/True'},
'stop': {'cmd': '/bin/True'},
'status': {'cmd': '/bin/True'},
}
},
}})
self.assertEqual(len(sergrp._subservices), 3)
self.assertTrue(sergrp.has_subservice('svc1'))
self.assertTrue(sergrp.has_subservice('svc2'))
self.assertTrue(sergrp.has_subservice('svc3'))
self.assertEqual(len(sergrp._subservices['svc1']._actions), 3)
self.assertEqual(len(sergrp._subservices['svc2']._actions), 3)
self.assertEqual(len(sergrp._subservices['svc3']._actions), 3)