VMware Cloud Community
Flipper35
Contributor
Contributor
Jump to solution

get virtual machine name from deployment

I have an automation setup to allow someone to choose part of the host name as resource name and when deployed it assigns a name as follows: 

${resource.name}_${userName}-${#####}

 

My question is, I need to add notes and notify the DR admin of the new machine so how do I get the name of the machine so I can add notes to it and email the name to the DR guy?

I currently have a workflow that runs after the deploy is complete and I can get the name minus the digits.

 

On a side note, some of the native workflows don't find a VM by name either, but I can find them in the drop down on the others when I run them if that helps.

Reply
0 Kudos
1 Solution

Accepted Solutions
emacintosh
Hot Shot
Hot Shot
Jump to solution

I believe the names are stored in the resourceNames array that is found in inputProperties.  We only ever have a single VM in a deployment, so we can just look at the first element of the array.  

 

So if you create a workflow in vRO that takes a single input of type Properties called inputProperties, then you can access the first resource name like this in a scriptable task (as long as inputProperties is added as an input to the task).

var serverName = inputProperties.resourceNames[0];
System.log("Server Name: " + serverName);

 

And then in Assembler, you can subscribe to say the compute.provision.post event topic and choose the workflow you created.  If that spits out the name there as expected during a build, then you can of course update it however you need to get that info to the DR admin.

 

View solution in original post

8 Replies
Flipper35
Contributor
Contributor
Jump to solution

I have noticed that during the create process the externalID shows the vm name, but once done it switches to an ID number instead.  Is there an event topic that can be triggered to read that string while the create is in progress?  I am not sure when I look through the event topics the exact trigger time and if they have the correct string at that point.

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

I believe the names are stored in the resourceNames array that is found in inputProperties.  We only ever have a single VM in a deployment, so we can just look at the first element of the array.  

 

So if you create a workflow in vRO that takes a single input of type Properties called inputProperties, then you can access the first resource name like this in a scriptable task (as long as inputProperties is added as an input to the task).

var serverName = inputProperties.resourceNames[0];
System.log("Server Name: " + serverName);

 

And then in Assembler, you can subscribe to say the compute.provision.post event topic and choose the workflow you created.  If that spits out the name there as expected during a build, then you can of course update it however you need to get that info to the DR admin.

 

Flipper35
Contributor
Contributor
Jump to solution

Looks like I can get the name that way so I can send the name to our DR guy.  It does not seem that the compute.provision.post carries the description variable from the form (where Deoloyment Completed does) in the custom properties now (where so that would not work for adding the notes.  I assume this would need to be in the blueprint as well as the custom form created in Service Broker then?  The Backup flag is there so I know it can pass info from the form, but that flag is in both where description is not.  I will go give that a try.

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

it might be a bit of work, but you will have the Deployment ID during compute provision post.  So at that time, you could use the API to update the deployment to include the backup flag and vm name in the deployments description. 

 

We do something similar in that we rename the deployment to include the vm name once we have determined what the name is going to be (which happens during compute.provision.pre for us).

Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

Thanks.  It is a time consuming thing to edit since it takes a bit for the blueprint to get picked up by the custom form to grab the fields from the blueprint.  I thought it would be a minute or two.

 

With your help I am very close to having it work exactly as needed.  Thanks.

Reply
0 Kudos
emacintosh
Hot Shot
Hot Shot
Jump to solution

If I remember correctly, the changes made in a blueprint in assembler are synced to the form in service broker every 6 hours.  But I think you can also force it in service broker.

 

Service Broker -> Content & Policies -> Content Sources -> <your source> -> Save & Import button.  

In theory, that should pull in those template changes immediately.

 

emacintosh_0-1683054301823.png

 

Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

OK, so we are really close, but why does the variable get passed this way now? How do I strip the quotes section out?  Is this because of the way it is in the blueprint? Does it need to be in both the input and resources section?

From the workflow System.log:

INFO payload.backup: {"backup":true}

From the custom properties in the deployment.

backup {"backup":true}

From the blueprint input section.

Backup:
title: Backup
type: boolean
description: Will this server need backups

From the resource section.

backup:
backup: ${input.Backup}

 

Reply
0 Kudos
Flipper35
Contributor
Contributor
Jump to solution

I remembered that you can pull them through manually after I posted that.  This project just started a few weeks ago and it has been a lot of info in a short time and most documentation is for v7.x

Thanks again.

Reply
0 Kudos