BrettK1
Enthusiast
Enthusiast

User Specified Hostname / VM Name

Jump to solution

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.

0 Kudos
1 Solution

Accepted Solutions
emacintosh
Enthusiast
Enthusiast

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

8 Replies
emacintosh
Enthusiast
Enthusiast

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.

0 Kudos
BrettK1
Enthusiast
Enthusiast

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...

0 Kudos
emacintosh
Enthusiast
Enthusiast

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.

0 Kudos
BrettK1
Enthusiast
Enthusiast

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...

0 Kudos
emacintosh
Enthusiast
Enthusiast

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

BrettK1
Enthusiast
Enthusiast

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
Enthusiast
Enthusiast

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

0 Kudos
BrettK1
Enthusiast
Enthusiast

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?)

0 Kudos