当前位置: 首页>>代码示例>>Python>>正文


Python BaseEntity.add_var方法代码示例

本文整理汇总了Python中MilkCheck.Engine.BaseEntity.BaseEntity.add_var方法的典型用法代码示例。如果您正苦于以下问题:Python BaseEntity.add_var方法的具体用法?Python BaseEntity.add_var怎么用?Python BaseEntity.add_var使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MilkCheck.Engine.BaseEntity.BaseEntity的用法示例。


在下文中一共展示了BaseEntity.add_var方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_resolve_property5

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 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,代码行数:9,代码来源:BaseEntityTest.py

示例2: test_resolve_2_command_substitutions

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 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,代码行数:10,代码来源:BaseEntityTest.py

示例3: test_lookup_variables3

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_lookup_variables3(self):
     '''Test variables resolution with an undefined var'''
     service = BaseEntity('test_service')
     service.add_var('VAR', 'test')
     group = BaseEntity('group_service')
     group.add_var('GVAR', 'group')
     service.parent = group
     self.assertRaises(UndefinedVariableError,
                       service._lookup_variable, 'BAD_VAR')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:11,代码来源:BaseEntityTest.py

示例4: test_lookup_variables2

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 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,代码行数:11,代码来源:BaseEntityTest.py

示例5: test_lookup_variables4

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 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,代码行数:12,代码来源:BaseEntityTest.py

示例6: test_resolve_all_variables

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 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,代码行数:13,代码来源:BaseEntityTest.py

示例7: test_resolve_property1

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 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,代码行数:14,代码来源:BaseEntityTest.py

示例8: test_remove_variable

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
    def test_remove_variable(self):
        '''Remove a variable, defined or not, is fine.'''
        svc = BaseEntity('test_var')
        svc.add_var('var', 'foo')
        self.assertEqual(svc._lookup_variable('var'), 'foo')

        # Remove it
        svc.remove_var('var')
        self.assertRaises(UndefinedVariableError, svc._lookup_variable, 'var')

        # Remove it again does not raise an exception.
        svc.remove_var('var')
        self.assertRaises(UndefinedVariableError, svc._lookup_variable, 'var')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:15,代码来源:BaseEntityTest.py

示例9: test_resolve_escape_char

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_resolve_escape_char(self):
     '''Test resolution with a variable escaping %'''
     service = BaseEntity('test_service')
     service.add_var('FOO', 'Keep my %%noeval!')
     self.assertEqual(service._resolve('%FOO'), 'Keep my %noeval!')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例10: test_resolve_2_variables

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_resolve_2_variables(self):
     '''Test resolution with two adjacent variables'''
     service = BaseEntity('test_service')
     service.add_var('FOO', 'foo')
     service.add_var('BAR', 'bar')
     self.assertEqual(service._resolve('%FOO%BAR'), 'foobar')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例11: test_resolve_property4

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_resolve_property4(self):
     '''Command substitution with a non-zero exit code should be ok'''
     service = BaseEntity('test_service')
     service.add_var('NODES', '%(/bin/false)')
     self.assertEqual(service._resolve('%NODES'), '')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例12: test_resolve_value3

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_resolve_value3(self):
     '''Test multiple variable replacements'''
     service = BaseEntity('test_service')
     service.add_var('NODES', 'localhost,127.0.0.1')
     self.assertEqual(service._resolve('%NODES %NAME'),
                      'localhost,127.0.0.1 test_service')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py

示例13: test_resolve_value2

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_resolve_value2(self):
     '''Test replacement of variable referenced in the entity'''
     service = BaseEntity('test_service')
     service.add_var('NODES', 'localhost,127.0.0.1')
     self.assertEqual(service._resolve('%NODES'), 'localhost,127.0.0.1')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例14: test_lookup_variables1

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_lookup_variables1(self):
     '''Test variables resolution through a single entity'''
     service = BaseEntity('test_service')
     service.add_var('VAR', 'test')
     self.assertEqual(service._lookup_variable('VAR'), 'test')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:7,代码来源:BaseEntityTest.py

示例15: test_resolve_recurse

# 需要导入模块: from MilkCheck.Engine.BaseEntity import BaseEntity [as 别名]
# 或者: from MilkCheck.Engine.BaseEntity.BaseEntity import add_var [as 别名]
 def test_resolve_recurse(self):
     '''Test recursive variable resolution'''
     service = BaseEntity('test_service')
     service.add_var('foo', 'key')
     service.add_var('bar', 'Keep my %foo')
     self.assertEqual(service._resolve('%bar'), 'Keep my key')
开发者ID:cea-hpc,项目名称:milkcheck,代码行数:8,代码来源:BaseEntityTest.py


注:本文中的MilkCheck.Engine.BaseEntity.BaseEntity.add_var方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。