-omf_rc_trigger_script="plc_trigger_omf_rc"
-
-### this returns the kind of virtualization on the node
-# either 'vs' or 'lxc'
-# also caches it in /etc/planetlab/virt for next calls
-# could be promoted to core nm if need be
-virt_stamp="/etc/planetlab/virt"
-def get_node_virt ():
- try:
- return file(virt_stamp).read().strip()
- except:
- pass
- logger.log("Computing virt..")
- vs_retcod=subprocess.call ([ 'vserver', '--help' ])
- if vs_retcod == 0:
- virt='vs'
- else:
- virt='lxc'
- with file(virt_stamp,"w") as f:
- f.write(virt)
- return virt
-
-def command_in_slice (slicename, argv):
- # with vserver this can be done using vserver .. exec <trigger-script>
- # with lxc this is less clear as we are still discussing how lxcsu should behave
- # ideally we'd need to run lxcsu .. <trigger-script>
- virt=get_node_virt()
- if virt=='vs':
- return [ 'vserver', slicename, 'exec', ] + argv
- elif virt=='lxc':
- return [ 'lxcsu', slicename, ] + argv
- logger.log("command_in_slice: WARNING: could not find a valid virt")
- return argv
+# given that we're now responsible for fetching this one, I have to
+# decide on an actual path - not jsut a name to search for in PATH
+omf_rc_trigger_script="/usr/bin/plc_trigger_omf_rc"
+omf_rc_trigger_log="/var/log/plc_trigger_omf_rc.log"
+
+# hopefully temporary: when trigger script is missing, fetch it at the url here
+omf_rc_trigger_url="http://git.mytestbed.net/?p=omf.git;a=blob_plain;f=omf_rc/bin/plc_trigger_omf_rc;hb=HEAD"
+def fetch_trigger_script_if_missing (slicename):
+ full_path="/vservers/%s/%s"%(slicename,omf_rc_trigger_script)
+ if not os.path.isfile (full_path):
+ retcod=subprocess.call (['curl','--silent','-o',full_path,omf_rc_trigger_url])
+ if retcod!=0:
+ logger.log("Could not fetch %s"%omf_rc_trigger_url)
+ else:
+ subprocess.call(['chmod','+x',full_path])
+ logger.log("omf_resctl: fetched %s"%(full_path))
+ logger.log("omf_resctl: from %s"%(omf_rc_trigger_url))