From 57b7c99c0f661f49c09b934762320a1721d265b5 Mon Sep 17 00:00:00 2001 From: phamt Date: Wed, 11 Apr 2012 22:33:50 +0000 Subject: [PATCH] Moved profile configuration and directory entry onto the xCAT MN under /var/opt/xcat/profiles. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12203 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/configure/service.js | 2 +- xCAT-UI/js/custom/zvm.js | 11 ++- xCAT-UI/js/custom/zvmUtils.js | 109 ++++++++++++++++++++++++++++++ xCAT-UI/xcat/plugins/webportal.pm | 60 ++++++---------- 4 files changed, 138 insertions(+), 44 deletions(-) diff --git a/xCAT-UI/js/configure/service.js b/xCAT-UI/js/configure/service.js index 4ab53ecd2..db749c145 100644 --- a/xCAT-UI/js/configure/service.js +++ b/xCAT-UI/js/configure/service.js @@ -143,7 +143,7 @@ function loadUserTable(data) { var table = new DataTable(tableId); // Add column for the checkbox - headers.unshift(''); + headers.unshift(''); table.init(headers); headers.shift(); diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js index 2dc03c6da..6cda7adde 100644 --- a/xCAT-UI/js/custom/zvm.js +++ b/xCAT-UI/js/custom/zvm.js @@ -29,8 +29,7 @@ zvmPlugin.prototype.loadConfigPage = function(tabId) { return; else $('#zvmConfigUser').append(createLoader('')); - - // Get user data + loadUserPanel('zvmConfigUser'); }); @@ -38,7 +37,13 @@ zvmPlugin.prototype.loadConfigPage = function(tabId) { var profileSection = $('
'); profileSection.append(createInfoBar('Create, edit, and delete virtual machine profiles used in the self-service portal')); var profileLnk = $('

Profiles

').click(function () { - + // Do not load panel again if it is already loaded + if ($('#zvmConfigProfile').find('.dataTables_wrapper').length) + return; + else + $('#zvmConfigProfile').append(createLoader('')); + + queryProfiles('zvmConfigProfile'); }); // Create accordion panel for nodes diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index ffaad4923..c12e5702f 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -3359,4 +3359,113 @@ function createzVM(tabId, group, hcp, img, owner) { // webportal provzlinux [group] [hcp] [image] [owner] var iframe = createIFrame('lib/srv_cmd.php?cmd=webportal&tgt=&args=provzlinux;' + group + ';' + hcp + ';' + img + ';' + owner + '&msg=&opts=flush'); iframe.prependTo($('#' + tabId)); +} + +/** + * Query the profiles that exists + * + * @param panelId + * Panel ID + * @return Nothing + */ +function queryProfiles(panelId) { + $.ajax( { + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'tabdump', + tgt : '', + args : 'osimage', + msg : panelId + }, + + success : function(data) { + var panelId = data.msg; + setOSImageCookies(data); + loadConfigProfilePanel(panelId); + } + }); +} + +/** + * Load the profiles 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(); + + // Create table + var tableId = 'zvmProfileTable'; + var table = new DataTable(tableId); + table.init(['', 'Profile', 'Disk pool', 'Disk size', 'Directory entry']); + + // Insert profiles into table + var profiles = $.cookie('profiles').split(','); + for (var i in profiles) { + if (profiles[i]) { + // Columns are: profile, disk pool, disk size, and directory entry + var cols = new Array(profiles[i], '', '', ''); + + // 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 + var dTable = $('#' + tableId).dataTable({ + 'iDisplayLength': 50, + 'bLengthChange': false, + "sScrollX": "100%", + "bAutoWidth": true + }); + + // Create action bar + var actionBar = $('
'); + + var createLnk = $('Create'); + createLnk.click(function() { + + }); + + var deleteLnk = $('Delete'); + deleteLnk.click(function() { + + }); + + var refreshLnk = $('Refresh'); + refreshLnk.click(function() { + + }); + + // Create an action menu + var actionsMenu = createMenu([createLnk, 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'); } \ No newline at end of file diff --git a/xCAT-UI/xcat/plugins/webportal.pm b/xCAT-UI/xcat/plugins/webportal.pm index 16c1f8b90..c40761ee7 100644 --- a/xCAT-UI/xcat/plugins/webportal.pm +++ b/xCAT-UI/xcat/plugins/webportal.pm @@ -135,66 +135,49 @@ sub provzlinux { my $disk_pool; my $eckd_size; my $fba_size; - my $default_conf = '/opt/zhcp/conf/default.conf'; - my $default_direct = "/opt/zhcp/conf/profiles/$profile.direct"; + my $default_conf = "/var/opt/xcat/profiles/$profile.conf"; + my $default_direct = "/var/opt/xcat/profiles/$profile.direct"; # Check if a group based directory entry exists, else use default one - if ( !(`ssh $hcp "test -e /opt/zhcp/conf/profiles/$profile.direct && echo Exists"`) ) { + if ( !(`test -e /var/opt/xcat/profiles/$profile.direct && echo Exists`) ) { println( $callback, "$profile.direct does not exist. Using default.direct to generate directory entry." ); # Exit if default.direct does not exist - $default_direct = '/opt/zhcp/conf/profiles/default.direct'; - if ( !(`ssh $hcp "test -e /opt/zhcp/conf/profiles/default.direct && echo Exists"`) ) { + $default_direct = '/var/opt/xcat/profiles/default.direct'; + if ( !(`test -e /var/opt/xcat/profiles/default.direct && echo Exists`) ) { println( $callback, '(Error) $default_direct does not exists' ); return; } } # Exit if default.conf does not exist - if ( !(`ssh $hcp "test -e $default_conf && echo Exists"`) ) { + if ( !(`test -e $default_conf && echo Exists`) ) { println( $callback, '(Error) $default_conf does not exists' ); return; } # Exit if default.direct does not exist - if ( !(`ssh $hcp "test -e $default_direct && echo Exists"`) ) { + if ( !(`test -e $default_direct && echo Exists`) ) { println( $callback, '(Error) $default_direct does not exists' ); return; } - $out = `ssh $hcp "cat $default_conf"`; + $out = `cat $default_conf`; @tmp = split( /\n/, $out ); # default.conf should contain: - # Default configuration for virtual machines handled by this zHCP + # Configuration for virtual machines # default_diskpool=POOL3 # default_eckd_size=10016 - # compute_diskpool=POOL3 - # compute_eckd_size=10016 my $profile_diskpool_parm = $profile . "_diskpool"; my $profile_eckd_size_parm = $profile . "_eckd_size"; my $profile_fba_size_parm = $profile . "_fba_size"; my $default_disk_pool; my $default_eckd_size; my $default_fba_size; - foreach (@tmp) { - # Get disk pool (default) - if ( $_ =~ m/default_diskpool=/i ) { - $default_disk_pool = $_; - $default_disk_pool =~ s/default_diskpool=//g; - } - # Get disk size (default) - elsif ( $_ =~ m/default_eckd_size=/i ) { - $default_eckd_size = $_; - $default_eckd_size =~ s/default_eckd_size=//g; - } - elsif ( $_ =~ m/default_fba_size=/i ) { - $default_fba_size = $_; - $default_fba_size =~ s/default_fba_size=//g; - } - + foreach (@tmp) { # Get profile disk pool (default) - elsif ( $_ =~ m/$profile_diskpool_parm=/i ) { + if ( $_ =~ m/$profile_diskpool_parm=/i ) { $disk_pool = $_; $disk_pool =~ s/$profile_diskpool_parm=//g; } @@ -211,11 +194,8 @@ sub provzlinux { # Use default configuration if profile configuration does not exist if (!$disk_pool && (!$eckd_size || !$fba_size)) { - println( $callback, "$profile configuration for disk pool and size does not exist. Using default configuration." ); - - $disk_pool = $default_disk_pool; - $eckd_size = $default_eckd_size; - $fba_size = $default_fba_size; + println( $callback, "(Error) $profile configuration for disk pool and size does not exist" ); + return; } my $site_tab = xCAT::Table->new('site'); @@ -263,7 +243,7 @@ sub provzlinux { # USER LXUSR PSWD 512M 1G G # INCLUDE LNXDFLT # COMMAND SET VSWITCH VSW2 GRANT LXUSR - $out = `ssh $hcp "sed $default_direct -e s/LXUSR/$userid/g" > /tmp/$node-direct.txt`; + $out = `sed $default_direct -e s/LXUSR/$userid/g > /tmp/$node-direct.txt`; $out = `mkvm $node /tmp/$node-direct.txt`; `rm -rf /tmp/$node-direct.txt`; println( $callback, "$out" ); @@ -648,26 +628,26 @@ sub clonezlinux { my $arch = $props->{'arch'}; my $profile = $props->{'profile'}; - # Read in default disk pool from /opt/zhcp/conf/default.conf on zHCP + # Read in default disk pool from /var/opt/xcat/profiles/default.conf on xCAT MN # pool = POOL3 # eckd_size = 10016 my $disk_pool; - my $default_conf = '/opt/zhcp/conf/default.conf'; - my $default_direct = '/opt/zhcp/conf/profiles/default.direct'; + my $default_conf = '/var/opt/xcat/profiles/default.conf'; + my $default_direct = '/var/opt/xcat/profiles/default.direct'; # Exit if default.conf does not exist - if ( !(`ssh $hcp "test -e $default_conf && echo Exists"`) ) { + if ( !(`test -e $default_conf && echo Exists`) ) { println( $callback, '(Error) $default_conf does not exists' ); return; } # Exit if default.direct does not exist - if ( !(`ssh $hcp "test -e $default_direct && echo Exists"`) ) { + if ( !(`test -e $default_direct && echo Exists`) ) { println( $callback, '(Error) $default_direct does not exists' ); return; } - $out = `ssh $hcp "cat $default_conf"`; + $out = `cat $default_conf`; @tmp = split( /\n/, $out ); # default.conf should contain: