* Started parsing drbdsetup JSON data.

* Fixed a bug with how we stored data from the drbdadm dump-xml data.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent bb4b5b1778
commit 36c0d3b921
  1. 63
      ocf/alteeve/server

@ -105,6 +105,7 @@ my $conf = {
cibadmin => "/usr/sbin/cibadmin", cibadmin => "/usr/sbin/cibadmin",
crm_error => "/usr/sbin/crm_error", crm_error => "/usr/sbin/crm_error",
drbdadm => "/usr/sbin/drbdadm", drbdadm => "/usr/sbin/drbdadm",
drbdsetup => "/usr/sbin/drbdsetup",
echo => "/usr/bin/echo", echo => "/usr/bin/echo",
free => "/usr/bin/free", free => "/usr/bin/free",
getent => "/usr/bin/getent", getent => "/usr/bin/getent",
@ -232,8 +233,8 @@ elsif ($conf->{switches}{notify})
else else
{ {
# We were called in some unexpected way. Log an error, show usage and exit. # We were called in some unexpected way. Log an error, show usage and exit.
to_log($conf, {message => "We were invoked with an unexpected (or no) command. Environment variables and arguments below.", 'line' => __LINE__, level => 0, priority => "warn"});
show_environment($conf, 0); show_environment($conf, 0);
to_log($conf, {message => "We were invoked with an unexpected (or no) command. Environment variables and arguments below.", 'line' => __LINE__, level => 0, priority => "warn"});
exit(1); exit(1);
} }
@ -449,14 +450,14 @@ sub validate_all
to_log($conf, {message => "- Sufficient RAM is available.", 'line' => __LINE__, level => 2}); to_log($conf, {message => "- Sufficient RAM is available.", 'line' => __LINE__, level => 2});
} }
# Validate storage (Disks and optical media)
validate_storage($conf);
to_log($conf, {message => "- Storage is valid and ready.", 'line' => __LINE__, level => 2});
# Validate bridges # Validate bridges
validate_bridges($conf); validate_bridges($conf);
to_log($conf, {message => "- Network bridge(s) are available.", 'line' => __LINE__, level => 2}); to_log($conf, {message => "- Network bridge(s) are available.", 'line' => __LINE__, level => 2});
# Validate storage (Disks and optical media)
validate_storage($conf);
to_log($conf, {message => "- Storage is valid and ready.", 'line' => __LINE__, level => 2});
exit(0); exit(0);
} }
@ -550,12 +551,12 @@ sub validate_storage
} }
} }
# Verify DRBD devices now
validate_storage_drbd($conf);
# Verify optical disks now # Verify optical disks now
validate_storage_optical($conf); validate_storage_optical($conf);
# Verify DRBD devices now
validate_storage_drbd($conf);
return(0); return(0);
} }
@ -588,10 +589,6 @@ sub validate_storage_drbd
to_log($conf, {message => $error, 'line' => __LINE__, level => 0, priority => "err"}); to_log($conf, {message => $error, 'line' => __LINE__, level => 0, priority => "err"});
exit(1); exit(1);
} }
else
{
#print Dumper $drbd_xml;
}
foreach my $resource (sort {$a cmp $b} keys %{$drbd_xml->{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$drbd_xml->{resource}})
{ {
@ -625,24 +622,20 @@ sub validate_storage_drbd
# This is us. # This is us.
$local = $host; $local = $host;
to_log($conf, {message => "Recording the local connection details for the resource: [$resource] -> [$address:$port].", 'line' => __LINE__, level => 2}); to_log($conf, {message => "Recording the local connection details for the resource: [$resource] -> [$address:$port].", 'line' => __LINE__, level => 2});
$conf->{server}{drbd}{'local'} = { $conf->{server}{drbd}{'local'}{hostname} = $host,
hostname => $host, $conf->{server}{drbd}{'local'}{short_hostname} = $short_hostname,
short_hostname => $short_hostname, $conf->{server}{drbd}{'local'}{address} = $address,
address => $address, $conf->{server}{drbd}{'local'}{port} = $port,
port => $port,
};
} }
else else
{ {
# This is our peer # This is our peer
$peer = $host; $peer = $host;
to_log($conf, {message => "Recording the peer's connection details for the resource: [$resource] -> [$address:$port].", 'line' => __LINE__, level => 2}); to_log($conf, {message => "Recording the peer's connection details for the resource: [$resource] -> [$address:$port].", 'line' => __LINE__, level => 2});
$conf->{server}{drbd}{peer} = { $conf->{server}{drbd}{peer}{hostname} = $host,
hostname => $host, $conf->{server}{drbd}{peer}{short_hostname} = $short_hostname,
short_hostname => $short_hostname, $conf->{server}{drbd}{peer}{address} = $address,
address => $address, $conf->{server}{drbd}{peer}{port} = $port,
port => $port,
};
} }
} }
} }
@ -665,6 +658,7 @@ sub validate_storage_drbd
{ {
to_log($conf, {message => "Checking that the DRBD device: [$device_path] is ready.", 'line' => __LINE__, level => 2}); to_log($conf, {message => "Checking that the DRBD device: [$device_path] is ready.", 'line' => __LINE__, level => 2});
to_log($conf, {message => "server::drbd::local::device::${device_path}::lv: [".$conf->{server}{drbd}{'local'}{device}{$device_path}{lv}."].", 'line' => __LINE__, level => 2});
if (not $conf->{server}{drbd}{'local'}{device}{$device_path}{lv}) if (not $conf->{server}{drbd}{'local'}{device}{$device_path}{lv})
{ {
# The backing LV doesn't exist. # The backing LV doesn't exist.
@ -683,6 +677,27 @@ sub validate_storage_drbd
} }
} }
# Now read in the status of the drbd devices
$return_code = undef;
($return_code, my $status_json) = shell_call($conf, $conf->{path}{exe}{drbdsetup}." status --json");
if ($return_code)
{
# Something went wrong.
to_log($conf, {message => "The attempt to read the DRBD status returned a non-zero code: [$return_code]. The returned output (if any) was: [$status_json].", 'line' => __LINE__, level => 0, priority => "err"});
exit(1);
}
my $json = JSON->new->allow_nonref;
my $drbd_status = $json->decode($status_json);
# Pull out my data
#my $local_disk_state =
foreach my $connection_ref (@{$drbd_status->[0]->{connections}})
{
}
print Dumper $drbd_status;
return(0); return(0);
} }

Loading…
Cancel
Save