summaryrefslogtreecommitdiff
path: root/lib/Vyatta
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-10 14:21:20 -0800
committerStephen Hemminger <stephen.hemminger@vyatta.com>2009-02-10 14:21:20 -0800
commit31747ed42038d00499099d11abf1e33b3ef7c26f (patch)
tree99dce067e965b78bb873e0e594bfe963494f873b /lib/Vyatta
parentc1d6c408046e0f7331d8ddb55a88b71ff7cc0f96 (diff)
downloadvyatta-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')
-rw-r--r--lib/Vyatta/Interface.pm16
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 {