diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js
index 6cda7adde..97b5d708b 100644
--- a/xCAT-UI/js/custom/zvm.js
+++ b/xCAT-UI/js/custom/zvm.js
@@ -35,7 +35,6 @@ zvmPlugin.prototype.loadConfigPage = function(tabId) {
// 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 ($('#zvmConfigProfile').find('.dataTables_wrapper').length)
diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js
index a991dd7be..4ab401a9b 100644
--- a/xCAT-UI/js/custom/zvmUtils.js
+++ b/xCAT-UI/js/custom/zvmUtils.js
@@ -3402,22 +3402,25 @@ function queryProfiles(panelId) {
success : function(data) {
var panelId = data.msg;
setOSImageCookies(data);
- loadConfigProfilePanel(panelId);
+ configProfilePanel(panelId);
}
});
}
/**
- * Load the profiles panel to configure directory entries and disks for a profile
+ * Panel to configure directory entries and disks for a profile
*
* @param panelId
* Panel ID
* @return Nothing
*/
-function loadConfigProfilePanel(panelId) {
- // Remove loader
- $('#' + panelId).find('img[src="images/loader.gif"]').remove();
+function configProfilePanel(panelId) {
+ // Wipe panel clean
+ $('#' + panelId).empty();
+ // Add info bar
+ $('#' + panelId).append(createInfoBar('Create, edit, and delete profiles for the self-service portal. Double-click on a cell to edit a users properties. Click outside the table to save changes. Hit the Escape key to ignore changes.'));
+
// Create table
var tableId = 'zvmProfileTable';
var table = new DataTable(tableId);
@@ -3425,6 +3428,7 @@ function loadConfigProfilePanel(panelId) {
// Insert profiles into table
var profiles = $.cookie('profiles').split(',');
+ profiles.push('default'); // Add default profile
for (var i in profiles) {
if (profiles[i]) {
// Columns are: profile, disk pool, disk size, and directory entry
@@ -3454,7 +3458,7 @@ function loadConfigProfilePanel(panelId) {
var createLnk = $('Create');
createLnk.click(function() {
-
+ profileDialog();
});
var deleteLnk = $('Delete');
@@ -3464,7 +3468,7 @@ function loadConfigProfilePanel(panelId) {
var refreshLnk = $('Refresh');
refreshLnk.click(function() {
-
+ queryProfiles(panelId);
});
// Create an action menu
@@ -3488,4 +3492,168 @@ function loadConfigProfilePanel(panelId) {
// Resize accordion
$('#zvmConfigAccordion').accordion('resize');
+
+ // Query directory entries and disk pool/size for each profile
+ for (var i in profiles) {
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'getdefaultuserentry;' + profiles[i],
+ msg : 'out=' + panelId + ';profile=' + profiles[i]
+ },
+
+ success: insertDirectoryentry
+ });
+
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'getzdiskinfo;' + profiles[i],
+ msg : 'out=' + panelId + ';profile=' + profiles[i]
+ },
+
+ success: insertDiskInfo
+ });
+ }
+}
+
+/**
+ * Insert the directory entry into the profile table
+ *
+ * @param data
+ * Data from HTTP request
+ * @return Nothing
+ */
+function insertDirectoryentry(data) {
+ var tableId = 'zvmProfileTable';
+ var args = data.msg.split(';');
+
+ var panelId = args[0].replace('out=', '');
+ var profile = args[1].replace('profile=', '');
+
+ // Do not continue if there is nothing
+ if (!data.rsp.length)
+ return;
+
+ var entry = data.rsp[0].replace(new RegExp('\n', 'g'), '
');
+
+ // Get the row containing the profile
+ var rowPos = findRow(profile, '#' + tableId, 1);
+ if (rowPos < 0)
+ return;
+
+ // Update the directory entry column
+ var dTable = $('#' + tableId).dataTable();
+ dTable.fnUpdate(entry, rowPos, 4, false);
+
+ // Adjust table styling
+ $('#' + tableId + ' td:nth-child(5)').css({
+ 'text-align': 'left'
+ });
+ adjustColumnSize(tableId);
+}
+
+/**
+ * Insert the disk info into the profile table
+ *
+ * @param data
+ * Data from HTTP request
+ * @return Nothing
+ */
+function insertDiskInfo(data) {
+ var tableId = 'zvmProfileTable';
+ var args = data.msg.split(';');
+
+ var panelId = args[0].replace('out=', '');
+ var profile = args[1].replace('profile=', '');
+
+ // Do not continue if there is nothing
+ if (!data.rsp.length)
+ return;
+
+ // Get the row containing the profile
+ var rowPos = findRow(profile, '#' + tableId, 1);
+ if (rowPos < 0)
+ return;
+
+ // Update the disk info columns
+ var dTable = $('#' + tableId).dataTable();
+
+ var tmp = "";
+ var pool = "";
+ var eckdSize = 0;
+ var info = data.rsp[0].split('\n');
+ for (var i in info) {
+ if (info[i].indexOf('diskpool') > -1) {
+ tmp = info[i].split('=');
+ pool = jQuery.trim(tmp[1]);
+
+ dTable.fnUpdate(pool, rowPos, 2, false);
+ } if (info[i].indexOf('eckd_size') > -1) {
+ tmp = info[i].split('=');
+ eckdSize = jQuery.trim(tmp[1]);
+
+ dTable.fnUpdate(eckdSize, rowPos, 3, false);
+ }
+ }
+
+ // Adjust table styling
+ adjustColumnSize(tableId);
+}
+
+/**
+ * Open profile dialog
+ */
+function profileDialog() {
+ // Create form to add profile
+ var profileForm = $('');
+
+ // Create info bar
+ var info = createInfoBar('Configure the default settings for a profile');
+ profileForm.append(info);
+
+ profileForm.append('');
+ profileForm.append('');
+ profileForm.append('');
+ profileForm.append('');
+
+ // Open dialog to add processor
+ profileForm.dialog({
+ title:'Configure profile',
+ modal: true,
+ close: function(){
+ $(this).remove();
+ },
+ width: 600,
+ buttons: {
+ "Ok": function(){
+ // Remove any warning messages
+ $(this).find('.ui-state-error').remove();
+
+ // Find profile attributes
+ var profile = $(this).find('input[name=profile]').val();
+ var pool = $(this).find('input[name=disk_pool]').val();
+ var size = $(this).find('input[name=disk_size_eckd]').val();
+ var entry = $(this).find('textarea[name=directory_entry]').val();
+
+ // If inputs are not complete, show warning message
+ if (!profile || !pool || !size || !entry) {
+ var warn = createWarnBar('Please provide a value for each missing field.');
+ warn.prependTo($(this));
+ } else {
+ // Close dialog
+ $(this).dialog( "close" );
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
}
\ No newline at end of file
diff --git a/xCAT-UI/xcat/plugins/web.pm b/xCAT-UI/xcat/plugins/web.pm
index 2d506fc0d..87b06d932 100644
--- a/xCAT-UI/xcat/plugins/web.pm
+++ b/xCAT-UI/xcat/plugins/web.pm
@@ -62,6 +62,7 @@ sub process_request {
'addnode' => \&web_addnode,
'graph' => \&web_graphinfo,
'getdefaultuserentry' => \&web_getdefaultuserentry,
+ 'getzdiskinfo' => \&web_getzdiskinfo,
'passwd' => \&web_passwd,
'updateuser' => \&web_updateuser,
'deleteuser' => \&web_deleteuser
@@ -2213,7 +2214,7 @@ sub web_getdefaultuserentry {
# Get default user entry
my ( $request, $callback, $sub_req ) = @_;
- # Get hardware control point
+ # Get profile
my $profile = $request->{arg}->[1];
if (!$profile) {
@@ -2283,4 +2284,26 @@ sub web_deleteuser() {
$callback->( { info => $info } );
return;
}
+
+sub web_getzdiskinfo() {
+ # Get default disk info
+ my ( $request, $callback, $sub_req ) = @_;
+
+ # Get profile
+ my $profile = $request->{arg}->[1];
+
+ if (!$profile) {
+ $profile = 'default';
+ }
+
+ my $info;
+ if (!(`test -e /var/opt/xcat/profiles/$profile.conf && echo 'File exists'`)) {
+ $info = `cat /var/opt/xcat/profiles/default.conf`;
+ } else {
+ $info = `cat /var/opt/xcat/profiles/$profile.conf`;
+ }
+
+ $callback->( { info => $info } );
+}
+
1;