From d671cb3fcaf9eeec6a4d8ff5a95f3c6c72bd2781 Mon Sep 17 00:00:00 2001 From: John Southworth Date: Fri, 6 Jan 2012 15:40:28 -0800 Subject: Add function to return zone policy information so that it may be easily queried from the webgui and operational commands --- lib/Vyatta/Zone.pm | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/lib/Vyatta/Zone.pm b/lib/Vyatta/Zone.pm index a4c9d64..763be7a 100755 --- a/lib/Vyatta/Zone.pm +++ b/lib/Vyatta/Zone.pm @@ -498,4 +498,31 @@ $zone_chain chain failed [$error]" if $error; return; } +sub get_zone_hash { + #### Return a hash containing zone policy for use in operational/gui commands + my $zone_hash = (); + my @zones = get_all_zones("listOrigNodes"); + for my $zone (@zones){ + my @from_zones = get_from_zones("listOrigNodes", $zone); + for my $from_zone (@from_zones){ + $zone_hash->{$zone}{'from'}->{$from_zone}{'firewall'}->{'ipv4'} = + get_firewall_ruleset("returnOrigValue", $zone, $from_zone, "name"); + $zone_hash->{$zone}{'from'}->{$from_zone}{'firewall'}->{'ipv6'} = + get_firewall_ruleset("returnOrigValue", $zone, $from_zone, "ipv6-name"); + $zone_hash->{$zone}{'from'}->{$from_zone}{'content-inspection'} = + is_ips_enabled("returnOrigValue", $zone, $from_zone, "enable"); + } + if (is_local_zone("existsOrig", $zone)){ + $zone_hash->{$zone}{'interfaces'} = ['local-zone']; + } else { + my @interfaces = get_zone_interfaces("returnOrigValues", $zone); + $zone_hash->{$zone}{'interfaces'} = [@interfaces]; + } + my $config = new Vyatta::Config; + my $desc = $config->returnOrigValue("zone-policy zone $zone description"); + $zone_hash->{$zone}{'description'} = $desc; + } + return $zone_hash; +} + 1; -- cgit v1.2.3