Commit 19cdaa6a authored by Weibin Sun's avatar Weibin Sun Committed by Robert Ricci
Browse files

Add command line option for log level in switch-side daemon.

Add fake commands for port-control to avoid errors since our Arista
  switch just support one mode.
Just double checked that _setAllowedVlansOnTrunkedPort does add or remove
  VLANs rather than setting them as the only ones.
parent 287a57f6
......@@ -435,6 +435,22 @@ sub isExpVlanName($$) {
# returns number of failed ports on failure.
# returns -1 if the operation is unsupported
#
# Special note for Arista: Our Arista switch just support 10Gb full-duplex port,
# so we can't set duplex mode or other speeds. Even
# 'auto' can't work because those ports just support
# one mode. But since 'auto' may be used as a free-form,
# we pretend to support it. We also pretend to support
# 'full' and '10000mbit' though we won't do anything.
#
# Even more special on Arista: The Python API can actually set interface speed
# and duplex attributes, to up to 100Gbps...
# But CLI won't allow you set this since the
# physical interface doesnot support those modes
# at all! It is API's fault. Don't trust it and
# believe we can actually set any port modes.
# This note serves as a reminder for future maintainers,
# unless a new kind of Arista switch is used.
#
sub portControl ($$@) {
my $self = shift;
my $cmd = shift;
......@@ -446,6 +462,14 @@ sub portControl ($$@) {
my @ifports = $self->convertPortFormat($PORT_FORMAT_IFINDEX, @ports);
# Our Arista switch doesn't support setting speed at all, so we just
# pretend we do to make sure the only supported speed mode can be set.
my %fakeCmds = (
'auto' => 1,
'10000mbit' => 1,
'full' => 1,
);
if (defined $cmdOIDs{$cmd}) {
my $oid = $cmdOIDs{$cmd};
foreach my $ifport (@ifports) {
......@@ -456,9 +480,9 @@ sub portControl ($$@) {
$errors++;
}
}
} else {
} elsif (! defined $fakeCmds{$cmd}) {
#
# Command not supported
# Command not supported, not even a fake command.
#
$self->debug("Unsupported port control command '$cmd' ignored.\n");
}
......
......@@ -13,6 +13,7 @@
import PyClient
import SimpleXMLRPCServer
import sys
import argparse
RPC_PORT = @ARISTA_SWITCH_XMLRPCPORT@
BIND_ADDR = "" # This is ANY
......@@ -37,10 +38,11 @@ DEFAULT_VLAN_NUM = 1
sysdbroot = None
sysdbclient = None
# Just on command line argument.
debug_level = 0;
if len(sys.argv) > 1:
debug_level = int(sys.argv[1])
# Just one command line argument.
ap = argparse.ArgumentParser(description='Snmpit agent on Arista switch')
ap.add_argument('-v', '--verbose', type=int, default=0, help='log verbose level')
args = ap.parse_args()
debug_level = args.verbose
def debug(msg, level = 1):
if level <= debug_level:
......@@ -377,7 +379,7 @@ def setBitmapByRanges(bmp, ranges, val = 1):
bmp[i] = val
return bmp
# Convert a string range to int tuple:
# Convert a string range to int tuple, e.g.:
# '200' => (200, 200), '100-200' => (100, 200)
def stringRange2IntTuple(sr):
bs = sr.split('-')
......@@ -422,7 +424,7 @@ def bitmap2String(bmp):
# Return 1 on success, 1 on failure.
#
# NOTE: Arista switch CLI supports more sophisticated VLAN range, here
# we only need deal the range value in existing trunkAllowedVlans.
# we only need deal with the range value in existing trunkAllowedVlans.
# This works because vnums are passed from snmpit, and are all
# single numbers.
#
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment