本文整理匯總了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)