diff --git a/xCAT-UI/js/configure/service.js b/xCAT-UI/js/configure/service.js
index ddd422034..7c92b5ef0 100644
--- a/xCAT-UI/js/configure/service.js
+++ b/xCAT-UI/js/configure/service.js
@@ -133,7 +133,7 @@ function loadUserTable(data) {
var headers = new Array('priority', 'username', 'password', 'max-vm');
// Create a new datatable
- var tableId = 'userDatatable';
+ var tableId = panelId + 'Datatable';
var table = new DataTable(tableId);
// Add column for the checkbox
@@ -522,4 +522,994 @@ function openDeleteUserDialog(users) {
function toFixed(value, precision) {
var power = Math.pow(10, precision || 0);
return String(Math.round(value * power) / power);
+}
+
+/**
+ * Query the images that exists
+ *
+ * @param panelId Panel ID
+ */
+function queryImages(panelId) {
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'tabdump',
+ tgt : '',
+ args : 'osimage',
+ msg : panelId
+ },
+
+ success : configImagePanel
+ });
+}
+
+/**
+ * Panel to configure OS images
+ *
+ * @param data Data from HTTP request
+ */
+function configImagePanel(data) {
+ var panelId = data.msg;
+ var rsp = data.rsp;
+
+ // Wipe panel clean
+ $('#' + panelId).empty();
+
+ // Add info bar
+ $('#' + panelId).append(createInfoBar('Create, edit, and delete operating system images for the self-service portal.'));
+
+ // Create table
+ var tableId = panelId + 'Datatable';
+ var table = new DataTable(tableId);
+ table.init([' ', 'Name', 'Selectable', 'OS Version', 'OS Arch', 'OS Name', 'Type', 'Profile', 'Method', 'Description']);
+
+ // Insert images into table
+ var imagePos = 0;
+ var profilePos = 0;
+ var osversPos = 0;
+ var osarchPos = 0;
+ var osnamePos = 0;
+ var imagetypePos = 0;
+ var provMethodPos = 0;
+ var comments = 0;
+ var desc, selectable, tmp;
+ // Get column index for each attribute
+ var colNameArray = rsp[0].substr(1).split(',');
+ for (var i in colNameArray){
+ switch (colNameArray[i]){
+ case 'imagename': {
+ imagePos = i;
+ }
+ break;
+
+ case 'profile':{
+ profilePos = i;
+ }
+ break;
+
+ case 'osvers':{
+ osversPos = i;
+ }
+ break;
+
+ case 'osarch':{
+ osarchPos = i;
+ }
+ break;
+
+ case 'osname':{
+ osnamePos = i;
+ }
+ break;
+
+ case 'imagetype':{
+ imagetypePos = i;
+ }
+ break;
+
+ case 'comments':{
+ comments = i;
+ }
+ break;
+
+ case 'provmethod':{
+ provMethodPos = i;
+ }
+ break;
+
+ default :
+ break;
+ }
+ }
+
+ // Go through each index
+ for (var i = 1; i < rsp.length; i++) {
+ // Get image name
+ var cols = rsp[i].split(',');
+ var name = cols[imagePos].replace(new RegExp('"', 'g'), '');
+ var profile = cols[profilePos].replace(new RegExp('"', 'g'), '');
+ var provMethod = cols[provMethodPos].replace(new RegExp('"', 'g'), '');
+ var osVer = cols[osversPos].replace(new RegExp('"', 'g'), '');
+ var osArch = cols[osarchPos].replace(new RegExp('"', 'g'), '');
+ var osName = cols[osnamePos].replace(new RegExp('"', 'g'), '');
+ var imageType = cols[imagetypePos].replace(new RegExp('"', 'g'), '');
+ var osComments = cols[comments].replace(new RegExp('"', 'g'), '');
+
+ // Only save install boot and s390x architectures
+ if (osArch == "s390x") {
+ // Set default description and selectable
+ selectable = "no";
+ desc = "No description";
+
+ if (osComments) {
+ tmp = osComments.split('|');
+ for (var j = 0; j < tmp.length; j++) {
+ // Save description
+ if (tmp[j].indexOf('description:') > -1) {
+ desc = tmp[j].replace('description:', '');
+ desc = jQuery.trim(desc);
+ }
+
+ // Is the image selectable?
+ if (tmp[j].indexOf('selectable:') > -1) {
+ selectable = tmp[j].replace('selectable:', '');
+ selectable = jQuery.trim(selectable);
+ }
+ }
+ }
+
+ // Columns are: name, selectable, OS version, OS arch, OS name, type, profile, method, and description
+ var cols = new Array(name, selectable, osVer, osArch, osName, imageType, profile, provMethod, desc);
+
+ // Add remove button where id = user name
+ cols.unshift(' ');
+
+ // Add row
+ table.add(cols);
+ }
+ }
+
+ // Append datatable to tab
+ $('#' + panelId).append(table.object());
+
+ // Turn into datatable
+ $('#' + tableId).dataTable({
+ 'iDisplayLength': 50,
+ 'bLengthChange': false,
+ "sScrollX": "100%",
+ "bAutoWidth": true
+ });
+
+ // Create action bar
+ var actionBar = $('
');
+
+ // Create a profile
+ var createLnk = $('Create ');
+ createLnk.click(function() {
+ imageDialog();
+ });
+
+ // Edit a profile
+ var editLnk = $('Edit ');
+ editLnk.click(function() {
+ var images = $('#' + tableId + ' input[type=checkbox]:checked');
+ for (var i in images) {
+ var image = images.eq(i).attr('name');
+ if (image) {
+ // Columns are: name, selectable, OS version, OS arch, OS name, type, profile, method, and description
+ var cols = images.eq(i).parents('tr').find('td');
+ var selectable = cols.eq(2).text();
+ var osVersion = cols.eq(3).text();
+ var osArch = cols.eq(4).text();
+ var osName = cols.eq(5).text();
+ var type = cols.eq(6).text();
+ var profile = cols.eq(7).text();
+ var method = cols.eq(8).text();
+ var description = cols.eq(9).text();
+
+ editImageDialog(image, selectable, osVersion, osArch, osName, type, profile, method, description);
+ }
+ }
+ });
+
+ // Delete a profile
+ var deleteLnk = $('Delete ');
+ deleteLnk.click(function() {
+ var images = getNodesChecked(tableId);
+ if (images) {
+ deleteImageDialog(images);
+ }
+ });
+
+ // Refresh profiles table
+ var refreshLnk = $('Refresh ');
+ refreshLnk.click(function() {
+ queryImages(panelId);
+ });
+
+ // Create an action menu
+ var actionsMenu = createMenu([createLnk, editLnk, deleteLnk, refreshLnk]);
+ actionsMenu.superfish();
+ actionsMenu.css('display', 'inline-block');
+ actionBar.append(actionsMenu);
+
+ // Set correct theme for action menu
+ actionsMenu.find('li').hover(function() {
+ setMenu2Theme($(this));
+ }, function() {
+ setMenu2Normal($(this));
+ });
+
+ // Create a division to hold actions menu
+ var menuDiv = $('');
+ $('#' + tableId + '_wrapper').prepend(menuDiv);
+ menuDiv.append(actionBar);
+ $('#' + tableId + '_filter').appendTo(menuDiv);
+
+ // Resize accordion
+ $('#' + tableId).parents('.ui-accordion').accordion('resize');
+}
+
+/**
+ * Open image dialog
+ */
+function imageDialog() {
+ // Create form to add profile
+ var dialogId = 'createImage';
+ var imageForm = $('
');
+
+ // Create info bar
+ var info = createInfoBar('Provide the following attributes for the image. The image name will be generated based on the attributes you will give.');
+ imageForm.append(info);
+
+ var imageName = $('Image name:
');
+ var selectable = $('Selectable:
');
+ var imageType = $('Image type:
');
+ var architecture = $('OS architecture:
');
+ var osName = $('OS name:
');
+ var osVersion = $('OS version:
');
+ var profile = $('Profile:
');
+ var provisionMethod = $('Provision method:
');
+ var provisionSelect = $(''
+ + ' '
+ + 'install '
+ + 'netboot '
+ + 'statelite '
+ + ' ');
+ provisionMethod.append(provisionSelect);
+ var comments = $('Description:
');
+ imageForm.append(imageName, selectable, imageType, architecture, osName, osVersion, profile, provisionMethod, comments);
+
+ // Open dialog to add image
+ imageForm.dialog({
+ title:'Create image',
+ modal: true,
+ close: function(){
+ $(this).remove();
+ },
+ width: 400,
+ buttons: {
+ "Ok": function() {
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Get image attributes
+ var imageType = $(this).find('input[name="imagetype"]');
+ var selectable = $(this).find('input[name="selectable"]');
+ var architecture = $(this).find('input[name="osarch"]');
+ var osName = $(this).find('input[name="osname"]');
+ var osVersion = $(this).find('input[name="osvers"]');
+ var profile = $(this).find('input[name="profile"]');
+ var provisionMethod = $(this).find('select[name="provmethod"]');
+ var comments = $(this).find('input[name="comments"]');
+
+ // Check that image attributes are provided before continuing
+ var ready = 1;
+ var inputs = new Array(imageType, architecture, osName, osVersion, profile, provisionMethod);
+ for (var i in inputs) {
+ if (!inputs[i].val()) {
+ inputs[i].css('border-color', 'red');
+ ready = 0;
+ } else
+ inputs[i].css('border-color', '');
+ }
+
+ // If inputs are not complete, show warning message
+ if (!ready) {
+ var warn = createWarnBar('Please provide a value for each missing field.');
+ warn.prependTo($(this));
+ } else {
+ // Override image name
+ $(this).find('input[name="imagename"]').val(osVersion.val() + '-' + architecture.val() + '-' + provisionMethod.val() + '-' + profile.val());
+ var imageName = $(this).find('input[name="imagename"]');
+
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Set default description
+ if (!comments.val())
+ comments.val('No description');
+
+ // Create arguments to send via AJAX
+ var args = 'updateosimage;' + imageName.val() + ';' +
+ imageType.val() + ';' +
+ architecture.val() + ';' +
+ osName.val() + ';' +
+ osVersion.val() + ';' +
+ profile.val() + ';' +
+ provisionMethod.val() + ';';
+
+ if (selectable.attr('checked'))
+ args += '"description:' + comments.val() + '|selectable:yes"';
+ else
+ args += '"description:' + comments.val() + '|selectable:no"';
+
+ // Add image to xCAT
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : args,
+ msg : dialogId
+ },
+
+ success : updatePanel
+ });
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Edit image dialog
+ *
+ * @param iName Image name
+ * @param iSelectable Is image selectable from service page
+ * @param iOsVersion OS version
+ * @param iProfile Profile name
+ * @param iMethod Provisioning method
+ * @param iComments Image description
+ */
+function editImageDialog(iName, iSelectable, iOsVersion, iOsArch, iOsName, iType, iProfile, iMethod, iComments) {
+ // Create form to add profile
+ var dialogId = 'editImage';
+ var imageForm = $('
');
+
+ // Create info bar
+ var info = createInfoBar('Provide the following attributes for the image. The image name will be generated based on the attributes you will give.');
+ imageForm.append(info);
+
+ var imageName = $('Image name:
');
+ var selectable = $('Selectable:
');
+ var imageType = $('Image type:
');
+ var architecture = $('OS architecture:
');
+ var osName = $('OS name:
');
+ var osVersion = $('OS version:
');
+ var profile = $('Profile:
');
+ var provisionMethod = $('Provision method:
');
+ var provisionSelect = $(''
+ + ' '
+ + 'install '
+ + 'netboot '
+ + 'statelite '
+ + ' ');
+ provisionMethod.append(provisionSelect);
+ var comments = $('Description:
');
+ imageForm.append(imageName, selectable, imageType, architecture, osName, osVersion, profile, provisionMethod, comments);
+
+ // Fill in image attributes
+ imageForm.find('input[name="imagename"]').val(iName);
+ imageForm.find('input[name="osvers"]').val(iOsVersion);
+ imageForm.find('input[name="osarch"]').val(iOsArch);
+ imageForm.find('input[name="osname"]').val(iOsName);
+ imageForm.find('input[name="imagetype"]').val(iType);
+ imageForm.find('input[name="profile"]').val(iProfile);
+ imageForm.find('select[name="provmethod"]').val(iMethod);
+ imageForm.find('input[name="comments"]').val(iComments);
+ if (iSelectable == "yes")
+ imageForm.find('input[name="selectable"]').attr('checked', 'checked');
+
+ // Open dialog to add image
+ imageForm.dialog({
+ title:'Edit image',
+ modal: true,
+ close: function(){
+ $(this).remove();
+ },
+ width: 400,
+ buttons: {
+ "Ok": function() {
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Get image attributes
+ var imageType = $(this).find('input[name="imagetype"]');
+ var selectable = $(this).find('input[name="selectable"]');
+ var architecture = $(this).find('input[name="osarch"]');
+ var osName = $(this).find('input[name="osname"]');
+ var osVersion = $(this).find('input[name="osvers"]');
+ var profile = $(this).find('input[name="profile"]');
+ var provisionMethod = $(this).find('select[name="provmethod"]');
+ var comments = $(this).find('input[name="comments"]');
+
+ // Check that image attributes are provided before continuing
+ var ready = 1;
+ var inputs = new Array(imageType, architecture, osName, osVersion, profile, provisionMethod);
+ for (var i in inputs) {
+ if (!inputs[i].val()) {
+ inputs[i].css('border-color', 'red');
+ ready = 0;
+ } else
+ inputs[i].css('border-color', '');
+ }
+
+ // If inputs are not complete, show warning message
+ if (!ready) {
+ var warn = createWarnBar('Please provide a value for each missing field.');
+ warn.prependTo($(this));
+ } else {
+ // Override image name
+ $(this).find('input[name="imagename"]').val(osVersion.val() + '-' + architecture.val() + '-' + provisionMethod.val() + '-' + profile.val());
+ var imageName = $(this).find('input[name="imagename"]');
+
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Set default description
+ if (!comments.val())
+ comments.val('No description');
+
+ // Create arguments to send via AJAX
+ var args = 'updateosimage;' + imageName.val() + ';' +
+ imageType.val() + ';' +
+ architecture.val() + ';' +
+ osName.val() + ';' +
+ osVersion.val() + ';' +
+ profile.val() + ';' +
+ provisionMethod.val() + ';';
+
+ if (selectable.attr('checked'))
+ args += '"description:' + comments.val() + '|selectable:yes"';
+ else
+ args += '"description:' + comments.val() + '|selectable:no"';
+
+ // Add image to xCAT
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : args,
+ msg : dialogId
+ },
+
+ success : updatePanel
+ });
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Open dialog to confirm image delete
+ *
+ * @param images Images to delete
+ */
+function deleteImageDialog(images) {
+ // Create form to delete disk to pool
+ var dialogId = 'deleteImage';
+ var deleteForm = $('
');
+
+ // Create info bar
+ var info = createInfoBar('Are you sure you want to delete ' + images.replace(new RegExp(',', 'g'), ', ') + '?');
+ deleteForm.append(info);
+
+ // Open dialog to delete user
+ deleteForm.dialog({
+ title:'Delete image',
+ modal: true,
+ width: 400,
+ close: function(){
+ $(this).remove();
+ },
+ buttons: {
+ "Ok": function(){
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Delete user
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'rmosimage;' + images,
+ msg : dialogId
+ },
+ success : updatePanel
+ });
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Query the groups that exists
+ *
+ * @param panelId Panel ID
+ */
+function queryGroups(panelId) {
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'tabdump',
+ tgt : '',
+ args : 'hosts',
+ msg : panelId
+ },
+
+ success : configGroupPanel
+ });
+}
+
+/**
+ * Panel to configure groups
+ *
+ * @param data Data from HTTP request
+ */
+function configGroupPanel(data) {
+ var panelId = data.msg;
+ var rsp = data.rsp;
+
+ // Wipe panel clean
+ $('#' + panelId).empty();
+
+ // Add info bar
+ $('#' + panelId).append(createInfoBar('Create, edit, and delete groups for the self-service portal.'));
+
+ // Create table
+ var tableId = panelId + 'Datatable';
+ var table = new DataTable(tableId);
+ table.init([' ', 'Name', 'Selectable', 'IP', 'Hostname', 'Network', 'Description']);
+
+ // Insert groups into table
+ var nodePos = 0;
+ var ipPos = 0;
+ var hostnamePos = 0;
+ var commentsPos = 0;
+ var desc, selectable, tmp;
+ // Get column index for each attribute
+ var colNameArray = rsp[0].substr(1).split(',');
+ for (var i in colNameArray){
+ switch (colNameArray[i]){
+ case 'node':
+ nodePos = i;
+ break;
+
+ case 'ip':
+ ipPos = i;
+ break;
+
+ case 'hostnames':
+ hostnamePos = i;
+ break;
+
+ case 'comments':
+ commentsPos = i;
+ break;
+
+ default :
+ break;
+ }
+ }
+
+ // Go through each index
+ for (var i = 1; i < rsp.length; i++) {
+ // Get image name
+ var cols = rsp[i].split(',');
+ var name = cols[nodePos].replace(new RegExp('"', 'g'), '');
+ var ip = cols[ipPos].replace(new RegExp('"', 'g'), '');
+ var hostname = cols[hostnamePos].replace(new RegExp('"', 'g'), '');
+ var comments = cols[commentsPos].replace(new RegExp('"', 'g'), '');
+
+ // Set default description and selectable
+ selectable = "no";
+ network = "";
+ desc = "No description";
+
+ if (comments) {
+ tmp = comments.split('|');
+ for (var j = 0; j < tmp.length; j++) {
+ // Save description
+ if (tmp[j].indexOf('description:') > -1) {
+ desc = tmp[j].replace('description:', '');
+ desc = jQuery.trim(desc);
+ }
+
+ // Save network
+ if (tmp[j].indexOf('network:') > -1) {
+ network = tmp[j].replace('network:', '');
+ network = jQuery.trim(network);
+ }
+
+ // Is the group selectable?
+ if (tmp[j].indexOf('selectable:') > -1) {
+ selectable = tmp[j].replace('selectable:', '');
+ selectable = jQuery.trim(selectable);
+ }
+ }
+ }
+
+ // Columns are: name, selectable, network, and description
+ var cols = new Array(name, selectable, ip, hostname, network, desc);
+
+ // Add remove button where id = user name
+ cols.unshift(' ');
+
+ // Add row
+ table.add(cols);
+ }
+
+ // Append datatable to tab
+ $('#' + panelId).append(table.object());
+
+ // Turn into datatable
+ $('#' + tableId).dataTable({
+ 'iDisplayLength': 50,
+ 'bLengthChange': false,
+ "sScrollX": "100%",
+ "bAutoWidth": true
+ });
+
+ // Create action bar
+ var actionBar = $('
');
+
+ // Create a group
+ var createLnk = $('Create ');
+ createLnk.click(function() {
+ groupDialog();
+ });
+
+ // Edit a group
+ var editLnk = $('Edit ');
+ editLnk.click(function() {
+ var groups = $('#' + tableId + ' input[type=checkbox]:checked');
+ for (var i in groups) {
+ var group = groups.eq(i).attr('name');
+ if (group) {
+ // Column order is: name, selectable, network, and description
+ var cols = groups.eq(i).parents('tr').find('td');
+ var selectable = cols.eq(2).text();
+ var ip = cols.eq(3).text();
+ var hostnames = cols.eq(4).text();
+ var network = cols.eq(5).text();
+ var description = cols.eq(6).text();
+
+ editGroupDialog(group, selectable, ip, hostnames, network, description);
+ }
+ }
+ });
+
+ // Delete a profile
+ var deleteLnk = $('Delete ');
+ deleteLnk.click(function() {
+ var groups = getNodesChecked(tableId);
+ if (groups) {
+ deleteGroupDialog(groups);
+ }
+ });
+
+ // Refresh profiles table
+ var refreshLnk = $('Refresh ');
+ refreshLnk.click(function() {
+ queryGroups(panelId);
+ });
+
+ // Create an action menu
+ var actionsMenu = createMenu([createLnk, editLnk, deleteLnk, refreshLnk]);
+ actionsMenu.superfish();
+ actionsMenu.css('display', 'inline-block');
+ actionBar.append(actionsMenu);
+
+ // Set correct theme for action menu
+ actionsMenu.find('li').hover(function() {
+ setMenu2Theme($(this));
+ }, function() {
+ setMenu2Normal($(this));
+ });
+
+ // Create a division to hold actions menu
+ var menuDiv = $('');
+ $('#' + tableId + '_wrapper').prepend(menuDiv);
+ menuDiv.append(actionBar);
+ $('#' + tableId + '_filter').appendTo(menuDiv);
+
+ // Resize accordion
+ $('#' + tableId).parents('.ui-accordion').accordion('resize');
+}
+
+/**
+ * Open group dialog
+ */
+function groupDialog() {
+ // Create form to add profile
+ var dialogId = 'createGroup';
+ var groupForm = $('
');
+
+ // Create info bar
+ var info = createInfoBar('Provide the following attributes for the group.');
+ groupForm.append(info);
+
+ var group = $('Group:
');
+ var selectable = $('Selectable:
');
+ var ip = $('IP:
');
+ var hostnames = $('Hostnames:
');
+ var network = $('Network:
');
+ var comments = $('Description:
');
+ groupForm.append(group, selectable, ip, hostnames, network, comments);
+
+ // Open dialog to add image
+ groupForm.dialog({
+ title:'Create group',
+ modal: true,
+ close: function(){
+ $(this).remove();
+ },
+ width: 400,
+ buttons: {
+ "Ok": function() {
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Get group attributes
+ var group = $(this).find('input[name="group"]');
+ var selectable = $(this).find('input[name="selectable"]');
+ var ip = $(this).find('input[name="ip"]');
+ var hostnames = $(this).find('input[name="hostnames"]');
+ var network = $(this).find('input[name="network"]');
+ var comments = $(this).find('input[name="comments"]');
+
+ // Check that group attributes are provided before continuing
+ var ready = 1;
+ var inputs = new Array(group, ip, hostnames, network);
+ for (var i in inputs) {
+ if (!inputs[i].val()) {
+ inputs[i].css('border-color', 'red');
+ ready = 0;
+ } else
+ inputs[i].css('border-color', '');
+ }
+
+ // If inputs are not complete, show warning message
+ if (!ready) {
+ var warn = createWarnBar('Please provide a value for each missing field.');
+ warn.prependTo($(this));
+ } else {
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Set default description
+ if (!comments.val())
+ comments.val('No description');
+
+ // Create arguments to send via AJAX
+ var args = "updategroup;" + group.val() + ";'" + ip.val() + "';'" + hostnames.val() + "';";
+
+ if (selectable.attr("checked"))
+ args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:yes";
+ else
+ args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:no";
+
+ // Add image to xCAT
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : args,
+ msg : dialogId
+ },
+
+ success : updatePanel
+ });
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Edit group dialog
+ *
+ * @param iGroup Group name
+ * @param iSelectable Is group selectable from the service page
+ * @param iIp Group IP regex
+ * @param iHostnames Group hostnames regex
+ * @param iNetwork Group network, e.g. 10.1.2.0/24
+ * @param iComments Group description
+ */
+function editGroupDialog(iGroup, iSelectable, iIp, iHostnames, iNetwork, iComments) {
+ // Create form to add profile
+ var dialogId = 'createGroup';
+ var groupForm = $('
');
+
+ // Create info bar
+ var info = createInfoBar('Provide the following attributes for the group.');
+ groupForm.append(info);
+
+ var group = $('Group:
');
+ var selectable = $('Selectable:
');
+ var ip = $('IP:
');
+ var hostnames = $('Hostnames:
');
+ var network = $('Network:
');
+ var comments = $('Description:
');
+ groupForm.append(group, selectable, ip, hostnames, network, comments);
+
+ // Fill in group attributes
+ groupForm.find('input[name="group"]').val(iGroup);
+ groupForm.find('input[name="ip"]').val(iIp);
+ groupForm.find('input[name="hostnames"]').val(iHostnames);
+ groupForm.find('input[name="network"]').val(iNetwork);
+ groupForm.find('input[name="comments"]').val(iComments);
+ if (iSelectable == "yes")
+ groupForm.find('input[name="selectable"]').attr('checked', 'checked');
+
+ // Open dialog to add image
+ groupForm.dialog({
+ title:'Edit group',
+ modal: true,
+ close: function(){
+ $(this).remove();
+ },
+ width: 400,
+ buttons: {
+ "Ok": function() {
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Get group attributes
+ var group = $(this).find('input[name="group"]');
+ var selectable = $(this).find('input[name="selectable"]');
+ var ip = $(this).find('input[name="ip"]');
+ var hostnames = $(this).find('input[name="hostnames"]');
+ var network = $(this).find('input[name="network"]');
+ var comments = $(this).find('input[name="comments"]');
+
+ // Check that group attributes are provided before continuing
+ var ready = 1;
+ var inputs = new Array(group, ip, hostnames, network);
+ for (var i in inputs) {
+ if (!inputs[i].val()) {
+ inputs[i].css('border-color', 'red');
+ ready = 0;
+ } else
+ inputs[i].css('border-color', '');
+ }
+
+ // If inputs are not complete, show warning message
+ if (!ready) {
+ var warn = createWarnBar('Please provide a value for each missing field.');
+ warn.prependTo($(this));
+ } else {
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Set default description
+ if (!comments.val())
+ comments.val('No description');
+
+ // Create arguments to send via AJAX
+ var args = "updategroup;" + group.val() + ";'" + ip.val() + "';'" + hostnames.val() + "';";
+
+ if (selectable.attr("checked"))
+ args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:yes";
+ else
+ args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:no";
+
+ // Add image to xCAT
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : args,
+ msg : dialogId
+ },
+
+ success : updatePanel
+ });
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Open dialog to confirm group delete
+ *
+ * @param groups Groups to delete
+ */
+function deleteGroupDialog(groups) {
+ // Create form to delete disk to pool
+ var dialogId = 'deleteImage';
+ var deleteForm = $('
');
+
+ // Create info bar
+ var info = createInfoBar('Are you sure you want to delete ' + groups.replace(new RegExp(',', 'g'), ', ') + '?');
+ deleteForm.append(info);
+
+ // Open dialog to delete user
+ deleteForm.dialog({
+ title:'Delete group',
+ modal: true,
+ width: 400,
+ close: function(){
+ $(this).remove();
+ },
+ buttons: {
+ "Ok": function(){
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Change dialog buttons
+ $(this).dialog('option', 'buttons', {
+ 'Close': function() {$(this).dialog("close");}
+ });
+
+ // Delete user
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'rmgroup;' + groups,
+ msg : dialogId
+ },
+ success : updatePanel
+ });
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
}
\ No newline at end of file
diff --git a/xCAT-UI/js/custom/blade.js b/xCAT-UI/js/custom/blade.js
index d153a179c..8c119fcc7 100644
--- a/xCAT-UI/js/custom/blade.js
+++ b/xCAT-UI/js/custom/blade.js
@@ -12,33 +12,6 @@ var bladePlugin = function() {
};
-/**
- * Clone node (service page)
- *
- * @param node Node to clone
- */
-bladePlugin.prototype.serviceClone = function(node) {
-
-};
-
-/**
- * Load provision page (service page)
- *
- * @param tabId Tab ID where page will reside
- */
-bladePlugin.prototype.loadServiceProvisionPage = function(tabId) {
-
-};
-
-/**
- * Show node inventory (service page)
- *
- * @param data Data from HTTP request
- */
-bladePlugin.prototype.loadServiceInventory = function(data) {
-
-};
-
/**
* Load node inventory
*
diff --git a/xCAT-UI/js/custom/esx.js b/xCAT-UI/js/custom/esx.js
index 105769dfc..d5e229ea2 100644
--- a/xCAT-UI/js/custom/esx.js
+++ b/xCAT-UI/js/custom/esx.js
@@ -19,7 +19,7 @@ var esxPlugin = function() {
*/
esxPlugin.prototype.loadConfigPage = function(tabId) {
var configAccordion = $('
');
-
+
// Create accordion panel for user
var userSection = $('
');
var userLnk = $('').click(function () {
@@ -28,32 +28,46 @@ esxPlugin.prototype.loadConfigPage = function(tabId) {
return;
else
$('#esxConfigUser').append(createLoader(''));
-
- // Get user data
+
loadUserPanel('esxConfigUser');
});
// Create accordion panel for profiles
var profileSection = $('
');
- profileSection.append(createInfoBar('Create, edit, and delete virtual machine profiles used in the self-service portal'));
var profileLnk = $('').click(function () {
-
+ // Do not load panel again if it is already loaded
+ if ($('#esxConfigProfile').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#esxConfigProfile').append(createLoader(''));
+
+ });
+
+ // Create accordion panel for images
+ var imgSection = $('
');
+ var imgLnk = $('').click(function () {
+ // Do not load panel again if it is already loaded
+ if ($('#esxConfigImages').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#esxConfigImages').append(createLoader(''));
+
+ queryImages('esxConfigImages');
});
// Create accordion panel for groups
var groupsSection = $('
');
var groupsLnk = $('').click(function () {
+ // Do not load panel again if it is already loaded
+ if ($('#esxConfigGroups').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#esxConfigGroups').append(createLoader(''));
- });
-
- // Create accordion panel for nodes
- var nodeSection = $('
');
- nodeSection.append(createInfoBar('Modify node attributes'));
- var nodeLnk = $('').click(function () {
-
+ queryGroups('esxConfigGroups');
});
-
- configAccordion.append(userLnk, userSection, profileLnk, profileSection, groupsLnk, groupsSection, nodeLnk, nodeSection);
+
+ configAccordion.append(userLnk, userSection, profileLnk, profileSection, imgLnk, imgSection, groupsLnk, groupsSection);
$('#' + tabId).append(configAccordion);
configAccordion.accordion();
diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js
index 29de5e6bd..044810dd8 100644
--- a/xCAT-UI/js/custom/hmc.js
+++ b/xCAT-UI/js/custom/hmc.js
@@ -36,33 +36,6 @@ hmcPlugin.prototype.getNextFunction = function() {
checkFrameMtms, undefined, undefined, collectInputValue ];
};
-/**
- * Clone node (service page)
- *
- * @param node Node to clone
- */
-hmcPlugin.prototype.serviceClone = function(node) {
-
-};
-
-/**
- * Load provision page (service page)
- *
- * @param tabId Tab ID where page will reside
- */
-hmcPlugin.prototype.loadServiceProvisionPage = function(tabId) {
-
-};
-
-/**
- * Show node inventory (service page)
- *
- * @param data Data from HTTP request
- */
-hmcPlugin.prototype.loadServiceInventory = function(data) {
-
-};
-
/**
* Load node inventory
*
diff --git a/xCAT-UI/js/custom/ipmi.js b/xCAT-UI/js/custom/ipmi.js
index 86d7d476b..00a2698d0 100644
--- a/xCAT-UI/js/custom/ipmi.js
+++ b/xCAT-UI/js/custom/ipmi.js
@@ -35,33 +35,6 @@ ipmiPlugin.prototype.getNextFunction = function() {
undefined ];
};
-/**
- * Clone node (service page)
- *
- * @param node Node to clone
- */
-ipmiPlugin.prototype.serviceClone = function(node) {
-
-};
-
-/**
- * Load provision page (service page)
- *
- * @param tabId Tab ID where page will reside
- */
-ipmiPlugin.prototype.loadServiceProvisionPage = function(tabId) {
-
-};
-
-/**
- * Show node inventory (service page)
- *
- * @param data Data from HTTP request
- */
-ipmiPlugin.prototype.loadServiceInventory = function(data) {
-
-};
-
/**
* Load node inventory
*
diff --git a/xCAT-UI/js/custom/kvm.js b/xCAT-UI/js/custom/kvm.js
index 5a16c13e4..d8cdc0bd0 100644
--- a/xCAT-UI/js/custom/kvm.js
+++ b/xCAT-UI/js/custom/kvm.js
@@ -26,32 +26,46 @@ kvmPlugin.prototype.loadConfigPage = function(tabId) {
return;
else
$('#kvmConfigUser').append(createLoader(''));
-
- // Get user data
+
loadUserPanel('kvmConfigUser');
});
// Create accordion panel for profiles
var profileSection = $('
');
- profileSection.append(createInfoBar('Create, edit, and delete virtual machine profiles used in the self-service portal'));
var profileLnk = $('').click(function () {
-
+ // Do not load panel again if it is already loaded
+ if ($('#kvmConfigProfile').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#kvmConfigProfile').append(createLoader(''));
+
+ });
+
+ // Create accordion panel for images
+ var imgSection = $('
');
+ var imgLnk = $('').click(function () {
+ // Do not load panel again if it is already loaded
+ if ($('#kvmConfigImages').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#kvmConfigImages').append(createLoader(''));
+
+ queryImages('kvmConfigImages');
});
// Create accordion panel for groups
var groupsSection = $('
');
var groupsLnk = $('').click(function () {
+ // Do not load panel again if it is already loaded
+ if ($('#kvmConfigGroups').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#kvmConfigGroups').append(createLoader(''));
- });
-
- // Create accordion panel for nodes
- var nodeSection = $('
');
- nodeSection.append(createInfoBar('Modify node attributes'));
- var nodeLnk = $('').click(function () {
-
+ queryGroups('kvmConfigGroups');
});
-
- configAccordion.append(userLnk, userSection, profileLnk, profileSection, groupsLnk, groupsSection, nodeLnk, nodeSection);
+
+ configAccordion.append(userLnk, userSection, profileLnk, profileSection, imgLnk, imgSection, groupsLnk, groupsSection);
$('#' + tabId).append(configAccordion);
configAccordion.accordion();
diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js
index 993a82d57..9507bb49e 100644
--- a/xCAT-UI/js/custom/zvmUtils.js
+++ b/xCAT-UI/js/custom/zvmUtils.js
@@ -3324,412 +3324,6 @@ function queryProfiles(panelId) {
});
}
-/**
- * Query the images that exists
- *
- * @param panelId Panel ID
- */
-function queryImages(panelId) {
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'tabdump',
- tgt : '',
- args : 'osimage',
- msg : panelId
- },
-
- success : configImagePanel
- });
-}
-
-/**
- * Query the groups that exists
- *
- * @param panelId Panel ID
- */
-function queryGroups(panelId) {
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'tabdump',
- tgt : '',
- args : 'hosts',
- msg : panelId
- },
-
- success : configGroupPanel
- });
-}
-
-/**
- * Panel to configure groups
- *
- * @param data Data from HTTP request
- */
-function configGroupPanel(data) {
- var panelId = data.msg;
- var rsp = data.rsp;
-
- // Wipe panel clean
- $('#' + panelId).empty();
-
- // Add info bar
- $('#' + panelId).append(createInfoBar('Create, edit, and delete groups for the self-service portal.'));
-
- // Create table
- var tableId = 'zvmGroupTable';
- var table = new DataTable(tableId);
- table.init([' ', 'Name', 'Selectable', 'IP', 'Hostname', 'Network', 'Description']);
-
- // Insert groups into table
- var nodePos = 0;
- var ipPos = 0;
- var hostnamePos = 0;
- var commentsPos = 0;
- var desc, selectable, tmp;
- // Get column index for each attribute
- var colNameArray = rsp[0].substr(1).split(',');
- for (var i in colNameArray){
- switch (colNameArray[i]){
- case 'node':
- nodePos = i;
- break;
-
- case 'ip':
- ipPos = i;
- break;
-
- case 'hostnames':
- hostnamePos = i;
- break;
-
- case 'comments':
- commentsPos = i;
- break;
-
- default :
- break;
- }
- }
-
- // Go through each index
- for (var i = 1; i < rsp.length; i++) {
- // Get image name
- var cols = rsp[i].split(',');
- var name = cols[nodePos].replace(new RegExp('"', 'g'), '');
- var ip = cols[ipPos].replace(new RegExp('"', 'g'), '');
- var hostname = cols[hostnamePos].replace(new RegExp('"', 'g'), '');
- var comments = cols[commentsPos].replace(new RegExp('"', 'g'), '');
-
- // Set default description and selectable
- selectable = "no";
- network = "";
- desc = "No description";
-
- if (comments) {
- tmp = comments.split('|');
- for (var j = 0; j < tmp.length; j++) {
- // Save description
- if (tmp[j].indexOf('description:') > -1) {
- desc = tmp[j].replace('description:', '');
- desc = jQuery.trim(desc);
- }
-
- // Save network
- if (tmp[j].indexOf('network:') > -1) {
- network = tmp[j].replace('network:', '');
- network = jQuery.trim(network);
- }
-
- // Is the group selectable?
- if (tmp[j].indexOf('selectable:') > -1) {
- selectable = tmp[j].replace('selectable:', '');
- selectable = jQuery.trim(selectable);
- }
- }
- }
-
- // Columns are: name, selectable, network, and description
- var cols = new Array(name, selectable, ip, hostname, network, desc);
-
- // Add remove button where id = user name
- cols.unshift(' ');
-
- // Add row
- table.add(cols);
- }
-
- // Append datatable to tab
- $('#' + panelId).append(table.object());
-
- // Turn into datatable
- $('#' + tableId).dataTable({
- 'iDisplayLength': 50,
- 'bLengthChange': false,
- "sScrollX": "100%",
- "bAutoWidth": true
- });
-
- // Create action bar
- var actionBar = $('
');
-
- // Create a group
- var createLnk = $('Create ');
- createLnk.click(function() {
- groupDialog();
- });
-
- // Edit a group
- var editLnk = $('Edit ');
- editLnk.click(function() {
- var groups = $('#' + tableId + ' input[type=checkbox]:checked');
- for (var i in groups) {
- var group = groups.eq(i).attr('name');
- if (group) {
- // Column order is: name, selectable, network, and description
- var cols = groups.eq(i).parents('tr').find('td');
- var selectable = cols.eq(2).text();
- var ip = cols.eq(3).text();
- var hostnames = cols.eq(4).text();
- var network = cols.eq(5).text();
- var description = cols.eq(6).text();
-
- editGroupDialog(group, selectable, ip, hostnames, network, description);
- }
- }
- });
-
- // Delete a profile
- var deleteLnk = $('Delete ');
- deleteLnk.click(function() {
- var groups = getNodesChecked(tableId);
- if (groups) {
- deleteGroupDialog(groups);
- }
- });
-
- // Refresh profiles table
- var refreshLnk = $('Refresh ');
- refreshLnk.click(function() {
- queryGroups(panelId);
- });
-
- // Create an action menu
- var actionsMenu = createMenu([createLnk, editLnk, deleteLnk, refreshLnk]);
- actionsMenu.superfish();
- actionsMenu.css('display', 'inline-block');
- actionBar.append(actionsMenu);
-
- // Set correct theme for action menu
- actionsMenu.find('li').hover(function() {
- setMenu2Theme($(this));
- }, function() {
- setMenu2Normal($(this));
- });
-
- // Create a division to hold actions menu
- var menuDiv = $('');
- $('#' + tableId + '_wrapper').prepend(menuDiv);
- menuDiv.append(actionBar);
- $('#' + tableId + '_filter').appendTo(menuDiv);
-
- // Resize accordion
- $('#zvmConfigAccordion').accordion('resize');
-}
-
-/**
- * Panel to configure OS images
- *
- * @param data Data from HTTP request
- */
-function configImagePanel(data) {
- var panelId = data.msg;
- var rsp = data.rsp;
-
- // Wipe panel clean
- $('#' + panelId).empty();
-
- // Add info bar
- $('#' + panelId).append(createInfoBar('Create, edit, and delete operating system images for the self-service portal.'));
-
- // Create table
- var tableId = 'zvmImageTable';
- var table = new DataTable(tableId);
- table.init([' ', 'Name', 'Selectable', 'OS Version', 'Profile', 'Method', 'Description']);
-
- // Insert images into table
- var imagePos = 0;
- var profilePos = 0;
- var osversPos = 0;
- var osarchPos = 0;
- var provMethodPos = 0;
- var comments = 0;
- var desc, selectable, tmp;
- // Get column index for each attribute
- var colNameArray = rsp[0].substr(1).split(',');
- for (var i in colNameArray){
- switch (colNameArray[i]){
- case 'imagename': {
- imagePos = i;
- }
- break;
-
- case 'profile':{
- profilePos = i;
- }
- break;
-
- case 'osvers':{
- osversPos = i;
- }
- break;
-
- case 'osarch':{
- osarchPos = i;
- }
- break;
-
- case 'comments':{
- comments = i;
- }
- break;
-
- case 'provmethod':{
- provMethodPos = i;
- }
- break;
-
- default :
- break;
- }
- }
-
- // Go through each index
- for (var i = 1; i < rsp.length; i++) {
- // Get image name
- var cols = rsp[i].split(',');
- var name = cols[imagePos].replace(new RegExp('"', 'g'), '');
- var profile = cols[profilePos].replace(new RegExp('"', 'g'), '');
- var provMethod = cols[provMethodPos].replace(new RegExp('"', 'g'), '');
- var osVer = cols[osversPos].replace(new RegExp('"', 'g'), '');
- var osArch = cols[osarchPos].replace(new RegExp('"', 'g'), '');
- var osComments = cols[comments].replace(new RegExp('"', 'g'), '');
-
- // Only save install boot and s390x architectures
- if (osArch == "s390x") {
- // Set default description and selectable
- selectable = "no";
- desc = "No description";
-
- if (osComments) {
- tmp = osComments.split('|');
- for (var j = 0; j < tmp.length; j++) {
- // Save description
- if (tmp[j].indexOf('description:') > -1) {
- desc = tmp[j].replace('description:', '');
- desc = jQuery.trim(desc);
- }
-
- // Is the image selectable?
- if (tmp[j].indexOf('selectable:') > -1) {
- selectable = tmp[j].replace('selectable:', '');
- selectable = jQuery.trim(selectable);
- }
- }
- }
-
- // Columns are: name, selectable, OS version, profile, method, and description
- var cols = new Array(name, selectable, osVer, profile, provMethod, desc);
-
- // Add remove button where id = user name
- cols.unshift(' ');
-
- // Add row
- table.add(cols);
- }
- }
-
- // Append datatable to tab
- $('#' + panelId).append(table.object());
-
- // Turn into datatable
- $('#' + tableId).dataTable({
- 'iDisplayLength': 50,
- 'bLengthChange': false,
- "sScrollX": "100%",
- "bAutoWidth": true
- });
-
- // Create action bar
- var actionBar = $('
');
-
- // Create a profile
- var createLnk = $('Create ');
- createLnk.click(function() {
- imageDialog();
- });
-
- // Edit a profile
- var editLnk = $('Edit ');
- editLnk.click(function() {
- var images = $('#' + tableId + ' input[type=checkbox]:checked');
- for (var i in images) {
- var image = images.eq(i).attr('name');
- if (image) {
- // Column order is: profile, selectable, disk pool, disk size, and directory entry
- var cols = images.eq(i).parents('tr').find('td');
- var selectable = cols.eq(2).text();
- var osVersion = cols.eq(3).text();
- var profile = cols.eq(4).text();
- var method = cols.eq(5).text();
- var description = cols.eq(6).text();
-
- editImageDialog(image, selectable, osVersion, profile, method, description);
- }
- }
- });
-
- // Delete a profile
- var deleteLnk = $('Delete ');
- deleteLnk.click(function() {
- var images = getNodesChecked(tableId);
- if (images) {
- deleteImageDialog(images);
- }
- });
-
- // Refresh profiles table
- var refreshLnk = $('Refresh ');
- refreshLnk.click(function() {
- queryImages(panelId);
- });
-
- // Create an action menu
- var actionsMenu = createMenu([createLnk, editLnk, deleteLnk, refreshLnk]);
- actionsMenu.superfish();
- actionsMenu.css('display', 'inline-block');
- actionBar.append(actionsMenu);
-
- // Set correct theme for action menu
- actionsMenu.find('li').hover(function() {
- setMenu2Theme($(this));
- }, function() {
- setMenu2Normal($(this));
- });
-
- // Create a division to hold actions menu
- var menuDiv = $('');
- $('#' + tableId + '_wrapper').prepend(menuDiv);
- menuDiv.append(actionBar);
- $('#' + tableId + '_filter').appendTo(menuDiv);
-
- // Resize accordion
- $('#zvmConfigAccordion').accordion('resize');
-}
-
/**
* Panel to configure directory entries and disks for a profile
*
@@ -3836,7 +3430,7 @@ function configProfilePanel(panelId) {
$('#' + tableId + '_filter').appendTo(menuDiv);
// Resize accordion
- $('#zvmConfigAccordion').accordion('resize');
+ $('#' + tableId).parents('.ui-accordion').accordion('resize');
// Query directory entries and disk pool/size for each profile
for (var i in profiles) {
@@ -3946,220 +3540,6 @@ function insertDiskInfo(data) {
adjustColumnSize(tableId);
}
-/**
- * Open group dialog
- */
-function groupDialog() {
- // Create form to add profile
- var dialogId = 'zvmCreateGroup';
- var groupForm = $('
');
-
- // Create info bar
- var info = createInfoBar('Provide the following attributes for the group.');
- groupForm.append(info);
-
- var group = $('Group:
');
- var selectable = $('Selectable:
');
- var ip = $('IP:
');
- var hostnames = $('Hostnames:
');
- var network = $('Network:
');
- var comments = $('Description:
');
- groupForm.append(group, selectable, ip, hostnames, network, comments);
-
- // Open dialog to add image
- groupForm.dialog({
- title:'Create group',
- modal: true,
- close: function(){
- $(this).remove();
- },
- width: 400,
- buttons: {
- "Ok": function() {
- // Remove any warning messages
- $(this).find('.ui-state-error').remove();
-
- // Get group attributes
- var group = $(this).find('input[name="group"]');
- var selectable = $(this).find('input[name="selectable"]');
- var ip = $(this).find('input[name="ip"]');
- var hostnames = $(this).find('input[name="hostnames"]');
- var network = $(this).find('input[name="network"]');
- var comments = $(this).find('input[name="comments"]');
-
- // Check that group attributes are provided before continuing
- var ready = 1;
- var inputs = new Array(group, ip, hostnames, network);
- for (var i in inputs) {
- if (!inputs[i].val()) {
- inputs[i].css('border-color', 'red');
- ready = 0;
- } else
- inputs[i].css('border-color', '');
- }
-
- // If inputs are not complete, show warning message
- if (!ready) {
- var warn = createWarnBar('Please provide a value for each missing field.');
- warn.prependTo($(this));
- } else {
- // Change dialog buttons
- $(this).dialog('option', 'buttons', {
- 'Close': function() {$(this).dialog("close");}
- });
-
- // Set default description
- if (!comments.val())
- comments.val('No description');
-
- // Create arguments to send via AJAX
- var args = "updategroup;" + group.val() + ";'" + ip.val() + "';'" + hostnames.val() + "';";
-
- if (selectable.attr("checked"))
- args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:yes";
- else
- args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:no";
-
- // Add image to xCAT
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : args,
- msg : dialogId
- },
-
- success : updatePanel
- });
- }
- },
- "Cancel": function() {
- $(this).dialog( "close" );
- }
- }
- });
-}
-
-/**
- * Open image dialog
- */
-function imageDialog() {
- // Create form to add profile
- var dialogId = 'zvmCreateImage';
- var imageForm = $('
');
-
- // Create info bar
- var info = createInfoBar('Provide the following attributes for the image. The image name will be generated based on the attributes you will give.');
- imageForm.append(info);
-
- var imageName = $('Image name:
');
- var selectable = $('Selectable:
');
- var imageType = $('Image type:
');
- var architecture = $('OS architecture:
');
- var osName = $('OS name:
');
- var osVersion = $('OS version:
');
- var profile = $('Profile:
');
- var provisionMethod = $('Provision method:
');
- var provisionSelect = $(''
- + ' '
- + 'install '
- + 'netboot '
- + 'statelite '
- + ' ');
- provisionMethod.append(provisionSelect);
- var comments = $('Description:
');
- imageForm.append(imageName, selectable, imageType, architecture, osName, osVersion, profile, provisionMethod, comments);
-
- // Open dialog to add image
- imageForm.dialog({
- title:'Create image',
- modal: true,
- close: function(){
- $(this).remove();
- },
- width: 400,
- buttons: {
- "Ok": function() {
- // Remove any warning messages
- $(this).find('.ui-state-error').remove();
-
- // Get image attributes
- var imageType = $(this).find('input[name="imagetype"]');
- var selectable = $(this).find('input[name="selectable"]');
- var architecture = $(this).find('input[name="osarch"]');
- var osName = $(this).find('input[name="osname"]');
- var osVersion = $(this).find('input[name="osvers"]');
- var profile = $(this).find('input[name="profile"]');
- var provisionMethod = $(this).find('select[name="provmethod"]');
- var comments = $(this).find('input[name="comments"]');
-
- // Check that image attributes are provided before continuing
- var ready = 1;
- var inputs = new Array(imageType, architecture, osName, osVersion, profile, provisionMethod);
- for (var i in inputs) {
- if (!inputs[i].val()) {
- inputs[i].css('border-color', 'red');
- ready = 0;
- } else
- inputs[i].css('border-color', '');
- }
-
- // If inputs are not complete, show warning message
- if (!ready) {
- var warn = createWarnBar('Please provide a value for each missing field.');
- warn.prependTo($(this));
- } else {
- // Override image name
- $(this).find('input[name="imagename"]').val(osVersion.val() + '-' + architecture.val() + '-' + provisionMethod.val() + '-' + profile.val());
- var imageName = $(this).find('input[name="imagename"]');
-
- // Change dialog buttons
- $(this).dialog('option', 'buttons', {
- 'Close': function() {$(this).dialog("close");}
- });
-
- // Set default description
- if (!comments.val())
- comments.val('No description');
-
- // Create arguments to send via AJAX
- var args = 'updateosimage;' + imageName.val() + ';' +
- imageType.val() + ';' +
- architecture.val() + ';' +
- osName.val() + ';' +
- osVersion.val() + ';' +
- profile.val() + ';' +
- provisionMethod.val() + ';';
-
- if (selectable.attr('checked'))
- args += '"description:' + comments.val() + '|selectable:yes"';
- else
- args += '"description:' + comments.val() + '|selectable:no"';
-
- // Add image to xCAT
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : args,
- msg : dialogId
- },
-
- success : updatePanel
- });
- }
- },
- "Cancel": function() {
- $(this).dialog( "close" );
- }
- }
- });
-}
-
/**
* Open profile dialog
*/
@@ -4415,354 +3795,4 @@ function editProfileDialog(profile, pool, size, entry) {
}
}
});
-}
-
-/**
- * Open dialog to confirm image delete
- *
- * @param images Images to delete
- */
-function deleteImageDialog(images) {
- // Create form to delete disk to pool
- var dialogId = 'zvmDeleteImage';
- var deleteForm = $('
');
-
- // Create info bar
- var info = createInfoBar('Are you sure you want to delete ' + images.replace(new RegExp(',', 'g'), ', ') + '?');
- deleteForm.append(info);
-
- // Open dialog to delete user
- deleteForm.dialog({
- title:'Delete image',
- modal: true,
- width: 400,
- close: function(){
- $(this).remove();
- },
- buttons: {
- "Ok": function(){
- // Remove any warning messages
- $(this).find('.ui-state-error').remove();
-
- // Change dialog buttons
- $(this).dialog('option', 'buttons', {
- 'Close': function() {$(this).dialog("close");}
- });
-
- // Delete user
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : 'rmosimage;' + images,
- msg : dialogId
- },
- success : updatePanel
- });
- },
- "Cancel": function() {
- $(this).dialog( "close" );
- }
- }
- });
-}
-
-/**
- * Open dialog to confirm group delete
- *
- * @param groups Groups to delete
- */
-function deleteGroupDialog(groups) {
- // Create form to delete disk to pool
- var dialogId = 'zvmDeleteImage';
- var deleteForm = $('
');
-
- // Create info bar
- var info = createInfoBar('Are you sure you want to delete ' + groups.replace(new RegExp(',', 'g'), ', ') + '?');
- deleteForm.append(info);
-
- // Open dialog to delete user
- deleteForm.dialog({
- title:'Delete group',
- modal: true,
- width: 400,
- close: function(){
- $(this).remove();
- },
- buttons: {
- "Ok": function(){
- // Remove any warning messages
- $(this).find('.ui-state-error').remove();
-
- // Change dialog buttons
- $(this).dialog('option', 'buttons', {
- 'Close': function() {$(this).dialog("close");}
- });
-
- // Delete user
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : 'rmgroup;' + groups,
- msg : dialogId
- },
- success : updatePanel
- });
- },
- "Cancel": function() {
- $(this).dialog( "close" );
- }
- }
- });
-}
-
-/**
- * Edit image dialog
- *
- * @param iName Image name
- * @param iSelectable Is image selectable from service page
- * @param iOsVersion OS version
- * @param iProfile Profile name
- * @param iMethod Provisioning method
- * @param iComments Image description
- */
-function editImageDialog(iName, iSelectable, iOsVersion, iProfile, iMethod, iComments) {
- // Create form to add profile
- var dialogId = 'zvmCreateImage';
- var imageForm = $('
');
-
- // Create info bar
- var info = createInfoBar('Provide the following attributes for the image. The image name will be generated based on the attributes you will give.');
- imageForm.append(info);
-
- var imageName = $('Image name:
');
- var selectable = $('Selectable:
');
- var imageType = $('Image type:
');
- var architecture = $('OS architecture:
');
- var osName = $('OS name:
');
- var osVersion = $('OS version:
');
- var profile = $('Profile:
');
- var provisionMethod = $('Provision method:
');
- var provisionSelect = $(''
- + ' '
- + 'install '
- + 'netboot '
- + 'statelite '
- + ' ');
- provisionMethod.append(provisionSelect);
- var comments = $('Description:
');
- imageForm.append(imageName, selectable, imageType, architecture, osName, osVersion, profile, provisionMethod, comments);
-
- // Fill in image attributes
- imageForm.find('input[name="imagename"]').val(iName);
- imageForm.find('input[name="osvers"]').val(iOsVersion);
- imageForm.find('input[name="profile"]').val(iProfile);
- imageForm.find('select[name="provmethod"]').val(iMethod);
- imageForm.find('input[name="comments"]').val(iComments);
- if (iSelectable == "yes")
- imageForm.find('input[name="selectable"]').attr('checked', 'checked');
-
- // Open dialog to add image
- imageForm.dialog({
- title:'Edit image',
- modal: true,
- close: function(){
- $(this).remove();
- },
- width: 400,
- buttons: {
- "Ok": function() {
- // Remove any warning messages
- $(this).find('.ui-state-error').remove();
-
- // Get image attributes
- var imageType = $(this).find('input[name="imagetype"]');
- var selectable = $(this).find('input[name="selectable"]');
- var architecture = $(this).find('input[name="osarch"]');
- var osName = $(this).find('input[name="osname"]');
- var osVersion = $(this).find('input[name="osvers"]');
- var profile = $(this).find('input[name="profile"]');
- var provisionMethod = $(this).find('select[name="provmethod"]');
- var comments = $(this).find('input[name="comments"]');
-
- // Check that image attributes are provided before continuing
- var ready = 1;
- var inputs = new Array(imageType, architecture, osName, osVersion, profile, provisionMethod);
- for (var i in inputs) {
- if (!inputs[i].val()) {
- inputs[i].css('border-color', 'red');
- ready = 0;
- } else
- inputs[i].css('border-color', '');
- }
-
- // If inputs are not complete, show warning message
- if (!ready) {
- var warn = createWarnBar('Please provide a value for each missing field.');
- warn.prependTo($(this));
- } else {
- // Override image name
- $(this).find('input[name="imagename"]').val(osVersion.val() + '-' + architecture.val() + '-' + provisionMethod.val() + '-' + profile.val());
- var imageName = $(this).find('input[name="imagename"]');
-
- // Change dialog buttons
- $(this).dialog('option', 'buttons', {
- 'Close': function() {$(this).dialog("close");}
- });
-
- // Set default description
- if (!comments.val())
- comments.val('No description');
-
- // Create arguments to send via AJAX
- var args = 'updateosimage;' + imageName.val() + ';' +
- imageType.val() + ';' +
- architecture.val() + ';' +
- osName.val() + ';' +
- osVersion.val() + ';' +
- profile.val() + ';' +
- provisionMethod.val() + ';';
-
- if (selectable.attr('checked'))
- args += '"description:' + comments.val() + '|selectable:yes"';
- else
- args += '"description:' + comments.val() + '|selectable:no"';
-
- // Add image to xCAT
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : args,
- msg : dialogId
- },
-
- success : updatePanel
- });
- }
- },
- "Cancel": function() {
- $(this).dialog( "close" );
- }
- }
- });
-}
-
-/**
- * Edit group dialog
- *
- * @param iGroup Group name
- * @param iSelectable Is group selectable from the service page
- * @param iIp Group IP regex
- * @param iHostnames Group hostnames regex
- * @param iNetwork Group network, e.g. 10.1.2.0/24
- * @param iComments Group description
- */
-function editGroupDialog(iGroup, iSelectable, iIp, iHostnames, iNetwork, iComments) {
- // Create form to add profile
- var dialogId = 'zvmCreateGroup';
- var groupForm = $('
');
-
- // Create info bar
- var info = createInfoBar('Provide the following attributes for the group.');
- groupForm.append(info);
-
- var group = $('Group:
');
- var selectable = $('Selectable:
');
- var ip = $('IP:
');
- var hostnames = $('Hostnames:
');
- var network = $('Network:
');
- var comments = $('Description:
');
- groupForm.append(group, selectable, ip, hostnames, network, comments);
-
- // Fill in group attributes
- groupForm.find('input[name="group"]').val(iGroup);
- groupForm.find('input[name="ip"]').val(iIp);
- groupForm.find('input[name="hostnames"]').val(iHostnames);
- groupForm.find('input[name="network"]').val(iNetwork);
- groupForm.find('input[name="comments"]').val(iComments);
- if (iSelectable == "yes")
- groupForm.find('input[name="selectable"]').attr('checked', 'checked');
-
- // Open dialog to add image
- groupForm.dialog({
- title:'Edit group',
- modal: true,
- close: function(){
- $(this).remove();
- },
- width: 400,
- buttons: {
- "Ok": function() {
- // Remove any warning messages
- $(this).find('.ui-state-error').remove();
-
- // Get group attributes
- var group = $(this).find('input[name="group"]');
- var selectable = $(this).find('input[name="selectable"]');
- var ip = $(this).find('input[name="ip"]');
- var hostnames = $(this).find('input[name="hostnames"]');
- var network = $(this).find('input[name="network"]');
- var comments = $(this).find('input[name="comments"]');
-
- // Check that group attributes are provided before continuing
- var ready = 1;
- var inputs = new Array(group, ip, hostnames, network);
- for (var i in inputs) {
- if (!inputs[i].val()) {
- inputs[i].css('border-color', 'red');
- ready = 0;
- } else
- inputs[i].css('border-color', '');
- }
-
- // If inputs are not complete, show warning message
- if (!ready) {
- var warn = createWarnBar('Please provide a value for each missing field.');
- warn.prependTo($(this));
- } else {
- // Change dialog buttons
- $(this).dialog('option', 'buttons', {
- 'Close': function() {$(this).dialog("close");}
- });
-
- // Set default description
- if (!comments.val())
- comments.val('No description');
-
- // Create arguments to send via AJAX
- var args = "updategroup;" + group.val() + ";'" + ip.val() + "';'" + hostnames.val() + "';";
-
- if (selectable.attr("checked"))
- args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:yes";
- else
- args += "'description:" + comments.val() + "|network:" + network.val() + "|selectable:no";
-
- // Add image to xCAT
- $.ajax( {
- url : 'lib/cmd.php',
- dataType : 'json',
- data : {
- cmd : 'webrun',
- tgt : '',
- args : args,
- msg : dialogId
- },
-
- success : updatePanel
- });
- }
- },
- "Cancel": function() {
- $(this).dialog( "close" );
- }
- }
- });
}
\ No newline at end of file