diff options
author | Szilard Cserey <szilard.cserey@ericsson.com> | 2015-04-14 15:47:45 +0200 |
---|---|---|
committer | Szilard Cserey <szilard.cserey@ericsson.com> | 2015-04-28 10:01:04 +0200 |
commit | 9c2b6848566a0b80bb44f27cca155a240d69f061 (patch) | |
tree | 5081686f09c3c4662f6b807a196a28cb4acab67a /fuel/deploy/cloud_deploy/cloud/common.py | |
parent | e2b2d46756213fde3bca42a49b04e6a1e8792498 (diff) |
Automatic Deployment
- node discovery
- refactoring to support multiple shelves
- configure nodes and interfaces
- provisioning
- deployment
- extending with autodeployment scripts from libvirt prototype
JIRA: [BGS-2] Create Fuel deployment scrip
Signed-off-by: Szilard Cserey <szilard.cserey@ericsson.com>
Change-Id: Ic48f93594914d5bef6c9de34d87434c7cd567198
Diffstat (limited to 'fuel/deploy/cloud_deploy/cloud/common.py')
-rw-r--r-- | fuel/deploy/cloud_deploy/cloud/common.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/fuel/deploy/cloud_deploy/cloud/common.py b/fuel/deploy/cloud_deploy/cloud/common.py new file mode 100644 index 0000000..365f6fb --- /dev/null +++ b/fuel/deploy/cloud_deploy/cloud/common.py @@ -0,0 +1,51 @@ +import subprocess +import sys +import os +import logging + +N = {'id': 0, 'status': 1, 'name': 2, 'cluster': 3, 'ip': 4, 'mac': 5, + 'roles': 6, 'pending_roles': 7, 'online': 8} +E = {'id': 0, 'status': 1, 'name': 2, 'mode': 3, 'release_id': 4, + 'changes': 5, 'pending_release_id': 6} +R = {'id': 0, 'name': 1, 'state': 2, 'operating_system': 3, 'version': 4} +RO = {'name': 0, 'conflicts': 1} + +LOG = logging.getLogger(__name__) +LOG.setLevel(logging.DEBUG) +formatter = logging.Formatter('%(message)s') +out_handler = logging.StreamHandler(sys.stdout) +out_handler.setFormatter(formatter) +LOG.addHandler(out_handler) +out_handler = logging.FileHandler('autodeploy.log', mode='w') +out_handler.setFormatter(formatter) +LOG.addHandler(out_handler) + +def exec_cmd(cmd): + process = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + shell=True) + return process.communicate()[0], process.returncode + +def run_proc(cmd): + process = subprocess.Popen(cmd, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + shell=True) + return process + +def parse(printout, *args): + parsed_list = [] + lines = printout[0].splitlines() + for l in lines[2:]: + parsed = [e.strip() for e in l.split('|')] + parsed_list.append(parsed) + return parsed_list + +def err(error_message): + LOG.error(error_message) + sys.exit(1) + +def check_file_exists(file_path): + if not os.path.isfile(file_path): + err('ERROR: File %s not found\n' % file_path) |