To successfully disable Snapshot Management for the members of a Virtual Server Owner (VSO) group, you cannot simply remove the respective permissions from the VSO role. Although the VSO users will not be able to access these functions, the "My Servers" portlet will still display the corresponding buttons, and will display an error if any VSO user clicks on them. To prevent this, perform some simple modifications to the Manage_MyServers portlet code so that it will not display these buttons.
There are no specific requirements for this document.
This document is not restricted to specific hardware and software versions.
For more information on document conventions, refer to Cisco Technical TipsConventions.
In this section, you are presented with the information needed to modify the Manage_MyServers portlet so that Snapshot buttons are removed for VSO users who should not have this access.
You can use any ASCII text editor to edit the portlet Javascript code, as long as it supports copy and paste and saving to file. We recommend that you use one that supports on-screen line numbering and search functions. Remember to save the original code in a local text file before you modify it, so that you can restore it easily if needed.
The code modifications are relatively simple. First you detect the user's role, then disable the Manage Snapshots buttons if the user is a member of the VSO group. Follow these steps:
Launch Cloud Portal and navigate to Portal Designer > Browse Portlets.
In the left panel, select the JavaScript folder and then select Manage_MyServers.
In the main panel, select the View tab. Cloud Portal displays the Javascript code for the Manage_MyServers portlet.
Select all of the code, then copy and paste it into your text editor. Save a copy of this original text as a file on a local machine, as a backup.
getActionButtonContent(cntName,cntStatus,cntOwned)
Add an open bracket ({) at the end of that line. Then add a line with the following code immediately after:
var personRole = getCurrentUserRole();
The two lines should now look like this:
function getActionButtonContent(cntName,cntStatus,cntOwned){ var personRole = getCurrentUserRole();
Locate the following section of the code (around line 1104):
buttons = buttons + '<div style="float:left; margin: 8px 9px; padding: 8px 2px; text-align: center; width: 10%; border: 1px solid #ffffff;">'+linkSnapshotStart+'<img src="http://www.cisco.com/RequestCenter/custom/EnterpriseEdition/'+imgSnapshot+'" '+imgSnapshotRollover+' alt="Create a named snapshot of the '+manageCntName+'\'s current state and data.">'+linkSnapshotEnd+'</Para><Para>Take Snapshot</div>';
On the line just before this section of code, add the following line:
if(personRole != 'Virtual Server Owner') {
Do not forget to insert the open bracket character ({) at the end of the line.
Now locate the following nearby section of code (around line 1112):
buttons = buttons + '<div style="float:left; margin: 8px 9px; padding: 8px 2px; text-align: center; width: 10%; border: 1px solid #ffffff;">'+linkDeleteSnapshotStart+'<img src="http://www.cisco.com/RequestCenter/custom/EnterpriseEdition/'+imgDeleteSnapshot+'" '+imgDeleteSnapshotRollover+' alt="Delete Snapshot of the Virtual Machine" title="Delete Snapshot of the '+manageCntName+'." >'+linkDeleteSnapshotEnd+'</Para><Para>Delete Snapshot</div>';
Add a close bracket (}) for the if statement on a new line immediately following this section. The complete section of modified code should now look like this:
if(personRole != Virtual Server Owner) { buttons = buttons + '<div style="float:left; margin: 8px 9px; padding: 8px 2px; text-align: center; width: 10%; border: 1px solid #ffffff;">'+linkSnapshotStart+'<img src="http://www.cisco.com/RequestCenter/custom/EnterpriseEdition/'+imgSnapshot+'" '+imgSnapshotRollover+' alt="Create a named snapshot of the '+manageCntName+'\'s current state and data.">'+linkSnapshotEnd+'</Para><Para>Take Snapshot</div>'; buttons = buttons + '<div style="float:left; margin: 8px 9px; padding: 8px 2px; text-align: center; width: 10%; border: 1px solid #ffffff;">'+linkViewSnapshotStart+'<img src="http://www.cisco.com/RequestCenter/custom/EnterpriseEdition/'+imgViewSnapshot+'" '+imgViewSnapshotRollover+' alt="View Snapshots of the Virtual Machine" title="View Snapshots of the '+manageCntName+'." >'+linkViewSnapshotEnd+'</Para><Para>View Snapshots</div>'; buttons = buttons + '<div style="float:left; margin: 8px 9px; padding: 8px 2px; text-align: center; width: 10%; border: 1px solid #ffffff;">'+linkRevertSnapshotStart+'<img src="http://www.cisco.com/RequestCenter/custom/EnterpriseEdition/'+imgRevertSnapshot+'" '+imgRevertSnapshotRollover+' alt="Revert to Snapshot" title="Revert a '+manageCntName+' to a previous state using the snapshot of your choice." >'+linkRevertSnapshotEnd+'</Para><Para>Revert to Snapshot</div>'; buttons = buttons + '<div style="float:left; margin: 8px 9px; padding: 8px 2px; text-align: center; width: 10%; border: 1px solid #ffffff;">'+linkDeleteSnapshotStart+'<img src="http://www.cisco.com/RequestCenter/custom/EnterpriseEdition/'+imgDeleteSnapshot+'" '+imgDeleteSnapshotRollover+' alt="Delete Snapshot of the Virtual Machine" title="Delete Snapshot of the '+manageCntName+'." >'+linkDeleteSnapshotEnd+'</Para><Para>Delete Snapshot</div>'; }
Copy the newly modified code back into the View tab for the Manage_MyServers portlet and click Save. The buttons will now be hidden for a VSO.
Revision | Publish Date | Comments |
---|---|---|
1.0 |
10-Jan-2013 |
Initial Release |