summaryrefslogtreecommitdiffstats
path: root/fuel/deploy/common.py
diff options
context:
space:
mode:
authorSzilard Cserey <szilard.cserey@ericsson.com>2015-06-17 12:14:54 +0200
committerSzilard Cserey <szilard.cserey@ericsson.com>2015-06-17 12:15:49 +0200
commitfbac78cb5277b044f3318c831d4da92663097a6c (patch)
tree3fc5b70bfc68977159f39ca663252be3ab8ab07c /fuel/deploy/common.py
parenteb887812da568cfb4908f6ae14449b2ceaeb5bc0 (diff)
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: Ia22ae9b050085aaa4cadb4ee6c7bfd556c4bc18a Signed-off-by: Szilard Cserey <szilard.cserey@ericsson.com>
Diffstat (limited to 'fuel/deploy/common.py')
-rw-r--r--fuel/deploy/common.py21
1 files changed, 21 insertions, 0 deletions
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)
+