cloudbase / cloudbase-init

Cross-platform instance initialization
http://openstack.org
Apache License 2.0
430 stars 152 forks source link

Customize VMWare Guest Info Service to get data from "guestinfo.ovfenv" #127

Open roct37 opened 1 year ago

roct37 commented 1 year ago

Hello,

Cloudinit gets userdatas and metadatas from the extra config key "guestinfo.ovfenv" on the vm properties which is built from ovf environment properties but cloudbase-init seems to only look for "guestinfo.userdata" and "guestinfo.metada". I use a terraform provider which doesnt allow me to add any vmware extra config properties, only vapp properties can be set.

Is it possible to customize cloudbase-init to look in "guestinfo.ovfenv" ?

Thanks in advance for every answers.

ader1990 commented 1 year ago

Hello, maybe OvfService might be a better option in your case?

Thank you.

roct37 commented 1 year ago

Hello, I also cant use ovfservice as the configuration for the ovftransport is always override from ISO image to VMWare tools when i deploy using this provider (i also have an opened issue for this on the provider repo). I can make cloud-init work with linux os because this key "guestinfo.ovfenv" is used, maybe cloudbase-init should use the same ?

ader1990 commented 1 year ago

Hello, I also cant use ovfservice as the configuration for the ovftransport is always override from ISO image to VMWare tools when i deploy using this provider (i also have an opened issue for this on the provider repo). I can make cloud-init work with linux os because this key "guestinfo.ovfenv" is used, maybe cloudbase-init should use the same ?

Hello, I think we can use the same approach, if it s already standard. Is it possible to provide us the cloud-init metadata service configuration that works on Linux?

roct37 commented 1 year ago

Thank you for your answers. With Linux, I use OVF Datasource with vmware guestinfo seed to retrieve the customization datas which are defined in "guestinfo.ovfenv" built from the vapp properties i configured when deploying.

With cloudbase-init, if possible, i'd like to be able to do the same, use OVF as Datasource which will retreive the datas from guestinfo.ovfenv using vmware tools.

Tom-0 commented 9 months ago

Hi Team,

@ader1990 do you know is it planned to implement "guestinfo.ovfEnv" datasource as per above? It would be a great thing to have.

As @roct37 mentioned, the good thing is, this method is very similar to already implemented in cloudbase-init "VMware GuestInfo" service. But all data is present into single "guestinfo.ovfEnv" property. In practice, this property contains the same "ovf-env.xml" as present for "regular" ISO transport method. Which for example is:

<Environment
     xmlns="http://schemas.dmtf.org/ovf/environment/1"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:oe="http://schemas.dmtf.org/ovf/environment/1"
     xmlns:ve="http://www.vmware.com/schema/ovfenv"
     oe:id=""
     ve:vCenterId=".....">
   <PlatformSection>
      <Kind>VMware ESXi</Kind>
      <Version>......</Version>
      <Vendor>VMware, Inc.</Vendor>
      <Locale>en</Locale>
   </PlatformSection>
   <PropertySection>
         <Property oe:key="user-data" oe:value=" BASE64 ENCODED user-data HERE "/>
   </PropertySection>
   <ve:EthernetAdapterSection>
      <ve:Adapter ve:mac="......" ve:network="......" ve:unitNumber="......"/>
   </ve:EthernetAdapterSection>
</Environment>

So the same as rpctool queries guestinfo here: https://github.com/cloudbase/cloudbase-init/blob/master/cloudbaseinit/metadata/services/vmwareguestinfoservice.py#L57 ... it can query "guestinfo.ovfEnv" and further also use base64 decoding.

It is all a bit confusing, TBH I was struggling to get my head around it, especially if cloud-init's documentation for OVF datasource is pretty short: https://cloudinit.readthedocs.io/en/latest/reference/datasources/ovf.html

But reading these two: https://kb.vmware.com/s/article/91809 https://github.com/canonical/cloud-init/pull/1573 ... and checking how it is implemented in cloud-init, finally helped me to understand: https://github.com/canonical/cloud-init/blob/main/cloudinit/sources/DataSourceOVF.py#L302

mehmetaydogduu commented 2 months ago

I prefer to use OVF datasource instead of vmware guestinfo, because OVF is compatible with all platforms with very basic CD-ROM insert. VMware is capable to read OVF data with rpctool or with a cdrom.

Linux cloud-init OVF datasource is reading attributes below:

I prefer to use the exactly same config. Otherwise the metadata server will be a nightmare implementation with 2 different output styles.

Source: https://github.com/canonical/cloud-init/blob/main/cloudinit/sources/DataSourceOVF.py

The solution is not revelant to VMware Guestinfo Service, rather it is revelant to the OVFService