Provision VMware VM programmitically via args

Hi there,

I’m currently trying to provision a vmware vm programmtically as described in the Automation book. Link

I created my args and executed the command as described but I always get the following error:

RuntimeError: Provision failed for the following reasons:
‘Network/Virtual Network’ is required

I don’t know what to do about this error. My args list looks like this, specifics are redacted but I think that a certain parameter value is missing.

arg1 = version

args = [‘1.1’]

arg2 = templateFields

args << {‘name’ => ‘template-name’,
‘request_type’ => ‘template’}

arg3 = vmFields

args << {‘vm_name’ => ‘vm_name’,
‘number_of_vms’ => ‘1’,
‘placement_cluster_name’ => ‘cluster-name’,
‘vlan’ => “vlan-name”,
‘network’ => “dvs-name”,
‘is_dvs’ => ‘true’,
‘portgroupName’ => ‘pg-name’,
‘vm_memory’ => ‘1024’,
‘sysprep_computer_name’ => ‘vm-name’,
‘ip_addr’ => ‘ip-addr’,
‘provision_type’ => ‘vmware’,
‘network_adapters’ => ‘1’}

arg4 = requester

args << {‘owner_email’ => ‘’,
‘owner_first_name’ => ‘first’,
‘owner_last_name’ => ‘last’}

arg5 = tags

args << nil

arg6 = additionalValues (ws_values)

args << {‘network’ => ‘dvs-name’ }

arg7 = emsCustomAttributes

args << nil

arg8 = miqCustomAttributes

args << nil

Any help is appreciated.

1 Like


I stumbled upon this Code Snippet

def validate_field_data(dialog_tab, dialog_group)
return if !required? && @value.blank? || !visible
return “#{dialog_tab.label}/#{dialog_group.label}/#{label} is required” if required? && @value.blank?
return “#{dialog_tab.label}/#{dialog_group.label}/#{label} must be an integer” if value_supposed_to_be_int?

# currently only regex is supported
rule = validator_rule if validator_type == ‘regex’

return unless rule
“#{dialog_tab.label}/#{dialog_group.label}/#{label} is invalid” unless @value.to_s =~ /#{rule}/

and therefore I looked up my preconfigured provisioning dialogs and found this part

 :description: Network
        :dvs: true
        :vlans: true
      :method: :allowed_vlans
    :description: Virtual Network
    :required: true
    :display: :edit
    :data_type: :string
    :description: MAC Address
    :required: false
    :display: :hide
    :data_type: :string

So I’m still trying to figure out which params and values are required in the args.

1 Like


just for anybody who stumbles across this post. The problem is partly solved.

As shown in the provisioning dialog snippet you need to set “vlan”.

I’m still not sure which values are accepted. I currently use the vlan name given by vmware. However, if it is a dvSwitch, the prefix “dvs_” must be set.

Maybe ManageIQ ID’s or something like that are also accepted as value but I had no success when testing.

Kind Regards,