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

Mira Limbeck m.limbeck at proxmox.com
Thu Sep 26 13:47:49 CEST 2019


I tried applying your patch, but it failed. Looks like the formatting is 
wrong.

Some things 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
> 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);
This should not be in a new line. Text wrap issue? How did you send the 
patch?
> +    my ($user_data, $vendor_data, $network_data, $meta_data) =
> get_custom_cloudinit_files($conf);
same as above
>       $user_data = cloudinit_userdata($conf, $vmid) if !defined($user_data);
> +    $vendor_data = cloudinit_vendordata($conf, $vmid) if
> !defined($vendor_data);
same as above
>       $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
>       };
after cleaning up the previous things, this fails to match.
> @@ -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