From 33f7ad52fd0b3578223c4b3472498f062389f2de Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sat, 22 Aug 2020 17:48:27 -0700 Subject: [PATCH] Don't include self-referential structures in list of interfaces, as they can't be serialized --- net/netplan-lib.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/net/netplan-lib.pl b/net/netplan-lib.pl index 1e1e0e0a1..8ab3fdf16 100644 --- a/net/netplan-lib.pl +++ b/net/netplan-lib.pl @@ -627,9 +627,23 @@ foreach my $origl (@$lref) { } $lnum++; } +&cleanup_yaml_parents($rv); return $rv; } +# cleanup_yaml_parents(&config) +# Remove all 'parent' fields once parsing is done, as they can't be serialized +sub cleanup_yaml_parents +{ +my ($conf) = @_; +foreach my $c (@$conf) { + delete($c->{'parent'}); + if ($c->{'members'}) { + &cleanup_yaml_parents($c->{'members'}); + } + } +} + # yaml_lines(&directive, indent-string) sub yaml_lines {