本文整理汇总了Python中xosconfig.Config.get_config_file方法的典型用法代码示例。如果您正苦于以下问题:Python Config.get_config_file方法的具体用法?Python Config.get_config_file怎么用?Python Config.get_config_file使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xosconfig.Config
的用法示例。
在下文中一共展示了Config.get_config_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_config_file
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import get_config_file [as 别名]
def test_get_config_file(self):
"""
[XOS-Config] Should return the config file in use
"""
Config.init(sample_conf)
res = Config.get_config_file()
self.assertEqual(res, sample_conf)
示例2: run_playbook
# 需要导入模块: from xosconfig import Config [as 别名]
# 或者: from xosconfig.Config import get_config_file [as 别名]
def run_playbook(ansible_hosts, ansible_config, fqp, opts):
args = {"ansible_hosts": ansible_hosts,
"ansible_config": ansible_config,
"fqp": fqp,
"opts": opts,
"config_file": Config.get_config_file()}
keep_temp_files = Config.get("keep_temp_files")
dir = tempfile.mkdtemp()
args_fn = None
result_fn = None
try:
log.info("creating args file",dir = dir)
args_fn = os.path.join(dir, "args")
result_fn = os.path.join(dir, "result")
open(args_fn, "w").write(pickle.dumps(args))
ansible_main_fn = os.path.join(os.path.dirname(__file__), "ansible_main.py")
os.system("python %s %s %s" % (ansible_main_fn, args_fn, result_fn))
result = pickle.loads(open(result_fn).read())
if hasattr(result, "exception"):
log.error("Exception in playbook",exception = result["exception"])
stats = result.get("stats", None)
aresults = result.get("aresults", None)
except Exception,e:
log.exception("Exception running ansible_main")
stats = None
aresults = None