summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-12 15:48:44 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-01-12 16:35:54 -0800
commit80f85801b57a030459cb6846bb229ca87d18cc5a (patch)
tree906ddae03b96176a50856153483d6e3a78eb3f86 /scripts
parente12098cc7b7d44636a78e4d69983590a528438b5 (diff)
downloadvyatta-cfg-80f85801b57a030459cb6846bb229ca87d18cc5a.tar.gz
vyatta-cfg-80f85801b57a030459cb6846bb229ca87d18cc5a.zip
Use new interfaces routines
Unify all code that does name -> interface attribute translation into one place. No need to pass interface path to scripts, and handle addresses correctly in DHCP code. Use 'undef' consitently for false in perl code.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/vyatta-interfaces.pl63
1 files changed, 7 insertions, 56 deletions
diff --git a/scripts/vyatta-interfaces.pl b/scripts/vyatta-interfaces.pl
index a39cde4..de31e5e 100755
--- a/scripts/vyatta-interfaces.pl
+++ b/scripts/vyatta-interfaces.pl
@@ -53,7 +53,6 @@ GetOptions("eth-addr-update=s" => \$eth_update,
"valid-mac=s" => \$mac,
"set-mac=s" => \$mac_update,
"op-command=s" => \$op_dhclient,
- "intf-cli-path=s" => \$intf_cli_path
);
if (defined $eth_update) { update_eth_addrs($eth_update, $dev); }
@@ -123,42 +122,6 @@ sub dhcp_conf_header {
return $output;
}
-sub is_address_enabled {
- my $intf = shift;
-
- 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!
- ## POSSIBLE SOLUTION: pass the cli-path uptill 'address' node from
- ## address/node.def so we don't have to determine the address type here
- if ($intf =~ m/^eth/) {
- if ($intf =~ m/(\w+)\.(\d+)/) {
- $config->setLevel("interfaces ethernet $1 vif $2");
- } else {
- $config->setLevel("interfaces ethernet $intf");
- }
- } elsif ($intf =~ m/^bond/) {
- if ($intf =~ m/(\w+)\.(\d+)/) {
- $config->setLevel("interfaces bonding $1 vif $2");
- } else {
- $config->setLevel("interfaces bonding $intf");
- }
- } elsif ($intf =~ m/^br/) {
- $config->setLevel("interfaces bridge $intf");
- } else {
- print "unsupported dhcp interface [$intf]\n";
- exit 1;
- }
- my @addrs = $config->returnOrigValues("address");
- foreach my $addr (@addrs) {
- if (defined $addr && $addr ne "dhcp") {
- return 1;
- }
- }
- return 0;
-}
-
sub get_hostname {
my $config = new Vyatta::Config;
$config->setLevel("system");
@@ -214,29 +177,17 @@ sub dhcp_update_config {
}
sub is_intf_disabled {
- my $intf = shift;
+ my $name = shift;
+ my $intf = new Vyatta::Interface($name);
+
+ $intf or die "Unknown interface name/type: $name\n";
# only do this if script run from config mode
if (!defined $op_dhclient) {
+ my $config = new Vyatta::Config;
+ $config->setLevel($intf->path());
- if (!defined $intf_cli_path) {
- print "unable to check if interface is disabled without cli path\n";
- exit 1;
- }
-
- my $config = new Vyatta::Config;
- $config->setLevel("$intf_cli_path");
-
- if ($intf =~ m/^br/) {
- if ($config->returnValue("disable") eq "true") {
- return 1;
- }
- } else {
- if ($config->exists("disable")) {
- return 1;
- }
- }
-
+ return $config->exists("disable");
}
return 0;
}