import curlwrapper
import logger
import tools
-
+import xmlrpclib
class conf_files:
def __init__(self, config, noscripts=False):
def system(self, cmd):
if not self.noscripts and cmd:
- logger.log('conf_files: running command %s' % cmd)
+ logger.verbose('conf_files: running command %s' % cmd)
return tools.fork_as(None, os.system, cmd)
else: return 0
def update_conf_file(self, cf_rec):
if not cf_rec['enabled']: return
dest = cf_rec['dest']
- # XXX Remove once old Node Manager is out of service
- if dest == '/etc/proper/propd.conf': return
err_cmd = cf_rec['error_cmd']
mode = string.atoi(cf_rec['file_permissions'], base=8)
try:
logger.log('conf_files: cannot find group %s -- %s not updated'%(cf_rec['file_group'],dest))
return
url = 'https://%s/%s' % (self.config.PLC_BOOT_HOST, cf_rec['source'])
+ # set node_id at the end of the request - hacky
+ if tools.node_id():
+ if url.find('?') >0: url += '&'
+ else: url += '?'
+ url += "node_id=%d"%tools.node_id()
+ else:
+ logger.log('%s -- WARNING, cannot add node_id to request'%dest)
+ # pass slicefamily as well, as stored in /etc/planetlab/slicefamily ont the node
+ if tools.slicefamily():
+ if url.find('?') >0: url += '&'
+ else: url += '?'
+ url += "slicefamily=%s"%tools.slicefamily()
try:
+ logger.verbose("retrieving URL=%s"%url)
contents = curlwrapper.retrieve(url, self.config.cacert)
except xmlrpclib.ProtocolError,e:
logger.log('conf_files: failed to retrieve %s from %s, skipping' % (dest, url))