public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH container 0/1] Set hostname to meta-data (nocloud method)
@ 2021-09-10 18:33 Serge Logvinov
  2021-09-10 18:33 ` [pve-devel] [PATCH container 1/1] feat: set hostname to meta Serge Logvinov
  0 siblings, 1 reply; 3+ messages in thread
From: Serge Logvinov @ 2021-09-10 18:33 UTC (permalink / raw)
  To: pve-devel; +Cc: Serge Logvinov

*** BLURB HERE ***

Serge Logvinov (1):
  feat: set hostname to meta

  Add hostname property in meta-data (nocloud method).
  Now only user-data has hostname of VM. If you redifine user-data, you lost the hostname.

  Example meta-data here https://cloudinit.readthedocs.io/en/latest/topics/datasources/nocloud.html#datasource-nocloud

  ---
  instance-id: iid-abcdefg
  network-interfaces: |
    iface eth0 inet static
    address 192.168.1.10
    network 192.168.1.0
    netmask 255.255.255.0
    broadcast 192.168.1.255
    gateway 192.168.1.254
  hostname: myhost
  ---

 PVE/QemuServer/Cloudinit.pm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

--
2.24.3 (Apple Git-128)



^ permalink raw reply	[flat|nested] 3+ messages in thread

* [pve-devel] [PATCH container 1/1] feat: set hostname to meta
  2021-09-10 18:33 [pve-devel] [PATCH container 0/1] Set hostname to meta-data (nocloud method) Serge Logvinov
@ 2021-09-10 18:33 ` Serge Logvinov
  2021-09-13  8:03   ` Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Serge Logvinov @ 2021-09-10 18:33 UTC (permalink / raw)
  To: pve-devel; +Cc: Serge Logvinov

Add hostname property in meta-data (nocloud method).
Now only user-data has hostname of VM. If you redifine user-data, you lost the hostname.

Signed-off-by: Serge Logvinov <serge.logvinov@sinextra.dev>
---
 PVE/QemuServer/Cloudinit.pm | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index a5474d3..b1df93d 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -479,15 +479,15 @@ sub nocloud_network {
 }
 
 sub nocloud_metadata {
-    my ($uuid) = @_;
-    return "instance-id: $uuid\n";
+    my ($uuid, $hostname) = @_;
+    return "instance-id: $uuid\nhostname: $hostname\n";
 }
 
 sub nocloud_gen_metadata {
-    my ($user, $network) = @_;
+    my ($user, $network, $hostname) = @_;
 
     my $uuid_str = Digest::SHA::sha1_hex($user.$network);
-    return nocloud_metadata($uuid_str);
+    return nocloud_metadata($uuid_str, $hostname);
 }
 
 sub generate_nocloud {
@@ -498,7 +498,8 @@ sub generate_nocloud {
     $network_data = nocloud_network($conf) if !defined($network_data);
 
     if (!defined($meta_data)) {
-	$meta_data = nocloud_gen_metadata($user_data, $network_data);
+	my ($hostname, $fqdn) = get_hostname_fqdn($conf, $vmid);
+	$meta_data = nocloud_gen_metadata($user_data, $network_data, $hostname);
     }
 
     my $files = {
@@ -589,7 +590,8 @@ sub dump_cloudinit_config {
 	my $user = cloudinit_userdata($conf, $vmid);
 	if ($format eq 'nocloud') {
 	    my $network = nocloud_network($conf);
-	    return nocloud_gen_metadata($user, $network);
+	    my ($hostname, $fqdn) = get_hostname_fqdn($conf, $vmid);
+	    return nocloud_gen_metadata($user, $network, $hostname);
 	} else {
 	    my $network = configdrive2_network($conf);
 	    return configdrive2_gen_metadata($user, $network);
-- 
2.24.3 (Apple Git-128)




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [pve-devel] [PATCH container 1/1] feat: set hostname to meta
  2021-09-10 18:33 ` [pve-devel] [PATCH container 1/1] feat: set hostname to meta Serge Logvinov
@ 2021-09-13  8:03   ` Thomas Lamprecht
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2021-09-13  8:03 UTC (permalink / raw)
  To: Proxmox VE development discussion, Serge Logvinov; +Cc: Serge Logvinov

On 10.09.21 20:33, Serge Logvinov wrote:
> Add hostname property in meta-data (nocloud method).
> Now only user-data has hostname of VM. If you redifine user-data, you lost the hostname.
> 

First, thanks for your contribution!

Before incorporating patches from you we'd need a signed CLA sent to office@proxmox.com
For more details about that see our Developer Documentation:
https://pve.proxmox.com/wiki/Developer_Documentation#Software_License_and_Copyright

cheers,
Thomas




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-09-13  8:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10 18:33 [pve-devel] [PATCH container 0/1] Set hostname to meta-data (nocloud method) Serge Logvinov
2021-09-10 18:33 ` [pve-devel] [PATCH container 1/1] feat: set hostname to meta Serge Logvinov
2021-09-13  8:03   ` Thomas Lamprecht

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal