From 2aa8a18e97fb5081691dca399ceada8fcae21ec7 Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Tue, 6 Apr 2010 09:42:02 -0700 Subject: Add input interface template Also change how interface qos-policy is generated, using a template for templates rather than using hardcode expansion. --- gen-interface-templates.pl | 76 ++++++++++++++++------------- interface-templates/qos-policy/in/node.def | 5 ++ interface-templates/qos-policy/out/node.def | 5 ++ 3 files changed, 51 insertions(+), 35 deletions(-) create mode 100644 interface-templates/qos-policy/in/node.def create mode 100644 interface-templates/qos-policy/out/node.def diff --git a/gen-interface-templates.pl b/gen-interface-templates.pl index 31816aa..8fb221c 100755 --- a/gen-interface-templates.pl +++ b/gen-interface-templates.pl @@ -42,6 +42,8 @@ my %interface_hash = ( 'tunnel/node.tag' => '$VAR(@)', 'bridge/node.tag' => '$VAR(@)', 'openvpn/node.tag' => '$VAR(@)', + 'input/node.tag' => '$VAR(@)', + 'wirelessmodem/node.tag' => '$VAR(@)', 'wireless/node.tag' => '$VAR(@)', 'wireless/node.tag/vif/node.tag' => '$VAR(../@).$VAR(@)', @@ -58,41 +60,48 @@ my %interface_hash = ( ); sub gen_template { - my ( $outpath, $ifname ) = @_; - $ifname =~ s#@\)#..\/..\/@\)#g; + my ( $inpath, $outpath, $ifname ) = @_; print $outpath, "\n" if ($debug); - $outpath .= "/qos-policy"; - mkdir $outpath - or die "Can't mkdir $outpath: $!"; - - open my $node, '>', "$outpath/node.def" - or die "Can't open $outpath/node.def: $!"; - print $node "help: Set Quality of Service (QOS) policy for interface\n"; - close $node - or die "Can't write $outpath/node.def: $!"; - - foreach my $dir qw(in out) { - my $path = "$outpath/$dir"; - - mkdir $path - or die "Can't create directory: $path: $!"; - open my $node, '>', "$path/node.def" - or die "Can't open $path/node.def: $!"; - select $node; - print <', $out or die "Can't open $out: $!"; + + while ( my $line = <$inf> ) { + $line =~ s#\$IFNAME#$ifname#; + print $outf $line; + } + close $inf; + close $outf or die "Close error $out:$!"; } + closedir $d; } +die "Usage: $0 output_directory\n" if ( $#ARGV < 0 ); + +my $outdir = $ARGV[0]; + sub mkdir_p { my $path = shift; @@ -104,15 +113,12 @@ sub mkdir_p { return mkdir($path); } -die "Usage: $0 output_directory\n" if ( $#ARGV < 0 ); - -my $outdir = $ARGV[0]; - foreach my $if_tree ( keys %interface_hash ) { + my $inpath = "interface-templates"; my $outpath = "$outdir/interfaces/$if_tree"; ( -d $outpath ) or mkdir_p($outpath) or die "Can't create $outpath:$!"; - gen_template( $outpath, $interface_hash{$if_tree} ); + gen_template( $inpath, $outpath, $interface_hash{$if_tree} ); } diff --git a/interface-templates/qos-policy/in/node.def b/interface-templates/qos-policy/in/node.def new file mode 100644 index 0000000..67d3e4b --- /dev/null +++ b/interface-templates/qos-policy/in/node.def @@ -0,0 +1,5 @@ +type: txt +help: Set inbound QOS policy for interface +allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy in +update: /opt/vyatta/sbin/vyatta-qos.pl --update-interface $IFNAME in $VAR(@) +delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-interface $IFNAME in diff --git a/interface-templates/qos-policy/out/node.def b/interface-templates/qos-policy/out/node.def new file mode 100644 index 0000000..1a4e213 --- /dev/null +++ b/interface-templates/qos-policy/out/node.def @@ -0,0 +1,5 @@ +type: txt +help: Set outbound QOS policy for interface +allowed: /opt/vyatta/sbin/vyatta-qos.pl --list-policy out +update: /opt/vyatta/sbin/vyatta-qos.pl --update-interface $IFNAME out $VAR(@) +delete: /opt/vyatta/sbin/vyatta-qos.pl --delete-interface $IFNAME out -- cgit v1.2.3