diff --git a/xCAT-UI/js/custom/esx.js b/xCAT-UI/js/custom/esx.js
index 79f74bc00..2caa2bb5b 100644
--- a/xCAT-UI/js/custom/esx.js
+++ b/xCAT-UI/js/custom/esx.js
@@ -40,6 +40,12 @@ esxPlugin.prototype.loadConfigPage = function(tabId) {
});
+ // Create accordion panel for groups
+ var groupsSection = $('
');
+ var groupsLnk = $('').click(function () {
+
+ });
+
// Create accordion panel for nodes
var nodeSection = $('');
nodeSection.append(createInfoBar('Modify node attributes'));
@@ -47,7 +53,7 @@ esxPlugin.prototype.loadConfigPage = function(tabId) {
});
- configAccordion.append(userLnk, userSection, profileLnk, profileSection, nodeLnk, nodeSection);
+ configAccordion.append(userLnk, userSection, profileLnk, profileSection, groupsLnk, groupsSection, nodeLnk, nodeSection);
$('#' + tabId).append(configAccordion);
configAccordion.accordion();
diff --git a/xCAT-UI/js/custom/kvm.js b/xCAT-UI/js/custom/kvm.js
index c81c906a4..f534c5625 100644
--- a/xCAT-UI/js/custom/kvm.js
+++ b/xCAT-UI/js/custom/kvm.js
@@ -40,6 +40,12 @@ kvmPlugin.prototype.loadConfigPage = function(tabId) {
});
+ // Create accordion panel for groups
+ var groupsSection = $('');
+ var groupsLnk = $('').click(function () {
+
+ });
+
// Create accordion panel for nodes
var nodeSection = $('');
nodeSection.append(createInfoBar('Modify node attributes'));
@@ -47,7 +53,7 @@ kvmPlugin.prototype.loadConfigPage = function(tabId) {
});
- configAccordion.append(userLnk, userSection, profileLnk, profileSection, nodeLnk, nodeSection);
+ configAccordion.append(userLnk, userSection, profileLnk, profileSection, groupsLnk, groupsSection, nodeLnk, nodeSection);
$('#' + tabId).append(configAccordion);
configAccordion.accordion();
diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js
index 97b5d708b..7e1da9090 100644
--- a/xCAT-UI/js/custom/zvm.js
+++ b/xCAT-UI/js/custom/zvm.js
@@ -45,6 +45,18 @@ zvmPlugin.prototype.loadConfigPage = function(tabId) {
queryProfiles('zvmConfigProfile');
});
+ // Create accordion panel for groups
+ var groupsSection = $('');
+ var groupsLnk = $('').click(function () {
+ // Do not load panel again if it is already loaded
+ if ($('#zvmConfigGroups').find('.dataTables_wrapper').length)
+ return;
+ else
+ $('#zvmConfigGroups').append(createLoader(''));
+
+// queryGroups('zvmConfigGroups');
+ });
+
// Create accordion panel for nodes
var nodeSection = $('');
nodeSection.append(createInfoBar('Modify node attributes'));
@@ -52,7 +64,7 @@ zvmPlugin.prototype.loadConfigPage = function(tabId) {
});
- configAccordion.append(userLnk, userSection, profileLnk, profileSection, nodeLnk, nodeSection);
+ configAccordion.append(userLnk, userSection, profileLnk, profileSection, groupsLnk, groupsSection, nodeLnk, nodeSection);
$('#' + tabId).append(configAccordion);
configAccordion.accordion();
diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js
index d0594924c..6fb81071f 100644
--- a/xCAT-UI/js/custom/zvmUtils.js
+++ b/xCAT-UI/js/custom/zvmUtils.js
@@ -3419,7 +3419,7 @@ function configProfilePanel(panelId) {
$('#' + 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.'));
+ $('#' + panelId).append(createInfoBar('Create, edit, and delete profiles for the self-service portal. It is important to note the default z/VM user ID for any profile should be LXUSR.'));
// Create table
var tableId = 'zvmProfileTable';
@@ -3456,23 +3456,47 @@ function configProfilePanel(panelId) {
// Create action bar
var actionBar = $('');
+ // Create a profile
var createLnk = $('Create');
createLnk.click(function() {
profileDialog();
});
+
+ // Edit a profile
+ var editLnk = $('Edit');
+ editLnk.click(function() {
+ var profiles = $('#' + tableId + ' input[type=checkbox]:checked');
+ for (var i in profiles) {
+ var profile = profiles.eq(i).attr('name');
+ if (profile) {
+ // Column order is: profile, selectable, disk pool, disk size, and directory entry
+ var cols = profiles.eq(i).parents('tr').find('td');
+ var pool = cols.eq(3).text();
+ var size = cols.eq(4).text();
+ var entry = cols.eq(5).html().replace(new RegExp('
', 'g'), '\n');
+
+ openEditProfileDialog(profile, pool, size, entry);
+ }
+ }
+ });
+ // Delete a profile
var deleteLnk = $('Delete');
deleteLnk.click(function() {
-
+ var profiles = getNodesChecked(tableId);
+ if (profiles) {
+ openDeleteProfileDialog(profiles);
+ }
});
+ // Refresh profiles table
var refreshLnk = $('Refresh');
refreshLnk.click(function() {
queryProfiles(panelId);
});
// Create an action menu
- var actionsMenu = createMenu([createLnk, deleteLnk, refreshLnk]);
+ var actionsMenu = createMenu([createLnk, editLnk, deleteLnk, refreshLnk]);
actionsMenu.superfish();
actionsMenu.css('display', 'inline-block');
actionBar.append(actionsMenu);
@@ -3505,7 +3529,7 @@ function configProfilePanel(panelId) {
msg : 'out=' + panelId + ';profile=' + profiles[i]
},
- success: insertDirectoryentry
+ success: insertDirectoryEntry
});
$.ajax({
@@ -3530,7 +3554,7 @@ function configProfilePanel(panelId) {
* Data from HTTP request
* @return Nothing
*/
-function insertDirectoryentry(data) {
+function insertDirectoryEntry(data) {
var tableId = 'zvmProfileTable';
var args = data.msg.split(';');
@@ -3612,13 +3636,24 @@ function insertDiskInfo(data) {
*/
function profileDialog() {
// Create form to add profile
- var profileForm = $('');
+ var dialogId = 'zvmCreateProfile';
+ var profileForm = $('');
// Create info bar
var info = createInfoBar('Configure the default settings for a profile');
profileForm.append(info);
- profileForm.append('');
+ // Insert profiles into select
+ var profileSelect = $('');
+ var profiles = $.cookie('profiles').split(',');
+ profiles.push('default'); // Add default profile
+ for (var i in profiles) {
+ if (profiles[i]) {
+ profileSelect.append($(''));
+ }
+ }
+
+ profileForm.append($('').append(profileSelect));
profileForm.append('');
profileForm.append('');
profileForm.append('');
@@ -3637,7 +3672,7 @@ function profileDialog() {
$(this).find('.ui-state-error').remove();
// Find profile attributes
- var profile = $(this).find('input[name=profile]').val();
+ var profile = $(this).find('select[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();
@@ -3646,9 +3681,211 @@ function profileDialog() {
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" );
+ } else {
+ // Change dialog buttons
+ $('#' + dialogId).dialog('option', 'buttons', {
+ 'Close':function(){
+ $(this).dialog('close');
+ }
+ });
+
+ // Write file to /var/tmp
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'write',
+ tgt : '/var/tmp/' + profile + '.direct',
+ args : '',
+ cont : entry,
+ msg : dialogId + ';' + profile + ';' + pool + ';' + size
+ },
+
+ success : function(data) {
+ var args = data.msg.split(';');
+
+ // Create profile in xCAT
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'mkzprofile;' + args[1] + ';' + args[2] + ';' + args[3],
+ msg : args[0]
+ },
+
+ success: updatePanel
+ });
+ }
+ });
+ }
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Open dialog to confirm profile delete
+ *
+ * @param profiles
+ * Profiles to delete
+ * @return Nothing
+ */
+function openDeleteProfileDialog(profiles) {
+ // Create form to delete disk to pool
+ var dialogId = 'zvmDeleteProfile';
+ var deleteForm = $('');
+
+ // Create info bar
+ var info = createInfoBar('Are you sure you want to delete ' + profiles.replace(new RegExp(',', 'g'), ', ') + '?');
+ deleteForm.append(info);
+
+ // Open dialog to delete user
+ deleteForm.dialog({
+ title:'Delete user',
+ 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 : 'rmzprofile;' + profiles,
+ msg : dialogId
+ },
+ success : updatePanel
+ });
+ },
+ "Cancel": function() {
+ $(this).dialog( "close" );
+ }
+ }
+ });
+}
+
+/**
+ * Open dialog to edit profile
+ *
+ * @param profile
+ * Profile to edit
+ * @param pool
+ * Disk pool
+ * @param size
+ * Disk size
+ * @param entry
+ * Directory entry
+ * @return Nothing
+ */
+function openEditProfileDialog(profile, pool, size, entry) {
+ // Create form to add profile
+ var dialogId = 'zvmEditProfile_' + profile;
+ var profileForm = $('');
+
+ // Create info bar
+ var info = createInfoBar('Configure the default settings for a profile');
+ profileForm.append(info);
+
+ // Insert profiles into select
+ var profileSelect = $('');
+ var profiles = $.cookie('profiles').split(',');
+ profiles.push('default'); // Add default profile
+ for (var i in profiles) {
+ if (profiles[i]) {
+ profileSelect.append($(''));
+ }
+ }
+
+ profileForm.append($('').append(profileSelect));
+ profileForm.append('');
+ profileForm.append('');
+ profileForm.append('');
+
+ // Insert profile values
+ profileSelect.val(profile);
+ profileForm.find('input[name=disk_pool]').val(pool);
+ profileForm.find('input[name=disk_size_eckd]').val(size);
+ profileForm.find('textarea[name=directory_entry]').val(entry);
+
+ // 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('select[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 {
+ // Change dialog buttons
+ $('#' + dialogId).dialog('option', 'buttons', {
+ 'Close':function(){
+ $(this).dialog('close');
+ }
+ });
+
+ // Write file to /var/tmp
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'write',
+ tgt : '/var/tmp/' + profile + '.direct',
+ args : '',
+ cont : entry,
+ msg : dialogId + ';' + profile + ';' + pool + ';' + size
+ },
+
+ success : function(data) {
+ var args = data.msg.split(';');
+
+ // Create profile in xCAT
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'mkzprofile;' + args[1] + ';' + args[2] + ';' + args[3],
+ msg : args[0]
+ },
+
+ success: updatePanel
+ });
+ }
+ });
}
},
"Cancel": function() {
diff --git a/xCAT-UI/lib/cmd.php b/xCAT-UI/lib/cmd.php
index 7fde777f3..d040fe499 100644
--- a/xCAT-UI/lib/cmd.php
+++ b/xCAT-UI/lib/cmd.php
@@ -21,6 +21,11 @@ if (isset($_GET["cmd"])) {
$tgt = $_GET["tgt"];
$args = $_GET["args"];
+ // File contents in case of file write
+ if (isset($_GET["cont"])) {
+ $cont = $_GET["cont"];
+ }
+
// Special messages put here
// This gets sent back to the AJAX request as is.
$msg = $_GET["msg"];
@@ -85,6 +90,17 @@ if (isset($_GET["cmd"])) {
// This command gets the nodes and groups
else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
$rsp = extractExtnoderange($xml);
+ }
+ // Write contents to file
+ else if(strncasecmp($cmd, "write", 4) == 0) {
+ // Directory should be /var/opt/xcat/profiles
+ // You can write anything to that directory
+ $file = "$tgt";
+ $handle = fopen($file, 'w') or die("Cannot open $file");
+ fwrite($handle, $cont);
+ fclose($handle);
+
+ $rsp = "Directory entry written to $file";
}
// Handle the typical output
else {
diff --git a/xCAT-UI/xCAT-UI.spec b/xCAT-UI/xCAT-UI.spec
index 2bf98abae..560acd7fa 100644
--- a/xCAT-UI/xCAT-UI.spec
+++ b/xCAT-UI/xCAT-UI.spec
@@ -142,9 +142,9 @@ chmod 755 $RPM_BUILD_ROOT%{prefix}/ui/*
if [ "$1" = 1 ] || [ "$1" = 2 ] # Install or upgrade
then
# Copy xCAT plugins to /opt/xcat/lib/perl/xCAT_plugin
- cp %{prefix}/ui/xcat/plugins/web.pm /opt/xcat/lib/perl/xCAT_plugin/
- cp %{prefix}/ui/xcat/plugins/webportal.pm /opt/xcat/lib/perl/xCAT_plugin/
- /bin/ln -s /opt/xcat/bin/xcatclientnnr /opt/xcat/bin/webportal
+ cp %{prefix}/ui/xcat/plugins/web.pm ../lib/perl/xCAT_plugin/
+ cp %{prefix}/ui/xcat/plugins/webportal.pm ../lib/perl/xCAT_plugin/
+ /bin/ln -s ../bin/xcatclientnnr ../bin/webportal
/etc/init.d/xcatd restart
# Copy php.ini file into /opt/xcat/ui and turn off output_buffering
@@ -167,7 +167,7 @@ chmod 755 $RPM_BUILD_ROOT%{prefix}/ui/*
echo "Updating IBM HTTP server configuration for xCAT..."
bin/rm -f /usr/IBM/HTTPServer/conf/xcat-ui.conf
cp /usr/IBM/HTTPServer/conf/httpd.conf /usr/IBM/HTTPServer/conf/httpd.conf.xcat.ui.bak
- cat /opt/xcat/ui/etc/apache2/conf.d/xcat-ui.conf >> /usr/IBM/HTTPServer/conf/httpd.conf
+ cat ../ui/etc/apache2/conf.d/xcat-ui.conf >> /usr/IBM/HTTPServer/conf/httpd.conf
/usr/IBM/HTTPServer/bin/apachectl restart
# Put the encrypted password in /etc/security/passwd into the xcat passwd database
diff --git a/xCAT-UI/xcat/plugins/web.pm b/xCAT-UI/xcat/plugins/web.pm
index ea97b5c90..ad3754b5c 100644
--- a/xCAT-UI/xcat/plugins/web.pm
+++ b/xCAT-UI/xcat/plugins/web.pm
@@ -65,7 +65,9 @@ sub process_request {
'getzdiskinfo' => \&web_getzdiskinfo,
'passwd' => \&web_passwd,
'updateuser' => \&web_updateuser,
- 'deleteuser' => \&web_deleteuser
+ 'deleteuser' => \&web_deleteuser,
+ 'mkzprofile' => \&web_mkzprofile,
+ 'rmzprofile' => \&web_rmzprofile
);
#check whether the request is authorized or not
@@ -2306,4 +2308,46 @@ sub web_getzdiskinfo() {
$callback->( { info => $info } );
}
+sub web_mkzprofile() {
+ # Create default profile
+ my ( $request, $callback, $sub_req ) = @_;
+
+ # Get profile
+ my $profile = $request->{arg}->[1];
+ my $pool = $request->{arg}->[2];
+ my $size = $request->{arg}->[3];
+
+ # Create profile under /var/opt/xcat/profiles
+ my $var = "";
+ `echo "# Configuration for virtual machines" > /var/opt/xcat/profiles/$profile.conf`;
+ $var = $profile . "_diskpool";
+ `echo "$var=$pool" >> /var/opt/xcat/profiles/$profile.conf`;
+ $var = $profile . "_eckd_size";
+ `echo "$var=$size" >> /var/opt/xcat/profiles/$profile.conf`;
+
+ # Move directory entry into /var/opt/xcat/profiles from /var/tmp
+ `mv /var/tmp/$profile.direct /var/opt/xcat/profiles`;
+
+ my $info = "Profile successfully created/updated";
+ $callback->( { info => $info } );
+}
+
+sub web_rmzprofile() {
+ # Delete default profile
+ my ( $request, $callback, $sub_req ) = @_;
+
+ # Get profile
+ my $profile = $request->{arg}->[1];
+ my @profiles = split( ',', $profile );
+
+ # Delete profile under /var/opt/xcat/profiles
+ foreach(@profiles) {
+ `rm /var/opt/xcat/profiles/$_.conf`;
+ `rm /var/opt/xcat/profiles/$_.direct`;
+ }
+
+ my $info = "Profile successfully deleted";
+ $callback->( { info => $info } );
+}
+
1;