From 9670a9c94a4bbf77092148a8103743cdb302919a Mon Sep 17 00:00:00 2001 From: bp-sawyers Date: Thu, 11 Jun 2009 13:28:27 +0000 Subject: [PATCH] Updates to system p hw discovery wizard for NCSA git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@3554 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-web/machines/discover.php | 158 +++++++++++++++++++++++++-------- 1 file changed, 121 insertions(+), 37 deletions(-) diff --git a/xCAT-web/machines/discover.php b/xCAT-web/machines/discover.php index b78060dae..59f1dd4b9 100644 --- a/xCAT-web/machines/discover.php +++ b/xCAT-web/machines/discover.php @@ -49,13 +49,29 @@ function expandNR($nr) { // see pping as an example of the client/server for noderange expansion $a = array(); if (empty($nr)) return $a; + +// Check for square bracket range +$parts = array(); +if (preg_match('/(.*?)\[(.*?)\](.*)/',$nr,$parts)) { + $range = preg_split('/([\-\:])/', $parts[2]); + if (count($range) < 2) { msg('E', "Invalid node range: $parts[2]"); return $a; } // ill-formed range + $numlen = strlen($range[0]); + for ($i=$range[0]; $i<=$range[1]; $i++) { + $istr = "$i"; + if (strlen($istr) < $numlen) { $istr = substr('000000',0,$numlen-strlen($istr)) . $istr; } + $a = array_merge($a, expandNR("$parts[1]$istr$parts[3]")); + } + return $a; +} + +// Check for range with dash if (strpos($nr,'-')===FALSE) { $a[] = $nr; return $a; } // a single node list($begin, $end) = explode('-', $nr); $begParts = array(); -if (!preg_match('/^(\D+)(\d+)$/', $begin, $begParts)) { msg('E',"Error in noderange syntax: $nr"); return NULL; } +if (!preg_match('/^(\D+)(\d+)$/', $begin, $begParts)) { $a[] = $nr; return $a; } // a single node $endParts = array(); -if (!preg_match('/^(\D+)(\d+)$/', $end, $endParts)) { msg('E',"Error in noderange syntax: $nr"); return NULL; } -if ($begParts[1] != $endParts[1]) { msg('E',"Error in noderange syntax: $nr"); return NULL; } +if (!preg_match('/^(\D+)(\d+)$/', $end, $endParts)) { $a[] = $nr; return $a; } // a single node +if ($begParts[1] != $endParts[1]) { $a[] = $nr; return $a; } // a single node $numlen = strlen($begParts[2]); for ($i=$begParts[2]; $i<=$endParts[2]; $i++) { $istr = "$i"; @@ -99,6 +115,7 @@ echo "