@ -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,43 +729,99 @@ sub gather_data
foreach my $ connection ( $ name - > findnodes ( './connection' ) )
{
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 } } ) ;
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' ) ; ;
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 = > {
"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 } ,
host1_name = > $ host1_name ,
host1_ip_address = > $ host1_ip_address ,
host1_tcp_port = > $ host1_tcp_port ,
} } ) ;
if ( not exists $ anvil - > data - > { n ew } { resource } { $ resource } { peer } { $ peer } { protocol } )
}
els e
{
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { protocol } = "unknown" ;
$ anvil - > data - > { new } { resource } { $ resource } { peer } { $ peer } { fencing } = "unknown" ;
$ 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 = > {
"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 } ,
host2_name = > $ host2_name ,
host2_ip_address = > $ host2_ip_address ,
host2_tcp_port = > $ host2_tcp_port ,
} } ) ;
}
foreach my $ volume ( sort { $ a cmp $ b } keys % { $ anvil - > data - > { new } { resource } { $ resource } { volume } } )
# $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})
# {
# $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 ) )
{
$ 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 ;
# 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
{
# 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}::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' ) )
@ -795,6 +857,19 @@ sub gather_data
}
}
}
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 ;
}
}
}
}
}
@ -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 )