diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/dns-forwarding/vyatta-dns-forwarding.pl | 16 | ||||
-rw-r--r-- | scripts/dynamic-dns/vyatta-dynamic-dns.pl | 6 | ||||
-rwxr-xr-x | scripts/keepalived/VyattaKeepalived.pm | 261 | ||||
-rw-r--r-- | scripts/keepalived/vyatta-clear-vrrp.pl | 22 | ||||
-rwxr-xr-x | scripts/keepalived/vyatta-keepalived.pl | 50 | ||||
-rwxr-xr-x | scripts/keepalived/vyatta-show-vrrp.pl | 20 | ||||
-rwxr-xr-x | scripts/keepalived/vyatta-vrrp-state.pl | 16 | ||||
-rwxr-xr-x | scripts/netplug/linkdown/dhclient | 8 | ||||
-rwxr-xr-x | scripts/netplug/linkup/dhclient | 8 | ||||
-rw-r--r-- | scripts/snmp/vyatta-snmp.pl | 6 | ||||
-rwxr-xr-x | scripts/system/vyatta_update_login.pl | 8 | ||||
-rwxr-xr-x | scripts/system/vyatta_update_resolv.pl | 4 | ||||
-rwxr-xr-x | scripts/vyatta-bonding.pl | 6 | ||||
-rwxr-xr-x | scripts/vyatta-passwd-sync | 10 |
14 files changed, 90 insertions, 351 deletions
diff --git a/scripts/dns-forwarding/vyatta-dns-forwarding.pl b/scripts/dns-forwarding/vyatta-dns-forwarding.pl index d0d7e36c..8c28becd 100644 --- a/scripts/dns-forwarding/vyatta-dns-forwarding.pl +++ b/scripts/dns-forwarding/vyatta-dns-forwarding.pl @@ -24,8 +24,8 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; -use VyattaMisc; +use Vyatta::Config; +use Vyatta::Misc; use Getopt::Long; use strict; @@ -60,7 +60,7 @@ sub dnsforwarding_get_values { my $outside_cli = shift; my $output = ''; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; my $use_dnsmasq_conf = 0; my (@listen_interfaces, $cache_size, @use_nameservers, $use_system_nameservers, @use_dhcp_nameservers); @@ -101,7 +101,7 @@ sub dnsforwarding_get_values { if (defined($use_system_nameservers)) { $use_dnsmasq_conf = 1; - my $sys_config = new VyattaConfig; + my $sys_config = new Vyatta::Config; $sys_config->setLevel("system"); my @system_nameservers; if ($outside_cli == 1){ @@ -156,7 +156,7 @@ sub check_nameserver { sub check_system_nameserver { - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("system"); my @system_nameservers = $config->returnValues("name-server"); return(@system_nameservers); @@ -165,7 +165,7 @@ sub check_system_nameserver { sub check_dhcp_any_interface { - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("interfaces ethernet"); my @eths = $config->listNodes("."); foreach my $eth (@eths) { @@ -207,7 +207,7 @@ sub check_dhcp_any_interface { sub is_dhcp_enabled { my $intf = shift; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; if ($intf =~ m/^eth/) { if ($intf =~ m/(\w+)\.(\d+)/) { @@ -278,7 +278,7 @@ if (defined $dhcp_interface) { if (defined $update_dnsforwarding) { my $config; - my $vyatta_config = new VyattaConfig; + my $vyatta_config = new Vyatta::Config; $vyatta_config->setLevel("service dns forwarding"); my $use_system_nameservers = $vyatta_config->exists("system"); diff --git a/scripts/dynamic-dns/vyatta-dynamic-dns.pl b/scripts/dynamic-dns/vyatta-dynamic-dns.pl index 06bd1ee5..30512bae 100644 --- a/scripts/dynamic-dns/vyatta-dynamic-dns.pl +++ b/scripts/dynamic-dns/vyatta-dynamic-dns.pl @@ -24,8 +24,8 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; -use VyattaMisc; +use Vyatta::Config; +use Vyatta::Misc; use Getopt::Long; use strict; @@ -110,7 +110,7 @@ sub dynamicdns_get_constants { sub dynamicdns_get_values { my $output = ''; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("service dns dynamic interface $interface"); my @services = $config->listNodes("service"); diff --git a/scripts/keepalived/VyattaKeepalived.pm b/scripts/keepalived/VyattaKeepalived.pm deleted file mode 100755 index 6507d8f7..00000000 --- a/scripts/keepalived/VyattaKeepalived.pm +++ /dev/null @@ -1,261 +0,0 @@ -# -# Module: VyattaKeepalived.pm -# -# **** 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) 2007 Vyatta, Inc. -# All Rights Reserved. -# -# Author: Stig Thormodsrud -# Date: October 2007 -# Description: Common keepalived definitions/funcitions -# -# **** End License **** -# -package VyattaKeepalived; - -use VyattaConfig; -use POSIX; - -use strict; -use warnings; - -my $daemon = '/usr/sbin/keepalived'; -my $keepalived_conf = '/etc/keepalived/keepalived.conf'; -my $sbin_dir = '/opt/vyatta/sbin'; -my $state_transition = "$sbin_dir/vyatta-vrrp-state.pl"; -my $keepalived_pid = '/var/run/keepalived_vrrp.pid'; -my $state_dir = '/var/log/vrrpd'; -my $vrrp_log = "$state_dir/vrrp.log"; - - -sub vrrp_log { - my $timestamp = strftime("%Y%m%d-%H:%M.%S", localtime); - open my $fh, ">>", $vrrp_log; - print $fh "$timestamp: ", @_ , "\n"; - close $fh; -} - -sub is_running { - if (-f $keepalived_pid) { - my $pid = `cat $keepalived_pid`; - $pid =~ s/\s+$//; # chomp doesn't remove nl - my $ps = `ps -p $pid -o comm=`; - - if (defined($ps) && $ps ne "") { - return 1; - } - } - return 0; -} - -sub start_daemon { - my ($conf) = @_; - - my $cmd = "$daemon --vrrp --log-facility 7 --log-detail --dump-conf"; - $cmd .= " --use-file $conf --vyatta-workaround"; - system($cmd); - vrrp_log("start_daemon"); -} - -sub stop_daemon { - if (is_running()) { - my $pid = `cat $keepalived_pid`; - $pid =~ s/\s+$//; # chomp doesn't remove nl - system("kill $pid"); - vrrp_log("stop_daemon"); - } else { - vrrp_log("stop daemon called while not running"); - } -} - -sub restart_daemon { - my ($conf) = @_; - - if (VyattaKeepalived::is_running()) { - my $pid = `cat $keepalived_pid`; - $pid =~ s/\s+$//; # chomp doesn't remove nl - system("kill -1 $pid"); - vrrp_log("restart_deamon"); - } else { - start_daemon($conf); - } -} - -sub get_conf_file { - return $keepalived_conf; -} - -sub get_state_script { - return $state_transition; -} - -sub get_state_file { - my ($vrrp_intf, $vrrp_group) = @_; - - my $file = "$state_dir/vrrpd_" . "$vrrp_intf" . "_" . "$vrrp_group.state"; - return $file; -} - -sub get_master_file { - my ($vrrp_intf, $vrrp_group) = @_; - - my $file = "$state_dir/vrrpd_" . "$vrrp_intf" . "_" . "$vrrp_group.master"; - return $file; -} - -sub get_state_files { - my ($intf, $group) = @_; - - # todo: fix sorting for ethX > 9 - my @state_files; - my $LS; - if ($group eq "all") { - open($LS,"ls $state_dir |grep '^vrrpd_$intf.*\.state\$' | sort |"); - } else { - my $intf_group = $intf . "_" . $group . ".state"; - open($LS, - "ls $state_dir |grep '^vrrpd_$intf_group\$' | sort |"); - } - @state_files = <$LS>; - close($LS); - foreach my $i (0 .. $#state_files) { - $state_files[$i] = "$state_dir/$state_files[$i]"; - } - chomp @state_files; - return @state_files; -} - -sub vrrp_get_config { - my ($intf, $group) = @_; - - my $path; - my $config = new VyattaConfig; - - if ($intf =~ m/(eth\d+)\.(\d+)/) { - $path = "interfaces ethernet $1 vif $2"; - } else { - $path = "interfaces ethernet $intf"; - } - - $config->setLevel($path); - my $primary_addr = $config->returnOrigValue("address"); - if (!defined $primary_addr) { - $primary_addr = "0.0.0.0"; - } - - if ($primary_addr =~ m/(\d+\.\d+\.\d+\.\d+)\/\d+/) { - $primary_addr = $1; - } - - $config->setLevel("$path vrrp vrrp-group $group"); - my @vips = $config->returnOrigValues("virtual-address"); - my $priority = $config->returnOrigValue("priority"); - if (!defined $priority) { - $priority = 1; - } - my $preempt = $config->returnOrigValue("preempt"); - if (!defined $preempt) { - $preempt = "true"; - } - my $advert_int = $config->returnOrigValue("advertise-interval"); - if (!defined $advert_int) { - $advert_int = 1; - } - $config->setLevel("$path vrrp vrrp-group $group authentication"); - my $auth_type = $config->returnOrigValue("type"); - if (!defined $auth_type) { - $auth_type = "none"; - } - - return ($primary_addr, $priority, $preempt, $advert_int, $auth_type, @vips); -} - -sub snoop_for_master { - my ($intf, $group, $vip, $timeout) = @_; - - my ($cap_filt, $dis_filt, $options, $cmd); - - my $file = get_master_file($intf, $group); - - # - # set up common tshark parameters - # - $cap_filt = "-f \"host 224.0.0.18"; - $dis_filt = "-R \"vrrp.virt_rtr_id == $group and vrrp.ip_addr == $vip\""; - $options = "-a duration:$timeout -p -i$intf -c1 -T pdml"; - - my $auth_type = (vrrp_get_config($intf, $group))[4]; - if (lc($auth_type) ne "ah") { - # - # the vrrp group is the 2nd byte in the vrrp header - # - $cap_filt .= " and proto VRRP and vrrp[1:1] = $group\""; - $cmd = "tshark $options $cap_filt $dis_filt"; - system("$cmd > $file 2> /dev/null"); - } else { - # - # if the vrrp group is using AH authentication, then the proto will be - # AH (0x33) instead of VRRP (0x70). So try snooping for AH and - # look for the vrrp group at byte 45 (ip_header=20, ah=24) - # - $cap_filt .= " and proto 0x33 and ip[45:1] = $group\""; - $cmd = "tshark $options $cap_filt $dis_filt"; - system("$cmd > $file 2> /dev/null"); - } -} - -sub vrrp_state_parse { - my ($file) = @_; - - $file =~ s/\s+$//; # chomp doesn't remove nl - if ( -f $file) { - my $line = `cat $file`; - chomp $line; - my ($start_time, $intf, $group, $state, $ltime) = split(' ', $line); - return ($start_time, $intf, $group, $state, $ltime); - } else { - return undef; - } -} - -sub vrrp_get_init_state { - my ($intf, $group, $vips, $preempt) = @_; - - my $init_state; - if (VyattaKeepalived::is_running()) { - my @state_files = VyattaKeepalived::get_state_files($intf, $group); - chomp @state_files; - if (scalar(@state_files) > 0) { - my ($start_time, $f_intf, $f_group, $state, $ltime) = - VyattaKeepalived::vrrp_state_parse($state_files[0]); - if ($state eq "master") { - $init_state = 'MASTER'; - } else { - $init_state = 'BACKUP'; - } - return $init_state; - } - # fall through to logic below - } - - if ($preempt eq "false") { - $init_state = 'BACKUP'; - } else { - $init_state = 'MASTER'; - } - - return $init_state; -} - -1; -#end of file diff --git a/scripts/keepalived/vyatta-clear-vrrp.pl b/scripts/keepalived/vyatta-clear-vrrp.pl index be33f2b9..612dae5f 100644 --- a/scripts/keepalived/vyatta-clear-vrrp.pl +++ b/scripts/keepalived/vyatta-clear-vrrp.pl @@ -24,14 +24,14 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaKeepalived; +use Vyatta::Keepalived; use Getopt::Long; use Sys::Syslog qw(:standard :macros); use strict; use warnings; -my $conf_file = VyattaKeepalived::get_conf_file(); +my $conf_file = Vyatta::Keepalived::get_conf_file(); sub keepalived_write_file { @@ -174,7 +174,7 @@ sub set_inital_state { my ($tmp_conf, $match_instance) = vrrp_extract_instance($conf, $instance); if (defined $match_instance) { - my $init = VyattaKeepalived::vrrp_get_init_state($intf, $group, + my $init = Vyatta::Keepalived::vrrp_get_init_state($intf, $group, "", "false"); $match_instance = set_instance_inital_state($match_instance, $init); $new_conf .= $match_instance . "\n\n"; @@ -207,12 +207,12 @@ my $login = getlogin(); # if ($action eq "clear_process") { syslog("warning", "clear vrrp process requested by $login"); - if (VyattaKeepalived::is_running()) { + if (Vyatta::Keepalived::is_running()) { print "Restarting VRRP...\n"; - VyattaKeepalived::restart_daemon(VyattaKeepalived::get_conf_file()); + Vyatta::Keepalived::restart_daemon(VyattaKeepalived::get_conf_file()); } else { print "Starting VRRP...\n"; - VyattaKeepalived::start_daemon(VyattaKeepalived::get_conf_file()); + Vyatta::Keepalived::start_daemon(VyattaKeepalived::get_conf_file()); } exit 0; } @@ -239,21 +239,21 @@ if ($action eq "clear_master") { } my $instance = "vyatta-" . "$vrrp_intf" . "-" . "$vrrp_group"; - my $state_file = VyattaKeepalived::get_state_file($vrrp_intf, $vrrp_group); + my $state_file = Vyatta::Keepalived::get_state_file($vrrp_intf, $vrrp_group); if (! -f $state_file) { print "Invalid interface/group [$vrrp_intf][$vrrp_group]\n"; exit 1; } my ($start_time, $intf, $group, $state, $ltime) = - VyattaKeepalived::vrrp_state_parse($state_file); + Vyatta::Keepalived::vrrp_state_parse($state_file); if ($state ne "master") { print "vrrp group $vrrp_group on $vrrp_intf is already in backup\n"; exit 1; } syslog("warning", "clear vrrp master [$instance] requested by $login"); - VyattaKeepalived::vrrp_log("vrrp clear_master $vrrp_intf $vrrp_group"); + Vyatta::Keepalived::vrrp_log("vrrp clear_master $vrrp_intf $vrrp_group"); # should add a file lock local($/, *FILE); # slurp mode @@ -283,7 +283,7 @@ if ($action eq "clear_master") { system("mv $conf_file $conf_file_bak"); system("cp $tmp_conf_file $conf_file"); - VyattaKeepalived::restart_daemon($conf_file); + Vyatta::Keepalived::restart_daemon($conf_file); print "Forcing $vrrp_intf-$group to BACKUP...\n"; sleep(3); @@ -294,7 +294,7 @@ if ($action eq "clear_master") { $new_conf .= "\n" . $match_instance . "\n"; keepalived_write_file($conf_file, $new_conf); - VyattaKeepalived::restart_daemon($conf_file); + Vyatta::Keepalived::restart_daemon($conf_file); system("rm $conf_file_bak $tmp_conf_file"); exit 0; diff --git a/scripts/keepalived/vyatta-keepalived.pl b/scripts/keepalived/vyatta-keepalived.pl index c41fa7e2..b2f0ba3b 100755 --- a/scripts/keepalived/vyatta-keepalived.pl +++ b/scripts/keepalived/vyatta-keepalived.pl @@ -24,15 +24,15 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; -use VyattaKeepalived; +use Vyatta::Config; +use Vyatta::Keepalived; use Getopt::Long; use strict; use warnings; my $changes_file = '/var/log/vrrpd/changes'; -my $conf_file = VyattaKeepalived::get_conf_file(); +my $conf_file = get_conf_file(); my %HoA_sync_groups; @@ -41,9 +41,9 @@ sub keepalived_get_values { my ($intf, $path) = @_; my $output = ''; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; - my $state_transition_script = VyattaKeepalived::get_state_script(); + my $state_transition_script = get_state_script(); $config->setLevel("$path vrrp vrrp-group"); my @groups = $config->listNodes(); @@ -51,8 +51,8 @@ sub keepalived_get_values { my $vrrp_instance = "vyatta-$intf-$group"; $config->setLevel("$path vrrp vrrp-group $group"); if ($config->exists("disable")) { - VyattaKeepalived::vrrp_log("$vrrp_instance disabled - skipping"); - my $state_file = VyattaKeepalived::get_state_file($intf, $group); + vrrp_log("$vrrp_instance disabled - skipping"); + my $state_file = get_state_file($intf, $group); system("rm -f $state_file"); next; } @@ -116,7 +116,7 @@ sub keepalived_get_values { $output .= "vrrp_instance $vrrp_instance \{\n"; my $init_state; - $init_state = VyattaKeepalived::vrrp_get_init_state($intf, $group, + $init_state = vrrp_get_init_state($intf, $group, $vips[0], $preempt); $output .= "\tstate $init_state\n"; $output .= "\tinterface $intf\n"; @@ -179,7 +179,7 @@ sub vrrp_save_changes { my @list = @_; my $num_changes = scalar(@list); - VyattaKeepalived::vrrp_log("saving changes file $num_changes"); + vrrp_log("saving changes file $num_changes"); open(my $FILE, ">", $changes_file) or die "Error: write $!"; print $FILE join("\n", @list), "\n"; close($FILE); @@ -188,7 +188,7 @@ sub vrrp_save_changes { sub vrrp_find_changes { my @list = (); - my $config = new VyattaConfig; + my $config = new Vyatta::Config; my $vrrp_instances = 0; $config->setLevel("interfaces ethernet"); @@ -201,7 +201,7 @@ sub vrrp_find_changes { my ($vrrp, $vrrp_status) = each(%vrrp_status_hash); if ($vrrp_status ne "static") { push @list, $eth; - VyattaKeepalived::vrrp_log("$vrrp_status found $eth"); + vrrp_log("$vrrp_status found $eth"); } } if ($config->exists("vif")) { @@ -217,7 +217,7 @@ sub vrrp_find_changes { my ($vrrp, $vrrp_status) = each(%vrrp_status_hash); if ($vrrp_status ne "static") { push @list, "$eth.$vif"; - VyattaKeepalived::vrrp_log("$vrrp_status found $eth.$vif"); + vrrp_log("$vrrp_status found $eth.$vif"); } } } @@ -234,7 +234,7 @@ sub vrrp_find_changes { $config->setLevel($path); if ($config->isDeleted("vrrp")) { push @list, $eth; - VyattaKeepalived::vrrp_log("Delete found $eth"); + vrrp_log("Delete found $eth"); } $config->setLevel("$path vif"); my @vifs = $config->listOrigNodes(); @@ -244,13 +244,13 @@ sub vrrp_find_changes { $config->setLevel($vif_path); if ($config->isDeleted("vrrp")) { push @list, "$eth.$vif"; - VyattaKeepalived::vrrp_log("Delete found $eth.$vif"); + vrrp_log("Delete found $eth.$vif"); } } } my $num = scalar(@list); - VyattaKeepalived::vrrp_log("Start transation: $num changes"); + vrrp_log("Start transation: $num changes"); if ($num) { vrrp_save_changes(@list); } @@ -271,7 +271,7 @@ sub remove_from_changes { my @new_lines = (); foreach my $line (@lines) { if ($line =~ /$intf$/) { - VyattaKeepalived::vrrp_log("remove_from_changes [$line]"); + vrrp_log("remove_from_changes [$line]"); } else { push @new_lines, $line; } @@ -292,7 +292,7 @@ sub vrrp_update_config { my $date = localtime(); my $output = "#\n# autogenerated by $0 on $date\n#\n\n"; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("interfaces ethernet"); my @eths = $config->listNodes(); @@ -316,7 +316,7 @@ sub vrrp_update_config { # my $vif_intf = $eth . "." . $vif; if (!(-d "/sys/class/net/$vif_intf")) { - VyattaKeepalived::vrrp_log("skipping $vif_intf"); + vrrp_log("skipping $vif_intf"); next; } my $vif_path = "$path $vif"; @@ -363,24 +363,24 @@ if (! defined $action) { } if ($action eq "update") { - VyattaKeepalived::vrrp_log("vrrp update $vrrp_intf"); + vrrp_log("vrrp update $vrrp_intf"); if ( ! -e $changes_file) { my $num_changes = vrrp_find_changes(); if ($num_changes == 0) { # # Shouldn't happen, but ... # - VyattaKeepalived::vrrp_log("unexpected 0 changes"); + vrrp_log("unexpected 0 changes"); } } my $vrrp_instances = vrrp_update_config($vrrp_intf); my $more_changes = remove_from_changes($vrrp_intf); - VyattaKeepalived::vrrp_log(" instances $vrrp_instances, $more_changes"); + vrrp_log(" instances $vrrp_instances, $more_changes"); if ($vrrp_instances > 0 and $more_changes == 0) { - VyattaKeepalived::restart_daemon($conf_file); + restart_daemon($conf_file); } if ($vrrp_instances == 0) { - VyattaKeepalived::stop_daemon(); + stop_daemon(); system("rm -f $conf_file"); } } @@ -390,8 +390,8 @@ if ($action eq "delete") { print "must include interface & group"; exit 1; } - VyattaKeepalived::vrrp_log("vrrp delete $vrrp_intf $vrrp_group"); - my $state_file = VyattaKeepalived::get_state_file($vrrp_intf, $vrrp_group); + vrrp_log("vrrp delete $vrrp_intf $vrrp_group"); + my $state_file = get_state_file($vrrp_intf, $vrrp_group); system("rm -f $state_file"); exit 0; } diff --git a/scripts/keepalived/vyatta-show-vrrp.pl b/scripts/keepalived/vyatta-show-vrrp.pl index e8157d21..4b8d6fec 100755 --- a/scripts/keepalived/vyatta-show-vrrp.pl +++ b/scripts/keepalived/vyatta-show-vrrp.pl @@ -23,7 +23,7 @@ # **** End License **** # use lib "/opt/vyatta/share/perl5/"; -use VyattaKeepalived; +use Vyatta::Keepalived; use strict; use warnings; @@ -119,14 +119,14 @@ sub get_master_info { # address and compare it to our masterfile. If it doesn't match # then we will snoop for the new master. - my $master_file = VyattaKeepalived::get_master_file($intf, $group); + my $master_file = Vyatta::Keepalived::get_master_file($intf, $group); my $arp_file = "$master_file.arp"; system("/usr/bin/arping -c1 -f -I $intf $vip > $arp_file"); my $arp_mac = parse_arping($arp_file); if ( ! -f $master_file) { - VyattaKeepalived::snoop_for_master($intf, $group, $vip, 2); + Vyatta::Keepalived::snoop_for_master($intf, $group, $vip, 2); } if ( -f $master_file) { @@ -140,7 +140,7 @@ sub get_master_info { { $master_mac = uc($1); if ($arp_mac ne $master_mac) { - VyattaKeepalived::snoop_for_master($intf, $group, $vip, 2); + Vyatta::Keepalived::snoop_for_master($intf, $group, $vip, 2); $master_ip = `grep ip.src $master_file 2> /dev/null`; } } @@ -172,11 +172,11 @@ sub vrrp_showsummary { my ($file) = @_; my ($start_time, $intf, $group, $state, $ltime) = - VyattaKeepalived::vrrp_state_parse($file); + Vyatta::Keepalived::vrrp_state_parse($file); my ($interface_state, $link) = get_state_link($intf); if ($state eq "master" || $state eq "backup" || $state eq "fault") { my ($primary_addr, $priority, $preempt, $advert_int, $auth_type, - @vips) = VyattaKeepalived::vrrp_get_config($intf, $group); + @vips) = Vyatta::Keepalived::vrrp_get_config($intf, $group); my $format = "\n%-16s%-8s%-8s%-16s%-16s%-16s"; printf($format, $intf, $group, 'int', $primary_addr, $link, $state); foreach my $vip (@vips){ @@ -192,12 +192,12 @@ sub vrrp_show { my $now_time = time; my ($start_time, $intf, $group, $state, $ltime) = - VyattaKeepalived::vrrp_state_parse($file); + Vyatta::Keepalived::vrrp_state_parse($file); my ($interface_state, $link) = get_state_link($intf); my $first_vip = ''; if ($state eq "master" || $state eq "backup" || $state eq "fault") { my ($primary_addr, $priority, $preempt, $advert_int, $auth_type, - @vips) = VyattaKeepalived::vrrp_get_config($intf, $group); + @vips) = Vyatta::Keepalived::vrrp_get_config($intf, $group); print "Physical interface: $intf, Address $primary_addr\n"; print " Interface state: $link, Group $group, State: $state\n"; print " Priority: $priority, Advertisement interval: $advert_int, "; @@ -256,7 +256,7 @@ if ($#ARGV == 1) { $group = $ARGV[1]; } -if (!VyattaKeepalived::is_running()) { +if (!Vyatta::Keepalived::is_running()) { print "VRRP isn't running\n"; exit 1; } @@ -273,7 +273,7 @@ if ($showsummary == 1) { $display_func = \&vrrp_show; } -my @state_files = VyattaKeepalived::get_state_files($intf, $group); +my @state_files = Vyatta::Keepalived::get_state_files($intf, $group); foreach my $state_file (@state_files) { &$display_func($state_file); } diff --git a/scripts/keepalived/vyatta-vrrp-state.pl b/scripts/keepalived/vyatta-vrrp-state.pl index a3be3095..930c7cd0 100755 --- a/scripts/keepalived/vyatta-vrrp-state.pl +++ b/scripts/keepalived/vyatta-vrrp-state.pl @@ -24,7 +24,7 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaKeepalived; +use Vyatta::Keepalived; use POSIX; use strict; @@ -35,7 +35,7 @@ sub vrrp_state_log { my ($state, $intf, $group) = @_; my $timestamp = strftime("%Y%m%d-%H:%M.%S", localtime); - my $file = VyattaKeepalived::get_state_file($intf, $group); + my $file = Vyatta::Keepalived::get_state_file($intf, $group); my $time = time(); my $line = "$time $intf $group $state $timestamp"; open my $fh, ">", $file; @@ -52,22 +52,22 @@ foreach my $arg (4 .. $#ARGV) { push @vrrp_vips, $ARGV[$arg]; } -my $sfile = VyattaKeepalived::get_state_file($vrrp_intf, $vrrp_group); +my $sfile = Vyatta::Keepalived::get_state_file($vrrp_intf, $vrrp_group); my ($old_time, $old_intf, $old_group, $old_state, $old_ltime) = - VyattaKeepalived::vrrp_state_parse($sfile); + Vyatta::Keepalived::vrrp_state_parse($sfile); if (defined $old_state and $vrrp_state eq $old_state) { # # restarts call the transition script even if it really hasn't # changed. # - VyattaKeepalived::vrrp_log("$vrrp_intf $vrrp_group same - $vrrp_state"); + Vyatta::Keepalived::vrrp_log("$vrrp_intf $vrrp_group same - $vrrp_state"); exit 0; } -VyattaKeepalived::vrrp_log("$vrrp_intf $vrrp_group transition to $vrrp_state"); +Vyatta::Keepalived::vrrp_log("$vrrp_intf $vrrp_group transition to $vrrp_state"); vrrp_state_log($vrrp_state, $vrrp_intf, $vrrp_group); if ($vrrp_state eq "backup") { - VyattaKeepalived::snoop_for_master($vrrp_intf, $vrrp_group, $vrrp_vips[0], + Vyatta::Keepalived::snoop_for_master($vrrp_intf, $vrrp_group, $vrrp_vips[0], 60); } elsif ($vrrp_state eq "master") { # @@ -83,7 +83,7 @@ if ($vrrp_state eq "backup") { # # remove the old master file since we are now master # - my $mfile = VyattaKeepalived::get_master_file($vrrp_intf, $vrrp_group); + my $mfile = Vyatta::Keepalived::get_master_file($vrrp_intf, $vrrp_group); system("rm -f $mfile"); } diff --git a/scripts/netplug/linkdown/dhclient b/scripts/netplug/linkdown/dhclient index 21623a8d..a69caed3 100755 --- a/scripts/netplug/linkdown/dhclient +++ b/scripts/netplug/linkdown/dhclient @@ -31,8 +31,8 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; -use VyattaMisc; +use Vyatta::Config; +use Vyatta::Misc; use strict; use warnings; @@ -40,7 +40,7 @@ use warnings; sub stop_dhclient { my $intf = shift; my $dhcp_daemon = '/sbin/dhclient'; - 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 = "sudo $dhcp_daemon -q -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file -r $intf 2> /dev/null"; system ($release_cmd); } @@ -53,7 +53,7 @@ sub stop_dhclient { my $dev=shift; # only do this if interface is configured to use dhcp for getting IP address -if (VyattaMisc::is_dhcp_enabled($dev, "outside_cli")) { +if (Vyatta::Misc::is_dhcp_enabled($dev, "outside_cli")) { # do a dhcp lease release for interface stop_dhclient($dev); } diff --git a/scripts/netplug/linkup/dhclient b/scripts/netplug/linkup/dhclient index 574b994f..c7370841 100755 --- a/scripts/netplug/linkup/dhclient +++ b/scripts/netplug/linkup/dhclient @@ -31,8 +31,8 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; -use VyattaMisc; +use Vyatta::Config; +use Vyatta::Misc; use strict; use warnings; @@ -40,7 +40,7 @@ use warnings; sub run_dhclient { my $intf = shift; my $dhcp_daemon = '/sbin/dhclient'; - 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 $cmd = "sudo $dhcp_daemon -q -nw -cf $intf_config_file -pf $intf_process_id_file -lf $intf_leases_file $intf 2> /dev/null &"; system ($cmd); } @@ -52,7 +52,7 @@ sub run_dhclient { my $dev=shift; # only do this if interface is configured to use dhcp for getting IP address -if (VyattaMisc::is_dhcp_enabled($dev, "outside_cli")) { +if (Vyatta::Misc::is_dhcp_enabled($dev, "outside_cli")) { # do a dhcp lease renew for interface run_dhclient($dev); } diff --git a/scripts/snmp/vyatta-snmp.pl b/scripts/snmp/vyatta-snmp.pl index 65247788..eb8e9ede 100644 --- a/scripts/snmp/vyatta-snmp.pl +++ b/scripts/snmp/vyatta-snmp.pl @@ -24,8 +24,8 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; -use VyattaMisc; +use Vyatta::Config; +use Vyatta::Misc; use Getopt::Long; use strict; @@ -74,7 +74,7 @@ sub snmp_get_constants { sub snmp_get_values { my $output = ''; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("protocols snmp community"); my @communities = $config->listNodes(); diff --git a/scripts/system/vyatta_update_login.pl b/scripts/system/vyatta_update_login.pl index ad33412a..eb7baeee 100755 --- a/scripts/system/vyatta_update_login.pl +++ b/scripts/system/vyatta_update_login.pl @@ -18,10 +18,10 @@ use strict; use lib "/opt/vyatta/share/perl5"; -use VyattaConfig; +use Vyatta::Config; # handle "user" -my $uconfig = new VyattaConfig; +my $uconfig = new Vyatta::Config; $uconfig->setLevel("system login user"); my %users = $uconfig->listNodeStatus(); @@ -170,7 +170,7 @@ sub remove_tacacs { # Finally, service and protocol will need to be removed. They are just # in there for troubleshootig purposes right now. # -my $tconfig = new VyattaConfig; +my $tconfig = new Vyatta::Config; if ($tconfig->isDeleted("system login tacacs-plus")) { remove_tacacs; } $tconfig->setLevel("system login tacacs-plus"); my @tacacs_params = $tconfig->listNodes(); @@ -291,7 +291,7 @@ sub add_radius_servers { } # handle "radius-server" -my $rconfig = new VyattaConfig; +my $rconfig = new Vyatta::Config; $rconfig->setLevel("system login radius-server"); my %servers = $rconfig->listNodeStatus(); my @server_keys = sort keys %servers; diff --git a/scripts/system/vyatta_update_resolv.pl b/scripts/system/vyatta_update_resolv.pl index 8f0e9ead..d8e30961 100755 --- a/scripts/system/vyatta_update_resolv.pl +++ b/scripts/system/vyatta_update_resolv.pl @@ -34,8 +34,8 @@ my $dhclient_script = 0; GetOptions("change_dir=s" => \$change_dir, "modify_dir=s" => \$modify_dir, "dhclient-script=i" => \$dhclient_script ); -use VyattaConfig; -my $vc = new VyattaConfig(); +use Vyatta::Config; +my $vc = new Vyatta::Config(); if ($change_dir ne '') { $vc->{_changes_only_dir_base} = $change_dir; diff --git a/scripts/vyatta-bonding.pl b/scripts/vyatta-bonding.pl index 4e44d67b..d9e0ebc4 100755 --- a/scripts/vyatta-bonding.pl +++ b/scripts/vyatta-bonding.pl @@ -29,7 +29,7 @@ # use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; +use Vyatta::Config; use Getopt::Long; use strict; @@ -47,7 +47,7 @@ my %modes = ( sub create_bond { my $bond = shift; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("interfaces bonding $bond"); my $mode = $modes{$config->returnValue("mode")}; @@ -78,7 +78,7 @@ sub delete_bond { # See if bonding device exists and the mode has changed sub change_bond { my $bond = shift; - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel("interfaces bonding"); if ( !( $config->isAdded($bond) || $config->isDeleted($bond) ) diff --git a/scripts/vyatta-passwd-sync b/scripts/vyatta-passwd-sync index 29748b67..f8c07a8f 100755 --- a/scripts/vyatta-passwd-sync +++ b/scripts/vyatta-passwd-sync @@ -15,7 +15,7 @@ # **** End License **** use lib "/opt/vyatta/share/perl5/"; -use VyattaConfig; +use Vyatta::Config; use strict; use Getopt::Long; @@ -29,7 +29,7 @@ GetOptions( ); # -# These should move to VyattaConfig.pm?? +# These should move to Vyatta::Config.pm?? # sub add_node { @@ -123,7 +123,7 @@ sub system_vyatta_users { } sub listOrigUsers { - my $config = new VyattaConfig; + my $config = new Vyatta::Config; my %users = (); foreach my $name ( $config->listOrigNodes('system login user') ) { @@ -181,7 +181,7 @@ sub check_config { } sub listUsers { - my $config = new VyattaConfig; + my $config = new Vyatta::Config; my %users = (); foreach my $name ( $config->listOrigNodes('system login user') ) { @@ -203,7 +203,7 @@ sub listUsers { sub resync_config { my %system_users = system_vyatta_users(); my %vyatta_users = listUsers(); - my $config = new VyattaConfig; + my $config = new Vyatta::Config; $config->setLevel('system login user'); |