From e6315798fc2df8329f2824dcfa2f1b1ea1ac7828 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Sun, 4 May 2014 15:30:04 +0100 Subject: [PATCH] start work on mkvlan support --- xCAT-client/pods/man1/mkvlan.1.pod | 74 +++++++++++++++++++ xCAT-server/lib/xcat/plugins/vlan.pm | 102 +++++++++++++++++++++++++++ 2 files changed, 176 insertions(+) create mode 100644 xCAT-client/pods/man1/mkvlan.1.pod create mode 100644 xCAT-server/lib/xcat/plugins/vlan.pm diff --git a/xCAT-client/pods/man1/mkvlan.1.pod b/xCAT-client/pods/man1/mkvlan.1.pod new file mode 100644 index 000000000..54c42ed13 --- /dev/null +++ b/xCAT-client/pods/man1/mkvlan.1.pod @@ -0,0 +1,74 @@ +=head1 Name + +B - Create vlan on switches + +=head1 B + +B [B<-h>|B<--help>|B|B<-v>|B<--version>] + +B {Ivlanid} -n I {B-i |B-m |B-t } + +=head1 B + +B creates tagged vlan on the switches corresponding to the attributes defined in the B table + +=head1 B + +=over 7 + +=item B + +The vlan to tag on the switch. + +=item B + +List all buses for each I/O slot. + +=item B + +Retrieves number of processors, speed, total memory, and DIMM +locations. + +=item B + +Retrieves model number. + +=item B<-h>|B<--help>|B + +Print help. + +=item B<-v>|B<--version> + +Print version. + +=back + +=back + +=head1 B + +=over 4 + +=item * + +To make a private vlan for stand-alone nodes for the management network, enter: + + mkvlan -n node1,node2,node3 + +=item * + +You can specify vlan id, subnet and netmask etc, enter: + + mkvlan 3 -n node1,node2,node3 -t 10.3.2.0 -m 255.255.255.0 + +=item * + +To create a tagged vlan on an interface, enter: + + mkvlan -n node1,node2,node3 -i eth1 + +=back + +=head1 SEE ALSO + +L diff --git a/xCAT-server/lib/xcat/plugins/vlan.pm b/xCAT-server/lib/xcat/plugins/vlan.pm new file mode 100644 index 000000000..f68e3afb0 --- /dev/null +++ b/xCAT-server/lib/xcat/plugins/vlan.pm @@ -0,0 +1,102 @@ +#!/usr/bin/perl +# OCF(c) 2014 EPL license http://www.eclipse.org/legal/epl-v10.html + +package xCAT_plugin::vlan; +BEGIN +{ + $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : '/opt/xcat'; +} +use lib "$::XCATROOT/lib/perl"; +use strict; +use warnings "all"; +use xCAT::GlobalDef; +use xCAT::SPD qw/decode_spd/; + +use xCAT::Utils; +use xCAT::TableUtils; +use xCAT::SvrUtils; +use xCAT::Usage; + +sub handled_commands { + return { + mkvlan => 'switch:vlan,port,switch', #done + chvlan => 'switch:vlan,port,switch', #done + lsvlan => 'switch:vlan,port,switch', #done + rmvlan => 'switch:vlan,port,switch', #done + } +} + + +use POSIX "WNOHANG"; +use IO::Handle; +use IO::Socket; +use IO::Select; +use Class::Struct; +use Digest::MD5 qw(md5); +use POSIX qw(WNOHANG mkfifo strftime); +use Fcntl qw(:flock); + + +#local to module +my $callback; +my $timeout; +my $port; +my $debug; +my $ndebug = 0; +my $sock; +my $noclose; +my %sessiondata; #hold per session variables, in preparation for single-process strategy +my %pendingtransactions; #list of peers with callbacks, callback arguments, and timer expiry data +my $enable_cache="yes"; +my $cache_dir = "/var/cache/xcat"; + +sub process_request +{ + my $req = shift; + my $callback = shift; + my $reqcmd = shift; + my $nodes = $req->{node}; + my $command = $req->{command}->[0]; + my $args = $req->{arg}; + my @nodes = $req + + if ($command eq 'mkvlan') + { + return mkvlan($req, $callback, $reqcmd); + } + elsif ($command eq 'chvlan') + { + return chvlan($req, $callback, $reqcmd); + } + elsif ($command eq 'lsvlan') + { + return lsvlan($req, $callback, $reqcmd); + } + elsif ($command eq 'rmvlan') + { + return rmvlan($req, $callback, $reqcmd); + } +} + + +sub mkvlan +{ + my $request = shift; + my $callback = shift; + my $reqcmd = shift; + + my $nodes = @{$req->{node}}; + my @args = @{$req->{arg}} if(exists($req->{arg})); + my @nodes = @{$req->{node}}; + + @ARGV = @{$req->{arg}}; + GetOptions( + 't=s' => \$subnet, + 'm=s' => \$mask, + 'v=s' => \$vlan, + 'i=s' => \$interface, + ); + +} + +1;