Hi together,
I've got a question regarding how to add date/time automatically to a vm attribute during deployment.
Currently my colleagues need to fill the text field which is linked to VM attribute manually.
They want an automatically filled field in custorm form or a workflow which adds the date/time during deployment to the defined VM attribute.
I've build a workflow which generates the current date, time but I didn't know how to link them to the VM attribute:
var day = new Date().getDate().toString();
var month = (new Date().getMonth() + 1).toString();
if(day.length < 2) {
day = "0" + day;
}
if(month.length < 2) {
month = "0" + month;
}
var hour = new Date().getHours().toString();
var minute = new Date().getMinutes().toString();
if(hour.length < 2) {
hour = "0" + hour;
}
if(minute.length < 2) {
minute = "0" + minute;
}
var date = day + "." + month + "." + new Date().getFullYear() + " " + hour + ":" + minute;
VM attribute: VMware.Attribute0.Value
Did someone no how to connect them so that I can use this workflow in my blueprint to fill automatically the needed attribute?
Thank you guys.
Hi n8watcher,
I think an easy way is to use pre-approval and subscription based on workflow (Scenario: Create a Pre-Approval Workflow Subscription ). In the pre-approval custom properties, add the custom property you want to modify (VMware.Attribute0.Name), and the value (VMware.Attribute0.Value) -- Configure the Approval Form to Include System and Custom Properties
Pre-Approval workflow will update the values previous the machine creation in vCenter and will populate the values in vCenter.
Pre-Approval wf needs to have (at least) two output values: approved (boolean) and fieldValues (Properties)
in approved you will have "true" and fieldValues will be the VMware.Attribute0.Name and VMware.Attribute0.Value:
Example for pre-approval wf:
var fieldValues = new Properties();
var approved = true;
fieldValues.put("source-provider-VMware.Attribute0.Name,VMware.Attribute0.Value);
Regards,
Leandro.
Another way can be like the one in:
How set vm-description/notes and get datastore name, where the vm is located (set vm-description part)
This will copy the description info for the machine in vCenter and add the values you want to add there
This can be executed at the end of machine provisioned with an event subscription.