本文整理汇总了Python中ooinstall.oo_config.OOConfig.save_to_disk方法的典型用法代码示例。如果您正苦于以下问题:Python OOConfig.save_to_disk方法的具体用法?Python OOConfig.save_to_disk怎么用?Python OOConfig.save_to_disk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ooinstall.oo_config.OOConfig
的用法示例。
在下文中一共展示了OOConfig.save_to_disk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_write_config
# 需要导入模块: from ooinstall.oo_config import OOConfig [as 别名]
# 或者: from ooinstall.oo_config.OOConfig import save_to_disk [as 别名]
def test_write_config(self):
cfg_path = self.write_config(os.path.join(self.work_dir,
'ooinstall.conf'), SAMPLE_CONFIG)
ooconfig = OOConfig(cfg_path)
ooconfig.save_to_disk()
f = open(cfg_path, 'r')
written_config = yaml.safe_load(f.read())
f.close()
self.assertEquals(3, len(written_config['deployment']['hosts']))
for h in written_config['deployment']['hosts']:
self.assertTrue('ip' in h)
self.assertTrue('public_ip' in h)
self.assertTrue('hostname' in h)
self.assertTrue('public_hostname' in h)
self.assertTrue('ansible_ssh_user' in written_config['deployment'])
self.assertTrue('variant' in written_config)
self.assertEquals('v2', written_config['version'])
# Some advanced settings should not get written out if they
# were not specified by the user:
self.assertFalse('ansible_inventory_directory' in written_config)
示例2: test_write_config
# 需要导入模块: from ooinstall.oo_config import OOConfig [as 别名]
# 或者: from ooinstall.oo_config.OOConfig import save_to_disk [as 别名]
def test_write_config(self):
cfg_path = self.write_config(os.path.join(self.work_dir, "ooinstall.conf"), SAMPLE_CONFIG)
ooconfig = OOConfig(cfg_path)
ooconfig.save_to_disk()
f = open(cfg_path, "r")
written_config = yaml.safe_load(f.read())
f.close()
self.assertEquals(3, len(written_config["hosts"]))
for h in written_config["hosts"]:
self.assertTrue("ip" in h)
self.assertTrue("public_ip" in h)
self.assertTrue("hostname" in h)
self.assertTrue("public_hostname" in h)
self.assertTrue("ansible_ssh_user" in written_config)
self.assertTrue("variant" in written_config)
self.assertEquals("v1", written_config["version"])
# Some advanced settings should not get written out if they
# were not specified by the user:
self.assertFalse("ansible_inventory_directory" in written_config)