Customizing VM Configuration Parameters

Problem:
Is there a way to set VM Configuration Parameters (e.g. disk.EnableUUID) for VMs created by Foreman on vSphere Compute Resources. I believe the VM is created through tfm-rubygem-fog-vsphere plugin. I am looking for some type of configuration or property file that could be modified. If the feature does not exist, maybe it could be added in a future release.
Expected outcome:
I am looking for some type of configuration or property file that could be modified.
Foreman and Proxy versions:
Foreman 1.22.0.33-1
Foreman and Proxy plugin versions:
tfm-rubygem-fog-vsphere 3.2.1-1
Distribution and version:
Red Hat Satellite 6.6.1 on RHEL 7.7
Other relevant data:

I’ve also hit this issue. I want to set disk.EnableUUID to true in advanced properties but can’t see a way to do it. There is an open issue for it but not updated in 3 years.

I have never looked at ruby before but had a search through this code and foreman. Maybe someone with more knowledge can look at this. It looks to me like a change is required in the fog-vsphere code before anything can be done in foreman

It looks like foreman:

def create_vm(args = { })
      vm = nil
      test_connection
      return unless errors.empty?

      args = parse_networks(args)
      args = args.with_indifferent_access
      if args[:provision_method] == 'image'
        clone_vm(args)
      else
        vm = new_vm(args)
        vm.firmware = 'bios' if vm.firmware == 'automatic'
        **vm.save** - actually creates vm
      end
    
def new_vm(args = {})
      args = parse_args args
      opts = vm_instance_defaults.symbolize_keys.merge(args.symbolize_keys).deep_symbolize_keys
      **client.servers.new opts** - gets  Fog::Vsphere::Compute::Server
    end
  1. Gets the connection to the server with Fog::Compute::new (provider = vsphere)
  2. Uses this Fog::Vsphere::Compute to get Fog::Vsphere::Compute::Servers

In fog-vsphere:

  1. Uses new method to get an instance of Fog::Vsphere::Compute::Server to manipulate before creating the VM (vm.save)
  1. Uses save method to create the actual vm which calls create_vm method in

Now here is where it gets interesting. It looks like the create_vm method arguments has an option for these extra parameters called “extra_config” that is used exactly for this, adding custom parameters:

def create_vm(attributes = {})
     ...
     vm_cfg = {
            name: attributes[:name],
            annotation: attributes[:annotation],
            guestId: attributes[:guest_id],
            version: attributes[:hardware_version],
            files: { vmPathName: vm_path_name(attributes) },
            numCPUs: attributes[:cpus],
            numCoresPerSocket: attributes[:corespersocket],
            memoryMB: attributes[:memory_mb],
            deviceChange: device_change(attributes),
            **extraConfig: extra_config(attributes)**
          }

But the Fog::Vsphere::Compute::Server doesn’t have this attribute, and hence foreman can’t set it

If this attribute was available on the Fog::Vsphere::Compute::Server class I think foreman could set it and it would end up in the VM.

Can someone check if I am right, if so I can make a one-line PR in fog-vsphere so at least there is an option for foreman to implement something.

Cheers

server.extra_config = {"disk.EnableUUID" => "TRUE"}

result in VM

image

Hi, @dave93cab!

Awesome work, the PR is definitelly a great direction for the support of the parameter.
I’ll review and it should not be hard to get it in.

Although enabling it on the foreman side will be bit tricky, do we want the extra parameters to be defined and accept only specific attributes we allow, or do we want free form and let users to define these attributes?
I’d be up for the more rigid definition of the attributes and thus allowing only specific attributes, but it would be neccessary for us to allow each manually, though with the right model, it should be quite easy to add another attribute.

Since VMware has a lot of hidden parameters which are only used in very specific situations, maybe leaving this open might be a better option. It’s for advanced use anyway, correct?

I’m sure there are many esoteric uses for them so my gut feeling would be to leaving them open too

Our virtualization team wants an advanced vSphere param set at host creation: snapshot.alwaysAllowNative = TRUE.

Your PR @dave93cab seems to be a great step towards being able to set such params via Foreman. :slight_smile:

Since you seem to have solved your disk.EnableUUID problem, could you point me in the right direction, where to start, if I´d like to pass such a parameter from Foreman to vSphere?
From what I´ve read so far, I´m guessing it is not yet possible to just add something like "extra_config": { "snapshot.alwaysAllowNative": "true" } to a host object passed to the Foreman API?

Any hints are much appreciated. :slight_smile:

Hi, I’d like to user the disk.EnableUUID option but haven’t been able to figure out how to set it in the foreman?

Curious about this as well. Is this feature exposed over the Foreman REST API, or accessible as a parameter under compute_attributes in the theforeman.foreman.host Ansible module? I’m looking to be able to set "efi.quickBoot.enabled" = "FALSE" for VMware virtual machines.