summaryrefslogtreecommitdiffstats
path: root/fuel/deploy/common.py
diff options
context:
space:
mode:
authorSzilard Cserey <szilard.cserey@ericsson.com>2015-05-21 15:57:35 +0200
committerSzilard Cserey <szilard.cserey@ericsson.com>2015-06-17 12:09:30 +0200
commit2654b0628e30f54b0b8e89208ab04204858cfae5 (patch)
treeba385d757efb92f7c8f8b13d55ae6a7c483e9dc4 /fuel/deploy/common.py
parent321aff98523fbe442af7ca4d935c83e2196eacee (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: I7101295ac4becfc5fa10eda757cec0c2ad127940 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)
+