From 2037adb5ce8f15280184192f58d79bca4a1dbeb9 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 23 Apr 2008 15:53:15 +0000 Subject: [PATCH] handling generic images - %a in filename gets replaced by arch --- PLC/Methods/GetBootMedium.py | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/PLC/Methods/GetBootMedium.py b/PLC/Methods/GetBootMedium.py index 0e760355..94651b78 100644 --- a/PLC/Methods/GetBootMedium.py +++ b/PLC/Methods/GetBootMedium.py @@ -80,6 +80,7 @@ class GetBootMedium(Method): - %v : the bootcd version string (e.g. 4.0) - %p : the PLC name - %f : the nodefamily + - %a : arch With the file-based return mechanism, the method returns the full pathname of the result file; ** WARNING ** @@ -223,6 +224,9 @@ class GetBootMedium(Method): except: (pldistro,arch) = ("planetlab","i386") + if not node: + return (pldistro,arch) + known_archs = [ 'i386', 'x86_64' ] nodegroupnames = [ ng['name'] for ng in NodeGroups (self.api, node['nodegroup_ids'],['name'])] # (1) if groupname == arch, nodefamily becomes pldistro-groupname @@ -305,12 +309,6 @@ class GetBootMedium(Method): raise PLCInvalidArgument, "No such node %r"%node_id_or_hostname node = nodes[0] nodename = node['hostname'] - # get nodefamily - (pldistro,arch) = self.get_nodefamily(node) - self.nodefamily="%s-%s"%(pldistro,arch) - # apply on globals - for attr in [ "BOOTCDDIR", "BOOTCDBUILD", "GENERICDIR" ]: - setattr(self,attr,getattr(self,attr).replace("@NODEFAMILY@",self.nodefamily)) else: node = None @@ -318,6 +316,13 @@ class GetBootMedium(Method): tempbytes = random.sample (xrange(0,256), 8); def hexa2 (c): return chr((c>>4)+65) + chr ((c&16)+65) nodename = "".join(map(hexa2,tempbytes)) + + # get nodefamily + (pldistro,arch) = self.get_nodefamily(node) + self.nodefamily="%s-%s"%(pldistro,arch) + # apply on globals + for attr in [ "BOOTCDDIR", "BOOTCDBUILD", "GENERICDIR" ]: + setattr(self,attr,getattr(self,attr).replace("@NODEFAMILY@",self.nodefamily)) ### handle filename # allow to set filename to None or any other empty value @@ -327,14 +332,12 @@ class GetBootMedium(Method): filename = filename.replace ("%s",suffix) filename = filename.replace ("%p",self.api.config.PLC_NAME) # let's be cautious - try: - filename = filename.replace ("%f", self.nodefamily) - except: - pass - try: - filename = filename.replace ("%v",self.bootcd_version()) - except: - pass + try: filename = filename.replace ("%f", self.nodefamily) + except: pass + try: filename = filename.replace ("%a", arch) + except: pass + try: filename = filename.replace ("%v",self.bootcd_version()) + except: pass ### Check filename location if filename != '': -- 2.47.0