From: Wolfgang Bumiller <w.bumiller@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>
Cc: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] applied: [PATCH pmg-api] config: add ips/nets uniquely to the template variables
Date: Tue, 14 Jun 2022 09:56:12 +0200 [thread overview]
Message-ID: <20220614075612.rsubdorhsnu42pml@casey.proxmox.com> (raw)
In-Reply-To: <20220531115253.3398902-1-d.csapak@proxmox.com>
could have probably gone with a single hash but it's clearer this way
given the function's length
applied
On Tue, May 31, 2022 at 01:52:53PM +0200, Dominik Csapak wrote:
> otherwise a config with many entries such as:
> domain1: ip1
> domain2: ip1
> domain3: ip1
> etc.
>
> unnecessarily adds 'ip1' multiple times to the 'mynetworks' variable
>
> to keep the output sorted (so it's stable) move the sort to the 'join'
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/PMG/Config.pm | 40 +++++++++++++++++++++-------------------
> 1 file changed, 21 insertions(+), 19 deletions(-)
>
> diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
> index 31f9c6f..9ba5c76 100755
> --- a/src/PMG/Config.pm
> +++ b/src/PMG/Config.pm
> @@ -1297,63 +1297,65 @@ sub get_template_vars {
> my $int_ip = PMG::Cluster::remote_node_ip($dnsinfo->{hostname});
> $vars->{ipconfig}->{int_ip} = $int_ip;
>
> - my $transportnets = [];
> + my $transportnets = {};
> + my $mynetworks = {
> + '127.0.0.0/8' => 1,
> + '[::1]/128', => 1,
> + };
>
> if (my $tmap = PVE::INotify::read_file('transport')) {
> - foreach my $domain (sort keys %$tmap) {
> + foreach my $domain (keys %$tmap) {
> my $data = $tmap->{$domain};
> my $host = $data->{host};
> if ($host =~ m/^$IPV4RE$/) {
> - push @$transportnets, "$host/32";
> + $transportnets->{"$host/32"} = 1;
> + $mynetworks->{"$host/32"} = 1;
(...)
prev parent reply other threads:[~2022-06-14 7:56 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-31 11:52 [pmg-devel] " Dominik Csapak
2022-06-14 7:56 ` Wolfgang Bumiller [this message]
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=20220614075612.rsubdorhsnu42pml@casey.proxmox.com \
--to=w.bumiller@proxmox.com \
--cc=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox