');
+ var hwAttr = $('');
hwFS.append($(''));
hwFS.append(hwAttr);
+
+ // Create tabs for basic and advanced hardware configuration
+ var hwTab = new Tab('hwConfig' + inst);
+ hwTab.init();
+ hwAttr.append(hwTab.object());
var osAttr = $('');
osFS.append($(''));
@@ -4853,7 +4858,7 @@ function createZProvisionNew(inst) {
var args = $(this).val().split('.');
if (!$.cookie(args[0] + 'diskpools')) {
// Get disk pools
- $.ajax( {
+ $.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
@@ -4869,7 +4874,7 @@ function createZProvisionNew(inst) {
if (!$.cookie(args[0] + 'zfcppools')) {
// Get zFCP pools
- $.ajax( {
+ $.ajax({
url : 'lib/cmd.php',
dataType : 'json',
data : {
@@ -4882,6 +4887,80 @@ function createZProvisionNew(inst) {
success : setZfcpPoolCookies
});
}
+
+ if (!$.cookie(args[0] + 'userprofiles')) {
+ // Get zFCP pools
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ async: false,
+ data : {
+ cmd : 'lsvm',
+ tgt : args[0],
+ args : '--userprofilenames',
+ msg : args[0]
+ },
+
+ success : setUserProfilesCookies
+ });
+ }
+
+ if (!$.cookie(args[0] + 'networks') || $.cookie(args[0] + 'networks') === null) {
+ // Get network names
+ $.ajax( {
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ async: false,
+ data : {
+ cmd : 'lsvm',
+ tgt : args[0],
+ args : '--getnetworknames',
+ msg : args[0]
+ },
+
+ success : setNetworkCookies
+ });
+ }
+
+ // Reset user profile and network drop down box
+ var thisTabId = $(this).parents('.tab').attr('id');
+ var thisUserProfile = $('#' + thisTabId + ' select[name=userProfile]');
+ thisUserProfile.children().remove();
+
+ var definedUserProfiles = $.cookie(args[0] + 'userprofiles').split(',');
+ for (var i in definedUserProfiles) {
+ thisUserProfile.append('');
+ }
+
+ var thisNetwork = $('#' + thisTabId + ' select[name=network]');
+ thisNetwork.children().remove();
+ var definedNetworks = $.cookie(args[0] + 'networks').split(',');
+ for (var i in definedNetworks) {
+ var directoryEntry, interfaceName;
+
+ // Generate directory entry statement for vSwitch, hipersocket, and guest LAN
+ if (definedNetworks[i].indexOf('VSWITCH ') != -1) {
+ interfaceName = jQuery.trim(definedNetworks[i].replace('VSWITCH ', ''));
+ directoryEntry = "TYPE QDIO LAN " + interfaceName;
+ } else if (definedNetworks[i].indexOf('LAN:HIPERS ') != -1) {
+ interfaceName = jQuery.trim(definedNetworks[i].replace('LAN:HIPERS ', ''));
+ directoryEntry = "TYPE HIPERSOCKETS LAN " + interfaceName;
+ } else {
+ interfaceName = jQuery.trim(definedNetworks[i].replace('LAN:QDIO ', ''));
+ directoryEntry = "TYPE QDIO LAN " + interfaceName;
+ }
+
+ thisNetwork.append('');
+ }
+
+ // Update user entry on change
+ thisNetwork.change(function() {
+ updateUserEntry(thisTabId);
+ });
+
+ thisUserProfile.change(function() {
+ updateUserEntry(thisTabId);
+ });
}
});
hcpDiv.append(hcpLabel);
@@ -4927,9 +5006,9 @@ function createZProvisionNew(inst) {
var defaultChkbox = $('').click(function() {
// Remove any warning messages
$(this).parents('.form').find('.ui-state-error').remove();
-
- // Get tab ID
- var thisTabId = $(this).parents('.ui-tabs-panel').attr('id');
+
+ // Get tab Id
+ var thisTabId = $(this).parents('.ui-tabs-panel').parents('.ui-tabs-panel').attr('id');
// Get objects for HCP, user ID, and OS
var userId = $('#' + thisTabId + ' input[name=userId]');
@@ -4989,11 +5068,73 @@ function createZProvisionNew(inst) {
});
var userEntry = $('');
userEntry.append($('').append(defaultChkbox, 'Use default'));
- hwAttr.append(userEntry);
+
+ // Add division on basic tab for specifying: memory, # of CPUs, privilege, user profile, and network.
+ var basicConfig = $('');
+ var userProfile = $('');
+ var cpuSelect = $('').change(function() {
+ updateUserEntry('zvmProvisionTab' + inst);
+ });
+ var cpuCount = $('').append(cpuSelect);
+ var memorySlider = $('');
+ var memorySize = $('');
+ var memory = $('').append(memorySlider, memorySize);
+ var acceptableMemorySize = ['512M', '1024M', '2G', '3G', '4G', '5G', '6G', '7G', '8G'];
+ memorySlider.slider({
+ value: 0,
+ min: 0,
+ max: 8,
+ step: 1,
+ slide: function(event, ui) {
+ $('#basicConfig' + inst + ' input[name=memory]').val(acceptableMemorySize[ui.value]);
+
+ // Update user entry on change
+ updateUserEntry('zvmProvisionTab' + inst);
+ }
+ });
+
+ // Initialize storage size
+ memorySize.val(acceptableMemorySize[0]);
+
+ var privilege = $('
' +
+ '
' +
+ ' A - Primary system operator ' +
+ ' B - System resource operator ' +
+ ' C - System programmer ' +
+ ' D - Spooling operator ' +
+ ' E - System analyst ' +
+ ' F - IBM service representative ' +
+ ' G - General user ' +
+ '
' +
+ '
');
+ privilege.find('input').change(function() {
+ updateUserEntry('zvmProvisionTab' + inst);
+ });
+
+ var network = $('');
+
+ basicConfig.append(userProfile, cpuCount, memory, privilege, network);
+ hwTab.add('basicConfig' + inst, 'Basic', basicConfig, false);
+
+ // Add division on advanced tab for specifying user directory entry
+ hwTab.add('advancedConfig' + inst, 'Advanced', userEntry, false);
// Create disk table
var diskDiv = $('');
- var diskLabel = $('');
+ var diskLabel = $('');
var diskTable = $('
');
var diskHeader = $('
Type
Address
Size
Mode
Pool
Password
');
// Adjust header width
@@ -5106,14 +5247,14 @@ function createZProvisionNew(inst) {
// Create zFCP table
var zfcpDiv = $('');
- var zfcpLabel = $('');
+ var zfcpLabel = $('');
var zfcpTable = $('
');
var zfcpHeader = $('
Address
Size
Pool
Tag
Port Name
Unit #
LOADDEV
');
// Adjust header width
- zfcpHeader.find('th').css( {
+ zfcpHeader.find('th').css({
'width' : '80px'
});
- zfcpHeader.find('th').eq(0).css( {
+ zfcpHeader.find('th').eq(0).css({
'width' : '20px'
});
var zfcpBody = $('');
@@ -5235,13 +5376,21 @@ function createZProvisionNew(inst) {
var thisTabId = $(this).parents('.ui-tabs-panel').attr('id');
// Get provision tab instance
var inst = thisTabId.replace('zvmProvisionTab', '');
-
+
+ // Get the selected hardware configuration tab
+ // Basic tab index = 0 & advanced tab index = 1
+ var hwTabIndex = $("#hwConfig" + inst).tabs('option', 'selected');
+
// Check node name, userId, hardware control point, and group
// Check disks and zFCP devices
var inputs = $('#' + thisTabId + ' input:visible');
- for ( var i = 0; i < inputs.length; i++) {
+ for (var i = 0; i < inputs.length; i++) {
// Do not check some inputs
- if (!inputs.eq(i).val()
+ if (inputs.eq(i).attr('name') == 'memory') {
+ // There should always be a value for memory
+ // Do not change the border
+ continue;
+ } else if (!inputs.eq(i).val()
&& inputs.eq(i).attr('type') != 'password'
&& inputs.eq(i).attr('name') != 'zfcpTag'
&& inputs.eq(i).attr('name') != 'zfcpPortName'
@@ -5254,42 +5403,44 @@ function createZProvisionNew(inst) {
}
var selects = $('#' + thisTabId + ' select:visible');
- for ( var i = 0; i < selects.length; i++) {
- if (!selects.eq(i).val() && selects.eq(i).attr('name') != 'os') {
+ for (var i = 0; i < selects.length; i++) {
+ if (!selects.eq(i).val() && selects.eq(i).attr('name') != 'os' && selects.eq(i).attr('name') != 'userProfile') {
selects.eq(i).css('border', 'solid #FF0000 1px');
ready = false;
} else {
selects.eq(i).css('border', 'solid #BDBDBD 1px');
}
}
+
+ if (hwTabIndex == 1) {
+ // Check user entry
+ var thisUserEntry = $('#' + thisTabId + ' textarea:visible');
+ thisUserEntry.val(thisUserEntry.val().toUpperCase());
+ if (!thisUserEntry.val()) {
+ thisUserEntry.css('border', 'solid #FF0000 1px');
+ ready = false;
+ } else {
+ thisUserEntry.css('border', 'solid #BDBDBD 1px');
+ }
- // Check user entry
- var thisUserEntry = $('#' + thisTabId + ' textarea:visible');
- thisUserEntry.val(thisUserEntry.val().toUpperCase());
- if (!thisUserEntry.val()) {
- thisUserEntry.css('border', 'solid #FF0000 1px');
- ready = false;
- } else {
- thisUserEntry.css('border', 'solid #BDBDBD 1px');
+ // Check if user entry contains user ID
+ var thisUserId = $('#' + thisTabId + ' input[name=userId]:visible');
+ var pos = thisUserEntry.val().indexOf('USER ' + thisUserId.val().toUpperCase());
+ if (pos < 0) {
+
+ pos = thisUserEntry.val().indexOf('IDENTITY ' + thisUserId.val().toUpperCase());
+ if (pos < 0) {
+ errMsg = errMsg + 'The directory entry does not contain the correct user/identity ID. ';
+ ready = false;
+ }
+ }
}
// Show error message for missing inputs
if (!ready) {
- errMsg = errMsg + 'Please provide a value for each missing field. ';
+ errMsg = errMsg + 'Please provide a value for each missing field. ';
}
-
- // Check if user entry contains user ID
- var thisUserId = $('#' + thisTabId + ' input[name=userId]:visible');
- var pos = thisUserEntry.val().indexOf('USER ' + thisUserId.val().toUpperCase());
- if (pos < 0) {
-
- pos = thisUserEntry.val().indexOf('IDENTITY ' + thisUserId.val().toUpperCase());
- if (pos < 0) {
- errMsg = errMsg + 'The directory entry does not contain the correct user/identity ID. ';
- ready = false;
- }
- }
-
+
// If no operating system is specified, create only user entry
os = $('#' + thisTabId + ' select[name=os]:visible');
@@ -5297,12 +5448,17 @@ function createZProvisionNew(inst) {
var diskRows = $('#' + thisTabId + ' table tr');
// If an OS is given, disks are needed
if (os.val() && (diskRows.length < 1)) {
- errMsg = errMsg + 'You need to add at some disks. ';
+ errMsg = errMsg + 'You need to add at some disks. ';
ready = false;
}
// If inputs are valid, ready to provision
if (ready) {
+ // Generate user directory entry if basic tab is selected
+ if (hwTabIndex == 0) {
+ updateUserEntry(thisTabId);
+ }
+
if (!os.val()) {
// If no OS is given, create a virtual server
var msg = '';
@@ -5789,6 +5945,26 @@ function setzHcpCookies(zhcps) {
}
}
+/**
+ * Set a cookie for z/VM user profile names of a given node
+ *
+ * @param data Data from HTTP request
+ */
+function setUserProfilesCookies(data) {
+ if (data.rsp[0].length) {
+ var node = data.msg;
+ var profiles = data.rsp[0].split(node + ': ');
+ for (var i in profiles) {
+ profiles[i] = jQuery.trim(profiles[i]);
+ }
+
+ // Set cookie to expire in 60 minutes
+ var exDate = new Date();
+ exDate.setTime(exDate.getTime() + (240 * 60 * 1000));
+ $.cookie(node + 'userprofiles', profiles, { expires: exDate });
+ }
+}
+
/**
* Create virtual machine (service page)
*
@@ -6398,4 +6574,66 @@ function getHcpZvmHash() {
}
return hcp2zvm;
+}
+
+/**
+ * Update the user entry text area on a given tab
+ *
+ * @param tabId Tab Id where user entry text area is contained
+ */
+function updateUserEntry(tabId) {
+ var userId = $('#' + tabId + ' input[name=userId]').val().toUpperCase();
+ var profile = $('#' + tabId + ' select[name=userProfile]').val();
+ var cpuCount = parseInt($('#' + tabId + ' select[name=cpuCount]').val());
+ var memory = $('#' + tabId + ' input[name=memory]').val();
+ var network = $('#' + tabId + ' select[name=network]').val();
+
+ var privilege = [];
+ $('#' + tabId + ' input[name=privilege]:checked').each(function () {
+ privilege.push($(this).val());
+ });
+ privilege = privilege.join('');
+
+ var userDirectoryEntry = generateUserEntry(userId, "XCAT", memory, privilege, profile, cpuCount, network);
+ $('#' + tabId + ' textarea').val(userDirectoryEntry);
+}
+
+/**
+ * Generate a user directory entry
+ *
+ * @param userId User Id
+ * @param password User password
+ * @param memory Memory to assign to virtual machine
+ * @param privilege User privilege class
+ * @param profile User profile
+ * @param cpuCount Number of CPU to assign to virtual machine
+ * @param network Network interface used by virtual machine
+ *
+ * @returns User directory entry
+ */
+function generateUserEntry(userId, password, memory, privilege, profile, cpuCount, network) {
+ var userDirectoryEntry = "USER " + userId + " XCAT " + memory + " " + memory + " " + privilege + "\n";
+
+ // Include user profile if there is one
+ if (profile) {
+ userDirectoryEntry += "INCLUDE " + profile + "\n";
+ }
+
+ // Only up to 8 CPU can be assigned
+ for (var i = 0; i < cpuCount; i++) {
+ userDirectoryEntry += "CPU 0" + i + "\n";
+ }
+
+ userDirectoryEntry += "CONSOLE 0009 3215 T\n";
+
+ // Include network interface if given
+ if (network) {
+ userDirectoryEntry += "NICDEF 0A00 " + network + "\n";
+ }
+
+ userDirectoryEntry += "SPOOL 000C 2540 READER *\n";
+ userDirectoryEntry += "SPOOL 000D 2540 PUNCH A\n";
+ userDirectoryEntry += "SPOOL 000E 1403 A\n";
+
+ return userDirectoryEntry;
}
\ No newline at end of file