real nodes -> warning only - review (wrongly) multiple loop on slices
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 7 Feb 2008 13:15:09 +0000 (13:15 +0000)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Thu, 7 Feb 2008 13:15:09 +0000 (13:15 +0000)
system/TestNode.py
system/TestPlc.py
system/TestSlice.py

index a79c7c3..9d3da8e 100644 (file)
@@ -14,16 +14,24 @@ class TestNode:
     def name(self):
         return self.node_spec['node_fields']['hostname']
         
+    @staticmethod
+    def is_vmware_model(model):
+        return model.find("vmware") >= 0        
     def is_vmware (self):
-        model=self.node_spec['node_fields']['model']
-        return model.find("vmware") >= 0
+        return TestNode.is_vmware_model(self.node_spec['node_fields']['model'])
 
-    def is_qemu (self):
-        model=self.node_spec['node_fields']['model']
+    @staticmethod
+    def is_qemu_model (model):
         return model.find("qemu") >= 0
+    def is_qemu (self):
+        return TestNode.is_qemu_model(self.node_spec['node_fields']['model'])
 
+    @staticmethod
+    def is_real_model (model):
+        return (not TestNode.is_vmware_model(model)) \
+            and (not TestNode.is_qemu_model(model))
     def is_real (self):
-        return (not self.is_vmware()) and (not self.is_qemu())
+        return TestNode.is_real_model (self.node_spec['node_fields']['model'])
 
     def host_box (self):
         try:
index fd061a3..cbb3ded 100644 (file)
@@ -380,8 +380,7 @@ class TestPlc:
                 else:
                     # if it's a real node, never mind
                     (site_spec,node_spec)=self.locate_node(hostname)
-                    test_node = TestNode(self,site_spec,node_spec)
-                    if test_node.is_real():
+                    if TestNode.is_real_model(node_spec['node_fields']['model']):
                         utils.header("WARNING - Real node %s in %s - ignored"%(hostname,boot_state))
                         # let's cheat
                         boot_state = 'boot'
@@ -436,6 +435,11 @@ class TestPlc:
                     utils.header('The node %s is sshable -->'%hostname)
                     # refresh tocheck
                     tocheck.remove(hostname)
+                else:
+                    (site_spec,node_spec)=self.locate_node(hostname)
+                    if TestNode.is_real_model(node_spec['node_fields']['model']):
+                        utils.header ("WARNING : check ssh access into real node %s - skipped"%hostname)
+                    tocheck.remove(hostname)
             if not tocheck:
                 return True
             if datetime.datetime.now() > timeout:
@@ -496,7 +500,7 @@ class TestPlc:
             site_spec = self.locate_site (slice_spec['sitename'])
             test_site = TestSite(self,site_spec)
             test_slice=TestSlice(self,test_site,slice_spec)
-            status=test_slice.do_check_slices(options)
+            status=test_slice.do_check_slice(options)
             return status
     
     def start_nodes (self, options):
index a3a4568..f4eb9c5 100644 (file)
@@ -79,45 +79,48 @@ class TestSlice:
 
         return (found,remote_privatekey)
 
-    def do_check_slices(self,options):
+    def do_check_slice(self,options):
         bool=True
         self.clear_known_hosts()
         start_time = datetime.datetime.now()
         dead_time=start_time + datetime.timedelta(minutes=15)
-        for slice_spec in self.test_plc.plc_spec['slices']:
-            for hostname in slice_spec['nodenames']:
-                slicename=slice_spec['slice_fields']['name']
-                (found,remote_privatekey)=self.locate_key(slice_spec)
-                if( not found):
-                    raise Exception,"Cannot find a valid key for slice %s"%slicename
-                    break 
-                while(bool):
-                    utils.header('trying to connect to %s@%s'%(slicename,hostname))
-                    Date=self.test_plc.run_in_guest('ssh -i %s %s@%s date'%(remote_privatekey,slicename,hostname))
-                    if (Date==0):
+        slice_spec = self.slice_spec
+        for hostname in slice_spec['nodenames']:
+            (site_spec,node_spec) = self.test_plc.locate_node(hostname)
+            if TestNode.is_real_model(node_spec['node_fields']['model']):
+                utils.header("WARNING : Checking slice %s on real node %s skipped"%(self.name(),hostname))
+                continue
+            (found,remote_privatekey)=self.locate_key(slice_spec)
+            if not found :
+                raise Exception,"Cannot find a valid key for slice %s"%self.name()
+                break 
+            while (bool):
+                utils.header('trying to connect to %s@%s'%(self.name(),hostname))
+                Date=self.test_plc.run_in_guest('ssh -i %s %s@%s date'%(remote_privatekey,self.name(),hostname))
+                if (Date==0):
+                    break
+                elif ( start_time  <= dead_time ) :
+                    start_time=datetime.datetime.now()+ datetime.timedelta(seconds=45)
+                    time.sleep(45)
+                elif (options.forcenm):
+                    utils.header('%s@%s : restarting nm in case is in option on %s'%(self.name(),hostname,hostname))
+                    access=self.test_plc.run_in_guest('ssh -i /etc/planetlab/root_ssh_key.rsa  root@%s service nm restart'%hostname)
+                    if (access==0):
+                        utils.header('nm restarted on %s'%hostname)
+                    else:
+                        utils.header('%s@%s : Failed to restart the NM on %s'%(self.name(),hostname,hostname))
+                    utils.header('Try to reconnect to  %s@%s after the tentative of restarting NM'%(self.name(),hostname))
+                    connect=self.test_plc.run_in_guest('ssh -i %s %s@%s date'%(remote_privatekey,self.name(),hostname))
+                    if (not connect):
+                        utils.header('connected to %s@%s -->'%(self.name(),hostname))
                         break
-                    elif ( start_time  <= dead_time ) :
-                        start_time=datetime.datetime.now()+ datetime.timedelta(seconds=45)
-                        time.sleep(45)
-                    elif (options.forcenm):
-                        utils.header('%s@%s : restarting nm in case is in option on %s'%(slicename,hostname,hostname))
-                        access=self.test_plc.run_in_guest('ssh -i /etc/planetlab/root_ssh_key.rsa  root@%s service nm restart'%hostname)
-                        if (access==0):
-                            utils.header('nm restarted on %s'%hostname)
-                        else:
-                            utils.header('%s@%s : Failed to restart the NM on %s'%(slicename,hostname,hostname))
-                        utils.header('Try to reconnect to  %s@%s after the tentative of restarting NM'%(slicename,hostname))
-                        connect=self.test_plc.run_in_guest('ssh -i %s %s@%s date'%(remote_privatekey,slicename,hostname))
-                        if (not connect):
-                            utils.header('connected to %s@%s -->'%(slicename,hostname))
-                            break
-                        else:
-                            utils.header('giving up with to %s@%s -->'%(slicename,hostname))
-                            bool=False
-                            break
                     else:
+                        utils.header('giving up with to %s@%s -->'%(self.name(),hostname))
                         bool=False
                         break
+                else:
+                    bool=False
+                    break
         return bool