@ -618,6 +618,12 @@ sub gather_data
$ anvil - > data - > { new } { scan_drbd } { scan_drbd_timeout } = 6 ; # Default is '60', 6 seconds
$ anvil - > data - > { new } { scan_drbd } { scan_drbd_total_sync_speed } = 0 ;
my $ local_host_name = $ anvil - > Get - > host_name ;
my $ local_short_host_name = $ anvil - > Get - > short_host_name ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
local_host_name = > $ local_host_name ,
local_short_host_name = > $ local_short_host_name ,
} } ) ;
foreach my $ name ( $ dom - > findnodes ( '/config/common/section' ) )
{
my $ section = $ name - > { name } ;
@ -706,7 +712,7 @@ sub gather_data
} } ) ;
# Record the local data only.
if ( ( $ this_host_name eq $ anvil - > Get - > host_name ) or ( $ this_host_name eq $ anvil - > Get - > short_host_name ) )
if ( ( $ this_host_name eq $ local_ host_name) or ( $ this_host_name eq $ local_ short_host_name) )
{
$ anvil - > data - > { new } { resource } { $ resource } { volume } { $ volume } { device_path } = $ volume_vnr - > findvalue ( './device' ) ;
$ anvil - > data - > { new } { resource } { $ resource } { volume } { $ volume } { backing_disk } = $ volume_vnr - > findvalue ( './disk' ) ;
@ -723,32 +729,135 @@ sub gather_data
foreach my $ connection ( $ name - > findnodes ( './connection' ) )
{
my $ peer = "" ;
my $ host1_name = "" ;
my $ host1_ip_address = "" ;
my $ host1_tcp_port = "" ;
my $ host2_name = "" ;
my $ host2_ip_address = "" ;
my $ host2_tcp_port = "" ;
my $ peer = "" ;
foreach my $ host ( $ connection - > findnodes ( './host' ) )
{
my $ this_host_name = $ host - > { name } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > { this_host_name = > $ this_host_name } } ) ;
if ( not $ host1_name )
{
$ host1_name = $ this_host_name ;
$ host1_ip_address = $ host - > findvalue ( './address' ) ;
$ host1_tcp_port = $ host - > findvalue ( './address/@port' ) ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
host1_name = > $ host1_name ,
host1_ip_address = > $ host1_ip_address ,
host1_tcp_port = > $ host1_tcp_port ,
} } ) ;
}
else
{
$ host2_name = $ this_host_name ;
$ host2_ip_address = $ host - > findvalue ( './address' ) ;
$ host2_tcp_port = $ host - > findvalue ( './address/@port' ) ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
host2_name = > $ host2_name ,
host2_ip_address = > $ host2_ip_address ,
host2_tcp_port = > $ host2_tcp_port ,
} } ) ;
}
next if ( ( $ this_host_name eq $ anvil - > Get - > host_name ) or ( $ this_host_name eq $ anvil - > Get - > short_host_name ) ) ;
$ peer = $ this_host_name ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { peer_ip_address } = $ host - > findvalue ( './address' ) ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { tcp_port } = $ host - > findvalue ( './address/@port' ) ; ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"s1:new::resource::${resource}::peer::${peer}::peer_ip_address" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { peer_ip_address } ,
"s2:new::resource::${resource}::peer::${peer}::tcp_port" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { tcp_port } ,
} } ) ;
# $peer = $this_host_name;
# $anvil->data->{new}{resource}{$resource}{peer}{$peer}{peer_ip_address} = $host->findvalue('./address');
# $anvil->data->{new}{resource}{$resource}{peer}{$peer}{tcp_port} = $host->findvalue('./address/@port');
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
# "s1:new::resource::${resource}::peer::${peer}::peer_ip_address" => $anvil->data->{new}{resource}{$resource}{peer}{$peer}{peer_ip_address},
# "s2:new::resource::${resource}::peer::${peer}::tcp_port" => $anvil->data->{new}{resource}{$resource}{peer}{$peer}{tcp_port}." (".$host->findvalue('./address/@port').")",
# }});
if ( not exists $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } )
# if (not exists $anvil->data->{new}{resource}{$resource}{peer}{$peer}{protocol})
# {
# $anvil->data->{new}{resource}{$resource}{peer}{$peer}{protocol} = "unknown";
# $anvil->data->{new}{resource}{$resource}{peer}{$peer}{fencing} = "unknown";
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
# "s1:new::resource::${resource}::peer::${peer}::protocol" => $anvil->data->{new}{resource}{$resource}{peer}{$peer}{protocol},
# "s2:new::resource::${resource}::peer::${peer}::fencing" => $anvil->data->{new}{resource}{$resource}{peer}{$peer}{fencing},
# }});
# }
#
# foreach my $volume (sort {$a cmp $b} keys %{$anvil->data->{new}{resource}{$resource}{volume}})
# {
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{connection_state} = "disconnected";
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{local_disk_state} = "down";
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{peer_disk_state} = "unknown";
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{local_role} = "down";
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{peer_role} = "unknown";
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{out_of_sync_size} = -1;
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{replication_speed} = 0;
# $anvil->data->{new}{resource}{$resource}{volume}{$volume}{peer}{$peer}{estimated_time_to_sync} = 0;
# }
}
if ( ( $ host1_name eq $ local_short_host_name ) or
( $ host1_name eq $ local_host_name ) or
( $ host2_name eq $ local_short_host_name ) or
( $ host2_name eq $ local_host_name ) )
{
# This is one of our connections.
my $ peer = "" ;
if ( ( $ host1_name eq $ local_short_host_name ) or ( $ host1_name eq $ local_host_name ) )
{
# Our peer is host2
$ peer = $ host2_name ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { peer_ip_address } = $ host2_ip_address ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { tcp_port } = $ host2_tcp_port ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"s1:new::resource::${resource}::peer::${peer}::peer_ip_address" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { peer_ip_address } ,
"s2:new::resource::${resource}::peer::${peer}::tcp_port" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { tcp_port } ,
} } ) ;
}
else
{
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } = "unknown" ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } = "unknown" ;
# Our peer is host1
$ peer = $ host1_name ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { peer_ip_address } = $ host1_ip_address ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { tcp_port } = $ host1_tcp_port ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"s1:new::resource::${resource}::peer::${peer}::protocol" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } ,
"s2:new::resource::${resource}::peer::${peer}::fencing" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } ,
"s1:new::resource::${resource}::peer::${peer}::peer_ip_address " = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { peer_ip_address } ,
"s2:new::resource::${resource}::peer::${peer}::tcp_port" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { tcp_port } ,
} } ) ;
}
foreach my $ name ( $ connection - > findnodes ( './section' ) )
{
my $ section = $ name - > { name } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > { section = > $ section } } ) ;
foreach my $ option_name ( $ name - > findnodes ( './option' ) )
{
my $ variable = $ option_name - > { name } ;
my $ value = $ option_name - > { value } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
's1:variable' = > $ variable ,
's2:value' = > $ value ,
} } ) ;
if ( $ section eq "net" )
{
if ( $ variable eq "protocol" )
{
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } = $ value ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"new::resource::${resource}::peer::${peer}::protocol" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } ,
} } ) ;
}
if ( $ variable eq "fencing" )
{
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } = $ value ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"new::resource::${resource}::peer::${peer}::fencing" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } ,
} } ) ;
}
}
}
}
foreach my $ volume ( sort { $ a cmp $ b } keys % { $ anvil - > data - > { new } { resource } { $ resource } { volume } } )
{
$ anvil - > data - > { new } { resource } { $ resource } { volume } { $ volume } { peer } { $ peer } { connection_state } = "disconnected" ;
@ -761,40 +870,6 @@ sub gather_data
$ anvil - > data - > { new } { resource } { $ resource } { volume } { $ volume } { peer } { $ peer } { estimated_time_to_sync } = 0 ;
}
}
foreach my $ name ( $ connection - > findnodes ( './section' ) )
{
my $ section = $ name - > { name } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > { section = > $ section } } ) ;
foreach my $ option_name ( $ name - > findnodes ( './option' ) )
{
my $ variable = $ option_name - > { name } ;
my $ value = $ option_name - > { value } ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
's1:variable' = > $ variable ,
's2:value' = > $ value ,
} } ) ;
if ( $ section eq "net" )
{
if ( $ variable eq "protocol" )
{
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } = $ value ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"new::resource::${resource}::peer::${peer}::protocol" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } ,
} } ) ;
}
if ( $ variable eq "fencing" )
{
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } = $ value ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > {
"new::resource::${resource}::peer::${peer}::fencing" = > $ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } ,
} } ) ;
}
}
}
}
}
}
}
@ -1394,7 +1469,7 @@ ORDER BY
's6:scan_drbd_volume_device_minor' = > $ scan_drbd_volume_device_minor ,
's7:scan_drbd_peer_host_name' = > $ scan_drbd_peer_host_name ,
's8:scan_drbd_peer_ip_address' = > $ scan_drbd_peer_ip_address ,
's9:scan_drbd_peer_protocol' = > $ scan_drbd_peer_protocol ,
's9:scan_drbd_peer_protocol' = > $ scan_drbd_peer_protocol ,
's10:scan_drbd_peer_fencing' = > $ scan_drbd_peer_fencing ,
's11:scan_drbd_peer_tcp_port' = > $ scan_drbd_peer_tcp_port ,
} } ) ;
@ -1446,13 +1521,15 @@ ORDER BY
my $ tcp_pair = "" ;
while ( $ looking )
{
if ( exists $ anvil - > data - > { drbd } { used_resources } { tcp_port } { $ free_port } )
if ( ( exists $ anvil - > data - > { drbd } { used_resources } { tcp_port } { $ free_port } ) &&
( $ anvil - > data - > { drbd } { used_resources } { tcp_port } { $ free_port } { used } ) )
{
$ free_port + + ;
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > { free_port = > $ free_port } } ) ;
}
else
{
$ anvil - > Log - > variables ( { source = > $ THIS_FILE , line = > __LINE__ , level = > $ debug , list = > { free_port = > $ free_port } } ) ;
if ( $ dr_tcp_ports )
{
if ( not $ tcp_pair )