/** * Global variables */ var diskDatatable; // zVM datatable containing disks var networkDatatable; // zVM datatable containing networks /** * Get the disk datatable * * @param Nothing * @return Data table object */ function getDiskDataTable() { return diskDatatable; } /** * Set the disk datatable * * @param table * Data table object * @return Nothing */ function setDiskDataTable(table) { diskDatatable = table; } /** * Get the network datatable * * @param Nothing * @return Data table object */ function getNetworkDataTable() { return networkDatatable; } /** * Set the network datatable * * @param table * Data table object * @return Nothing */ function setNetworkDataTable(table) { networkDatatable = table; } /** * Load HCP specific info * * @param data * Data from HTTP request * @return Nothing */ function loadHcpInfo(data) { var args = data.msg.split(';'); // Get group var group = args[0].replace('group=', ''); // Get hardware control point var hcp = args[1].replace('hcp=', ''); // Get user directory entry var userEntry = data.rsp; if (userEntry) { // Get disk pools $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'lsvm', tgt : hcp, args : '--diskpoolnames', msg : hcp }, success : setDiskPoolCookies }); // Get network names $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'lsvm', tgt : hcp, args : '--getnetworknames', msg : hcp }, success : setNetworkCookies }); } else { // Create warning dialog var warnDialog = $('
' + 'z/VM SMAPI is not responding to ' + hcp + '. It needs to be reset.
' + '(Error) Failed to create node definition
'); } else { $('#' + statBarId).append('Node definition created for ' + node + '
'); $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'makehosts', tgt : '', args : '', msg : 'cmd=makehosts;out=' + out2Id }, success : updateZProvisionNewStatus }); } } /** * (3) Update DNS */ else if (cmd == 'makehosts') { // If there was an error, do not continue if (rsp.length) { $('#' + loaderId).hide(); $('#' + statBarId).append('(Error) Failed to update /etc/hosts
'); } else { $('#' + statBarId).append('/etc/hosts updated
'); $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'makedns', tgt : '', args : '', msg : 'cmd=makedns;out=' + out2Id }, success : updateZProvisionNewStatus }); } } /** * (4) Create user entry */ else if (cmd == 'makedns') { // Reset number of tries $.cookie('tries4' + tabId, 0); // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); // Get user entry var userEntry = $('#' + tabId + ' textarea').val(); // Create user entry $.ajax( { url : 'lib/zCmd.php', dataType : 'json', data : { cmd : 'mkvm', tgt : node, args : '', att : userEntry, msg : 'cmd=mkvm;out=' + out2Id }, success : updateZProvisionNewStatus }); } /** * (5) Add disk */ else if (cmd == 'mkvm') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); // If there was an error, do not continue if (prg.html().indexOf('Error') > -1) { // Try again var tries = parseInt($.cookie('tries4' + tabId)); if (tries < 2) { $('#' + statBarId).append('Trying again...
'); tries = tries + 1; // One more try $.cookie('tries4' + tabId, tries); // Get user entry var userEntry = $('#' + tabId + ' textarea').val(); // Create user entry $.ajax( { url : 'lib/zCmd.php', dataType : 'json', data : { cmd : 'mkvm', tgt : node, args : '', att : userEntry, msg : 'cmd=mkvm;out=' + out2Id }, success : updateZProvisionNewStatus }); } else { $('#' + loaderId).hide(); } } else { // Reset number of tries $.cookie('tries4' + tabId, 0); // Set cookie for number of disks var diskRows = $('#' + tabId + ' table:visible tr'); $.cookie('zProvisionDisks2Add' + out2Id, diskRows.length); if (diskRows.length > 0) { for ( var i = 0; i < diskRows.length; i++) { // Get disk type, address, size, mode, pool, and password var diskArgs = diskRows.eq(i).find('td'); var type = diskArgs.eq(1).find('select').val(); var address = diskArgs.eq(2).find('input').val(); var size = diskArgs.eq(3).find('input').val(); var mode = diskArgs.eq(4).find('select').val(); var pool = diskArgs.eq(5).find('input').val(); var password = diskArgs.eq(6).find('input').val(); // Create ajax arguments var args = ''; if (type == '3390') { args = '--add' + type + ';' + pool + ';' + address + ';' + size + ';' + mode + ';' + password + ';' + password + ';' + password; } else if (type == '9336') { var blkSize = '512'; args = '--add' + type + ';' + pool + ';' + address + ';' + blkSize + ';' + size + ';' + mode + ';' + password + ';' + password + ';' + password; } // Add disk $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'chvm', tgt : node, args : args, msg : 'cmd=chvm;out=' + out2Id }, success : updateZProvisionNewStatus }); } } else { $('#' + loaderId).hide(); } } } /** * (6) Set operating system for given node */ else if (cmd == 'chvm') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); // If there was an error, do not continue if (prg.html().indexOf('Error') > -1) { $('#' + loaderId).hide(); // Try again var tries = parseInt($.cookie('tries4' + tabId)); if (tries < 2) { $('#' + statBarId).append('Trying again...
'); tries = tries + 1; // One more try $.cookie('tries4' + tabId, tries); // Set cookie for number of disks var diskRows = $('#' + tabId + ' table:visible tr'); $.cookie('zProvisionDisks2Add' + out2Id, diskRows.length); if (diskRows.length > 0) { for ( var i = 0; i < diskRows.length; i++) { // Get disk type, address, size, pool, and password var diskArgs = diskRows.eq(i).find('td'); var type = diskArgs.eq(1).find('select').val(); var address = diskArgs.eq(2).find('input').val(); var size = diskArgs.eq(3).find('input').val(); var mode = diskArgs.eq(4).find('select').val(); var pool = diskArgs.eq(5).find('input').val(); var password = diskArgs.eq(6).find('input').val(); // Create ajax arguments var args = ''; if (type == '3390') { args = '--add' + type + ';' + pool + ';' + address + ';' + size + ';' + mode + ';' + password + ';' + password + ';' + password; } else if (type == '9336') { var blkSize = '512'; args = '--add' + type + ';' + pool + ';' + address + ';' + blkSize + ';' + size + ';' + mode + ';' + password + ';' + password + ';' + password; } // Add disk $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'chvm', tgt : node, args : args, msg : 'cmd=chvm;out=' + out2Id }, success : updateZProvisionNewStatus }); } } else { $('#' + loaderId).hide(); } } else { $('#' + loaderId).hide(); } } else { // Reset number of tries $.cookie('tries4' + tabId, 0); // Get operating system image var osImage = $('#' + tabId + ' input[name=os]:visible').val(); // Get cookie for number of disks var disks2add = $.cookie('zProvisionDisks2Add' + out2Id); // One less disk to add disks2add = disks2add - 1; // Set cookie for number of disks $.cookie('zProvisionDisks2Add' + out2Id, disks2add); // If an operating system image is given if (osImage) { var tmp = osImage.split('-'); // Get operating system, architecture, provision method, and profile var os = tmp[0]; var arch = tmp[1]; var profile = tmp[3]; // If the last disk is added if (disks2add < 1) { $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'nodeadd', tgt : '', args : node + ';noderes.netboot=zvm;nodetype.os=' + os + ';nodetype.arch=' + arch + ';nodetype.profile=' + profile, msg : 'cmd=noderes;out=' + out2Id }, success : updateZProvisionNewStatus }); } } else { $('#' + loaderId).hide(); } } } /** * (7) Update DHCP */ else if (cmd == 'noderes') { // If there was an error, do not continue if (rsp.length) { $('#' + loaderId).hide(); $('#' + statBarId).append('(Error) Failed to set operating system
'); } else { $('#' + statBarId).append('Operating system for ' + node + ' set
'); $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'makedhcp', tgt : '', args : '-a', msg : 'cmd=makedhcp;out=' + out2Id }, success : updateZProvisionNewStatus }); } } /** * (8) Prepare node for boot */ else if (cmd == 'makedhcp') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); // Prepare node for boot $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'nodeset', tgt : node, args : 'install', msg : 'cmd=nodeset;out=' + out2Id }, success : updateZProvisionNewStatus }); } /** * (9) Boot node to network */ else if (cmd == 'nodeset') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); // If there was an error // Do not continue if (prg.html().indexOf('Error') > -1) { $('#' + loaderId).hide(); } else { $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'rnetboot', tgt : node, args : 'ipl=000C', msg : 'cmd=rnetboot;out=' + out2Id }, success : updateZProvisionNewStatus }); } } /** * (10) Done */ else if (cmd == 'rnetboot') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); if (prg.html().indexOf('Error') < 0) { $('#' + statBarId).append('Open a VNC viewer to see the installation progress. It might take a couple of minutes before you can connect.
'); } // Hide loader $('#' + loaderId).hide(); } } /** * Update the provision existing node status * * @param data * Data returned from HTTP request * @return Nothing */ function updateZProvisionExistingStatus(data) { // Get ajax response var rsp = data.rsp; var args = data.msg.split(';'); // Get command invoked var cmd = args[0].replace('cmd=', ''); // Get provision tab instance var inst = args[1].replace('out=', ''); // Get provision tab and status bar ID var statBarId = 'zProvisionStatBar' + inst; var tabId = 'zvmProvisionTab' + inst; /** * (2) Prepare node for boot */ if (cmd == 'nodeadd') { // Get operating system var bootMethod = $('#' + tabId + ' select[name=bootMethod]').val(); // Get nodes that were checked var dTableId = 'zNodesDatatable' + inst; var tgts = getNodesChecked(dTableId); // Prepare node for boot $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'nodeset', tgt : tgts, args : bootMethod, msg : 'cmd=nodeset;out=' + inst }, success : updateZProvisionExistingStatus }); } /** * (3) Boot node from network */ else if (cmd == 'nodeset') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); // If there was an error, do not continue if (prg.html().indexOf('Error') > -1) { var loaderId = 'zProvisionLoader' + inst; $('#' + loaderId).remove(); return; } // Get nodes that were checked var dTableId = 'zNodesDatatable' + inst; var tgts = getNodesChecked(dTableId); // Boot node from network $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'rnetboot', tgt : tgts, args : 'ipl=000C', msg : 'cmd=rnetboot;out=' + inst }, success : updateZProvisionExistingStatus }); } /** * (4) Done */ else if (cmd == 'rnetboot') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + statBarId).append(prg); var loaderId = 'zProvisionLoader' + inst; $('#' + loaderId).remove(); } } /** * Update zVM node status * * @param data * Data returned from HTTP request * @return Nothing */ function updateZNodeStatus(data) { var node = data.msg; var rsp = data.rsp; // Get cookie for number processes performed against this node var actions = $.cookie(node + 'Processes'); // One less process actions = actions - 1; $.cookie(node + 'Processes', actions); if (actions < 1) { // Hide loader when there are no more processes var statusBarLoaderId = node + 'StatusBarLoader'; $('#' + statusBarLoaderId).hide(); } var statBarId = node + 'StatusBar'; // Write ajax response to status bar var prg = writeRsp(rsp, '[A-Za-z0-9._-]+:'); $('#' + statBarId).append(prg); } /** * Update clone status * * @param data * Data returned from HTTP request * @return Nothing */ function updateZCloneStatus(data) { // Get ajax response var rsp = data.rsp; var args = data.msg.split(';'); var cmd = args[0].replace('cmd=', ''); // Get provision instance var inst = args[1].replace('inst=', ''); // Get output division ID var out2Id = args[2].replace('out=', ''); /** * (2) Update /etc/hosts */ if (cmd == 'nodeadd') { var node = args[3].replace('node=', ''); // If there was an error, do not continue if (rsp.length) { $('#' + out2Id).find('img').hide(); $('#' + out2Id).append('(Error) Failed to create node definition
'); } else { $('#' + out2Id).append('Node definition created for ' + node + '
'); // If last node definition was created var tmp = inst.split('/'); if (tmp[0] == tmp[1]) { $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'makehosts', tgt : '', args : '', msg : 'cmd=makehosts;inst=' + inst + ';out=' + out2Id }, success : updateZCloneStatus }); } } } /** * (3) Update DNS */ else if (cmd == 'makehosts') { // If there was an error, do not continue if (rsp.length) { $('#' + out2Id).find('img').hide(); $('#' + out2Id).append('(Error) Failed to update /etc/hosts
'); } else { $('#' + out2Id).append('/etc/hosts updated
'); $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'makedns', tgt : '', args : '', msg : 'cmd=makedns;inst=' + inst + ';out=' + out2Id }, success : updateZCloneStatus }); } } /** * (4) Clone */ else if (cmd == 'makedns') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + out2Id).append(prg); // Get clone tab var tabId = out2Id.replace('CloneStatusBar', 'CloneTab'); // If a node range is given var tgtNodeRange = $('#' + tabId + ' input[name=tgtNode]').val(); var tgtNodes = ''; if (tgtNodeRange.indexOf('-') > -1) { var tmp = tgtNodeRange.split('-'); // Get node base name var nodeBase = tmp[0].match(/[a-zA-Z]+/); // Get the starting index var nodeStart = parseInt(tmp[0].match(/\d+/)); // Get the ending index var nodeEnd = parseInt(tmp[1].match(/\d+/)); for ( var i = nodeStart; i <= nodeEnd; i++) { // Do not append comma for last node if (i == nodeEnd) { tgtNodes += nodeBase + i.toString(); } else { tgtNodes += nodeBase + i.toString() + ','; } } } else { tgtNodes = tgtNodeRange; } // Get other inputs var srcNode = $('#' + tabId + ' input[name=srcNode]').val(); hcp = $('#' + tabId + ' input[name=newHcp]').val(); var group = $('#' + tabId + ' input[name=newGroup]').val(); var diskPool = $('#' + tabId + ' input[name=diskPool]').val(); var diskPw = $('#' + tabId + ' input[name=diskPw]').val(); if (!diskPw) { diskPw = ''; } // Clone $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'mkvm', tgt : tgtNodes, args : srcNode + ';pool=' + diskPool + ';pw=' + diskPw, msg : 'cmd=mkvm;inst=' + inst + ';out=' + out2Id }, success : updateZCloneStatus }); } /** * (5) Done */ else if (cmd == 'mkvm') { // Write ajax response to status bar var prg = writeRsp(rsp, ''); $('#' + out2Id).append(prg); // Hide loader $('#' + out2Id).find('img').hide(); } } /** * Get zVM resources * * @param data * Data from HTTP request * @return Nothing */ function getZResources(data) { // Do not continue if there is no output if (data.rsp) { // Loop through each line var node, hcp; var hcpHash = new Object(); for ( var i in data.rsp) { node = data.rsp[i][0]; hcp = data.rsp[i][1]; hcpHash[hcp] = 1; } // Create an array for hardware control points var hcps = new Array(); for ( var key in hcpHash) { hcps.push(key); // Get the short host name hcp = key.split('.')[0]; // Get disk pools $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'lsvm', tgt : hcp, args : '--diskpoolnames', msg : hcp }, success : getDiskPool }); // Get network names $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'lsvm', tgt : hcp, args : '--getnetworknames', msg : hcp }, success : getNetwork }); } // Set cookie $.cookie('HCP', hcps); } } /** * Get node attributes from HTTP request data * * @param propNames * Hash table of property names * @param keys * Property keys * @param data * Data from HTTP request * @return Hash table of property values */ function getAttrs(keys, propNames, data) { // Create hash table for property values var attrs = new Object(); // Go through inventory and separate each property out var curKey; // Current property key var addLine; // Add a line to the current property? for ( var i = 1; i < data.length; i++) { addLine = true; // Loop through property keys // Does this line contains one of the properties? for ( var j = 0; j < keys.length; j++) { // Find property name if (data[i].indexOf(propNames[keys[j]]) > -1) { attrs[keys[j]] = new Array(); // Get rid of property name in the line data[i] = data[i].replace(propNames[keys[j]], ''); // Trim the line data[i] = jQuery.trim(data[i]); // Do not insert empty line if (data[i].length > 0) { attrs[keys[j]].push(data[i]); } curKey = keys[j]; addLine = false; // This line belongs to a property } } // Line does not contain a property // Must belong to previous property if (addLine && data[i].length > 1) { data[i] = jQuery.trim(data[i]); attrs[curKey].push(data[i]); } } return attrs; } /** * Create add processor dialog * * @param node * Node to add processor to * @return Nothing */ function openAddProcDialog(node) { // Create form to add processor var addProcForm = $(''); // Create info bar var info = createInfoBar('Add a temporary processor'); addProcForm.append(info); addProcForm.append(''); addProcForm.append(''); // Create drop down for processor type var procType = $(''); procType.append(''); var typeSelect = $(''); typeSelect.append('' + '' + '' + '' ); procType.append(typeSelect); addProcForm.append(procType); // Open dialog to add processor addProcForm.dialog({ modal: true, width: 400, buttons: { "Ok": function(){ // Remove any warning messages $(this).find('.ui-state-error').remove(); // Get inputs var node = $(this).find('input[name=procNode]').val(); var address = $(this).find('input[name=procAddress]').val(); var type = $(this).find('select[name=procType]').val(); // If inputs are not complete, show warning message if (!node || !address || !type) { var warn = createWarnBar('You are missing inputs.'); warn.prependTo($(this)); } else { // Add processor $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'chvm', tgt : node, args : '--addprocessoractive;' + address + ';' + type, msg : node }, success : updateZNodeStatus }); // Increment node process incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; var statusBarLoaderId = node + 'StatusBarLoader'; $('#' + statusBarLoaderId).show(); $('#' + statusId).show(); // Close dialog $(this).dialog( "close" ); } }, "Cancel": function() { $(this).dialog( "close" ); } } }); } /** * Create add disk dialog * * @param node * Node to add disk to * @param hcp * Hardware control point of node * @return Nothing */ function openAddDiskDialog(node, hcp) { // Get list of disk pools var cookie = $.cookie(hcp + 'DiskPools'); var pools = cookie.split(','); // Create form to add disk var addDiskForm = $(''); // Create info bar var info = createInfoBar('Add a disk'); addDiskForm.append(info); addDiskForm.append(''); addDiskForm.append(''); addDiskForm.append(''); addDiskForm.append(''); // Create drop down for disk pool var diskPool = $(''); diskPool.append(''); var poolSelect = $(''); for ( var i = 0; i < pools.length; i++) { poolSelect.append(''); } diskPool.append(poolSelect); addDiskForm.append(diskPool); // Create drop down for disk mode var diskMode = $(''); diskMode.append(''); var modeSelect = $(''); modeSelect.append('' + '' + '' + '' + '' + '' + '' ); diskMode.append(modeSelect); addDiskForm.append(diskMode); addDiskForm.append(''); // Open dialog to add disk addDiskForm.dialog({ modal: true, width: 400, buttons: { "Ok": function(){ // Remove any warning messages $(this).find('.ui-state-error').remove(); // Get inputs var node = $(this).find('input[name=diskNode]').val(); var type = $(this).find('select[name=diskType]').val(); var address = $(this).find('input[name=diskAddress]').val(); var size = $(this).find('input[name=diskSize]').val(); var pool = $(this).find('select[name=diskPool]').val(); var mode = $(this).find('select[name=diskMode]').val(); var password = $(this).find('input[name=diskPassword]').val(); // If inputs are not complete, show warning message if (!node || !type || !address || !size || !pool || !mode) { var warn = createWarnBar('You are missing inputs.'); warn.prependTo($(this)); } else { // Add disk if (type == '3390') { $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'chvm', tgt : node, args : '--add3390;' + pool + ';' + address + ';' + size + ';' + mode + ';' + password + ';' + password + ';' + password, msg : node }, success : updateZNodeStatus }); // Increment node process incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; var statusBarLoaderId = node + 'StatusBarLoader'; $('#' + statusBarLoaderId).show(); $('#' + statusId).show(); } else if (type == '9336') { // Default block size for FBA volumes = 512 var blkSize = '512'; $.ajax( { url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'chvm', tgt : node, args : '--add9336;' + pool + ';' + address + ';' + blkSize + ';' + size + ';' + mode + ';' + password + ';' + password + ';' + password, msg : node }, success : updateZNodeStatus }); // Increment node process incrementNodeProcess(node); // Show loader var statusId = node + 'StatusBar'; var statusBarLoaderId = node + 'StatusBarLoader'; $('#' + statusBarLoaderId).show(); $('#' + statusId).show(); } // Close dialog $(this).dialog( "close" ); } // End of else }, "Cancel": function() { $(this).dialog( "close" ); } } }); } /** * Create add NIC dialog * * @param node * Node to add NIC to * @param hcp * Hardware control point of node * @return Nothing */ function openAddNicDialog(node, hcp) { // Get network names var networks = $.cookie(hcp + 'Networks').split(','); // Create form to add NIC var addNicForm = $(''); // Create info bar var info = createInfoBar('Add a NIC'); addNicForm.append(info); addNicForm.append(''); addNicForm.append(''); // Create drop down for NIC types var nicType = $(''); nicType.append(''); var nicTypeSelect = $(''); nicTypeSelect.append('' + '' + '' ); nicType.append(nicTypeSelect); addNicForm.append(nicType); // Create drop down for network types var networkType = $(''); networkType.append(''); var networkTypeSelect = $(''); networkTypeSelect.append('' + '' + '' ); networkType.append(networkTypeSelect); addNicForm.append(networkType); // Create drop down for network names var gLansQdioSelect = $(''); var gLansHipersSelect = $(''); var vswitchSelect = $(''); for ( var i = 0; i < networks.length; i++) { var network = networks[i].split(' '); var networkOption = $(''); if (network[0] == 'VSWITCH') { vswitchSelect.append(networkOption); } else if (network[0] == 'LAN:QDIO') { gLansQdioSelect.append(networkOption); } else if (network[0] == 'LAN:HIPERS') { gLansHipersSelect.append(networkOption); } } // Hide network name drop downs until the NIC type and network type is selected // QDIO Guest LAN drop down var guestLanQdio = $('').hide(); guestLanQdio.append(''); guestLanQdio.append(gLansQdioSelect); addNicForm.append(guestLanQdio); // HIPERS Guest LAN drop down var guestLanHipers = $('').hide(); guestLanHipers.append(''); guestLanHipers.append(gLansHipersSelect); addNicForm.append(guestLanHipers); // VSWITCH drop down var vswitch = $('').hide(); vswitch.append(''); vswitch.append(vswitchSelect); addNicForm.append(vswitch); // Show network names on change networkTypeSelect.change(function(){ // Remove any warning messages $(this).parent().parent().find('.ui-state-error').remove(); // Get NIC type and network type var nicType = $(this).parent().parent().find('select[name=nicType]').val(); var networkType = $(this).val(); // Hide network name drop downs var guestLanQdio = $(this).parent().parent().find('select[name=nicLanQdioName]').parent(); var guestLanHipers = $(this).parent().parent().find('select[name=nicLanHipersName]').parent(); var vswitch = $(this).parent().parent().find('select[name=nicVSwitchName]').parent(); guestLanQdio.hide(); guestLanHipers.hide(); vswitch.hide(); // Show correct network name if (networkType == 'Guest LAN' && nicType == 'QDIO') { guestLanQdio.show(); } else if (networkType == 'Guest LAN' && nicType == 'HiperSockets') { guestLanHipers.show(); } else if (networkType == 'Virtual Switch') { if (nicType == 'QDIO') { vswitch.show(); } else { // No such thing as HIPERS VSWITCH var warn = createWarnBar('The selected choices are not valid.'); warn.prependTo($(this).parent().parent()); } } }); // Show network names on change nicTypeSelect.change(function(){ // Remove any warning messages $(this).parent().parent().find('.ui-state-error').remove(); // Get NIC type and network type var nicType = $(this).val(); var networkType = $(this).parent().parent().find('select[name=nicNetworkType]').val(); // Hide network name drop downs var guestLanQdio = $(this).parent().parent().find('select[name=nicLanQdioName]').parent(); var guestLanHipers = $(this).parent().parent().find('select[name=nicLanHipersName]').parent(); var vswitch = $(this).parent().parent().find('select[name=nicVSwitchName]').parent(); guestLanQdio.hide(); guestLanHipers.hide(); vswitch.hide(); // Show correct network name if (networkType == 'Guest LAN' && nicType == 'QDIO') { guestLanQdio.show(); } else if (networkType == 'Guest LAN' && nicType == 'HiperSockets') { guestLanHipers.show(); } else if (networkType == 'Virtual Switch') { if (nicType == 'QDIO') { vswitch.show(); } else { // No such thing as HIPERS VSWITCH var warn = createWarnBar('The selected choices are not valid.'); warn.prependTo($(this).parent().parent()); } } }); // Open dialog to add NIC addNicForm.dialog({ modal: true, width: 400, buttons: { "Ok": function(){ // Remove any warning messages $(this).find('.ui-state-error').remove(); var ready = true; var errMsg = ''; // Get inputs var node = $(this).find('input[name=nicNode]').val(); var nicType = $(this).find('select[name=nicType]').val(); var networkType = $(this).find('select[name=nicNetworkType]').val(); var address = $(this).find('input[name=nicAddress]').val(); // If inputs are not complete, show warning message if (!node || !nicType || !networkType || !address) { errMsg = 'You are missing inputs.Select a group to view its nodes
' + msg + '