conf_files has support for @SLICEFAMILY@ in sources
[nodemanager.git] / conf_files.py
index c5d5924..8b0119f 100644 (file)
@@ -10,7 +10,7 @@ import threading
 import curlwrapper
 import logger
 import tools
-
+import xmlrpclib
 
 class conf_files:
     def __init__(self, config, noscripts=False):
@@ -50,9 +50,20 @@ class conf_files:
             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)
+        # replace @SLICEFAMILY@ with what's stored on the node
+        if tools.slicefamily():
+            url = url.replace("@SLICEFAMILY@",tools.slicefamily())
         try:
+            logger.log("retrieving URL=%s"%url)
             contents = curlwrapper.retrieve(url, self.config.cacert)
-        except curlwrapper.CurlException:
+        except xmlrpclib.ProtocolError,e:
             logger.log('conf_files: failed to retrieve %s from %s, skipping' % (dest, url))
             return
         if not cf_rec['always_update'] and sha.new(contents).digest() == self.checksum(dest):