Salome HOME
sat #8523 : protection d'appels ssh inutiles sur plateforme windows
authorcrouzet <nicolas.crouzet@cea.fr>
Wed, 6 Feb 2019 07:49:25 +0000 (08:49 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Wed, 6 Feb 2019 07:49:25 +0000 (08:49 +0100)
commands/application.py
commands/compile.py
commands/launcher.py
commands/test.py

index 9067b0a530ee2928d075e12f41030bfe3105aae7..f700febbbbcf18cb47877603205b146a6e2179f6 100644 (file)
@@ -342,36 +342,41 @@ def generate_catalog(machines, config, logger):
     catalog = file(catfile, "w")
     catalog.write("<!DOCTYPE ResourcesCatalog>\n<resources>\n")
     for k in machines:
-        logger.write("    ssh %s " % (k + " ").ljust(20, '.'), 4)
-        logger.flush()
-
-        ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
-        p = subprocess.Popen(ssh_cmd, shell=True,
-                stdin=subprocess.PIPE,
-                stdout=subprocess.PIPE,
-                stderr=subprocess.PIPE)
-        p.wait()
-
-        if p.returncode != 0:
-            logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4)
-            logger.write("    " + src.printcolors.printcWarning(p.stderr.read()),
-                         2)
-        else:
-            logger.write(src.printcolors.printc(src.OK_STATUS) + "\n", 4)
-            lines = p.stdout.readlines()
-            freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
-            nb_proc = len(lines) -1
-            memory = lines[-1].split(':')[-1].split()[0].strip()
-            memory = int(memory) / 1000
+        if not src.architecture.is_windows(): 
+            logger.write("    ssh %s " % (k + " ").ljust(20, '.'), 4)
+            logger.flush()
+
+            ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
+            p = subprocess.Popen(ssh_cmd, shell=True,
+                    stdin=subprocess.PIPE,
+                    stdout=subprocess.PIPE,
+                    stderr=subprocess.PIPE)
+            p.wait()
+
+            machine_access = (p.returncode == 0) 
+            if not machine_access:
+                logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4)
+                logger.write("    " + src.printcolors.printcWarning(p.stderr.read()),
+                             2)
+            else:
+                logger.write(src.printcolors.printc(src.OK_STATUS) + "\n", 4)
+                lines = p.stdout.readlines()
+                freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
+                nb_proc = len(lines) -1
+                memory = lines[-1].split(':')[-1].split()[0].strip()
+                memory = int(memory) / 1000
 
             catalog.write("    <machine\n")
             catalog.write("        protocol=\"ssh\"\n")
             catalog.write("        nbOfNodes=\"1\"\n")
             catalog.write("        mode=\"interactif\"\n")
             catalog.write("        OS=\"LINUX\"\n")
-            catalog.write("        CPUFreqMHz=\"%s\"\n" % freq)
-            catalog.write("        nbOfProcPerNode=\"%s\"\n" % nb_proc)
-            catalog.write("        memInMB=\"%s\"\n" % memory)
+
+            if (not src.architecture.is_windows()) and machine_access:
+                catalog.write("        CPUFreqMHz=\"%s\"\n" % freq)
+                catalog.write("        nbOfProcPerNode=\"%s\"\n" % nb_proc)
+                catalog.write("        memInMB=\"%s\"\n" % memory)
+
             catalog.write("        userName=\"%s\"\n" % user)
             catalog.write("        name=\"%s\"\n" % k)
             catalog.write("        hostname=\"%s\"\n" % k)
index dc21fb010eff15a954152a17c1ce6a5cba854c42..f7bcb0d2d65b5375552e283a7cfb13263ea0ea62 100644 (file)
@@ -283,7 +283,6 @@ def compile_all_products(sat, config, options, products_infos, logger):
                       verbose=0,
                       logger_add_link = logger)
 
-        # DBG.write("Only for test of check_config_exists", src.product.check_config_exists(config, "/volatile/wambeke/SAT5/MATIX_V24_S840/INSTALL/PACKAGESPY", p_info, verbose=True), True)
 
         # Clean the the install directory 
         # if the corresponding option was called
index 1f18f5b7aa4c6e63226e16c6126fbf7f8ce6f9c1..0955d9544683c52d5afb8d304f3181d7ae3ccbfc 100644 (file)
@@ -179,44 +179,49 @@ def generate_catalog(machines, config, logger):
     # Write into it
     catalog.write("<!DOCTYPE ResourcesCatalog>\n<resources>\n")
     for k in machines:
