summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-21 17:09:30 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2008-11-21 17:09:30 -0800
commit32cefc2d846f9946bf6e5b84cd914b5e2959dbfa (patch)
tree0bbb5d52e5621b84a897bd023ae51e15c9e72be9
parent6d87be16190a658ac324488024a82961774f0ece (diff)
downloadvyatta-cfg-32cefc2d846f9946bf6e5b84cd914b5e2959dbfa.tar.gz
vyatta-cfg-32cefc2d846f9946bf6e5b84cd914b5e2959dbfa.zip
Convert VyattaConfig (et al) to Vyatta::Config
Use hierarchal directory structure
-rw-r--r--Makefile.am15
-rwxr-xr-xlib/Vyatta/Config.pm (renamed from scripts/VyattaConfig.pm)34
-rwxr-xr-xlib/Vyatta/ConfigDOMTree.pm (renamed from scripts/VyattaConfigDOMTree.pm)6
-rwxr-xr-xlib/Vyatta/ConfigLoad.pm (renamed from scripts/VyattaConfigLoad.pm)11
-rwxr-xr-xlib/Vyatta/ConfigOutput.pm (renamed from scripts/VyattaConfigOutput.pm)13
-rwxr-xr-xlib/Vyatta/Misc.pm (renamed from scripts/VyattaMisc.pm)8
-rwxr-xr-xlib/Vyatta/TypeChecker.pm (renamed from scripts/VyattaTypeChecker.pm)11
-rwxr-xr-xscripts/VyattaIpTablesAddressFilter.pm207
-rwxr-xr-x[-rw-r--r--]scripts/vyatta-check-typeless-node.pl6
-rwxr-xr-xscripts/vyatta-cli-expand-var.pl4
-rwxr-xr-x[-rw-r--r--]scripts/vyatta-config-gen-sets.pl4
-rwxr-xr-xscripts/vyatta-config-loader.pl4
-rwxr-xr-xscripts/vyatta-find-type.pl4
-rwxr-xr-x[-rw-r--r--]scripts/vyatta-interfaces.pl26
-rwxr-xr-xscripts/vyatta-load-config.pl6
-rwxr-xr-xscripts/vyatta-output-config.pl12
-rwxr-xr-xscripts/vyatta-save-config.pl8
-rwxr-xr-xscripts/vyatta-validate-type.pl4
18 files changed, 92 insertions, 291 deletions
diff --git a/Makefile.am b/Makefile.am
index 7de4e17..9e60f85 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,5 +1,5 @@
cfgdir = $(datadir)/vyatta-cfg/templates
-share_perl5dir = /opt/vyatta/share/perl5
+share_perl5dir = /opt/vyatta/share/perl5/Vyatta
completiondir = /etc/bash_completion.d
initddir = /etc/init.d
defaultdir = /etc/default
@@ -45,13 +45,12 @@ sbin_SCRIPTS += scripts/vyatta-interfaces.pl
sbin_SCRIPTS += scripts/vyatta-irqaffin
sbin_SCRIPTS += scripts/vyatta-check-typeless-node.pl
-share_perl5_SCRIPTS = scripts/VyattaConfig.pm
-share_perl5_SCRIPTS += scripts/VyattaConfigDOMTree.pm
-share_perl5_SCRIPTS += scripts/VyattaConfigOutput.pm
-share_perl5_SCRIPTS += scripts/VyattaConfigLoad.pm
-share_perl5_SCRIPTS += scripts/VyattaMisc.pm
-share_perl5_SCRIPTS += scripts/VyattaTypeChecker.pm
-share_perl5_SCRIPTS += scripts/VyattaIpTablesAddressFilter.pm
+share_perl5_DATA = lib/Vyatta/Config.pm
+share_perl5_DATA += lib/Vyatta/Misc.pm
+share_perl5_DATA += lib/Vyatta/TypeChecker.pm
+share_perl5_DATA += lib/Vyatta/ConfigDOMTree.pm
+share_perl5_DATA += lib/Vyatta/ConfigOutput.pm
+share_perl5_DATA += lib/Vyatta/ConfigLoad.pm
default_DATA = etc/default/vyatta-cfg
diff --git a/scripts/VyattaConfig.pm b/lib/Vyatta/Config.pm
index 9ddc8ef..7074d9c 100755
--- a/scripts/VyattaConfig.pm
+++ b/lib/Vyatta/Config.pm
@@ -19,11 +19,11 @@
# All Rights Reserved.
# **** End License ****
-package VyattaConfig;
+package Vyatta::Config;
use strict;
-use VyattaConfigDOMTree;
+use Vyatta::ConfigDOMTree;
my %fields = (
_changes_only_dir_base => $ENV{VYATTA_CHANGES_ONLY_DIR},
@@ -84,7 +84,7 @@ sub listNodes {
$path = $self->{_new_config_dir_base} . $self->{_current_dir_level};
}
- #print "DEBUG VyattaConfig->listNodes(): path = $path\n";
+ #print "DEBUG Vyatta::Config->listNodes(): path = $path\n";
opendir DIR, "$path" or return ();
@nodes = grep !/^\./, readdir DIR;
closedir DIR;
@@ -94,7 +94,7 @@ sub listNodes {
my $tmp = pop (@nodes);
$tmp =~ s/\n//g;
$tmp =~ s/%2F/\//g;
- #print "DEBUG VyattaConfig->listNodes(): node = $tmp\n";
+ #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n";
push @nodes_modified, $tmp;
}
@@ -119,7 +119,7 @@ sub listOrigNodes {
$path = $self->{_active_dir_base} . $self->{_current_dir_level};
}
- #print "DEBUG VyattaConfig->listNodes(): path = $path\n";
+ #print "DEBUG Vyatta::Config->listNodes(): path = $path\n";
opendir DIR, "$path" or return ();
@nodes = grep !/^\./, readdir DIR;
closedir DIR;
@@ -129,7 +129,7 @@ sub listOrigNodes {
my $tmp = pop (@nodes);
$tmp =~ s/\n//g;
$tmp =~ s/%2F/\//g;
- #print "DEBUG VyattaConfig->listNodes(): node = $tmp\n";
+ #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n";
push @nodes_modified, $tmp;
}
@@ -154,7 +154,7 @@ sub listOrigNodesNoDef {
$path = $self->{_active_dir_base} . $self->{_current_dir_level};
}
- #print "DEBUG VyattaConfig->listNodes(): path = $path\n";
+ #print "DEBUG Vyatta::Config->listNodes(): path = $path\n";
opendir DIR, "$path" or return ();
@nodes = grep !/^\./, readdir DIR;
closedir DIR;
@@ -164,7 +164,7 @@ sub listOrigNodesNoDef {
my $tmp = pop (@nodes);
$tmp =~ s/\n//g;
$tmp =~ s/%2F/\//g;
- #print "DEBUG VyattaConfig->listNodes(): node = $tmp\n";
+ #print "DEBUG Vyatta::Config->listNodes(): node = $tmp\n";
if ($tmp ne 'def') {
push @nodes_modified, $tmp;
}
@@ -376,13 +376,13 @@ sub isChangedOrDeleted {
sub isAdded {
my ($self, $node) = @_;
- #print "DEBUG VyattaConfig->isAdded(): node $node\n";
+ #print "DEBUG Vyatta::Config->isAdded(): node $node\n";
# let's setup the filepath for the modify dir
$node =~ s/\//%2F/g;
$node =~ s/\s+/\//g;
my $filepathNewConfig = "$self->{_new_config_dir_base}$self->{_current_dir_level}/$node";
- #print "DEBUG VyattaConfig->isAdded(): filepath $filepathNewConfig\n";
+ #print "DEBUG Vyatta::Config->isAdded(): filepath $filepathNewConfig\n";
# if the node doesn't exist in the modify dir, it's not
# been added. so short circuit and return false.
@@ -415,7 +415,7 @@ sub listNodeStatus {
@nodes = $self->listNodes("$path");
foreach my $node (@nodes) {
if ($node =~ /.+/) {
- #print "DEBUG VyattaConfig->listNodeStatus(): node $node\n";
+ #print "DEBUG Vyatta::Config->listNodeStatus(): node $node\n";
# No deleted nodes -- added, changed, ot static only.
if ($self->isAdded("$path $node")) { $nodehash{$node} = "added"; }
elsif ($self->isChanged("$path $node")) { $nodehash{$node} = "changed"; }
@@ -433,7 +433,7 @@ sub createActiveDOMTree {
my $self = shift;
- my $tree = new VyattaConfigDOMTree($self->{_active_dir_base} . $self->{_current_dir_level},"active");
+ my $tree = new Vyatta::Config::DOMTree($self->{_active_dir_base} . $self->{_current_dir_level},"active");
return $tree;
}
@@ -443,7 +443,7 @@ sub createChangesOnlyDOMTree {
my $self = shift;
- my $tree = new VyattaConfigDOMTree($self->{_changes_only_dir_base} . $self->{_current_dir_level},
+ my $tree = new Vyatta::Config::DOMTree($self->{_changes_only_dir_base} . $self->{_current_dir_level},
"changes_only");
return $tree;
@@ -453,11 +453,9 @@ sub createChangesOnlyDOMTree {
sub createNewConfigDOMTree {
my $self = shift;
+ my $level = $self->{_new_config_dir_base} . $self->{_current_dir_level};
- my $tree = new VyattaConfigDOMTree($self->{_new_config_dir_base} . $self->{_current_dir_level},
- "new_config");
-
- return $tree;
+ return new Vyatta::Config::DOMTree($level, "new_config");
}
@@ -601,3 +599,5 @@ sub compareValueLists {
}
return %comp_hash;
}
+
+1;
diff --git a/scripts/VyattaConfigDOMTree.pm b/lib/Vyatta/ConfigDOMTree.pm
index 4e7ce31..865f17b 100755
--- a/scripts/VyattaConfigDOMTree.pm
+++ b/lib/Vyatta/ConfigDOMTree.pm
@@ -32,7 +32,7 @@
#
#
-package VyattaConfigDOMTree;
+package Vyatta::ConfigDOMTree;
use strict;
@@ -350,7 +350,7 @@ sub _construct_dom_tree {
$valuePresent++;
}
} elsif (-d $fn) {
- my $subnode = new VyattaConfigDOMTree($fn,$entry);
+ my $subnode = new Vyatta::ConfigDOMTree($fn,$entry);
if(defined $subnode) {
if(! defined $self->{_subnodes} ) {
$self->{_subnodes} = {};
@@ -368,3 +368,5 @@ sub _construct_dom_tree {
return $self;
}
+
+1;
diff --git a/scripts/VyattaConfigLoad.pm b/lib/Vyatta/ConfigLoad.pm
index 5305dc8..f7c0154 100755
--- a/scripts/VyattaConfigLoad.pm
+++ b/lib/Vyatta/ConfigLoad.pm
@@ -18,13 +18,16 @@
# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc.
# All Rights Reserved.
-package VyattaConfigLoad;
+package Vyatta::ConfigLoad;
+
+our @EXPORT = qw(getStartupConfigStatements loadConfigHierarchy getConfigDiff);
+use base qw(Exporter);
use strict;
use sort 'stable';
-use lib "/opt/vyatta/share/perl5/";
+use lib "/opt/vyatta/share/perl5";
use XorpConfigParser;
-use VyattaConfig;
+use Vyatta::Config;
# configuration ordering. higher rank configured before lower rank.
my $default_rank = 0;
@@ -390,7 +393,7 @@ sub findSetNodes {
# $0: hash ref of config hierarchy.
# return: hash containing the diff.
sub getConfigDiff {
- $active_cfg = new VyattaConfig;
+ $active_cfg = new Vyatta::Config;
$new_cfg_ref = shift;
@set_list = ();
@delete_list = ();
diff --git a/scripts/VyattaConfigOutput.pm b/lib/Vyatta/ConfigOutput.pm
index fa0b274..c45dff9 100755
--- a/scripts/VyattaConfigOutput.pm
+++ b/lib/Vyatta/ConfigOutput.pm
@@ -27,11 +27,14 @@
# outputActiveConfig()
# prints the "active" config. suitable for "saving", for example.
-package VyattaConfigOutput;
+package Vyatta::ConfigOutput;
+our @EXPORT = qw(setshow_all set_hide_password outputActiveConfig outputNewConfig);
+use base qw(Exporter);
use strict;
-use lib '/opt/vyatta/share/perl5/';
-use VyattaConfig;
+use lib '/opt/vyatta/share/perl5';
+use Vyatta::Config;
+
use Sort::Versions;
# whether to show default values
@@ -324,7 +327,7 @@ sub displayChildren {
# @ARGV: represents the 'root' path. the output starts at this point under
# the new config.
sub outputNewConfig {
- $config = new VyattaConfig;
+ $config = new Vyatta::Config;
$config->setLevel(join ' ', @_);
my %rnodes = $config->listNodeStatus();
if (scalar(keys %rnodes) > 0) {
@@ -363,7 +366,7 @@ sub outputNewConfig {
# @ARGV: represents the 'root' path. the output starts at this point under
# the active config.
sub outputActiveConfig {
- $config = new VyattaConfig;
+ $config = new Vyatta::Config;
$config->setLevel(join ' ', @_);
displayDeletedOrigChildren([ @_ ], '', 1);
}
diff --git a/scripts/VyattaMisc.pm b/lib/Vyatta/Misc.pm
index 5f7b436..463f5d1 100755
--- a/scripts/VyattaMisc.pm
+++ b/lib/Vyatta/Misc.pm
@@ -21,7 +21,7 @@
# All Rights Reserved.
# **** End License ****
-package VyattaMisc;
+package Vyatta::Misc;
require Exporter;
@ISA = qw(Exporter);
@EXPORT = qw(getNetAddIP isIpAddress is_ip_v4_or_v6);
@@ -30,7 +30,7 @@ require Exporter;
use strict;
-use VyattaConfig;
+use Vyatta::Config;
sub get_sysfs_value {
my ($intf, $name) = @_;
@@ -48,7 +48,7 @@ sub get_sysfs_value {
sub is_dhcp_enabled {
my ($intf, $outside_cli) = @_;
- my $config = new VyattaConfig;
+ my $config = new Vyatta::Config;
if (!($outside_cli eq '')) {
$config->{_active_dir_base} = "/opt/vyatta/config/active/";
}
@@ -483,4 +483,4 @@ sub getPortRuleString {
return ($rule_str, undef);
}
-return 1;
+1;
diff --git a/scripts/VyattaTypeChecker.pm b/lib/Vyatta/TypeChecker.pm
index f77664f..124dc17 100755
--- a/scripts/VyattaTypeChecker.pm
+++ b/lib/Vyatta/TypeChecker.pm
@@ -21,9 +21,9 @@
# Perl module for type validation.
# Usage 1: validate a value of a specific type.
-# use VyattaTypeChecker;
+# use Vyatta::TypeChecker;
# ...
-# if (VyattaTypeChecker::validateType('ipv4', '1.1.1.1')) {
+# if (validateType('ipv4', '1.1.1.1')) {
# # valid
# ...
# } else {
@@ -33,7 +33,7 @@
#
# Usage 2: find the type of a value (from a list of candidates), returns
# undef if the value is not valid for any of the candidates.
-# $valtype = VyattaTypeChecker::findType('1.1.1.1', 'ipv4', 'ipv6');
+# $valtype = findType('1.1.1.1', 'ipv4', 'ipv6');
# if (!defined($valtype)) {
# # neither ipv4 nor ipv6
# ...
@@ -45,7 +45,9 @@
# }
# }
-package VyattaTypeChecker;
+package Vyatta::TypeChecker;
+our @EXPORT = qw(findType validateType);
+use base qw(Exporter);
use strict;
@@ -225,4 +227,3 @@ sub findType {
}
1;
-
diff --git a/scripts/VyattaIpTablesAddressFilter.pm b/scripts/VyattaIpTablesAddressFilter.pm
deleted file mode 100755
index 9789fef..0000000
--- a/scripts/VyattaIpTablesAddressFilter.pm
+++ /dev/null
@@ -1,207 +0,0 @@
-#!/usr/bin/perl
-
-# Author: An-Cheng Huang <ancheng@vyatta.com>
-# Date: 2007
-# Description: IP tables address filter
-
-# **** License ****
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License version 2 as
-# published by the Free Software Foundation.
-#
-# This program is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# General Public License for more details.
-#
-# This code was originally developed by Vyatta, Inc.
-# Portions created by Vyatta are Copyright (C) 2006, 2007, 2008 Vyatta, Inc.
-# All Rights Reserved.
-# **** End License ****
-
-package VyattaIpTablesAddressFilter;
-
-use VyattaConfig;
-use VyattaMisc;
-use VyattaTypeChecker;
-
-my %_protocolswithports = (
- tcp => 1,
- udp => 1,
- 6 => 1,
- 17 => 1,
-);
-
-my %fields = (
- _srcdst => undef,
- _range_start => undef,
- _range_stop => undef,
- _network => undef,
- _address => undef,
- _port => undef,
- _protocol => undef,
- _src_mac => undef,
-);
-
-sub new {
- my $that = shift;
- my $class = ref ($that) || $that;
- my $self = {
- %fields,
- };
-
- bless $self, $class;
- return $self;
-}
-
-sub setup {
- my ($self, $level) = @_;
- my $config = new VyattaConfig;
-
- $config->setLevel("$level");
-
- # setup needed parent nodes
- $self->{_srcdst} = $config->returnParent("..");
- $self->{_protocol} = $config->returnValue(".. protocol");
-
- # setup address filter nodes
- $self->{_address} = $config->returnValue("address");
- $self->{_network} = undef;
- $self->{_range_start} = undef;
- $self->{_range_stop} = undef;
- if (defined($self->{_address})) {
- if ($self->{_address} =~ /\//) {
- $self->{_network} = $self->{_address};
- $self->{_address} = undef;
- } elsif ($self->{_address} =~ /^([^-]+)-([^-]+)$/) {
- $self->{_range_start} = $1;
- $self->{_range_stop} = $2;
- $self->{_address} = undef;
- }
- }
-
- $self->{_port} = $config->returnValue("port");
- $self->{_src_mac} = $config->returnValue("mac-address");
-
- return 0;
-}
-
-sub setupOrig {
- my ($self, $level) = @_;
- my $config = new VyattaConfig;
-
- $config->setLevel("$level");
-
- # setup needed parent nodes
- $self->{_srcdst} = $config->returnParent("..");
- $self->{_protocol} = $config->returnOrigValue(".. protocol");
-
- # setup address filter nodes
- $self->{_address} = $config->returnOrigValue("address");
- $self->{_network} = undef;
- $self->{_range_start} = undef;
- $self->{_range_stop} = undef;
- if (defined($self->{_address})) {
- if ($self->{_address} =~ /\//) {
- $self->{_network} = $self->{_address};
- $self->{_address} = undef;
- } elsif ($self->{_address} =~ /^([^-]+)-([^-]+)$/) {
- $self->{_range_start} = $1;
- $self->{_range_stop} = $2;
- $self->{_address} = undef;
- }
- }
-
- $self->{_port} = $config->returnOrigValue("port");
- $self->{_src_mac} = $config->returnValue("mac-address");
-
- return 0;
-}
-
-sub print {
- my ($self) = @_;
-
- print "srcdst: $self->{_srcdst}\n" if defined $self->{_srcdst};
- print "range start: $self->{_range_start}\n" if defined $self->{_range_start};
- print "range stop: $self->{_range_stop}\n" if defined $self->{_range_stop};
- print "network: $self->{_network}\n" if defined $self->{_network};
- print "address: $self->{_address}\n" if defined $self->{_address};
- print "port: $self->{_port}\n" if defined $self->{_port};
- print "protocol: $self->{_protocol}\n" if defined $self->{_protocol};
- print "src-mac: $self->{_src_mac}\n" if defined $self->{_src_mac};
-
- return 0;
-}
-
-sub rule {
- my ($self) = @_;
- my $rule = "";
- my $can_use_port = 1;
-
- if (!defined($self->{_protocol})
- || !defined($_protocolswithports{$self->{_protocol}})) {
- $can_use_port = 0;
- }
-
- if (($self->{_srcdst} eq "source") && (defined($self->{_src_mac}))) {
- # handle src mac
- my $str = $self->{_src_mac};
- $str =~ s/^\!(.*)$/! $1/;
- $rule .= "-m mac --mac-source $str ";
- }
-
- # set the address filter parameters
- if (defined($self->{_network})) {
- my $str = $self->{_network};
- return (undef, "\"$str\" is not a valid IP subnet")
- if (!VyattaTypeChecker::validateType('ipv4net_negate', $str, 1));
- $str =~ s/^\!(.*)$/! $1/;
- $rule .= "--$self->{_srcdst} $str ";
- } elsif (defined($self->{_address})) {
- my $str = $self->{_address};
- return (undef, "\"$str\" is not a valid IP address")
- if (!VyattaTypeChecker::validateType('ipv4_negate', $str, 1));
- $str =~ s/^\!(.*)$/! $1/;
- $rule .= "--$self->{_srcdst} $str ";
- } elsif ((defined $self->{_range_start}) && (defined $self->{_range_stop})) {
- my $start = $self->{_range_start};
- my $stop = $self->{_range_stop};
- return (undef, "\"$start-$stop\" is not a valid IP range")
- if (!VyattaTypeChecker::validateType('ipv4_negate', $start, 1)
- || !VyattaTypeChecker::validateType('ipv4', $stop, 1));
- my $negate = '';
- if ($self->{_range_start} =~ /^!(.*)$/) {
- $start = $1;
- $negate = '! '
- }
- if ("$self->{_srcdst}" eq "source") {
- $rule .= ("-m iprange $negate--src-range $start-$self->{_range_stop} ");
- }
- elsif ("$self->{_srcdst}" eq "destination") {
- $rule .= ("-m iprange $negate--dst-range $start-$self->{_range_stop} ");
- }
- }
-
- my ($port_str, $port_err)
- = VyattaMisc::getPortRuleString($self->{_port}, $can_use_port,
- ($self->{_srcdst} eq "source") ? "s" : "d",
- $self->{_protocol});
- return (undef, $port_err) if (!defined($port_str));
- $rule .= $port_str;
- return ($rule, undef);
-}
-
-sub outputXmlElem {
- my ($name, $value, $fh) = @_;
- print $fh " <$name>$value</$name>\n";
-}
-
-sub outputXml {
- my ($self, $prefix, $fh) = @_;
- outputXmlElem("${prefix}_addr", $self->{_address}, $fh);
- outputXmlElem("${prefix}_net", $self->{_network}, $fh);
- outputXmlElem("${prefix}_addr_start", $self->{_range_start}, $fh);
- outputXmlElem("${prefix}_addr_stop", $self->{_range_stop}, $fh);
- outputXmlElem("${prefix}_port", $self->{_port}, $fh);
-}
-
diff --git a/scripts/vyatta-check-typeless-node.pl b/scripts/vyatta-check-typeless-node.pl
index 65a7408..1780a5e 100644..100755
--- a/scripts/vyatta-check-typeless-node.pl
+++ b/scripts/vyatta-check-typeless-node.pl
@@ -1,7 +1,7 @@
#!/usr/bin/perl
use lib "/opt/vyatta/share/perl5/";
-use VyattaConfig;
-use VyattaMisc;
+use Vyatta::Config;
+use Vyatta::Misc;
use Getopt::Long;
## Check if a typeless node exists
@@ -9,7 +9,7 @@ use Getopt::Long;
# i.e. $VAR(./node/) always expands to true. Once bug 2525 is properly
# fixed, this can go away
my $node = shift;
-my $config = new VyattaConfig;
+my $config = new Vyatta::Config;
if ($config->exists("$node")) {
exit 0;
diff --git a/scripts/vyatta-cli-expand-var.pl b/scripts/vyatta-cli-expand-var.pl
index 2691615..f690f0b 100755
--- a/scripts/vyatta-cli-expand-var.pl
+++ b/scripts/vyatta-cli-expand-var.pl
@@ -21,7 +21,7 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
-use VyattaConfig;
+use Vyatta::Config;
# expand a variable reference
if ($#ARGV != 0) {
@@ -59,7 +59,7 @@ if (/\@/) {
exit 1;
}
-my $config = new VyattaConfig;
+my $config = new Vyatta::Config;
my $path_str = join ' ', (split /\//);
my $val_str = "";
if ($multi_val) {
diff --git a/scripts/vyatta-config-gen-sets.pl b/scripts/vyatta-config-gen-sets.pl
index b9b083e..2fe4ac6 100644..100755
--- a/scripts/vyatta-config-gen-sets.pl
+++ b/scripts/vyatta-config-gen-sets.pl
@@ -25,7 +25,7 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
-use VyattaConfigLoad;
+use Vyatta::ConfigLoad;
my $conf_file = '/opt/vyatta/etc/config/config.boot';
@@ -33,7 +33,7 @@ $conf_file = $ARGV[0] if defined $ARGV[0];
# get a list of all config statement in the startup config file
# (sorted by rank).
-my @all_nodes = VyattaConfigLoad::getStartupConfigStatements($conf_file);
+my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($conf_file);
if (scalar(@all_nodes) == 0) {
# no config statements
exit 1;
diff --git a/scripts/vyatta-config-loader.pl b/scripts/vyatta-config-loader.pl
index 29b6bcd..856799a 100755
--- a/scripts/vyatta-config-loader.pl
+++ b/scripts/vyatta-config-loader.pl
@@ -24,7 +24,7 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
-use VyattaConfigLoad;
+use Vyatta::ConfigLoad;
umask 0002;
@@ -47,7 +47,7 @@ sub restore_fds {
# get a list of all config statement in the startup config file
# (sorted by rank).
-my @all_nodes = VyattaConfigLoad::getStartupConfigStatements($ARGV[0]);
+my @all_nodes = Vyatta::ConfigLoad::getStartupConfigStatements($ARGV[0]);
if (scalar(@all_nodes) == 0) {
# no config statements
restore_fds();
diff --git a/scripts/vyatta-find-type.pl b/scripts/vyatta-find-type.pl
index 3c9ccc6..9621a58 100755
--- a/scripts/vyatta-find-type.pl
+++ b/scripts/vyatta-find-type.pl
@@ -21,7 +21,7 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
-use VyattaTypeChecker;
+use Vyatta::TypeChecker;
# find the type of a value (from a list of candidates)
if ($#ARGV < 1) {
@@ -29,7 +29,7 @@ if ($#ARGV < 1) {
exit 1;
}
-if (my $type = VyattaTypeChecker::findType(@ARGV)) {
+if (my $type = Vyatta::TypeChecker::findType(@ARGV)) {
# type found
print "$type";
exit 0;
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index 6453717..31b7d8d 100644..100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -31,8 +31,8 @@
#
use lib "/opt/vyatta/share/perl5/";
-use VyattaConfig;
-use VyattaMisc;
+use Vyatta::Config;
+use Vyatta::Misc;
use Getopt::Long;
use POSIX;
@@ -126,7 +126,7 @@ sub dhcp_conf_header {
sub is_address_enabled {
my $intf = shift;
- my $config = new VyattaConfig;
+ my $config = new Vyatta::Config;
## FIXME this is name based madness find a better way
## so we don't have to redo with each interface type!
@@ -160,20 +160,20 @@ sub is_address_enabled {
}
sub get_hostname {
- my $config = new VyattaConfig;
+ my $config = new Vyatta::Config;
$config->setLevel("system");
return $config->returnValue("host-name");
}
sub is_domain_name_set {
- my $config = new VyattaConfig;
+ my $config = new Vyatta::Config;
$config->setLevel("system");
return $config->returnValue("domain-name");
}
sub get_mtu {
my $intf = shift;
- my $config = new VyattaConfig;
+ my $config = new Vyatta::Config;
$config->setLevel("interfaces $intf");
return $config->returnValue("mtu");
}
@@ -224,7 +224,7 @@ sub is_intf_disabled {
exit 1;
}
- my $config = new VyattaConfig;
+ my $config = new Vyatta::Config;
$config->setLevel("$intf_cli_path");
if ($intf =~ m/^br/) {
@@ -245,7 +245,7 @@ sub is_intf_disabled {
sub run_dhclient {
my $intf = shift;
- my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = VyattaMisc::generate_dhclient_intf_files($intf);
+ my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = Vyatta::Misc::generate_dhclient_intf_files($intf);
dhcp_update_config($intf_config_file, $intf);
if (!(is_intf_disabled($intf))) {
my $cmd = "$dhcp_daemon -q -nw -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file $intf 2> /dev/null &";
@@ -258,7 +258,7 @@ sub run_dhclient {
sub stop_dhclient {
my $intf = shift;
if (!(is_intf_disabled($intf))) {
- my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = VyattaMisc::generate_dhclient_intf_files($intf);
+ my ($intf_config_file, $intf_process_id_file, $intf_leases_file) = Vyatta::Misc::generate_dhclient_intf_files($intf);
my $release_cmd = "$dhcp_daemon -q -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file -r $intf 2> /dev/null";
system ($release_cmd) == 0
or warn "stop $dhcp_daemon failed: $?\n";
@@ -387,7 +387,7 @@ sub is_valid_addr {
print "Error: can't use dhcp client on loopback interface\n";
exit 1;
}
- if (VyattaMisc::is_dhcp_enabled($intf)) {
+ if (Vyatta::Misc::is_dhcp_enabled($intf)) {
print "Error: dhcp already configured for $intf\n";
exit 1;
}
@@ -433,7 +433,7 @@ sub is_valid_addr {
}
}
- if (VyattaMisc::is_dhcp_enabled($intf)) {
+ if (Vyatta::Misc::is_dhcp_enabled($intf)) {
print "Error: remove dhcp before adding static addresses for $intf\n";
exit 1;
}
@@ -459,12 +459,12 @@ sub is_valid_addr {
sub op_dhcp_command {
my ($op_command, $intf) = @_;
- if (!VyattaMisc::is_dhcp_enabled($intf)) {
+ if (!Vyatta::Misc::is_dhcp_enabled($intf)) {
print "$intf is not using DHCP to get an IP address\n";
exit 1;
}
- my $flags = VyattaMisc::get_sysfs_value($intf, 'flags');
+ my $flags = Vyatta::Misc::get_sysfs_value($intf, 'flags');
my $hex_flags = hex($flags);
if (!($hex_flags & 0x1)) {
print "$intf is disabled. Unable to release/renew lease\n";
diff --git a/scripts/vyatta-load-config.pl b/scripts/vyatta-load-config.pl
index dfbf575..664fd2a 100755
--- a/scripts/vyatta-load-config.pl
+++ b/scripts/vyatta-load-config.pl
@@ -26,7 +26,7 @@ use lib "/opt/vyatta/share/perl5/";
use POSIX;
use IO::Prompt;
use Sys::Syslog qw(:standard :macros);
-use VyattaConfigLoad;
+use Vyatta::ConfigLoad;
$SIG{'INT'} = 'IGNORE';
@@ -147,7 +147,7 @@ syslog("warning", "Load config [$orig_load_file] by $login");
system("$sbindir/vyatta_config_migrate.pl $load_file");
print "Loading config file $load_file...\n";
-my %cfg_hier = VyattaConfigLoad::loadConfigHierarchy($load_file);
+my %cfg_hier = Vyatta::ConfigLoad::loadConfigHierarchy($load_file);
if (scalar(keys %cfg_hier) == 0) {
print "The specified file does not contain any configuration.\n";
print "Do you want to remove everything in the running configuration? [no] ";
@@ -158,7 +158,7 @@ if (scalar(keys %cfg_hier) == 0) {
}
}
-my %cfg_diff = VyattaConfigLoad::getConfigDiff(\%cfg_hier);
+my %cfg_diff = Vyatta::ConfigLoad::getConfigDiff(\%cfg_hier);
my @delete_list = @{$cfg_diff{'delete'}};
my @set_list = @{$cfg_diff{'set'}};
diff --git a/scripts/vyatta-output-config.pl b/scripts/vyatta-output-config.pl
index 05bdc4c..e47f718 100755
--- a/scripts/vyatta-output-config.pl
+++ b/scripts/vyatta-output-config.pl
@@ -20,20 +20,20 @@
# **** End License ****
use strict;
-use lib "/opt/vyatta/share/perl5/";
-use VyattaConfigOutput;
+use lib "/opt/vyatta/share/perl5";
+use Vyatta::Config::Output;
if ($ARGV[0] eq '-all') {
shift;
- VyattaConfigOutput::set_show_all(1);
+ set_show_all(1);
}
if ($ARGV[0] eq '-active') {
shift;
- VyattaConfigOutput::set_hide_password(1);
- VyattaConfigOutput::outputActiveConfig(@ARGV);
+ set_hide_password(1);
+ outputActiveConfig(@ARGV);
} else {
- VyattaConfigOutput::outputNewConfig(@ARGV);
+ outputNewConfig(@ARGV);
}
exit 0;
diff --git a/scripts/vyatta-save-config.pl b/scripts/vyatta-save-config.pl
index 2c02766..f33a693 100755
--- a/scripts/vyatta-save-config.pl
+++ b/scripts/vyatta-save-config.pl
@@ -20,8 +20,8 @@
# **** End License ****
use strict;
-use lib "/opt/vyatta/share/perl5/";
-use VyattaConfigOutput;
+use lib "/opt/vyatta/share/perl5";
+use Vyatta::Config::Output;
my $etcdir = "/opt/vyatta/etc";
my $bootpath = $etcdir . "/config";
@@ -84,8 +84,8 @@ if ($mode eq 'local') {
}
select SAVE;
-VyattaConfigOutput::set_show_all(1);
-VyattaConfigOutput::outputActiveConfig();
+set_show_all(1);
+outputActiveConfig();
print $version_str;
close SAVE;
select STDOUT;
diff --git a/scripts/vyatta-validate-type.pl b/scripts/vyatta-validate-type.pl
index eecc024..f180489 100755
--- a/scripts/vyatta-validate-type.pl
+++ b/scripts/vyatta-validate-type.pl
@@ -21,7 +21,7 @@
use strict;
use lib "/opt/vyatta/share/perl5/";
-use VyattaTypeChecker;
+use Vyatta::TypeChecker;
# validate a value of a specific type
if ($#ARGV < 1) {
@@ -35,5 +35,5 @@ if ($ARGV[0] eq '-q') {
$quiet = 1;
}
-exit 0 if (VyattaTypeChecker::validateType($ARGV[0], $ARGV[1], $quiet));
+exit 0 if (Vyatta::TypeChecker::validateType($ARGV[0], $ARGV[1], $quiet));
exit 1;