VMware Cloud Community
BrettK1
Enthusiast
Enthusiast
Jump to solution

User Specified Hostname / VM Name

vRA 8.4 and vSphere 6.7, trying to migrate from vRA 7.6 and seeing that I'll mostly be redoing everything from the infrastructure layout to completely rewriting bluepri... err... Cloud Templates almost from scratch.

Something that seems super simple - specifying a Cloud.vSphere.Machine hostname (and VM name) via user input.
vRA 7.x had the 'Hostname' custom property.  So far all my searches have turned up things like 'create a vRO workflow' and change the name after the fact (which seems overly complicated for something that was so simple previously, <edit>would necessitate storage vmotioning to fix filenames, TWICE to put things back where they were originally deployed, </edit> and I don't want to think about such a workflow butting up against the next decision of 'continue using customization specs or switch to cloudbase-init', both of which have their own hurdles to overcome).
Sure, I'll start playing with vRO workflows eventually, but this doesn't seem like a worthy task for it.

Reply
0 Kudos
1 Solution

Accepted Solutions
emacintosh
Hot Shot
Hot Shot
Jump to solution

If you get a chance then, maybe try that last option.  Using this as your naming template in the project:  ${resource.name}  .... and just set the name property in cloud template like you did originally.  I'm pretty sure that's what we were doing before we implemented out automatic naming convention.

View solution in original post

10 Replies
emacintosh
Hot Shot
Hot Shot
Jump to solution

I think you can just get the input from the user and then specify that as the resourceName property in your cloud template? 

In our case, our naming convention is automated and we have some work to do to find the next available name, so we do use a vRO workflow.  But that workflow is called during the compute allocation event and updates the resourceNames property with the correct name....so the server is still built with the right name, we definitely don't rename after the build.

Reply
0 Kudos
BrettK1
Enthusiast
Enthusiast
Jump to solution

If you mean the 'name' property of the Cloud.vSphere.Machine resource, that's one path I assumed would work, but did not.
The VM name gets set to whatever I set the name property to, and appends its own '-mcm###-############' to the end of it.
The Hostname is also set to the resource.name PLUS "-mcm-###-###########', trunced to 15 characters (because Windows).

So neither the VM name or Hostname are set to ${resource.name}, nor do they even match (due to Windows hostname length limit).
The project is not using a Custom Naming template

Edit: I see others have basically the same question here: https://communities.vmware.com/t5/vRealize-Automation-Tools/Windows-Host-name-is-not-correct/m-p/527...

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

No, I meant "resourceName" of the Cloud.vSphere.Machine resource.  Not sure if that will work or not, but that is the same property we manipulate in our workflows to set the name.

I also vaguely remember setting the template name in our projects to something like ${resource.name} - that was early on while we were getting familiar with 8.x.  If I recall correctly, the effect was that it would just use the name property we provided....it's been a while, but i think that's how it worked for us.

Reply
0 Kudos
BrettK1
Enthusiast
Enthusiast
Jump to solution

Removing 'name' and adding in 'resourceName' and having NEITHER of them produced the same results.
The VM would be named after the resources label, and I could not use a variable for the label.
i.e.

resources:
 2019VM:
  type: Cloud.vSphere.Machine

The VM created would be named "2019VM-mcm###-############", and Windows Hostname "2019VM-mcm###-#"

Setting 'resourceName' had no affect, and YAML really didn't like swapping out 2019VM with any 'input'.
Thanks for the suggestion, but alas...

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

If you get a chance then, maybe try that last option.  Using this as your naming template in the project:  ${resource.name}  .... and just set the name property in cloud template like you did originally.  I'm pretty sure that's what we were doing before we implemented out automatic naming convention.

BrettK1
Enthusiast
Enthusiast
Jump to solution

Just to recap (and I posted this in the linked thread as well):

1) In the Project, set the 'custom naming' to ${resource.name} and
2) In the Template, set the Cloud.vSphere.Machine property 'name: '${input.Your_Hostname_Input_Field}'

emacintosh
Hot Shot
Hot Shot
Jump to solution

Glad you got it working....agreed though, a bit much for just setting the name to what the user specified.

Reply
0 Kudos
BrettK1
Enthusiast
Enthusiast
Jump to solution

Yea, I mostly wanted to remove the Custom Naming portion to leave naming of other items out of it - then again our current use, the only thing being created and therefore named are VMs (or the 'resource instance' of the Networks, but we're not creating any actual named networks this way, so does it really matter?)

Reply
0 Kudos
Enter123
Enthusiast
Enthusiast
Jump to solution

Does anyone know if it is possible to bypass "Custom naming - Scope Organization" in vRA 8.10.2 and allow users to specify VM name in the custom form? Free text, no predefined naming convention standard, pattern etc.

Basically, I don't need or want to use naming convention at all for some CloudTemplates.

This option to create another naming convention per project might work if there is no other way, but I really want to create any kind of naming templates for this specific case. Just offer users free text. 

Reply
0 Kudos
xian_
Expert
Expert
Jump to solution

Add your custom hostname input as a custom property to the VM, on the cloud template:

inputs:
  hostname:
    type: string
resources:
  vm:
    type: Cloud.vSphere.Machine
    properties:
      hostname: ${input.hostname}

Create a vRO workflow with:

inputs: 
inputProperties (Properties)

outputs:
resourceNames (Array/string)

Assign the hostname in the workflow to the output variable:

resourceNames = [inputProperties.customProperties.hostname];

Create an EBS at event topic "Compute allocation" (compute.allocation.pre), assign the workflow to it, and make it blocking.