X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=scripts%2Fupdate_bios_settings.py;h=1412dfc041ba1ccd77e858c55b2879fda0c22ee1;hb=a87fe956a57bc2294926cdb1020ab74676f5739d;hp=4472ad49d173db30f74473207c1c061d60c33912;hpb=98efca144dbc3dac0022543bdc0812a37bdb8a8c;p=yaml_builds.git diff --git a/scripts/update_bios_settings.py b/scripts/update_bios_settings.py index 4472ad4..1412dfc 100644 --- a/scripts/update_bios_settings.py +++ b/scripts/update_bios_settings.py @@ -1,4 +1,6 @@ -opyright (c) 2018 AT&T Intellectual Property. All rights reserved. # + +############################################################################## +# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. # # # # Licensed under the Apache License, Version 2.0 (the "License"); you may # # not use this file except in compliance with the License. # @@ -23,10 +25,10 @@ def create_node_rcfile(nodes, defaults, j2template, rcfile_suffix): env = jinja2.Environment() env.trim_blocks = True env.lstrip_blocks = True - + with open(j2template) as fd: template = env.from_string(fd.read()) - + if type(nodes) is list: for node in nodes: newnode = dict( defaults.items() + node.items() ) @@ -49,8 +51,9 @@ def create_node_rcfile(nodes, defaults, j2template, rcfile_suffix): if newnode['vendor'] == "HP" or newnode['vendor'] == "HPE": command = '/opt/akraino/redfish/apply_hpejson.sh --rc {0} --template {1} --no-confirm'.format(rcfile, newnode["bios_template"]) if command: - print 'command: {0}'.format(command) - os.system(command) + p=subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True, preexec_fn=os.setsid) + print 'process: {} command: {}'.format(p.pid, command) + plist.append(p) ### MAIN ### if len(sys.argv) != 2: @@ -60,13 +63,15 @@ if len(sys.argv) != 2: with open(sys.argv[1]) as f: siteyaml = yaml.safe_load(f) +# list of background processes created +plist = [] + # create set of defaults based on top level ipmi_admin and hardware key/value pairs defaults = dict( siteyaml["ipmi_admin"].items() + siteyaml["hardware"].items() ) # add keys for backward compatibility defaults = dict( [('oob_user',siteyaml['ipmi_admin']['username'])] + defaults.items()) defaults = dict( [('oob_password',siteyaml['ipmi_admin']['password'])] + defaults.items()) -defaults = dict( [('oem',siteyaml['hardware']['vendor'])] + defaults.items()) print 'Using defaults:' for line in yaml.dump(defaults,default_flow_style=False).split('\n'): @@ -78,3 +83,10 @@ if 'masters' in siteyaml: if 'workers' in siteyaml: create_node_rcfile(siteyaml["workers"], defaults, "tools/j2/serverrc_raid.j2", "rc.raid") +# print output from background processes +for p in plist: + print "waiting for process {}".format(p.pid) + exitcode=p.wait() + print 'Process {0} ended with exit code {1}'.format(p.pid, p.returncode) + print p.communicate()[0] +