def main():
try:
function = sys.argv[1]
except:
log.log(log.LOG_ERROR, "No action defined (Valid: dump, import, cleanup)")
sys.exit(1)
if os.path.isfile(sys.argv[1]):
config_file = sys.argv[1]
function = "legacy"
else:
try:
config_file = sys.argv[2]
except IndexError:
log.log(log.LOG_ERROR, "No YAML provided")
sys.exit(1)
try:
config_file = open(config_file, 'r')
config = yaml.load(config_file)
config_file.close()
except:
log.log(log.LOG_ERROR, "Failed to load/parse config")
sys.exit(1)
if (function == "import"):
fm = ForemanImport(config)
fm.connect()
fm_import(fm)
if (function == "dump"):
fm = ForemanDump(config)
fm.connect()
fm_dump(fm)
if (function == "cleanup"):
fm = ForemanCleanup(config)
fm_cleanup(fm)
if (function == "legacy"):
fm_cls = ForemanCleanup(config)
fm_cls.connect()
fm_cleanup(fm_cls)
fm_imp = ForemanImport(config)
fm_imp.connect()
fm_import(fm_imp)
评论列表
文章目录