VMware Cloud Community
KThorlund
Enthusiast
Enthusiast
Jump to solution

Windows machine name when using event broker - is it possible?

Hey, I have some issue when using the event broker to name and create my VMs.

I have a custom form, where the user can specify X names of their machines they wanna create. When the dispatch the request, X machines with my machine prefix, e.g. 2016-xxx are created.

I have created a workflow, which catch this my the event broker as a blocking event, which allows me to modify the vCAC entity before the machine is build.. E.g. I set the VirtualMachineName to fit the name request the user made. Its working well. The machine gets right name in both VC, vCAC and the actually Windows names as well..

I do the following:

var virtualMachineEntity = System.getModule("com.vmware.library.vcac").getVirtualMachineEntityFromId(null,virtualMachineId) ;

var vmEntityProps = virtualMachineEntity.getProperties();

vmEntityProps.remove('VirtualMachineName');

vmEntityProps.put('VirtualMachineName', hostname);

var hostId = virtualMachineEntity.hostId;

var modelName = virtualMachineEntity.modelName;

var entitySetName = virtualMachineEntity.entitySetName;

var entityIdString = virtualMachineEntity.keyString;

var actionResult = System.getModule("com.vmware.library.vcac").updateVCACEntity(hostId,modelName,entitySetName,entityIdString,vmEntityProps,null,null);

The actual name change happens in

vmEntityProps.remove('VirtualMachineName');

vmEntityProps.put('VirtualMachineName', hostname);

So far, so good.

My issue - and frustration - is, that in Active Directory I have to machines created for the request. One object for the 2016-xxx and one with the new name.

If I destroy the machine again, only the object 2016-xxx will be removed.

This is odd!!

It seems that the AD account (2016-xxx) is actually created prior to reaching the PRE - BuildMachine state in the event broker..

I have tried to update the property "ext.policy.activedirectory.machineName" in the blocking PRE buildmachine, but it is too late.. It has no affect.  It only works, if it is set directly on my custom form.

Do you manually create the AD object with an earlier event broker state, or rename the pre-created to the actually new name or something completely different?

I would be nice to have the object created as early as possible to it is being "reserved" in AD..

How do you deal with this?

Regards, Kjeld 

0 Kudos
1 Solution

Accepted Solutions
darrenoid
Enthusiast
Enthusiast
Jump to solution

You could try changing your EBS to an earlier life cycle state like VMPSMasterWorkflow32.Requested, that is what we use for our custom hostname workflow.

View solution in original post

4 Replies
KThorlund
Enthusiast
Enthusiast
Jump to solution

By the way. vRealize 7.5

0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

You're making your life really difficult for you here when it doesn't have to be. Check out the SovLabs module for AD and Custom Naming. They work together and don't require any of this mess. All names are generated like you want, and things are rolled into and out of AD automatically.

0 Kudos
darrenoid
Enthusiast
Enthusiast
Jump to solution

You could try changing your EBS to an earlier life cycle state like VMPSMasterWorkflow32.Requested, that is what we use for our custom hostname workflow.

KThorlund
Enthusiast
Enthusiast
Jump to solution

Thanks to both of you.

I have just moved the code to an ealier state as suggested, and this works very well.

Thanks for your hint!

0 Kudos