Commit 67e4c29c authored by Robert Ricci's avatar Robert Ricci
Browse files

Add the -C option to list control net, rather than experimental net,

ports.
parent 122dbb92
...@@ -42,6 +42,7 @@ Usage: $0 [-h] <-p | <pid> <eid> > [vname ...] [vname:port ...] ...@@ -42,6 +42,7 @@ Usage: $0 [-h] <-p | <pid> <eid> > [vname ...] [vname:port ...]
-p The machines given are physical, not virtual, node IDs. No pid and -p The machines given are physical, not virtual, node IDs. No pid and
eid should be given when using this option. eid should be given when using this option.
-s Ports are specified in switch.port syntax -s Ports are specified in switch.port syntax
-C List control net, rather than experimental net, ports
If only pid and eid are given, prints out information about all ports in the If only pid and eid are given, prints out information about all ports in the
experiment. Otherwise, output is limited to the nodes and/or ports given. experiment. Otherwise, output is limited to the nodes and/or ports given.
...@@ -61,7 +62,8 @@ END ...@@ -61,7 +62,8 @@ END
# Process command-line arguments # Process command-line arguments
# #
my %opt = (); my %opt = ();
GetOptions(\%opt,'h','a','e','p','b','z','q','c','s'); Getopt::Long::Configure("no_ignore_case");
GetOptions(\%opt,'h','a','e','p','b','z','q','c','s','C');
if ($opt{h}) { if ($opt{h}) {
exit &usage; exit &usage;
...@@ -212,7 +214,7 @@ elsif ($opt{p}) { ...@@ -212,7 +214,7 @@ elsif ($opt{p}) {
my ($hostname,$portnumber) = ($1,$3); my ($hostname,$portnumber) = ($1,$3);
if (defined $portnumber) { if (defined $portnumber) {
push @ports, $port; push @ports, $port;
} else { } else {
my $interfaces = DBQueryFatal("select card from interfaces " . my $interfaces = DBQueryFatal("select card from interfaces " .
"where node_id = '$hostname'"); "where node_id = '$hostname'");
while (my ($card) = $interfaces->fetchrow()) { while (my ($card) = $interfaces->fetchrow()) {
...@@ -221,7 +223,17 @@ elsif ($opt{p}) { ...@@ -221,7 +223,17 @@ elsif ($opt{p}) {
} }
} }
} else { } else {
my @experimentPorts = getExperimentPorts($pid,$eid); my @experimentPorts;
#
# Get control net or experimental net ports, depending on what they
# asked for
#
if ($opt{C}) {
@experimentPorts = getExperimentControlPorts($pid,$eid);
} else {
@experimentPorts = getExperimentPorts($pid,$eid);
}
print "ep: " . join(";",@experimentPorts) . "\n";
if (@passedPorts) { if (@passedPorts) {
# #
# Handle a set of passed-in ports # Handle a set of passed-in ports
......
...@@ -24,6 +24,7 @@ use Exporter; ...@@ -24,6 +24,7 @@ use Exporter;
getDeviceOptions getTrunks getTrunksFromSwitches getDeviceOptions getTrunks getTrunksFromSwitches
getTrunkHash getTrunkHash
getExperimentPorts snmpitGet snmpitGetWarn snmpitGetFatal getExperimentPorts snmpitGet snmpitGetWarn snmpitGetFatal
getExperimentControlPorts
snmpitSet snmpitSetWarn snmpitSetFatal snmpitSet snmpitSetWarn snmpitSetFatal
snmpitBulkwalk snmpitBulkwalkWarn snmpitBulkwalkFatal snmpitBulkwalk snmpitBulkwalkWarn snmpitBulkwalkFatal
printVars tbsort ); printVars tbsort );
...@@ -291,6 +292,29 @@ sub getExperimentPorts ($$) { ...@@ -291,6 +292,29 @@ sub getExperimentPorts ($$) {
return getVlanPorts(getExperimentVlans($pid,$eid)); return getVlanPorts(getExperimentVlans($pid,$eid));
} }
#
# Returns an array of control net ports used by a given experiment
#
sub getExperimentControlPorts ($$) {
my ($pid, $eid) = @_;
#
# Get a list of all *physical* nodes in the experiment
#
my $exp = Experiment->Lookup($pid,$eid);
my @nodes = $exp->NodeList(0,0);
#
# Get control net interfaces
#
my @ports = map { $_->node_id() . ":" . $_->control_iface() } @nodes;
#
# Convert from iface to port number when we return
#
return convertPortsFromIfaces(@ports);
}
# #
# Usage: getDeviceNames(@ports) # Usage: getDeviceNames(@ports)
# #
......
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