';
-
- $.prompt(procForm, {
- callback : addProcessor,
- buttons : {
- Ok : true,
- Cancel : false
- },
- prefix : 'cleanblue'
- });
- });
+ createAddProcDialog(node);
+ });
+
procFooter.append(addProcLink);
procTable.append(procFooter);
@@ -653,48 +634,8 @@ zvmPlugin.prototype.loadInventory = function(data) {
*/
var addDasdLink = $('Add disk');
addDasdLink.bind('click', function(event) {
- // Get list of disk pools
- var temp = attrs['hcp'][0].split('.');
- var cookie = $.cookie(temp[0] + 'DiskPools');
-
- // Create drop down list for disk pool
- var pools = cookie.split(',');
- var selectPool = '';
-
- // Create drop down list for disk mode
- var selectMode = '';
-
- var dasdForm = '
'
- + ''
- + ''
- + ''
- + ''
- + '
' + selectPool + '
'
- + '
' + selectMode + '
'
- + ''
- + '
';
-
- $.prompt(dasdForm, {
- callback : addDisk,
- buttons : {
- Ok : true,
- Cancel : false
- },
- prefix : 'cleanblue'
- });
+ var hcp = attrs['hcp'][0].split('.');
+ createAddDiskDialog(node, hcp[0]);
});
dasdFooter.append(addDasdLink);
dasdTable.append(dasdFooter);
@@ -774,148 +715,8 @@ zvmPlugin.prototype.loadInventory = function(data) {
*/
var addNicLink = $('Add NIC');
addNicLink.bind('click', function(event) {
- // Get network names
- var temp = attrs['hcp'][0].split('.');
- var networks = $.cookie(temp[0] + 'Networks').split(',');
-
- // Create a drop down list
- var gLansQdio = '';
-
- var nicTypeForm = '
'
- + ''
- + ''
- + '
'
- + ''
- + ''
- + ''
- + ''
- + '
'
- + '
'
- + ''
- + ''
- + '' + ''
- + '
'
- + '
';
- var configGuestLanQdioForm = '
' + gLansQdio + '
';
- var configGuestLanHipersForm = '
' + gLansHipers + '
';
- var configVSwitchForm = '
' + vswitches + '
';
- var notSupportedForm = '
The requested operation is not supported
';
-
- var states = {
- // Select NIC type
- type : {
- html : nicTypeForm,
- buttons : {
- Ok : true,
- Cancel : false
- },
- focus : 1,
- prefix : 'cleanblue',
- submit : function(v, m, f) {
- if (!v) {
- return true;
- } else {
- var nicType = f.nicType;
- var networkType = f.nicNetworkType;
- if (networkType == 'Guest LAN' && nicType == 'QDIO')
- $.prompt.goToState('configGuestLanQdio');
- else if (networkType == 'Guest LAN' && nicType == 'HiperSockets')
- $.prompt.goToState('configGuestLanHipers');
- else if (networkType == 'Virtual Switch' && nicType == 'QDIO')
- $.prompt.goToState('configVSwitch');
- else
- $.prompt.goToState('notSupported');
- return false;
- }
- }
- },
-
- // Configure QDIO guest LAN page
- configGuestLanQdio : {
- html : configGuestLanQdioForm,
- callback : addNic,
- buttons : {
- Ok : true,
- Cancel : false
- },
- focus : 1,
- prefix : 'cleanblue',
- submit : function(v, m, f) {
- if (v) {
- return true;
- }
- }
- },
-
- // Configure HIPERS guest LAN page
- configGuestLanHipers : {
- html : configGuestLanHipersForm,
- callback : addNic,
- buttons : {
- Ok : true,
- Cancel : false
- },
- focus : 1,
- prefix : 'cleanblue',
- submit : function(v, m, f) {
- if (v) {
- return true;
- }
- }
- },
-
- // Configure VSwitch page
- configVSwitch : {
- html : configVSwitchForm,
- callback : addNic,
- buttons : {
- Ok : true,
- Cancel : false
- },
- focus : 1,
- prefix : 'cleanblue',
- submit : function(v, m, f) {
- if (v) {
- return true;
- }
- }
- },
-
- // Not supported page
- notSupported : {
- html : notSupportedForm,
- buttons : {
- Ok : false
- },
- focus : 1,
- prefix : 'cleanblue',
- submit : function(v, m, f) {
- if (v) {
- return true;
- }
- }
- }
- };
-
- $.prompt(states, {
- callback : addNic,
- prefix : 'cleanblue'
- });
+ var hcp = attrs['hcp'][0].split('.');
+ createAddNicDialog(node, hcp[0]);
});
nicFooter.append(addNicLink);
nicTable.append(nicFooter);
@@ -1064,179 +865,197 @@ zvmPlugin.prototype.loadResources = function() {
/**
* Add node
*
- * @param f
- * Key/value pairs of the form values
* @return Nothing
*/
-zvmPlugin.prototype.addNode = function(f) {
- var nodeRange = f.node;
- var group = f.group;
- var hcp = f.hcp;
- var userIdRange = f.userId;
-
- // Check node range and user ID range
- var errMsg = '';
- var ready = true;
- if (nodeRange.indexOf('-') > -1 || userIdRange.indexOf('-') > -1) {
- if (nodeRange.indexOf('-') < 0 || userIdRange.indexOf('-') < 0) {
- errMsg = errMsg + 'A user ID range and node range needs to be given. ';
- ready = false;
- } else {
- var tmp = nodeRange.split('-');
-
- // Get node base name
- var nodeBase = tmp[0].match(/[a-zA-Z]+/);
- // Get starting index
- var nodeStart = parseInt(tmp[0].match(/\d+/));
- // Get ending index
- var nodeEnd = parseInt(tmp[1]);
-
- tmp = userIdRange.split('-');
-
- // Get user ID base name
- var userIdBase = tmp[0].match(/[a-zA-Z]+/);
- // Get starting index
- var userIdStart = parseInt(tmp[0].match(/\d+/));
- // Get ending index
- var userIdEnd = parseInt(tmp[1]);
-
- // If starting and ending index do not match
- if (!(nodeStart == userIdStart) || !(nodeEnd == userIdEnd)) {
- // Not ready
- errMsg = errMsg + 'The node range and user ID range does not match. ';
- ready = false;
- }
- }
- }
-
- // If there are no errors catched
- if (ready) {
- // If a node range is given
- if (nodeRange.indexOf('-') > -1 && userIdRange.indexOf('-') > -1) {
- var tmp = nodeRange.split('-');
+zvmPlugin.prototype.addNode = function() {
+ var info = createInfoBar('Add a new node');
+ var addNodeForm = $('');
+ addNodeForm.append(info);
+ addNodeForm.append('');
+ addNodeForm.append('');
+ addNodeForm.append('');
+ addNodeForm.append('');
+
+ // Create add node dialog
+ addNodeForm.dialog({
+ position: 'top',
+ modal: true,
+ width: 400,
+ buttons: {
+ "Cancel": function(){
+ // Close dialog
+ $(this).dialog( "close" );
+ },
+ "Ok": function(){
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Get inputs
+ var nodeRange = $(this).find('input[name=node]').val();
+ var userIdRange = $(this).find('input[name=userId]').val();
+ var group = $(this).find('input[name=group]').val();
+ var hcp = $(this).find('input[name=hcp]').val();
+
+ if (!nodeRange || !userIdRange || !group || !hcp) {
+ var warn = createWarnBar('Missing values');
+ warn.prependTo($(this));
+ } else {
+ // Check node range and user ID range
+ var errMsg = '';
+ var ready = true;
+ if (nodeRange.indexOf('-') > -1 || userIdRange.indexOf('-') > -1) {
+ if (nodeRange.indexOf('-') < 0 || userIdRange.indexOf('-') < 0) {
+ errMsg = errMsg + 'A user ID range and node range needs to be given. ';
+ ready = false;
+ } else {
+ var tmp = nodeRange.split('-');
- // Get node base name
- var nodeBase = tmp[0].match(/[a-zA-Z]+/);
- // Get starting index
- var nodeStart = parseInt(tmp[0].match(/\d+/));
- // Get ending index
- var nodeEnd = parseInt(tmp[1]);
+ // Get node base name
+ var nodeBase = tmp[0].match(/[a-zA-Z]+/);
+ // Get starting index
+ var nodeStart = parseInt(tmp[0].match(/\d+/));
+ // Get ending index
+ var nodeEnd = parseInt(tmp[1]);
- tmp = userIdRange.split('-');
+ tmp = userIdRange.split('-');
- // Get user ID base name
- var userIdBase = tmp[0].match(/[a-zA-Z]+/);
- // Get starting index
- var userIdStart = parseInt(tmp[0].match(/\d+/));
- // Get ending index
- var userIdEnd = parseInt(tmp[1]);
+ // Get user ID base name
+ var userIdBase = tmp[0].match(/[a-zA-Z]+/);
+ // Get starting index
+ var userIdStart = parseInt(tmp[0].match(/\d+/));
+ // Get ending index
+ var userIdEnd = parseInt(tmp[1]);
- // Loop through each node in the node range
- for ( var i = nodeStart; i <= nodeEnd; i++) {
- var node = nodeBase + i.toString();
- var userId = userIdBase + i.toString();
- var inst = i + '/' + nodeEnd;
-
- /**
- * (1) Define node
- */
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'nodeadd',
- tgt : '',
- args : node + ';zvm.hcp=' + hcp
- + ';zvm.userid=' + userId
- + ';nodehm.mgt=zvm' + ';groups=' + group,
- msg : 'cmd=addnewnode;inst=' + inst + ';noderange=' + nodeRange
- },
-
- /**
- * Return function on successful AJAX call
- *
- * @param data
- * Data returned from HTTP request
- * @return Nothing
- */
- success : function (data) {
- // Get ajax response
- var rsp = data.rsp;
- var args = data.msg.split(';');
-
- // Get command invoked
- var cmd = args[0].replace('cmd=', '');
- var inst = args[1].replace('inst=', '');
- var nodeRange = args[2].replace('noderange=', '');
-
- // If the last node was added
- var tmp = inst.split('/');
- if (tmp[0] == tmp[1]) {
- // If there was an error, do not continue
- var msg;
- if (rsp.length) {
- msg = '
(Error) Failed to create node definition
';
- } else {
- msg = '
Node definitions created for ' + nodeRange + '
';
- }
-
- $.prompt(msg, {
- buttons: { Ok: true },
- prefix: 'cleanblue'
- });
+ // If starting and ending index do not match
+ if (!(nodeStart == userIdStart) || !(nodeEnd == userIdEnd)) {
+ // Not ready
+ errMsg = errMsg + 'The node range and user ID range does not match. ';
+ ready = false;
+ }
}
}
- });
- }
- } else {
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'nodeadd',
- tgt : '',
- args : nodeRange + ';zvm.hcp=' + hcp
- + ';zvm.userid=' + userIdRange
- + ';nodehm.mgt=zvm' + ';groups=' + group,
- msg : 'cmd=addnewnode;node=' + nodeRange
- },
-
- /**
- * Return function on successful AJAX call
- *
- * @param data
- * Data returned from HTTP request
- * @return Nothing
- */
- success : function (data) {
- // Get ajax response
- var rsp = data.rsp;
- var args = data.msg.split(';');
-
- // Get command invoked
- var cmd = args[0].replace('cmd=', '');
- var node = args[1].replace('node=', '');
- // If there was an error, do not continue
- var msg;
- if (rsp.length) {
- msg = '
(Error) Failed to create node definition
';
+ // If there are no errors
+ if (ready) {
+ // If a node range is given
+ if (nodeRange.indexOf('-') > -1 && userIdRange.indexOf('-') > -1) {
+ var tmp = nodeRange.split('-');
+
+ // Get node base name
+ var nodeBase = tmp[0].match(/[a-zA-Z]+/);
+ // Get starting index
+ var nodeStart = parseInt(tmp[0].match(/\d+/));
+ // Get ending index
+ var nodeEnd = parseInt(tmp[1]);
+
+ tmp = userIdRange.split('-');
+
+ // Get user ID base name
+ var userIdBase = tmp[0].match(/[a-zA-Z]+/);
+ // Get starting index
+ var userIdStart = parseInt(tmp[0].match(/\d+/));
+ // Get ending index
+ var userIdEnd = parseInt(tmp[1]);
+
+ // Loop through each node in the node range
+ for ( var i = nodeStart; i <= nodeEnd; i++) {
+ var node = nodeBase + i.toString();
+ var userId = userIdBase + i.toString();
+ var inst = i + '/' + nodeEnd;
+
+ /**
+ * (1) Define node
+ */
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'nodeadd',
+ tgt : '',
+ args : node + ';zvm.hcp=' + hcp
+ + ';zvm.userid=' + userId
+ + ';nodehm.mgt=zvm' + ';groups=' + group,
+ msg : 'cmd=addnewnode;inst=' + inst + ';noderange=' + nodeRange
+ },
+
+ /**
+ * Return function on successful AJAX call
+ *
+ * @param data
+ * Data returned from HTTP request
+ * @return Nothing
+ */
+ success : function (data) {
+ // Get ajax response
+ var rsp = data.rsp;
+ var args = data.msg.split(';');
+
+ // Get command invoked
+ var cmd = args[0].replace('cmd=', '');
+ var inst = args[1].replace('inst=', '');
+ var nodeRange = args[2].replace('noderange=', '');
+
+ // If the last node was added
+ var tmp = inst.split('/');
+ if (tmp[0] == tmp[1]) {
+ // If there was an error, do not continue
+ if (rsp.length) {
+ openDialog('(Error) Failed to create node definition');
+ } else {
+ openDialog('Node definitions created for ' + nodeRange);
+ }
+ }
+ }
+ });
+ }
+ } else {
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'nodeadd',
+ tgt : '',
+ args : nodeRange + ';zvm.hcp=' + hcp
+ + ';zvm.userid=' + userIdRange
+ + ';nodehm.mgt=zvm' + ';groups=' + group,
+ msg : 'cmd=addnewnode;node=' + nodeRange
+ },
+
+ /**
+ * Return function on successful AJAX call
+ *
+ * @param data
+ * Data returned from HTTP request
+ * @return Nothing
+ */
+ success : function (data) {
+ // Get ajax response
+ var rsp = data.rsp;
+ var args = data.msg.split(';');
+
+ // Get command invoked
+ var cmd = args[0].replace('cmd=', '');
+ var node = args[1].replace('node=', '');
+
+ // If there was an error, do not continue
+ if (rsp.length) {
+ openDialog('(Error) Failed to create node definition');
+ } else {
+ openDialog('Node definitions created for ' + node);
+ }
+ }
+ });
+ }
+
+ // Close dialog
+ $(this).dialog( "close" );
} else {
- msg = '
');
+ warnBar.append(msg);
+
+ return warnBar;
+}
+
/**
* Create a loader
*
@@ -504,4 +519,29 @@ function writeRsp(rsp, pattern) {
}
return prg;
-}
\ No newline at end of file
+}
+
+/**
+ * Open a dialog and show given message
+ *
+ * @param msg
+ * Message to show
+ * @return Nothing
+ */
+function openDialog(msg) {
+ // If there was an error, do not continue
+ var div = $('