diff options
author | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-02-10 14:21:20 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen.hemminger@vyatta.com> | 2009-02-10 14:21:20 -0800 |
commit | 31747ed42038d00499099d11abf1e33b3ef7c26f (patch) | |
tree | 99dce067e965b78bb873e0e594bfe963494f873b /lib/Vyatta/Interface.pm | |
parent | c1d6c408046e0f7331d8ddb55a88b71ff7cc0f96 (diff) | |
download | vyatta-cfg-31747ed42038d00499099d11abf1e33b3ef7c26f.tar.gz vyatta-cfg-31747ed42038d00499099d11abf1e33b3ef7c26f.zip |
Add new option for checking name validity
Many templates should allow any known interface type, since
interface may be created later. So create some generic hooks
for validation.
Diffstat (limited to 'lib/Vyatta/Interface.pm')
-rw-r--r-- | lib/Vyatta/Interface.pm | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/Vyatta/Interface.pm b/lib/Vyatta/Interface.pm index ea9c40f..017b7e4 100644 --- a/lib/Vyatta/Interface.pm +++ b/lib/Vyatta/Interface.pm @@ -77,6 +77,9 @@ sub new { my $class = ref($that) || $that; my ($dev, $vif); + # need argument to constructor + return unless $name; + # Strip off vif from name if ( $name =~ m/(\w)+\.(\d)+/ ) { $dev = $1; @@ -87,20 +90,21 @@ sub new { foreach my $prefix (keys %net_prefix) { next unless $dev =~ /$prefix/; - my $path = $net_prefix{$prefix}{path}; + my $type = $net_prefix{$prefix}{path}; my $vifpath = $net_prefix{$prefix}{vif}; # Interface name has vif, but this type doesn't support vif! return if ( $vif && !$vifpath ); # Check path if given - return if ( $#_ >= 0 && join( ' ', @_ ) ne $path ); + return if ( $#_ >= 0 && join( ' ', @_ ) ne $type ); - $path = "interfaces $path $dev"; + my $path = "interfaces $type $dev"; $path .= " $vifpath $vif" if $vif; my $self = { name => $name, + type => $type, path => $path, dev => $dev, vif => $vif, @@ -108,7 +112,6 @@ sub new { bless $self, $class; return $self; - } return; # nothing @@ -135,6 +138,11 @@ sub physicalDevice { return $self->{dev}; } +sub type { + my $self = shift; + return $self->{type}; +} + ## Configuration checks sub configured { |