From 2654b0628e30f54b0b8e89208ab04204858cfae5 Mon Sep 17 00:00:00 2001 From: Szilard Cserey Date: Thu, 21 May 2015 15:57:35 +0200 Subject: Fuel Config Reap + Additional Refactoring for Autodeployment 1. Refactor the whole autodeployment code in such a way that the preparation of Fuel VM + networking and the autodeployment itself can be executed all at once 2. Functionality added that allows reaping of Fuel configuration from an existing environment and create DHA and DEA configuration files from it JIRA: [BGS-2] Create Fuel deployment script Change-Id: I7101295ac4becfc5fa10eda757cec0c2ad127940 Signed-off-by: Szilard Cserey --- fuel/deploy/common.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'fuel/deploy/common.py') diff --git a/fuel/deploy/common.py b/fuel/deploy/common.py index 6dbda67..dc12637 100644 --- a/fuel/deploy/common.py +++ b/fuel/deploy/common.py @@ -2,6 +2,7 @@ import subprocess import sys import os import logging +import argparse N = {'id': 0, 'status': 1, 'name': 2, 'cluster': 3, 'ip': 4, 'mac': 5, 'roles': 6, 'pending_roles': 7, 'online': 8} @@ -73,6 +74,19 @@ def check_dir_exists(dir_path): if not os.path.isdir(dir_path): err('ERROR: Directory %s not found\n' % dir_path) +def create_dir_if_not_exists(dir_path): + if not os.path.isdir(dir_path): + log('Creating directory %s' % dir_path) + os.makedirs(dir_path) + +def commafy(comma_separated_list): + l = [c.strip() for c in comma_separated_list.split(',')] + return ','.join(l) + +def delete_file(file): + if os.path.exists(file): + os.remove(file) + def check_if_root(): r = exec_cmd('whoami') if r != 'root': @@ -80,3 +94,10 @@ def check_if_root(): def log(message): LOG.debug('%s\n' % message) + +class ArgParser(argparse.ArgumentParser): + def error(self, message): + sys.stderr.write('ERROR: %s\n' % message) + self.print_help() + sys.exit(2) + -- cgit 1.2.3-korg