103 lines
2.1 KiB
Perl

#!/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;