-        logger.write("    ssh %s " % (k + " ").ljust(20, '.'), 4)
-        logger.flush()
-
-        # Verify that the machine is accessible
-        ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
-        p = subprocess.Popen(ssh_cmd, shell=True,
-                stdin=subprocess.PIPE,
-                stdout=subprocess.PIPE,
-                stderr=subprocess.PIPE)
-        p.wait()
-
-        if p.returncode != 0: # The machine is not accessible
-            logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4)
-            logger.write("    " + 
-                         src.printcolors.printcWarning(p.stderr.read()), 2)
-        else:
-            # The machine is accessible, write the corresponding section on
-            # the xml file
-            logger.write(src.printcolors.printc(src.OK_STATUS) + "\n", 4)
-            lines = p.stdout.readlines()
-            freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
-            nb_proc = len(lines) -1
-            memory = lines[-1].split(':')[-1].split()[0].strip()
-            memory = int(memory) / 1000
-
-            catalog.write("    <machine\n")
-            catalog.write("        protocol=\"ssh\"\n")
-            catalog.write("        nbOfNodes=\"1\"\n")
-            catalog.write("        mode=\"interactif\"\n")
-            catalog.write("        OS=\"LINUX\"\n")
+        if not src.architecture.is_windows(): 
+            logger.write("    ssh %s " % (k + " ").ljust(20, '.'), 4)
+            logger.flush()
+
+            # Verify that the machine is accessible
+            ssh_cmd = 'ssh -o "StrictHostKeyChecking no" %s %s' % (k, cmd)
+            p = subprocess.Popen(ssh_cmd, shell=True,
+                    stdin=subprocess.PIPE,
+                    stdout=subprocess.PIPE,
+                    stderr=subprocess.PIPE)
+            p.wait()
+
+            machine_access = (p.returncode == 0) 
+            if not machine_access: # The machine is not accessible
+                logger.write(src.printcolors.printc(src.KO_STATUS) + "\n", 4)
+                logger.write("    " + 
+                             src.printcolors.printcWarning(p.stderr.read()), 2)
+            else:
+                # The machine is accessible, write the corresponding section on
+                # the xml file
+                logger.write(src.printcolors.printc(src.OK_STATUS) + "\n", 4)
+                lines = p.stdout.readlines()
+                freq = lines[0][:-1].split(':')[-1].split('.')[0].strip()
+                nb_proc = len(lines) -1
+                memory = lines[-1].split(':')[-1].split()[0].strip()
+                memory = int(memory) / 1000
+
+        catalog.write("    <machine\n")
+        catalog.write("        protocol=\"ssh\"\n")
+        catalog.write("        nbOfNodes=\"1\"\n")
+        catalog.write("        mode=\"interactif\"\n")
+        catalog.write("        OS=\"LINUX\"\n")
+
+        if (not src.architecture.is_windows()) and machine_access :
             catalog.write("        CPUFreqMHz=\"%s\"\n" % freq)
             catalog.write("        nbOfProcPerNode=\"%s\"\n" % nb_proc)
             catalog.write("        memInMB=\"%s\"\n" % memory)
-            catalog.write("        userName=\"%s\"\n" % user)
-            catalog.write("        name=\"%s\"\n" % k)
-            catalog.write("        hostname=\"%s\"\n" % k)
-            catalog.write("    >\n")
-            catalog.write("    </machine>\n")
+
+        catalog.write("        userName=\"%s\"\n" % user)
+        catalog.write("        name=\"%s\"\n" % k)
+        catalog.write("        hostname=\"%s\"\n" % k)
+        catalog.write("    >\n")
+        catalog.write("    </machine>\n")
 
     catalog.write("</resources>\n")
     catalog.close()
index 0d39d2567e9e74b163490057af4b95daedeaed0f..62fd7fef5cc6d55e793a4955b2dc6bde2f4ebc72 100644 (file)
@@ -636,7 +636,7 @@ def run(args, runner, logger):
     show_desktop = (options.display and options.display.upper() == "NO")
     if options.display and options.display != "NO":
         remote_name = options.display.split(':')[0]
-        if remote_name != "":
+        if remote_name != "" and (not src.architecture.is_windows()):
             check_remote_machine(remote_name, logger)
         # if explicitly set use user choice
         os.environ['DISPLAY'] = options.display