VMware Cloud Community
GMCON
Enthusiast
Enthusiast
Jump to solution

"Owner" Custom Property

This is a hybrid vCAC vCO question.  I am trying to find what the custom property for Owner would be.  I am using the vCAC vCO workflow Display inputs to pull in the properties from a machine request in vCAC to pass those into an email to send out.  I have got everything else working but cannot find the custom property for "Owner" the person submitting the VM.  I tried VirtualMachine.Admin.Owner and that did not work.  Anyone know?

Reply
0 Kudos
1 Solution

Accepted Solutions
GMCON
Enthusiast
Enthusiast
Jump to solution

I ended up finding the custom property that is passed in that workflow.  It is __Legacy.Workflow.User

View solution in original post

Reply
0 Kudos
3 Replies
SeanKohler
Expert
Expert
Jump to solution

I created an Action to get it...  It searches all machines, verifies machine is managed and returns either the owner or a statement that the machine is not managed.

Had to use VC:VirtualMachine and then get the equivalent VCAC Entity.

=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

string getOwnerOfOneManagedVcVm (VC:VirtualMachine vcVm,vCAC:VCACHost host)

{

     if (host == null || vcVm == null) return null;

     var vcacVms = Server.findAllForType("VCAC:VirtualMachine");

     for each (var vcacVm in vcacVms){

            if (vcVm.name == vcacVm.virtualMachineName){

                 if (vcacVm.isManaged==true){

                      vcacEntity = vcacVm.getEntity();

                      var ownerEntity = vcacEntity.getLink(host,"Owner")[0];

                      return ownerEntity.getProperty("UserName");

                 }else{

                      return "UNMANAGED-VM";

                }

            break;

            }

         }

}

=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+

Below are the bits that gets the owner (user principle name) more or less.  What we are considering doing is just stamping the owner during machine build into a VCAC custom property because getting the owner through the Entity is a bit slow. If you have to do it once, it is fine.  If you have to do it looping through 500 machines, go get a cup of coffee and a doughnut because you are going to have some time on your hands.

vcacEntity = vcacVm.getEntity();

var ownerEntity = vcacEntity.getLink(host,"Owner")[0];

return ownerEntity.getProperty("UserName");  // or var vcacMachineEntityOwner = ownerEntity.getProperty("UserName");

I attached the action I pieced together should it interest you to import and play with.

Reply
0 Kudos
GMCON
Enthusiast
Enthusiast
Jump to solution

I ended up finding the custom property that is passed in that workflow.  It is __Legacy.Workflow.User

Reply
0 Kudos
SeanKohler
Expert
Expert
Jump to solution

Ah gotcha... That works during the WF request and we are doing the same.  Later down the road, we were looking for a way to get the owner of an already provisioned machine.  That is where looking into the Entity properties came into play.

Couple of other thoughts...

1. In addition to your email, if you also stamp the owner during the request into a custom property for the machine... it is easier to retrieve later.  (at least that was what we have ascertained so far based on what knowledge is available)

2. __Legacy.Workflow.User gives you the requester.  The problem with this value is that if the "On Behalf Of" section of VCAC is leveraged, a different "owner" is applied to the machine.  We got around this in our Build Machine Master by comparing the requester with the actual machine entity owner, thusly...

// Compare Legacy user versus on Behalf of user and use on behalf of user if different

//var vmEntity = System.getModule("com.vmware.library.vcac").getVirtualMachineEntity(vCACHost,vCACVm) ;

var ownerEntity = virtualMachineEntity.getLink(vCACHost,"Owner")[0];

var ownerName = ownerEntity.getProperty("UserName");

if (ownerName != username){

username = ownerName;

}

... where username was assigned via __Legacy.Workflow.User prior...