[pve-devel] [PATCH] Implement support for Cloud-Init vendor data

Mira Limbeck m.limbeck at proxmox.com
Wed Sep 4 15:59:44 CEST 2019


Hi,

Thank you for the patch, will take a closer look as soon as possible.

Three things:

1) What's your use case that 'vendor-data' is required or preferred 
instead of 'user-data'?

2) Did you test it with configdrive2 (on Linux and Windows)? You change 
it not only for nocloud, but also for configdrive2.

3) To support 'vendor-data' you will have to also add it as a possible 
option to 'cicustom' in the API (see the variable $cicustom_fmt in 
PVE/QemuServer.pm).

And one more thing inline

On 9/1/19 8:22 PM, Marlin Cremers wrote:
> The current implementation of Cloud-Init uses user data to set the
> hostname, username, password and SSH keys of the virtual machine.
> This has affect that overriding the user data also stops the logins
> from working using the information provided in the UI. This makes

Do you mean that users that changed the password in the VM can't login 
after a reboot because the original password, set in the cloudinit 
options (and in return in user-data) override the one set by the user?

> implementing a proper user data implementation very difficult as
> it would require merging the actual user data with the credentials
> or avoiding the Proxmox Cloud-Init implementation at all.
>
> This patch includes support for vendor data, this allows Proxmox
> to set the credentials and other settings it needs but still allows
> users to set their own user data. The vendor data can also be
> overridden when necessary.
>
> Signed-off-by: Marlin Cremers <mcremers at cloudbear.nl>
> ---
>   PVE/QemuServer/Cloudinit.pm | 20 +++++++++++++++++---
>   1 file changed, 17 insertions(+), 3 deletions(-)
>
> diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
> index f46f7fd..52c089f 100644
> --- a/PVE/QemuServer/Cloudinit.pm
> +++ b/PVE/QemuServer/Cloudinit.pm
> @@ -106,6 +106,10 @@ sub get_dns_conf {
>   }
>
>   sub cloudinit_userdata {
> +    return ""
> +}
> +
> +sub cloudinit_vendordata {
>       my ($conf, $vmid) = @_;
>
>       my ($hostname, $fqdn) = get_hostname_fqdn($conf, $vmid);
> @@ -216,8 +220,9 @@ EOF
>   sub generate_configdrive2 {
>       my ($conf, $vmid, $drive, $volname, $storeid) = @_;
>
> -    my ($user_data, $network_data, $meta_data) =
> get_custom_cloudinit_files($conf);
> +    my ($user_data, $vendor_data, $network_data, $meta_data) =
> get_custom_cloudinit_files($conf);
>       $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data);
> +    $vendor_data = cloudinit_vendordata($conf, $vmid) if
> !defined($vendor_data);
>       $network_data = configdrive2_network($conf) if !defined($network_data);
>
>       if (!defined($meta_data)) {
> @@ -228,6 +233,7 @@ sub generate_configdrive2 {
>       }
>       my $files = {
>    '/openstack/latest/user_data' => $user_data,
> + '/openstack/latest/vendor_data' => $vendor_data,
>    '/openstack/content/0000' => $network_data,
>    '/openstack/latest/meta_data.json' => $meta_data
>       };
> @@ -388,8 +394,9 @@ sub nocloud_metadata {
>   sub generate_nocloud {
>       my ($conf, $vmid, $drive, $volname, $storeid) = @_;
>
> -    my ($user_data, $network_data, $meta_data) =
> get_custom_cloudinit_files($conf);
> +    my ($user_data, $vendor_data, $network_data, $meta_data) =
> get_custom_cloudinit_files($conf);
>       $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data);
> +    $vendor_data = cloudinit_vendordata($conf, $vmid) if
> !defined($vendor_data);
>       $network_data = nocloud_network($conf) if !defined($network_data);
>
>       if (!defined($meta_data)) {
> @@ -401,6 +408,7 @@ sub generate_nocloud {
>
>       my $files = {
>    '/user-data' => $user_data,
> + '/vendor-data' => $vendor_data,
>    '/network-config' => $network_data,
>    '/meta-data' => $meta_data
>       };
> @@ -415,6 +423,7 @@ sub get_custom_cloudinit_files {
>
>       my $network_volid = $files->{network};
>       my $user_volid = $files->{user};
> +    my $vendor_volid = $files->{vendor};
>       my $meta_volid = $files->{meta};
>
>       my $storage_conf = PVE::Storage::config();
> @@ -429,12 +438,17 @@ sub get_custom_cloudinit_files {
>    $user_data = read_cloudinit_snippets_file($storage_conf, $user_volid);
>       }
>
> +    my $vendor_data;
> +    if ($vendor_volid) {
> +        $vendor_data = read_cloudinit_snippets_file($storage_conf,
> $vendor_volid);
> +    }
> +
>       my $meta_data;
>       if ($meta_volid) {
>    $meta_data = read_cloudinit_snippets_file($storage_conf, $meta_volid);
>       }
>
> -    return ($user_data, $network_data, $meta_data);
> +    return ($user_data, $vendor_data, $network_data, $meta_data);
>   }
>
>   sub read_cloudinit_snippets_file {




More information about the pve-devel mailing list