本文整理汇总了Python中ambari_agent.AmbariConfig.AmbariConfig.remove_option方法的典型用法代码示例。如果您正苦于以下问题:Python AmbariConfig.remove_option方法的具体用法?Python AmbariConfig.remove_option怎么用?Python AmbariConfig.remove_option使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ambari_agent.AmbariConfig.AmbariConfig
的用法示例。
在下文中一共展示了AmbariConfig.remove_option方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_server_hostname_override
# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import remove_option [as 别名]
def test_server_hostname_override(self):
hostname.cached_server_hostname = None
fd = tempfile.mkstemp(text=True)
tmpname = fd[1]
os.close(fd[0])
os.chmod(tmpname, os.stat(tmpname).st_mode | stat.S_IXUSR)
tmpfile = file(tmpname, "w+")
config = AmbariConfig()
try:
tmpfile.write("#!/bin/sh\n\necho 'test.example.com'")
tmpfile.close()
config.set('server', 'hostname_script', tmpname)
self.assertEquals(hostname.server_hostname(config), 'test.example.com', "expected hostname 'test.example.com'")
finally:
os.remove(tmpname)
config.remove_option('server', 'hostname_script')
pass
示例2: test_server_hostnames_multiple_override
# 需要导入模块: from ambari_agent.AmbariConfig import AmbariConfig [as 别名]
# 或者: from ambari_agent.AmbariConfig.AmbariConfig import remove_option [as 别名]
def test_server_hostnames_multiple_override(self):
hostname.cached_server_hostnames = []
fd = tempfile.mkstemp(text=True)
tmpname = fd[1]
os.close(fd[0])
os.chmod(tmpname, os.stat(tmpname).st_mode | stat.S_IXUSR)
tmpfile = file(tmpname, "w+")
config = AmbariConfig()
try:
tmpfile.write("#!/bin/sh\n\necho 'host1.example.com, host2.example.com, host3.example.com'")
tmpfile.close()
config.set('server', 'hostname_script', tmpname)
expected_hostnames = ['host1.example.com', 'host2.example.com', 'host3.example.com']
server_hostnames = hostname.server_hostnames(config)
self.assertEquals(server_hostnames, expected_hostnames, "expected hostnames {0}; got {1}".format(expected_hostnames, server_hostnames))
finally:
os.remove(tmpname)
config.remove_option('server', 'hostname_script')
pass