6 N = {'id': 0, 'status': 1, 'name': 2, 'cluster': 3, 'ip': 4, 'mac': 5,
7 'roles': 6, 'pending_roles': 7, 'online': 8}
8 E = {'id': 0, 'status': 1, 'name': 2, 'mode': 3, 'release_id': 4,
9 'changes': 5, 'pending_release_id': 6}
10 R = {'id': 0, 'name': 1, 'state': 2, 'operating_system': 3, 'version': 4}
11 RO = {'name': 0, 'conflicts': 1}
13 LOG = logging.getLogger(__name__)
14 LOG.setLevel(logging.DEBUG)
15 formatter = logging.Formatter('%(message)s')
16 out_handler = logging.StreamHandler(sys.stdout)
17 out_handler.setFormatter(formatter)
18 LOG.addHandler(out_handler)
19 out_handler = logging.FileHandler('autodeploy.log', mode='w')
20 out_handler.setFormatter(formatter)
21 LOG.addHandler(out_handler)
24 process = subprocess.Popen(cmd,
25 stdout=subprocess.PIPE,
26 stderr=subprocess.STDOUT,
28 return process.communicate()[0], process.returncode
31 process = subprocess.Popen(cmd,
32 stdout=subprocess.PIPE,
33 stderr=subprocess.STDOUT,
37 def parse(printout, *args):
39 lines = printout[0].splitlines()
41 parsed = [e.strip() for e in l.split('|')]
42 parsed_list.append(parsed)
45 def err(error_message):
46 LOG.error(error_message)
49 def check_file_exists(file_path):
50 if not os.path.isfile(file_path):
51 err('ERROR: File %s not found\n' % file_path)