Added groups panel in service config tab. Added create, edit, and delete functionality into zVM service profile config panel. Removed /opt/xcat from .spec file.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12286 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
0825693212
commit
4dc359e733
@ -40,6 +40,12 @@ esxPlugin.prototype.loadConfigPage = function(tabId) {
|
||||
|
||||
});
|
||||
|
||||
// Create accordion panel for groups
|
||||
var groupsSection = $('<div id="esxConfigGroups"></div>');
|
||||
var groupsLnk = $('<h3><a href="#">Groups</a></h3>').click(function () {
|
||||
|
||||
});
|
||||
|
||||
// Create accordion panel for nodes
|
||||
var nodeSection = $('<div id="esxConfigNode"></div>');
|
||||
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();
|
||||
|
||||
|
@ -40,6 +40,12 @@ kvmPlugin.prototype.loadConfigPage = function(tabId) {
|
||||
|
||||
});
|
||||
|
||||
// Create accordion panel for groups
|
||||
var groupsSection = $('<div id="kvmConfigGroups"></div>');
|
||||
var groupsLnk = $('<h3><a href="#">Groups</a></h3>').click(function () {
|
||||
|
||||
});
|
||||
|
||||
// Create accordion panel for nodes
|
||||
var nodeSection = $('<div id="kvmConfigNode"></div>');
|
||||
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();
|
||||
|
||||
|
@ -45,6 +45,18 @@ zvmPlugin.prototype.loadConfigPage = function(tabId) {
|
||||
queryProfiles('zvmConfigProfile');
|
||||
});
|
||||
|
||||
// Create accordion panel for groups
|
||||
var groupsSection = $('<div id="zvmConfigGroups"></div>');
|
||||
var groupsLnk = $('<h3><a href="#">Groups</a></h3>').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 = $('<div id="zvmConfigNode"></div>');
|
||||
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();
|
||||
|
||||
|
@ -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 = $('<div class="actionBar"></div>');
|
||||
|
||||
// Create a profile
|
||||
var createLnk = $('<a>Create</a>');
|
||||
createLnk.click(function() {
|
||||
profileDialog();
|
||||
});
|
||||
|
||||
// Edit a profile
|
||||
var editLnk = $('<a>Edit</a>');
|
||||
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('<br>', 'g'), '\n');
|
||||
|
||||
openEditProfileDialog(profile, pool, size, entry);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Delete a profile
|
||||
var deleteLnk = $('<a>Delete</a>');
|
||||
deleteLnk.click(function() {
|
||||
|
||||
var profiles = getNodesChecked(tableId);
|
||||
if (profiles) {
|
||||
openDeleteProfileDialog(profiles);
|
||||
}
|
||||
});
|
||||
|
||||
// Refresh profiles table
|
||||
var refreshLnk = $('<a>Refresh</a>');
|
||||
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 = $('<div class="form"></div>');
|
||||
var dialogId = 'zvmCreateProfile';
|
||||
var profileForm = $('<div id="' + dialogId + '" class="form"></div>');
|
||||
|
||||
// Create info bar
|
||||
var info = createInfoBar('Configure the default settings for a profile');
|
||||
profileForm.append(info);
|
||||
|
||||
profileForm.append('<div><label>Profile:</label><input type="text" name="profile"/></div>');
|
||||
// Insert profiles into select
|
||||
var profileSelect = $('<select name="profile"></select>');
|
||||
var profiles = $.cookie('profiles').split(',');
|
||||
profiles.push('default'); // Add default profile
|
||||
for (var i in profiles) {
|
||||
if (profiles[i]) {
|
||||
profileSelect.append($('<option>' + profiles[i] + '</option>'));
|
||||
}
|
||||
}
|
||||
|
||||
profileForm.append($('<div><label>Profile:</label></div>').append(profileSelect));
|
||||
profileForm.append('<div><label>Disk pool:</label><input type="text" name="disk_pool"/></div>');
|
||||
profileForm.append('<div><label>Disk size (ECKD):</label><input type="text" name="disk_size_eckd"/></div>');
|
||||
profileForm.append('<div><label style="vertical-align: top;">Directory entry:</label><textarea name="directory_entry"/></div>');
|
||||
@ -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 = $('<div id="' + dialogId + '" class="form"></div>');
|
||||
|
||||
// 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 = $('<div id="' + dialogId + '" class="form"></div>');
|
||||
|
||||
// Create info bar
|
||||
var info = createInfoBar('Configure the default settings for a profile');
|
||||
profileForm.append(info);
|
||||
|
||||
// Insert profiles into select
|
||||
var profileSelect = $('<select name="profile"></select>');
|
||||
var profiles = $.cookie('profiles').split(',');
|
||||
profiles.push('default'); // Add default profile
|
||||
for (var i in profiles) {
|
||||
if (profiles[i]) {
|
||||
profileSelect.append($('<option value="' + profiles[i] + '">' + profiles[i] + '</option>'));
|
||||
}
|
||||
}
|
||||
|
||||
profileForm.append($('<div><label>Profile:</label></div>').append(profileSelect));
|
||||
profileForm.append('<div><label>Disk pool:</label><input type="text" name="disk_pool"/></div>');
|
||||
profileForm.append('<div><label>Disk size (ECKD):</label><input type="text" name="disk_size_eckd"/></div>');
|
||||
profileForm.append('<div><label style="vertical-align: top;">Directory entry:</label><textarea name="directory_entry"/></div>');
|
||||
|
||||
// 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() {
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user