VMware Cloud Community
bdamian
Expert
Expert
Jump to solution

vRA 7.3 - Hide "Custom Properies" Tab on Reconfigure for Support role

Hi all,

In vRA 6.x, a user with support role couldn't see the "Properties" Tab for a VM in the Reconfigure Screen. Now, in vRA 7.3 they can see this tab.

Is there any way to hide that tab?

Thanks,

D.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
Tags (2)
1 Solution

Accepted Solutions
daphnissov
Immortal
Immortal
Jump to solution

Not any supported way of doing so. I'm not even sure you could hack it into submission.

View solution in original post

Reply
0 Kudos
11 Replies
daphnissov
Immortal
Immortal
Jump to solution

Not any supported way of doing so. I'm not even sure you could hack it into submission.

Reply
0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

Agree with daphnissov​ there is no supported way to do this, but as it turns out you can hack it into submission:

pastedImage_0.png

It's all hackable.  But just because you can, does that mean you should?

If you're interested I can provide details.  Let me know.

Reply
0 Kudos
bdamian
Expert
Expert
Jump to solution

Hi Justin,

I am interested in the hack. As long as we don't lose official support.

Thanks a lot

D.

---
Damián Bacalov
vExpert 2017-2023 (7 years)
https://www.linkedin.com/in/damianbacalov/
https://tecnologiaimasd.blogspot.com/
twitter @bdamian
Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

I'd be interested to know, just so I can file it away in the folder "things you can but shouldn't do" Smiley Happy

Reply
0 Kudos
lukez1985
Contributor
Contributor
Jump to solution

Dennis has this on his Blog: http://www.automate-it.today/advanced-options-vrealize-automation-hide-properties-snapshots-tab/

I have added a comment today which shows exactly where to add the bit of code....I have copied my comment below in quotes:

I would also like to hide various tabs on the request such as Storage etc but this is vRA content not IaaS. Does anyone know what file and code needs editing to hide tabs on the VM request?

I had the exact same problem as I am running vRA 7.3 and this blog had the line “…so the line looks like this” but had no indication of the code.

Luckily I have a dev environment so was able to ‘play’. It is a parameter of the tag, so…

<dxtc:TabPage Text="” Name=”Properties”>

becomes…

<dxtc:TabPage Text="” Name=”Properties” ClientVisible=False>

Notice ClientVisible is set with…

ClientVisible=False

not…

ClientVisible=”False”

The parameter has to be Boolean, not String.

Reply
0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

To make the modification I put a screenshot of in my previous post to this thread, I added some import directives at the top of the C:\Program Files (x86)\VMware\vCAC\Server\Website\Leases\EditVirtualMachine.aspx file on the IaaS server hosting the vCAC server component (under the first <%@ Page line) so I could put some custom code in to make a decision about hiding the tab if you're not a manager (being unable to change the code behind the ASPX pages, this is a hack to change it on the "front side"):

<%@ Import Namespace="System.Reflection" %>

<%@ Import Namespace="DynamicOps.Web.Leases" %>

<%@ Import Namespace="System.Security.Claims" %>

Then I added the following code block, directly underneath the Javascript code block near the top:

