VMware Cloud Community
ZEisenberg
Contributor
Contributor
Jump to solution

Adding custom attributes to new VMs created in a blueprint

Hi all,

I'm successfully using the 'Add custom attribute to a virtual machine' workflow as a standalone XaaS blueprint in vRA. I even was able to modify it to add multiple attributes to multiple machines. Now I am trying to incorporate it into a blueprint (so that my custom attributes are populated automatically at provisioning time instead of making the user come back and run a separate task) but am stumped on how to get the vCenter VM I'm making in the blueprint to be recognized as a VC:VirtualMachine object so I can link the XaaS blueprint to the VM.

Am I approaching this the correct way? Is it a simple re-write or is a different approach needed? Any ideas?

Thanks in advance...

1 Solution

Accepted Solutions
daphnissov
Immortal
Immortal
Jump to solution

pedjono

You're going about this in a WAY too complicated. You don't need any EBS subscriptions or vRO workflows. Look at the custom property reference. You need two custom properties placed on the machine component:  VMware.AttributeN.Name and VMware.AttributeN.Value. That's it. Add the custom properties and give them the needed values. When the deployment completes, the vSphere agent will write these out to the machine as custom attributes.

View solution in original post

Reply
0 Kudos
10 Replies
filosmith
Enthusiast
Enthusiast
Jump to solution

You could wrap the 'Add custom attributes' workflow in another outer workflow which takes the vm name as an input, and run 'Get virtual machine by name' to convert it to the VcVm object first.

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

If you want to add custom attributes to VMs at time of deployment, you don't need XaaS for this. You can use IaaS and add some custom properties to the machine object and it'll tell the vSphere Agent to write these out as custom attributes once provisioned. See the custom property reference for more information. This is far simpler than writing XaaS.

daphnissov
Immortal
Immortal
Jump to solution

pedjono

You're going about this in a WAY too complicated. You don't need any EBS subscriptions or vRO workflows. Look at the custom property reference. You need two custom properties placed on the machine component:  VMware.AttributeN.Name and VMware.AttributeN.Value. That's it. Add the custom properties and give them the needed values. When the deployment completes, the vSphere agent will write these out to the machine as custom attributes.

Reply
0 Kudos
pedjono
Enthusiast
Enthusiast
Jump to solution

daphnissov​    {I will go ahead and delete my previous comment, as it might just confuse people.}

ah. I see what you mean. that wrote it out before me wf even ran...

To make it easier for others to find....this is the useful bit of the reference for the VM attributes

Property Description
VMware.AttributeN.NameSpecifies the name of an attribute in vRealize Orchestrator. For example, it specifies the value of the attribute used in the VMware.AttributeN.Name property. Replace the letter N with a number, starting with 0 and increasing for each attribute to set.
VMware.AttributeN.ValueSpecifies the value of the attribute used in the VMware.AttributeN.Name property. Replace the letter N with a number, starting with 0 and increasing for each attribute to set.

will look more that more, I need to make it show labels though rather than the "name"

Reply
0 Kudos
daphnissov
Immortal
Immortal
Jump to solution

Not sure what you mean by "labels" here. vSphere custom attributes are key:value pairs. The Name is the key; the Value is the value. If you wanted to set the custom attribute "Department = Sales" you would set VMware.Attribute1.Name to "Department" and VMware.Attribute1.Value to "Sales".

Reply
0 Kudos
ZEisenberg
Contributor
Contributor
Jump to solution

Another victory for simplicity. From the way it's written in the custom property reference, I thought it was something that would be sent to vRO (like an attribute in a workflow), not just simply used in vCenter directly like that.

Thanks for the help!

Reply
0 Kudos
pedjono
Enthusiast
Enthusiast
Jump to solution

Hi daphnissov

By labels I meant something more user readable on a blueprint, once its made available as a catalog item.

This is easy with custom forms, but I need it for a standard blueprint.

We are using the Custom Attributes fields like tags, and some of them need to be editable / selected via the catalog item by the user, these are things like, Billing info, project, squad etc.

While you are correct, VMware.Attribute1.Name to "Department" and VMware.Attribute1.Value to "Sales" work, its not "pretty" for the end user to see on the catalog item.

I have actually ended up going back to my more complicated answer using the payload of custom properties, configuring the Event Broker to run a workflow, that sets them on the VM.  The only snag I found was I get the VM name via the payload as a string, to set the attribute, i had to add a script that converts that machineName to a vmobject.. It then worked perfectly.

So for future readers:

If your in a situation, where you need users to be able to input into the attributes, and dont use custom forms, then there is another option, that can have things show on your catalog item like this:

pastedImage_4.png

And end up on the VM like this:

pastedImage_5.png

Message me for how to...   I will try and get this into a blog post or something as the full details is to much for here.

Reply
0 Kudos
cnaidunaveen
Contributor
Contributor
Jump to solution

Could you please tell me how to add the custom attributes to newly created vm. I need for VRA 8.

Reply
0 Kudos
BrettK1
Enthusiast
Enthusiast
Jump to solution

I'll second this for vRA 8, I've seen a way to do it the complicated way (vRO and event subscriptions, etc) , but wondering if there's something more elegant?

Reply
0 Kudos
swapsweet
Enthusiast
Enthusiast
Jump to solution

I am creating XaaS for updating Custom Attributes of vCenter Vm with user entered values as string or from some predefined list .
How can I have them in XaaS input form (as Simple Input paramter for each Custom Attribiute or Composite types etc ) . Your response to the query is highly appricated 

Reply
0 Kudos