cross-module change for 4.2
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 24 Jun 2008 16:12:40 +0000 (16:12 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Tue, 24 Jun 2008 16:12:40 +0000 (16:12 +0000)
- NodeManager/conf_files set node_id when invoking source URL
- nodeconfig/yum.conf.php : no functional change, but uses node_id to gather nodegroups and displays them in comments

conf_files.py

index 24d5509..64e18c2 100644 (file)
@@ -19,6 +19,17 @@ class conf_files:
         self.cond = threading.Condition()
         self.data = None
 
+    # get node_id from /etc/planetlab/node_id and cache it
+    _node_id=None
+    @staticmethod 
+    def node_id():
+        if conf_files._node_id is None:
+            try:
+                conf_files._node_id=int(file("/etc/planetlab/node_id").read())
+            except:
+                conf_files._node_id=""
+        return conf_files._node_id
+
     def checksum(self, path):
         try:
             f = open(path)
@@ -50,7 +61,13 @@ 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 conf_files.node_id():
+            if url.find('?') >0: url += '&'
+            else:                url += '?'
+            url += "node_id=%d"%conf_files.node_id()
         try:
+            logger.log("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))