add/remove interfaces (which are up) from bridge
authorDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 8 Sep 2009 20:21:25 +0000 (20:21 +0000)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Tue, 8 Sep 2009 20:21:25 +0000 (20:21 +0000)
lib/PXElator/html.pm
lib/PXElator/httpd.pm

index a1fd6f6..a2845cd 100644 (file)
@@ -51,7 +51,6 @@ sub select {
                , qq|<select type=select name=$name>|
                , join("\n", map { my $selected = $_ eq $selected_option ? 'selected' : ''; qq|<option name=$_ $selected>$_</option>| } @_ )
                , qq|</select>|
-               , qq|</form>|
        );
 }
 
index 0c46e36..50cd65b 100644 (file)
@@ -366,17 +366,42 @@ warn "XXX pids = ", dump( $daemons::pids );
                                </form>
                        |;
                }
+
+
        } elsif ( $path =~ m{^/brctl} ) {
-               print $client ok, html::table( -4,
+
+               system 'brctl addif virtual ' . $param->{addif} if $param->{addif};
+               system 'brctl delif virtual ' . $param->{delif} if $param->{delif};
+
+               my $in_virtual;
+
+               my @table =
                        map {
                                my @c = split(/\t+/,$_,4);
                                if ( $#c == 1 ) {
-                                       ( '', '', '', $c[1] )
+                                       $in_virtual->{ $c[1] }++;
+                                       @c = ( '', '', '', $c[1] );
                                } else {
-                                       @c
+                                       $in_virtual->{ $c[3] }++;
+                               }
+                               if ( $c[3] =~ m{\d$} ) {
+                                       $c[3] = qq|<input type=submit name=delif value=$c[3] style="color:red" title="remove $c[3] from bridge">|;
                                }
+                               @c
                        } split(/\n/, `brctl show`)
-               );
+               ;
+
+               my @add_ifs = grep { ! $in_virtual->{$_} && $_ ne 'virtual' } ip::devices_up;
+
+               push @table, ( '', '', '', html::select( 'addif', @add_ifs ) . qq|<input type=submit value=add></form>| );
+
+               print $client ok
+                       , qq|<form>|
+                       , html::table( -4, @table )
+                       , qq|</form>|
+                       ;
+
+
        } elsif ( $path =~ m{^/ip/?(\w+)?} ) {
                print $client ok
                        , join("\n", map { qq|<a href=/ip/$_>$_</a>| } ( qw/link addr route neigh ntable tunnel maddr mroute xfrm/ ))