Guest

Cisco Intelligent Automation for Cloud

Cisco IAC: Disabling Snapshot Management for the VSO Role

Document ID: 115623

Updated: Jan 10, 2013

   Print

Introduction

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.

Before You Begin

Requirements

There are no specific requirements for this document.

Components Used

This document is not restricted to specific hardware and software versions.

Conventions

For more information on document conventions, refer to Cisco Technical TipsConventions.

Modifying the Manage_MyServers Portlet Code

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.

Using a Text Editor

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.

Disabling Snapshot Buttons for the VSO Role

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:

  1. Launch Cloud Portal and navigate to Portal Designer > Browse Portlets.

  2. In the left panel, select the JavaScript folder and then select Manage_MyServers.

  3. In the main panel, select the View tab. Cloud Portal displays the Javascript code for the Manage_MyServers portlet.

  4. 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) 
  5. 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();
    
    
  6. 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>';
  7. 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.

  8. 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>';
  9. 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>';
    }
    
  10. 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.

Related Information

Updated: Jan 10, 2013
Document ID: 115623