[pmg-devel] applied: [RFC pmg-api 2/4] PMG::Config: refactor dns info collection
Dietmar Maurer
dietmar at proxmox.com
Thu Nov 14 08:04:51 CET 2019
applied
> On 12 November 2019 15:16 Stoiko Ivanov <s.ivanov at proxmox.com> wrote:
>
>
> Create a sub for gathering dns info of the current node (hostname, domainname,
> fqdn) - so we can reuse it.
>
> Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
> ---
> src/PMG/Config.pm | 30 +++++++++++++++++++++---------
> 1 file changed, 21 insertions(+), 9 deletions(-)
>
> diff --git a/src/PMG/Config.pm b/src/PMG/Config.pm
> index 4634bd5..4cbc520 100755
> --- a/src/PMG/Config.pm
> +++ b/src/PMG/Config.pm
> @@ -1175,13 +1175,31 @@ PVE::INotify::register_file('transport', $transport_map_filename,
>
> # config file generation using templates
>
> +sub get_host_dns_info {
> + my ($self) = @_;
> +
> + my $dnsinfo = {};
> + my $nodename = PVE::INotify::nodename();
> +
> + $dnsinfo->{hostname} = $nodename;
> + my $resolv = PVE::INotify::read_file('resolvconf');
> +
> + my $domain = $resolv->{search} // 'localdomain';
> + $dnsinfo->{domain} = $domain;
> +
> + $dnsinfo->{fqdn} = "$nodename.$domain";
> +
> + return $dnsinfo;
> +}
> +
> sub get_template_vars {
> my ($self) = @_;
>
> my $vars = { pmg => $self->get_config() };
>
> - my $nodename = PVE::INotify::nodename();
> - my $int_ip = PMG::Cluster::remote_node_ip($nodename);
> + my $dnsinfo = get_host_dns_info();
> + $vars->{dns} = $dnsinfo;
> + my $int_ip = PMG::Cluster::remote_node_ip($dnsinfo->{hostname});
> $vars->{ipconfig}->{int_ip} = $int_ip;
>
> my $transportnets = [];
> @@ -1259,13 +1277,7 @@ sub get_template_vars {
> $vars->{postfix}->{int_ip} = $int_ip;
> }
>
> - my $resolv = PVE::INotify::read_file('resolvconf');
> - $vars->{dns}->{hostname} = $nodename;
> -
> - my $domain = $resolv->{search} // 'localdomain';
> - $vars->{dns}->{domain} = $domain;
> -
> - my $wlbr = "$nodename.$domain";
> + my $wlbr = $dnsinfo->{fqdn};
> foreach my $r (PVE::Tools::split_list($vars->{pmg}->{spam}->{wl_bounce_relays})) {
> $wlbr .= " $r"
> }
> --
> 2.20.1
>
>
> _______________________________________________
> pmg-devel mailing list
> pmg-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel
More information about the pmg-devel
mailing list