diff --git a/xCAT-UI/css/style.css b/xCAT-UI/css/style.css index d39e7c8a3..342ec0991 100644 --- a/xCAT-UI/css/style.css +++ b/xCAT-UI/css/style.css @@ -712,4 +712,39 @@ table a:hover { .lparStatus { width: 5px; height: 5px; +} + +.discoverstep{ + width : 200px; + vertical-align: top; + float: left; + position: relative; + margin: 15px 0px 15px 15px; + overflow: auto; + background-color : #CCCCFF; + padding : 10px 0px 0px 5px; + -moz-border-radius: .5em; + -webkit-border-radius: .5em; + border-radius: .5em; +} + +.discoverstep span{ + font: normal bold 13px/35px verdana, arial, helvetica, sans-serif; + margin: 0px 0px 10px 0px; +} + +.discovercontent{ + width : 700px; + display : inline-table; + padding : 20px; +} + +.discovercontent td{ + font: 12px verdana, arial, helvetica, sans-serif; +} + +.discovercontent th{ + font : normal bold 15px verdana, arial, helvetica, sans-serif; + text-align: center; + padding : 20px 0px 10px 0px; } \ No newline at end of file diff --git a/xCAT-UI/discover.php b/xCAT-UI/discover.php new file mode 100644 index 000000000..5b4af181c --- /dev/null +++ b/xCAT-UI/discover.php @@ -0,0 +1,20 @@ + diff --git a/xCAT-UI/js/discover/discover.js b/xCAT-UI/js/discover/discover.js new file mode 100644 index 000000000..035b3b5ff --- /dev/null +++ b/xCAT-UI/js/discover/discover.js @@ -0,0 +1,392 @@ +/*associate the step name with step number*/ +var steps = ['Discover Hardware', + 'Cluster Patterns', + 'Switch Ports', + 'More Cluster Patterns', + 'Prepare Management Node', + 'Power On Hardware', + 'Discover HW Control Points', + 'Update Definitions', + 'Configure HW Control Points', + 'Create Nodes', + 'Complete']; + +/*associate the function with step number*/ +var initFunctions = [initSelectPlatform, + initBasicPattern, + initSwitch, + initAdvancedPattern]; + +/*associate the function witch should be called before the page changed(when click next or back) + * if there is no need to call functions, use undefined.*/ +var nextFunctions = [undefined, + collectInputValue, + collectInputValue, + collectInputValue]; +/*save current step number*/ +var currentStep = 0; + +/*save user's input*/ +var discoverEnv; + +/** + * create the discover page + * + * @param + * + * @return + */ +function loadDiscoverPage(){ + currentStep = 0; + discoverEnv = new Object(); + $('#content').append('
'); + updateDiscoverStep(); + + $('#content').append('
'); + initSelectPlatform(); +} + +/** + * update the step show are on the left side of discover page + * + * @param + * + * @return + */ +function updateDiscoverStep(){ + $('#discoverStepDiv').empty(); + var showString = ''; + for(var index in steps){ + showString += '
'; + } + $('#discoverStepDiv').html(showString); +} + +/** + * create the navigator buttons on the bottom of discover page + * + * @param + * + * @return + */ +function createDiscoverButtons(){ + var buttonDiv = $('
'); + var backButton = createBackButton(); + var nextButton = createNextButton(); + var cancelButton = createButton('Cancel'); + cancelButton.bind('click', function(){ + $('#content').empty(); + for (var name in discoverEnv){ + delete discoverEnv[name]; + } + loadDiscoverPage(); + }); + + if (backButton){ + buttonDiv.append(backButton); + } + + if(nextButton){ + buttonDiv.append(nextButton); + } + + buttonDiv.append(cancelButton); + $('#discoverContentDiv').append(buttonDiv); +} + +/** + * create the next button base on the currentStep, the last step does not need this button + * + * @param + * + * @return + */ +function createNextButton(){ + if ((steps.length - 1) == currentStep){ + return undefined; + } + + var nextButton = createButton('Next'); + nextButton.bind('click', function(){ + if (nextFunctions[currentStep]){ + nextFunctions[currentStep](); + } + currentStep ++; + updateDiscoverStep(); + initFunctions[currentStep](); + }); + + return nextButton; +} + +/** + * create the next button base on the currentStep, the first step does not need this button + * + * @param + * + * @return + */ +function createBackButton(){ + if (0 == currentStep){ + return undefined; + } + + var backButton = createButton('Back'); + backButton.bind('click', function(){ + if (nextFunctions[currentStep]){ + nextFunctions[currentStep](); + } + currentStep--; + updateDiscoverStep(); + initFunctions[currentStep](); + }); + + return backButton; +} + +/** + * get the input value on discover page + * + * @param + * envName : value's name(discoverEnv's key) + * + * @return + * if there is assciate value, return the value. + * else return null. + */ +function getDiscoverEnv(envName){ + if (discoverEnv[envName]){ + return discoverEnv[envName]; + } + else{ + return ''; + } +} +/** + * Expand the noderange into node names. + * + * @param + * nodeRange : + * + * @return + * node names array. + * + */ +function expandNR(nodeRange){ + var retArray = new Array(); + var tempResult; + if ('' == nodeRange){ + return retArray; + } + + tempResult = nodeRange.match(/(.*?)\[(.*?)\](.*)/); + if (null != tempResult){ + var parts = tempResult[2].split('-'); + if (2 > parts.length){ + return retArray; + } + + var start = Number(parts[0]); + var end = Number(parts[1]); + var len = parts[0].length; + for(var i = parts[0]; i <= parts[1]; i++){ + var ts = i.toString(); + if (ts.length < len){ + ts = "000000".substring(0, (len - ts.length)) + ts; + } + retArray = retArray.concat(expandNR(tempResult[1] + ts + tempResult[3])); + } + return retArray; + } + + var tempArray = nodeRange.split('-'); + if (2 > tempArray.length){ + retArray.push(nodeRange); + return retArray; + } + + var begin = tempArray[0].match(/^(\D+)(\d+)$/); + if(2 > begin){ + retArray.push(nodeRange); + return retArray; + } + + var end = tempArray[1].match(/^(\D+)(\d+)$/); + if(2 > end){ + retArray.push(nodeRange); + return retArray; + } + + if(begin[1] != end[1]){ + retArray.push(nodeRange); + return retArray; + } + + var prefix = begin[1]; + var len = begin[2].length; + for(var i = begin[2]; i <= end[2]; i++){ + var ts = i.toString(); + if (ts.length < len){ + ts = "000000".substring(0, (len - ts.length)) + ts; + } + retArray.push(prefix + ts); + } + + return retArray; +} + +/** + * Step 1: show the wizard's function + * platform selector(system P or system X) + * + * @param + * + * @return + */ +function initSelectPlatform(){ + var temp = ''; + $('#discoverContentDiv').empty(); + temp += '

' + steps[currentStep] + '

'; + temp += '

This wizard will guide you through the process of defining the naming conventions within' + + 'your cluster, discovering the hardware on your network, and automatically defining it in the xCAT' + + 'database.
Choose which type of hardware you want to discover, and then click Next.

'; + + temp += ' System x hardware (not implemented yet)
'; + temp += ' System p hardware (only partially implemented)
'; + temp += '




'; + $('#discoverContentDiv').append(temp); + + createDiscoverButtons(); +} + +/** + * Step 2: Cluster basic patterns + * users can input the switches' name range, the number of port, start ip and port prefix + * hmcs' name range, number and start ip + * frames' name range, number and start ip + * drawers' name range, number and start ip + * + * @param + * + * @return + */ +function initBasicPattern(){ + $('#discoverContentDiv').empty(); + var showString = '

' + steps[currentStep] + '

'; + showString += ''; + //switch title + showString += ''; + //switch name + showString += ''; + showString += ''; + //switch start ip + showString += ''; + //Number of Ports Per Switch + showString += ''; + showString += ''; + //ports' name prefix + showString += ''; + //hmc title + showString += ''; + //hmc name + showString += ''; + showString += ''; + //hmc start ip + showString += ''; + //Number of Frames per HMC + showString += ''; + //BPA title + showString += ''; + //BPA Name + showString += ''; + showString += ''; + //BPA start ip + showString += ''; + //Number of Drawers per Frame + showString += ''; + //FSP title + showString += ''; + //FSP name + showString += ''; + showString += ''; + //FSP start ip + showString += ''; + //Number of LPARs per Drawer: + showString += ''; + showString += '
Service LAN Switches
Hostname Range:Starting IP Address:
Number of Ports Per Switch:Switch Port Prefix:
HMCs
Hostname Range:Starting IP Address:
Number of Frames per HMC:
Frames (BPAs)
Hostname Range:Starting IP Address:
Number of Drawers per Frame:
Drawers (FSPs/CECs)
Hostname Range:Starting IP Address:
Number of LPARs per Drawer:
'; + $('#discoverContentDiv').append(showString); + $('#discoverContentDiv input[type=text][title]').tooltip({ + position: "center right", + offset: [-2, 10], + effect: "fade", + opacity: 1 + }); + createDiscoverButtons(); +} + +/** + * Step 2: Cluster basic patterns + * save all of users' input into the global object discoverEnv + * + * @param + * + * @return + */ +function collectInputValue(){ + $('#discoverContentDiv input[type=text]').each(function(){ + var name = $(this).attr('name'); + var value = $(this).attr('value'); + if('' != value){ + discoverEnv[name] = value; + } + else{ + if(discoverEnv[name]){ + delete discoverEnv[name]; + } + } + }); + + return; +} + +/** + * Step 3: define switch ports + * + * @param + * + * @return + */ +function initSwitch(){ + $('#discoverContentDiv').empty(); + var showString = '

' + steps[currentStep] + '

'; + showString += ''; + //Discovery Information title + showString += ''; + //Dynamic IP Range for DHCP + showString += ''; + showString += ''; + //IP Address to Broadcast + showString += ''; + showString += '
Switch Port Assignments
Dynamic IP Range for DHCP:IP Address to Broadcast From:
'; + $('#discoverContentDiv').append(showString); + createDiscoverButtons(); +} + +function initAdvancedPattern(){ + $('#discoverContentDiv').empty(); + var showString = '

' + steps[currentStep] + '

'; + showString += ''; + showString += ''; + //Starting Subnet IP for Cluster Mgmt LAN: + showString += ''; + showString += ''; + //Compute Node Hostname Range + showString += ''; + showString += '
Building Blocks
Starting Subnet IP for Cluster Mgmt LAN:Compute Node Hostname Range:
'; + $('#discoverContentDiv').append(showString); + createDiscoverButtons(); +} \ No newline at end of file diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index 1b368ea94..a267464c5 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -472,6 +472,10 @@ function initPage() { includeJs("js/monitor/gangliamon.js"); headers.eq(3).css('background-color', '#A9D0F5'); loadMonitorPage(); + } else if (page == 'discover.php'){ + includeJs("js/discover/discover.js"); + headers.eq(4).css('background-color', '#A9D0F5'); + loadDiscoverPage(); } else { headers.eq(0).css('background-color', '#A9D0F5'); loadNodesPage(); diff --git a/xCAT-UI/lib/ui.php b/xCAT-UI/lib/ui.php index c568f5495..fd6f9f21f 100644 --- a/xCAT-UI/lib/ui.php +++ b/xCAT-UI/lib/ui.php @@ -33,6 +33,7 @@ function loadPage(){
  • Configure
  • Provision
  • Monitor
  • +
  • Wizard
  • '; // User name and log out section