<%

        EditVirtualMachine evm = this;

        FieldInfo pi = this.GetType().BaseType.GetField("canEditProperties", BindingFlags.Instance | BindingFlags.NonPublic);

        string groupName = ((DynamicOps.ManagementModel.VirtualMachine)this.GetType().BaseType.GetField("virtualMachine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(evm)).VirtualMachineExt.GroupName;

        bool admin = false;

        bool support = false;

        Type t = this.GetType().BaseType;

var roles = ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Value);

        foreach(string r in Roles.GetRolesForUser(User.Identity.Name))

        {

            if(r == groupName + "|My business group Administration User Interface") admin = true;

            if(r == groupName + "|Operate On Behalf Of User") support = true;

        }

        bool show = admin || (!admin && !support);             

        this.MachineRecord.GetTabPage("Properties").Visible = show;

        this.MachineRecord.GetTabPage("Properties").ClientVisible = show;

   

%>

It will show the tab if you own the machine or are an admin, but not if you're support.  It can be made so only admins can see it by changing the "bool show = admin || ..." line to just "bool show = admin;".  It will also be in effect on both new submissions and reconfigurations.  I was going to add some logic to account for this, but didn't get to it.

Posting this in case it's helpful to anyone, but it is important to note that I am sure this is not supported and you should be sure to test it thoroughly in your environment before making the change.

This was created in/for vRA 7.3, but would most likely work in 7.x

Reply
0 Kudos
lukez1985
Contributor
Contributor
Jump to solution

Nice! thanks

I will try that out because if it does hide on requesting VMs too that solves what I was looking for Smiley Happy

To try and do the reverse, will...

this.MachineRecord.GetTabPage("Properties").ClientVisible = hide

work instead of...

this.MachineRecord.GetTabPage("Properties").ClientVisible = show?

Reply
0 Kudos
lukez1985
Contributor
Contributor
Jump to solution

jasnyder There is no "VirtualMachineLeases.aspx" file in "C:\Program Files (x86)\VMware\vCAC\Server\Website\Leases\"

Reply
0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

show is a boolean variable set to the value admin (user is a member of the group manager role) or - user is both not a manager and not in the support role - i.e. a support user. 

If either of those cases is true, show is true and then it shows the object.

If you just want to hide it, this.MachineRecord.GetTabPage("Properties").ClientVisible = false;  would do the trick.

I have noticed that on the component, this will hide it for regular users, but for admin and support users will not hide it.  On the deployment, it does hide it for all, and on the machine inspection or reconfigure, it will hide it for all.

Something about that initial request form overrides the properties tab for some users on properties as well as storage.  I'll keep working on it and let you know if I can figure something out.

Reply
0 Kudos
jasnyder
Hot Shot
Hot Shot
Jump to solution

Sorry, typo on my part, I edited the post, but it is supposed to be the C:\Program Files (x86)\VMware\vCAC\Server\Website\Leases\EditVirtualMachine.aspx file.

Reply
0 Kudos
KocPawel
Hot Shot
Hot Shot
Jump to solution

Hello,

I tried to copy that code to file but I have error. Can anyone help ? My file looks like:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" AutoEventWireup="true" Inherits="DynamicOps.Web.Leases.EditVirtualMachine" CodeBehind="EditVirtualMachine.aspx.cs" uiCulture="auto" %>

<%@ Register TagPrefix="vmps" TagName="PropertyBag" Src="~/UserControls/PropertyBag.ascx" %>

<%@ Register TagPrefix="vmps" TagName="HardwarePanel" Src="~/UserControls/HardwarePanel.ascx" %>

<%@ Register TagPrefix="vmps" TagName="EbsStorage" Src="~/UserControls/EbsStorageGrid.ascx" %>

<%@ Register TagPrefix="vmps" TagName="ListBoxPicker" Src="~/UserControls/ListBoxPicker.ascx" %>

<%@ Register TagPrefix="vmps" TagName="LoadBalancersGrid" Src="~/UserControls/LoadBalancersGrid.ascx" %>

<%@ Register TagPrefix="vmps" TagName="Network" Src="~/UserControls/NetworkGrid.ascx" %>

<%@ Register TagPrefix="vmps" TagName="Storage" Src="~/UserControls/StorageGrid.ascx" %>

<%@ Register TagPrefix="vmps" TagName="SnapshotManager" Src="~/UserControls/SnapshotManager.ascx" %>

<%@ Register TagPrefix="vmps" TagName="ComponentMachinesGrid" Src="~/UserControls/ComponentMachinesGrid.ascx" %>

<%@ Register TagPrefix="vmps" TagName="SecurityObjects" Src="~/UserControls/SecurityObjects.ascx" %>

 

<%@ Import Namespace="System.Reflection" %>

<%@ Import Namespace="DynamicOps.Web.Leases" %>

<%@ Import Namespace="System.Security.Claims" %>

<%

        EditVirtualMachine evm = this;

        FieldInfo pi = this.GetType().BaseType.GetField("canEditProperties", BindingFlags.Instance | BindingFlags.NonPublic);

        string groupName = ((DynamicOps.ManagementModel.VirtualMachine)this.GetType().BaseType.GetField("virtualMachine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(evm)).VirtualMachineExt.GroupName;

        bool admin = false;

        bool support = false;

        Type t = this.GetType().BaseType;

var roles = ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Value);

 

        foreach(string r in Roles.GetRolesForUser(User.Identity.Name))

        {

            if(r == groupName + "|My business group Administration User Interface") admin = true;

            if(r == groupName + "|Operate On Behalf Of User") support = true;

        }

 

       bool show = admin || (!admin && !support);             

        this.MachineRecord.GetTabPage("Properties").Visible = show;

        this.MachineRecord.GetTabPage("Properties").ClientVisible = show;

%>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server">

..............................

<%@ Page Language="C#" MasterPageFile="~/MasterPages/Default.master" AutoEventWireup="true" Inherits="DynamicOps.Web.Leases.EditVirtualMachine" CodeBehind="EditVirtualMachine.aspx.cs" uiCulture="auto" %>
 
<%@ Register TagPrefix="vmps" TagName="PropertyBag" Src="~/UserControls/PropertyBag.ascx" %>
<%@ Register TagPrefix="vmps" TagName="HardwarePanel" Src="~/UserControls/HardwarePanel.ascx" %>
<%@ Register TagPrefix="vmps" TagName="EbsStorage" Src="~/UserControls/EbsStorageGrid.ascx" %>
<%@ Register TagPrefix="vmps" TagName="ListBoxPicker" Src="~/UserControls/ListBoxPicker.ascx" %>
<%@ Register TagPrefix="vmps" TagName="LoadBalancersGrid" Src="~/UserControls/LoadBalancersGrid.ascx" %>
<%@ Register TagPrefix="vmps" TagName="Network" Src="~/UserControls/NetworkGrid.ascx" %>
<%@ Register TagPrefix="vmps" TagName="Storage" Src="~/UserControls/StorageGrid.ascx" %>
<%@ Register TagPrefix="vmps" TagName="SnapshotManager" Src="~/UserControls/SnapshotManager.ascx" %>
<%@ Register TagPrefix="vmps" TagName="ComponentMachinesGrid" Src="~/UserControls/ComponentMachinesGrid.ascx" %>
<%@ Register TagPrefix="vmps" TagName="SecurityObjects" Src="~/UserControls/SecurityObjects.ascx" %>
 
<%@ Import Namespace="System.Reflection" %>
<%@ Import Namespace="DynamicOps.Web.Leases" %>
<%@ Import Namespace="System.Security.Claims" %>
<%
        EditVirtualMachine evm = this;
        FieldInfo pi = this.GetType().BaseType.GetField("canEditProperties", BindingFlags.Instance | BindingFlags.NonPublic);
        string groupName = ((DynamicOps.ManagementModel.VirtualMachine)this.GetType().BaseType.GetField("virtualMachine", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(evm)).VirtualMachineExt.GroupName;
        bool admin = false;
        bool support = false;
        Type t = this.GetType().BaseType;
var roles = ((ClaimsIdentity)User.Identity).Claims.Select(c => c.Value);
 
        foreach(string r in Roles.GetRolesForUser(User.Identity.Name))
        {
            if(r == groupName + "|My business group Administration User Interface") admin = true;
            if(r == groupName + "|Operate On Behalf Of User") support = true;
        }
 
       bool show = admin || (!admin && !support);             
        this.MachineRecord.GetTabPage("Properties").Visible = show;
        this.MachineRecord.GetTabPage("Properties").ClientVisible = show;
%>
 
 
<asp:Content ID="Content1" ContentPlaceHolderID="MainContentPlaceHolder" runat="Server">
Reply
0 Kudos