Cleaned up code

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6775 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2010-07-15 23:22:13 +00:00
parent 84a98b3e5c
commit 6699e33fc0
3 changed files with 89 additions and 84 deletions

View File

@ -1361,4 +1361,28 @@ function loadProvisionPage(tabId) {
}
});
provForm.append(provisionBtn);
}
/**
* Load the resources
*
* @return Nothing
*/
function loadResources() {
// Reset resource table
setDiskDataTable('');
setNetworkDataTable('');
// Get hardware control points
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodels',
tgt : 'mgt==zvm',
args : 'zvm.hcp',
msg : ''
},
success : getZResources
});
}

View File

@ -923,6 +923,66 @@ function updateCloneStatus(data) {
}
}
/**
* Get the resources
*
* @param data
* Data from HTTP request
* @return Nothing
*/
function getZResources(data) {
// Do not set cookie 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
*
@ -1287,66 +1347,6 @@ function setNetworkCookies(data) {
}
}
/**
* Get the resources for ZVM
*
* @param data
* Data from HTTP request
* @return Nothing
*/
function getZResources(data) {
// Do not set cookie 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 the contents of each disk pool
*

View File

@ -71,7 +71,7 @@ function loadMonitorPage() {
// Create info bar
var resrcInfoBar = createInfoBar('Select a hardware to view its resources');
resrcForm.append(resrcInfoBar);
// Create drop-down menu
// Hardware available to provision - ipmi, blade, hmc, ivm, fsp, and zvm
var div = $('<div></div>');
@ -104,32 +104,13 @@ function loadMonitorPage() {
// Generate new tab ID
var newTabId = hw + 'ResourceTab';
if (!$('#' + newTabId).length) {
var loader = createLoader('zvmResourceLoader');
var loader = createLoader(hw + 'ResourceLoader');
loader = $('<center></center>').append(loader);
tab.add(newTabId, hw, loader);
if (hw == 'zvm') {
// Reset resource table
setDiskDataTable('');
setNetworkDataTable('');
// Get hardware control points
$.ajax( {
url : 'lib/cmd.php',
dataType : 'json',
data : {
cmd : 'nodels',
tgt : 'mgt==zvm',
args : 'zvm.hcp',
msg : ''
},
success : getZResources
});
}
// TODO: Add other platforms to this section
else {
$('#' + newTabId).append();
}
// Load plugin code
includeJs("js/custom/" + hw + ".js");
loadResources();
}
// Select tab