[ixpmanager] update-l2database.pl uses unqualified hostnames

Marco d'Itri md at Linux.IT
Tue Jan 23 22:13:17 GMT 2018


switch.name is just the switch description.
I am not sure if this patch is correct for other cases, but it works for me.

index 20684f0..26d7fc3 100755
--- a/tools/runtime/l2database/update-l2database.pl
+++ b/tools/runtime/l2database/update-l2database.pl
@@ -104,7 +104,7 @@ if (defined $vlanid) {
 	}
 
 	# then retrieve a list of relevant switches
-	$query = "SELECT sw.name, sw.snmppasswd FROM (vlan vl, switch sw) WHERE vl.infrastructureid = sw.infrastructure AND sw.active AND vl.id = ?";
+	$query = "SELECT sw.name, sw.hostname, sw.snmppasswd FROM (vlan vl, switch sw) WHERE vl.infrastructureid = sw.infrastructure AND sw.active AND vl.id = ?";
 	($sth = $dbh->prepare($query)) or die "$dbh->errstr\n";
 	$sth->execute($vlanid) or die "$dbh->errstr\n";
 
@@ -114,18 +114,18 @@ if (defined $vlanid) {
 	# IXP, so this is not recommended.
 
 	print STDERR "WARNING: executing this program without the \"--vlanid\" parameter is deprecated and will be removed in a future version of IXP Manager.\n";
-	$query = "SELECT sw.name, sw.snmppasswd FROM (vlan vl, switch sw) WHERE vl.infrastructureid = sw.infrastructure AND sw.active AND vl.number = ?";
+	$query = "SELECT sw.name, sw.hostname, sw.snmppasswd FROM (vlan vl, switch sw) WHERE vl.infrastructureid = sw.infrastructure AND sw.active AND vl.number = ?";
 	($sth = $dbh->prepare($query)) or die "$dbh->errstr\n";
 	$sth->execute($vlan) or die "$dbh->errstr\n";
 } else {
 	print STDERR "WARNING: executing this program without the \"--vlanid\" parameter is deprecated and will be removed in a future version of IXP Manager.\n";
 	# otherwise query all switches for legacy behaviour
-	$query = "SELECT name, snmppasswd FROM switch WHERE active AND switchtype = ?";
+	$query = "SELECT name, hostname, snmppasswd FROM switch WHERE active AND switchtype = ?";
 	($sth = $dbh->prepare($query)) or die "$dbh->errstr\n";
 	$sth->execute(SWITCHTYPE_SWITCH) or die "$dbh->errstr\n";
 }
 
-my $switches = $sth->fetchall_hashref('name');
+my $switches = $sth->fetchall_hashref('hostname');
 
 foreach my $switch (keys %{$switches}) {
 	$l2mapping->{$switch} = trawl_switch_snmp($switch, $switches->{$switch}->{snmppasswd}, $vlan);

-- 
ciao,
Marco
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://www.inex.ie/pipermail/ixpmanager/attachments/20180123/347341a8/attachment.bin>


More information about the ixpmanager mailing list