Index: /trunk/klask
===================================================================
--- /trunk/klask (revision 249)
+++ /trunk/klask (revision 250)
@@ -467,4 +467,20 @@
#---------------------------------------------------------------
+sub format_aggregator4html {
+ my $port_hr = shift;
+ $port_hr =~ s/($SEP_AGGREGATOR_PORT)/: /; # First occurence
+ $port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
+ return $port_hr;
+ }
+
+#---------------------------------------------------------------
+sub format_aggregator4dot {
+ my $port_hr = shift;
+ $port_hr =~ s/($SEP_AGGREGATOR_PORT)/ - /; # First occurence
+ $port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
+ return $port_hr;
+ }
+
+#---------------------------------------------------------------
# return the port and the switch where the computer is connected
sub find_switch_port {
@@ -1483,11 +1499,8 @@
$vlan = $computerdb->{$ip}{network}.' ('.get_current_vlan_id($computerdb->{$ip}{network}).')' if $computerdb->{$ip}{network};
- my $switch_port_hr = $computerdb->{$ip}{switch_port_hr} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
- $switch_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
-
print <<"END_HTML";
$switch_hostname |
- $switch_port_hr |
+ format_aggregator4html($computerdb->{$ip}{switch_port_hr}) |
$arrow |
$computerdb->{$ip}{hostname_fq} |
@@ -1532,15 +1545,9 @@
my ( $host_short ) = sprintf '%s %3s' , split(m/ \. /xms, $db_switch_parent{$sw}->{'switch'}, 1), $db_switch_parent{$sw}->{port_hr};
- my $switch_port_hr = $db_switch_output_port{$sw} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
- $switch_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
-
- my $switch_connected_port_hr = $db_switch_parent{$sw}->{port_hr} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
- $switch_connected_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
-
print <<"END_HTML";
$sw |
- $switch_port_hr |
- $arrow | $switch_connected_port_hr |
+ format_aggregator4html($db_switch_output_port{$sw}) |
+ $arrow | format_aggregator4html($db_switch_parent{$sw}->{port_hr}) |
$db_switch_parent{$sw}->{'switch'} |
$ipv4_address |
@@ -1552,11 +1559,8 @@
}
else {
- my $switch_port_hr = $db_switch_output_port{$sw} =~ s/($SEP_AGGREGATOR_PORT)/: /r; # First occurence
- $switch_port_hr =~ s/($SEP_AGGREGATOR_PORT)/ /g; # Other occurence
-
print <<"END_HTML";
$sw |
- $switch_port_hr |
+ format_aggregator4html($db_switch_output_port{$sw}) |
$arrow | |
router |
@@ -1601,6 +1605,6 @@
$sw_connect |
- $port_connect |
- $arrow | $db_switch_output_port{$sw} |
+ format_aggregator4html($port_connect) |
+ $arrow | format_aggregator4html($db_switch_output_port{$sw}) |
$sw |
$ipv4_address |
@@ -1615,5 +1619,5 @@
$sw_connect |
- $port_connect |
+ format_aggregator4html($port_connect) |
$arrow | |
$sw |
@@ -2752,5 +2756,5 @@
for my $sw (keys %{$db_building{$building}->{$loc}}) {
- print "\"$sw:$db_switch_output_port{$sw}\" [label = \"$db_switch_output_port{$sw}\", color = black, fillcolor = lightblue, peripheries = 2, style = filled];\n";
+ print "\"$sw:$db_switch_output_port{$sw}\" [label = \"".format_aggregator4dot($db_switch_output_port{$sw})"\", color = black, fillcolor = lightblue, peripheries = 2, style = filled];\n";
my $swname = $sw;
@@ -2765,5 +2769,5 @@
next if not $sw_connect eq $sw;
next if $port_connect eq $db_switch_output_port{$sw};
- print "\"$sw:$port_connect\" [label = \"$port_connect\", color = black, fillcolor = plum, peripheries = 1, style = filled];\n";
+ print "\"$sw:$port_connect\" [label = \"".format_aggregator4dot($port_connect)."\", color = black, fillcolor = plum, peripheries = 1, style = filled];\n";
print "\"$sw:$port_connect\" -> \"$sw\" [len=2, style=bold, arrowhead= normal, arrowtail = inv]\n";
}