From: Serge Logvinov <serge.logvinov@gmail.com>
To: pve-devel@lists.proxmox.com
Cc: Serge Logvinov <serge.logvinov@sinextra.dev>
Subject: [pve-devel] [PATCH container 1/1] feat: set hostname to meta
Date: Fri, 10 Sep 2021 21:33:43 +0300 [thread overview]
Message-ID: <20210910183343.69805-2-serge.logvinov@sinextra.dev> (raw)
In-Reply-To: <20210910183343.69805-1-serge.logvinov@sinextra.dev>
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)
next prev parent reply other threads:[~2021-09-10 18:34 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2021-09-13 8:03 ` [pve-devel] [PATCH container 1/1] feat: set hostname to meta Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210910183343.69805-2-serge.logvinov@sinextra.dev \
--to=serge.logvinov@gmail.com \
--cc=pve-devel@lists.proxmox.com \
--cc=serge.logvinov@sinextra.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.