Commit fd4af9a5 authored by Leigh B Stoller's avatar Leigh B Stoller
Browse files

Improve stringify function for vlans to be more helpful.

Add a KeepInSync() primitive to flag vlans that we do not want to
attempt to keep in sync (like the default and control vlans).
Minor tweaks to RecordVlanInsertion(); do not need to pass in
the experiment since its already part of the vlan object.
parent 12ddf0d3
......@@ -2309,14 +2309,24 @@ sub Refresh($)
return $self->GetLan()->Refresh();
}
#
# Stringify for output.
#
#
# Stringify for output.
#
sub Stringify($)
{
my ($self) = @_;
my $pid = $self->pid();
my $eid = $self->eid();
my $vname = $self->vname();
my $id = $self->lanid();
my $tag = $self->GetTag();
$tag = (defined($tag) ? ":${tag}" : "");
return "V" . $self->GetLan()->Stringify();
return "[VLan ${id}${tag}: $pid/$eid/$vname]";
}
#
......@@ -2909,6 +2919,23 @@ sub Instantiate($;$)
return 0;
}
#
# Some vlans are not kept sync with the DB; too difficult. Might
# reexamine this later. For sure, keeping the default vlan and the
# control vlan in sync would be really hard since these tend to
# get mucked with on the switch console instead of through snmpit.
#
sub KeepInSync($)
{
my ($self) = @_;
my $tag = $self->GetReservedVlanTag();
return 0
if ($self->IsInternal() && $tag <= 10);
return 1;
}
#
# Utility function to remove a vlan from the switch infrastructure.
#
......@@ -2943,19 +2970,19 @@ sub UnInstantiate($;$)
# Class methods to maintain the backup vlans table, which records what
# is on the switches.
#
sub RecordVlanInsertion($$$$)
sub RecordVlanInsertion($$$)
{
my ($class, $experiment, $vlan, $stack) = @_;
my ($class, $vlan, $stack) = @_;
my $pid = $experiment->pid();
my $eid = $experiment->eid();
my $exptidx = $experiment->idx();
if (!ref($vlan)) {
$vlan = VLan->Lookup($vlan);
}
return -1
if (!defined($vlan));
my $pid = $vlan->pid();
my $eid = $vlan->eid();
my $exptidx = $vlan->exptidx();
my $lanid = $vlan->lanid();
my $vname = $vlan->vname();
my $tag = $vlan->GetReservedVlanTag();
......
Markdown is supported
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