X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=plugins%2Fomf_resctl.py;h=7b9b1eb1ede22194d49920373a1df27bf15c8762;hb=4cac061c0af2d895895afd3bb08092af3289c0cf;hp=a5f4c687d8fb0ab4f7e7b75ba19fceae45e89357;hpb=fbf0fd3367f34d39b0b562820d786d7854824ba6;p=nodemanager.git diff --git a/plugins/omf_resctl.py b/plugins/omf_resctl.py index a5f4c68..7b9b1eb 100644 --- a/plugins/omf_resctl.py +++ b/plugins/omf_resctl.py @@ -23,14 +23,16 @@ def start(): # hard-wire this for now # once the variables are expanded, this is expected to go into config_ple_template="""--- -# slicename = _slicename_ -# hostname = _hostname_ -# xmpp_server = _xmpp_server_ # we extract expires time here, even in a comment so that the # trigger script gets called whenever this changes # expires: _expires_ - -:uid: _slicename_@_hostname_ + +# these are not actual OMF parameters, they are only used by the trigger script +:hostname: _hostname_ +:slicename: _slicename_ + +# OMF configuration +:uid: _slicename_%_hostname_ :uri: xmpp://_slicename_-_hostname_-<%= "#{Process.pid}" %>:_slicename_-_hostname_-<%= "#{Process.pid}" %>@_xmpp_server_ :environment: production :debug: false @@ -111,17 +113,20 @@ def GetSlivers(data, conf = None, plc = None): try: fetch_trigger_script_if_missing (slicename) # the trigger script actually needs to be run in the slice context of course + # in addition there is a requirement to pretend we run as a login shell + # hence sudo -i slice_command = [ "sudo", "-i", omf_rc_trigger_script ] to_run = tools.command_in_slice (slicename, slice_command) - logger.log("command_in_slice: %s"%to_run) - sp=subprocess.Popen(to_run, stdout=subprocess.PIPE,stderr=subprocess.STDOUT) - (out,err)=sp.communicate() - retcod=sp.returncode - # we don't wait for that, try to display a retcod for info purpose only - # might be None if that config script lasts or hangs whatever - logger.log("omf_resctl: %s: called OMF rc control script (imm. retcod=%r)"%(slicename,retcod)) - logger.log("omf_resctl: got stdout\n%s"%out) - logger.log("omf_resctl: got stderr\n%s"%err) + log_filename = "/vservers/%s/var/log/%s.log"%(slicename,omf_rc_trigger_script) + logger.log("omf_resctl: starting %s"%to_run) + logger.log("redirected into %s"%log_filename) + logger.log("*not* waiting for completion..") + with open(log_filename,"a") as log_file: + subprocess.Popen(to_run, stdout=log_file,stderr=subprocess.STDOUT) + # a first version tried to 'communicate' on that subprocess instance + # but that tended to create deadlocks in some cases + # causing nodemanager to stall... + # we're only losing the child's retcod, no big deal except: import traceback traceback.print_exc()