diff --git a/xCAT-UI/index.php b/xCAT-UI/index.php
index 4f97e3e5a..a7dbfc6d6 100644
--- a/xCAT-UI/index.php
+++ b/xCAT-UI/index.php
@@ -20,15 +20,30 @@ if (!isAuthenticated()) {
* Test lib/cmd.php
*/
function testCmdPhp() {
- $xml = docmd('lsdef', NULL, array('all'));
+ $xml = docmd('rinv', 'ca4dsls08', array('all'));
$rsp = array();
foreach ($xml->children() as $child) {
- foreach ($child->children() as $data) {
- array_push($rsp, "$data");
+ // Get the 1st level child
+ foreach ($child->children() as $level_one) {
+ if ($level_one->children()) {
+ // Get the 2nd level child
+ foreach ($level_one->children() as $level_two) {
+ if ($level_two->children()) {
+ // Get the 3rd level child
+ foreach ($level_two->children() as $level_three) {
+ array_push($rsp, "$level_three");
+ }
+ } else {
+ array_push($rsp, "$level_two");
+ }
+ }
+ } else {
+ array_push($rsp, "$level_one");
+ }
}
}
-
+
$rtn = array("rsp" => $rsp, "msg" => '');
echo json_encode($rtn);
}
diff --git a/xCAT-UI/js/custom/blade.js b/xCAT-UI/js/custom/blade.js
index d3fcec564..88f36ddd6 100644
--- a/xCAT-UI/js/custom/blade.js
+++ b/xCAT-UI/js/custom/blade.js
@@ -2,6 +2,15 @@ $(document).ready(function(){
// Include utility scripts
});
+/**
+ * Constructor
+ *
+ * @return Nothing
+ */
+var blade = function() {
+
+};
+
/**
* Load node inventory
*
@@ -9,9 +18,9 @@ $(document).ready(function(){
* Data from HTTP request
* @return Nothing
*/
-function loadInventory(data) {
+blade.prototype.loadInventory = function(data) {
-}
+};
/**
* Load clone page
@@ -20,9 +29,9 @@ function loadInventory(data) {
* Source node to clone
* @return Nothing
*/
-function loadClonePage(node) {
+blade.prototype.loadClonePage = function(node) {
-}
+};
/**
* Load provision page
@@ -31,7 +40,7 @@ function loadClonePage(node) {
* The provision tab ID
* @return Nothing
*/
-function loadProvisionPage(tabId) {
+blade.prototype.loadProvisionPage = function(tabId) {
var errMsg;
// Get the OS image names
@@ -197,13 +206,13 @@ function loadProvisionPage(tabId) {
// Insert provision code here
});
provForm.append(provisionBtn);
-}
+};
/**
* Load resources
*
* @return Nothing
*/
-function loadResources() {
+blade.prototype.loadResources = function() {
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/fsp.js b/xCAT-UI/js/custom/fsp.js
index a69587737..6877c8f66 100644
--- a/xCAT-UI/js/custom/fsp.js
+++ b/xCAT-UI/js/custom/fsp.js
@@ -2,6 +2,15 @@ $(document).ready(function(){
// Include utility scripts
});
+/**
+ * Constructor
+ *
+ * @return Nothing
+ */
+var fsp = function() {
+
+};
+
/**
* Load node inventory
*
@@ -9,9 +18,9 @@ $(document).ready(function(){
* Data from HTTP request
* @return Nothing
*/
-function loadInventory(data) {
+fsp.prototype.loadInventory = function(data) {
-}
+};
/**
* Load clone page
@@ -20,9 +29,9 @@ function loadInventory(data) {
* Source node to clone
* @return Nothing
*/
-function loadClonePage(node) {
+fsp.prototype.loadClonePage = function(node) {
-}
+};
/**
* Load provision page
@@ -31,7 +40,7 @@ function loadClonePage(node) {
* The provision tab ID
* @return Nothing
*/
-function loadProvisionPage(tabId) {
+fsp.prototype.loadProvisionPage = function(tabId) {
var errMsg;
// Get the OS image names
@@ -197,13 +206,13 @@ function loadProvisionPage(tabId) {
// Insert provision code here
});
provForm.append(provisionBtn);
-}
+};
/**
* Load resources
*
* @return Nothing
*/
-function loadResources() {
+fsp.prototype.loadResources = function() {
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js
index 367a69f30..ddf57860b 100644
--- a/xCAT-UI/js/custom/hmc.js
+++ b/xCAT-UI/js/custom/hmc.js
@@ -2,6 +2,15 @@ $(document).ready(function(){
// Include utility scripts
});
+/**
+ * Constructor
+ *
+ * @return Nothing
+ */
+var hmc = function() {
+
+};
+
/**
* Load node inventory
*
@@ -9,9 +18,45 @@ $(document).ready(function(){
* Data from HTTP request
* @return Nothing
*/
-function loadInventory(data) {
+hmc.prototype.loadInventory = function(data) {
+ var args = data.msg.split(',');
+
+ // Get tab ID
+ var tabId = args[0].replace('out=', '');
+ // Get node
+ var node = args[1].replace('node=', '');
+ // Get node inventory
+ var inv = data.rsp;
-}
+ // Remove loader
+ var loaderId = node + 'TabLoader';
+ $('#' + loaderId).remove();
+
+ // Create division to hold inventory
+ var invDivId = node + 'Inventory';
+ var invDiv = $('
');
+
+ var fieldSet = $('');
+ var legend = $('');
+ fieldSet.append(legend);
+ var oList = $('
');
+ var item, label, input, args;
+
+ // Loop through each property
+ for ( var k = 0; k < inv.length; k++) {
+ if (inv[k] != '0' && inv[k].indexOf(node) < 0) {
+ // Create a list item for each property
+ item = $('');
+ item.append(inv[k]);
+ oList.append(item);
+ }
+ }
+
+ // Append to inventory form
+ fieldSet.append(oList);
+ invDiv.append(fieldSet);
+ $('#' + tabId).append(invDiv);
+};
/**
* Load clone page
@@ -20,9 +65,9 @@ function loadInventory(data) {
* Source node to clone
* @return Nothing
*/
-function loadClonePage(node) {
+hmc.prototype.loadClonePage = function(node) {
-}
+};
/**
* Load provision page
@@ -31,7 +76,7 @@ function loadClonePage(node) {
* The provision tab ID
* @return Nothing
*/
-function loadProvisionPage(tabId) {
+hmc.prototype.loadProvisionPage = function(tabId) {
var errMsg;
// Get the OS image names
@@ -197,13 +242,13 @@ function loadProvisionPage(tabId) {
// Insert provision code here
});
provForm.append(provisionBtn);
-}
+};
/**
* Load resources
*
* @return Nothing
*/
-function loadResources() {
+hmc.prototype.loadResources = function() {
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/ipmi.js b/xCAT-UI/js/custom/ipmi.js
index c5432e7a1..e51d95160 100644
--- a/xCAT-UI/js/custom/ipmi.js
+++ b/xCAT-UI/js/custom/ipmi.js
@@ -2,6 +2,15 @@ $(document).ready(function(){
// Include utility scripts
});
+/**
+ * Constructor
+ *
+ * @return Nothing
+ */
+var ipmi = function() {
+
+};
+
/**
* Load node inventory
*
@@ -9,9 +18,9 @@ $(document).ready(function(){
* Data from HTTP request
* @return Nothing
*/
-function loadInventory(data) {
+ipmi.prototype.loadInventory = function(data) {
-}
+};
/**
* Load clone page
@@ -20,9 +29,9 @@ function loadInventory(data) {
* Source node to clone
* @return Nothing
*/
-function loadClonePage(node) {
+ipmi.prototype.loadClonePage = function(node) {
-}
+};
/**
* Load provision page
@@ -31,7 +40,7 @@ function loadClonePage(node) {
* The provision tab ID
* @return Nothing
*/
-function loadProvisionPage(tabId) {
+ipmi.prototype.loadProvisionPage = function(tabId) {
var errMsg;
// Get the OS image names
@@ -197,13 +206,13 @@ function loadProvisionPage(tabId) {
// Insert provision code here
});
provForm.append(provisionBtn);
-}
+};
/**
* Load resources
*
* @return Nothing
*/
-function loadResources() {
+ipmi.prototype.loadResources = function() {
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/ivm.js b/xCAT-UI/js/custom/ivm.js
index c43dddc77..4f0073a8e 100644
--- a/xCAT-UI/js/custom/ivm.js
+++ b/xCAT-UI/js/custom/ivm.js
@@ -2,6 +2,15 @@ $(document).ready(function(){
// Include utility scripts
});
+/**
+ * Constructor
+ *
+ * @return Nothing
+ */
+var ivm = function() {
+
+};
+
/**
* Load node inventory
*
@@ -9,9 +18,9 @@ $(document).ready(function(){
* Data from HTTP request
* @return Nothing
*/
-function loadInventory(data) {
+ivm.prototype.loadInventory = function(data) {
-}
+};
/**
* Load clone page
@@ -20,9 +29,9 @@ function loadInventory(data) {
* Source node to clone
* @return Nothing
*/
-function loadClonePage(node) {
+ivm.prototype.loadClonePage = function(node) {
-}
+};
/**
* Load provision page
@@ -31,7 +40,7 @@ function loadClonePage(node) {
* The provision tab ID
* @return Nothing
*/
-function loadProvisionPage(tabId) {
+ivm.prototype.loadProvisionPage = function(tabId) {
var errMsg;
// Get the OS image names
@@ -197,13 +206,13 @@ function loadProvisionPage(tabId) {
// Insert provision code here
});
provForm.append(provisionBtn);
-}
+};
/**
* Load resources
*
* @return Nothing
*/
-function loadResources() {
+ivm.prototype.loadResources = function() {
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js
index 1457349ca..4f7ccef36 100644
--- a/xCAT-UI/js/custom/zvm.js
+++ b/xCAT-UI/js/custom/zvm.js
@@ -3,6 +3,15 @@ $(document).ready(function() {
includeJs("js/custom/zvmUtils.js");
});
+/**
+ * Constructor
+ *
+ * @return Nothing
+ */
+var zvm = function() {
+
+};
+
/**
* Load clone page
*
@@ -10,7 +19,7 @@ $(document).ready(function() {
* Source node to clone
* @return Nothing
*/
-function loadClonePage(node) {
+zvm.prototype.loadClonePage = function(node) {
// Get nodes tab
var tab = getNodesTab();
var newTabId = node + 'CloneTab';
@@ -261,7 +270,7 @@ function loadClonePage(node) {
}
tab.select(newTabId);
-}
+};
/**
* Load node inventory
@@ -270,7 +279,7 @@ function loadClonePage(node) {
* Data from HTTP request
* @return Nothing
*/
-function loadInventory(data) {
+zvm.prototype.loadInventory = function(data) {
var args = data.msg.split(',');
// Get tab ID
@@ -889,7 +898,7 @@ function loadInventory(data) {
$('#' + tabId).append(toggleLnkDiv);
$('#' + tabId).append(ueDiv);
$('#' + tabId).append(invDiv);
-}
+};
/**
* Load provision page
@@ -898,7 +907,7 @@ function loadInventory(data) {
* The provision tab ID
* @return Nothing
*/
-function loadProvisionPage(tabId) {
+zvm.prototype.loadProvisionPage = function(tabId) {
var errMsg;
// Get the OS image names
@@ -1343,14 +1352,14 @@ function loadProvisionPage(tabId) {
}
});
provForm.append(provisionBtn);
-}
+};
/**
* Load the resources
*
* @return Nothing
*/
-function loadResources() {
+zvm.prototype.loadResources = function() {
// Reset resource table
setDiskDataTable('');
setNetworkDataTable('');
@@ -1367,4 +1376,4 @@ function loadResources() {
},
success : getZResources
});
-}
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/xCAT-UI/js/monitor/monitor.js b/xCAT-UI/js/monitor/monitor.js
index 94c6fb277..4bae01fbe 100644
--- a/xCAT-UI/js/monitor/monitor.js
+++ b/xCAT-UI/js/monitor/monitor.js
@@ -108,9 +108,30 @@ function loadMonitorPage() {
loader = $('').append(loader);
tab.add(newTabId, hw, loader);
- // Load plugin code
- includeJs("js/custom/" + hw + ".js");
- loadResources();
+ // Create an instance of the plugin
+ var plugin;
+ switch(hw) {
+ case "blade":
+ plugin = new blade();
+ break;
+ case "fsp":
+ plugin = new fsp();
+ break;
+ case "hmc":
+ plugin = new hmc();
+ break;
+ case "ipmi":
+ plugin = new ipmi();
+ break;
+ case "ivm":
+ plugin = new ivm();
+ break;
+ case "zvm":
+ plugin = new zvm();
+ break;
+ }
+
+ plugin.loadResources();
}
// Select tab
diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js
index a2feb0302..77f190342 100644
--- a/xCAT-UI/js/nodes/nodes.js
+++ b/xCAT-UI/js/nodes/nodes.js
@@ -169,8 +169,6 @@ function loadNodes(data) {
var attrs = new Object();
// Node attributes
var headers = new Object();
- // Plugins hash
- var plugins = new Object();
var node;
var args;
@@ -194,19 +192,6 @@ function loadNodes(data) {
// Create a hash table
attrs[node][key] = val;
headers[key] = 1;
-
- // Create a plugins hash
- if (key == 'mgt') {
- plugins[val] = 1;
- }
- }
-
- // Load the plugin code
- // Plugin code should be located under js/custom/
- // Plugin names should be valid values of nodehm.mgt
- for ( var p in plugins) {
- resetJs();
- includeJs("js/custom/" + p + ".js");
}
// Sort headers
@@ -296,7 +281,32 @@ function loadNodes(data) {
cloneLnk.bind('click', function(event) {
var tgtNodes = getNodesChecked().split(',');
for ( var i = 0; i < tgtNodes.length; i++) {
- loadClonePage(tgtNodes[i]);
+ var mgt = getNodeMgt(tgtNodes[i]);
+
+ // Create an instance of the plugin
+ var plugin;
+ switch(mgt) {
+ case "blade":
+ plugin = new blade();
+ break;
+ case "fsp":
+ plugin = new fsp();
+ break;
+ case "hmc":
+ plugin = new hmc();
+ break;
+ case "ipmi":
+ plugin = new ipmi();
+ break;
+ case "ivm":
+ plugin = new ivm();
+ break;
+ case "zvm":
+ plugin = new zvm();
+ break;
+ }
+
+ plugin.loadClonePage(tgtNodes[i]);
}
});
@@ -598,6 +608,29 @@ function loadNode(e) {
// Get node that was clicked
var node = (e.target) ? e.target.id : e.srcElement.id;
var mgt = getNodeMgt(node);
+
+ // Create an instance of the plugin
+ var plugin;
+ switch(mgt) {
+ case "blade":
+ plugin = new blade();
+ break;
+ case "fsp":
+ plugin = new fsp();
+ break;
+ case "hmc":
+ plugin = new hmc();
+ break;
+ case "ipmi":
+ plugin = new ipmi();
+ break;
+ case "ivm":
+ plugin = new ivm();
+ break;
+ case "zvm":
+ plugin = new zvm();
+ break;
+ }
// Get tab area where a new tab will be inserted
var myTab = getNodesTab();
@@ -623,7 +656,7 @@ function loadNode(e) {
msg : msg
},
- success : loadInventory
+ success : plugin.loadInventory
});
// Select new tab
diff --git a/xCAT-UI/js/provision/provision.js b/xCAT-UI/js/provision/provision.js
index 515d7d125..36909f04e 100644
--- a/xCAT-UI/js/provision/provision.js
+++ b/xCAT-UI/js/provision/provision.js
@@ -98,13 +98,32 @@ function loadProvisionPage() {
tab.add(newTabId, hw, '');
- // Load plugin code
- resetJs();
- includeJs("js/custom/" + hw + ".js");
+ // Create an instance of the plugin
+ var plugin;
+ switch(hw) {
+ case "blade":
+ plugin = new blade();
+ break;
+ case "fsp":
+ plugin = new fsp();
+ break;
+ case "hmc":
+ plugin = new hmc();
+ break;
+ case "ipmi":
+ plugin = new ipmi();
+ break;
+ case "ivm":
+ plugin = new ivm();
+ break;
+ case "zvm":
+ plugin = new zvm();
+ break;
+ }
// Select tab
tab.select(newTabId);
- loadProvisionPage(newTabId);
+ plugin.loadProvisionPage(newTabId);
});
provForm.append(okBtn);
diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js
index 9e09bb345..d3c3622dd 100644
--- a/xCAT-UI/js/ui.js
+++ b/xCAT-UI/js/ui.js
@@ -404,6 +404,14 @@ function initPage() {
includeJs("js/monitor/monitor.js");
includeJs("js/nodes/nodes.js");
includeJs("js/provision/provision.js");
+
+ // Custom plugins
+ includeJs("js/custom/blade.js");
+ includeJs("js/custom/fsp.js");
+ includeJs("js/custom/hmc.js");
+ includeJs("js/custom/ipmi.js");
+ includeJs("js/custom/ivm.js");
+ includeJs("js/custom/zvm.js");
// Get the page being loaded
var url = window.location.pathname;
@@ -425,9 +433,6 @@ function initPage() {
} else if (page == 'monitor.php') {
headers.eq(3).css('background-color', '#A9D0F5');
loadMonitorPage();
- } else if (page == 'update.php') {
- headers.eq(4).css('background-color', '#A9D0F5');
- loadUpdatePage();
} else {
headers.eq(0).css('background-color', '#A9D0F5');
loadNodesPage();
@@ -451,37 +456,8 @@ function includeJs(file) {
script.attr( {
type : 'text/javascript',
src : file
- })
+ });
$('head').append(script);
}
-}
-
-/**
- * Reset the javascript files in to its original content
- *
- * @param file
- * File to include
- * @return Nothing
- */
-function resetJs() {
- var scripts = $('head script');
- for ( var i = 0; i < scripts.length; i++) {
- var file = scripts.eq(i).attr('src');
-
- // Remove ipmi, blade, hmc, ivm, fsp javascripts
- if (file == 'js/custom/ipmi.js') {
- scripts.eq(i).remove();
- } else if (file == 'js/custom/blade.js') {
- scripts.eq(i).remove();
- } else if (file == 'js/custom/hmc.js') {
- scripts.eq(i).remove();
- } else if (file == 'js/custom/ivm.js') {
- scripts.eq(i).remove();
- } else if (file == 'js/custom/fsp.js') {
- scripts.eq(i).remove();
- } else if (file == 'js/custom/zvm.js') {
- scripts.eq(i).remove();
- }
- }
}
\ No newline at end of file
diff --git a/xCAT-UI/lib/cmd.php b/xCAT-UI/lib/cmd.php
index 897fc4e57..92f72df84 100644
--- a/xCAT-UI/lib/cmd.php
+++ b/xCAT-UI/lib/cmd.php
@@ -64,8 +64,23 @@ if (isset($_GET["cmd"])) {
// Handle the typical output
else {
foreach ($xml->children() as $child) {
- foreach ($child->children() as $data) {
- array_push($rsp, "$data");
+ // Get the 1st level child
+ foreach ($child->children() as $level_one) {
+ if ($level_one->children()) {
+ // Get the 2nd level child
+ foreach ($level_one->children() as $level_two) {
+ if ($level_two->children()) {
+ // Get the 3rd level child
+ foreach ($level_two->children() as $level_three) {
+ array_push($rsp, "$level_three");
+ }
+ } else {
+ array_push($rsp, "$level_two");
+ }
+ }
+ } else {
+ array_push($rsp, "$level_one");
+ }
}
}
}