# $testdir/hardware_status Hardware description (number of nodes, ...)
# $testdir/manager_status CRM status (start with {})
# $testdir/service_config Service configuration
+# $testdir/static_service_stats Static service usage information (cpu, memory)
# $testdir/groups HA groups configuration
# $testdir/service_status_<node> Service status
# $testdir/datacenter.cfg Datacenter wide HA configuration
#
# $testdir/status/cluster_locks Cluster locks
# $testdir/status/hardware_status Hardware status (power/network on/off)
+# $testdir/status/static_service_stats Static service usage information (cpu, memory)
# $testdir/status/watchdog_status Watchdog status
#
# runtime status
return $res;
}
+sub read_static_service_stats {
+ my ($self) = @_;
+
+ my $filename = "$self->{statusdir}/static_service_stats";
+ my $stats = eval { PVE::HA::Tools::read_json_from_file($filename) };
+ $self->log('error', "loading static service stats failed - $@") if $@;
+
+ return $stats;
+}
+
my $default_group_config = <<__EOD;
group: prefer_node1
nodes node1
copy("$testdir/datacenter.cfg", "$statusdir/datacenter.cfg");
}
+ if (-f "$testdir/static_service_stats") {
+ copy("$testdir/static_service_stats", "$statusdir/static_service_stats");
+ }
+
my $cstatus = $self->read_hardware_status_nolock();
foreach my $node (sort keys %$cstatus) {
# power <node> <on|off>
# network <node> <on|off>
# delay <seconds>
+# skip-round <crm|lrm> [<rounds=1>]
# cfs <node> <rw|update> <work|fail>
# reboot <node>
# shutdown <node>
my $cstatus = $self->read_hardware_status_nolock();
- my ($cmd, $objid, $action, $param) = split(/\s+/, $cmdstr);
+ my ($cmd, $objid, $action, @params) = split(/\s+/, $cmdstr);
+ my $param = $params[0]; # for convenience/legacy
die "sim_hardware_cmd: no node or service for command specified"
if !$objid;
}
} elsif ($action eq 'start') {
$d->{crm} = $self->crm_control('start', $d, $lock_fh) if !defined($d->{crm});
+ } elsif ($action eq 'enable-node-maintenance' || $action eq 'disable-node-maintenance') {
+ $self->queue_crm_commands_nolock("$action $node");
} else {
die "sim_hardware_cmd: unknown action '$action'";
}
} elsif ($action eq 'add') {
- $self->add_service($sid, {state => 'started', node => $param});
+ $self->add_service($sid, {state => $params[1] || 'started', node => $param});
} elsif ($action eq 'delete') {
return &$modify_watchog($self, $code);
}
+sub get_static_node_stats {
+ my ($self) = @_;
+
+ my $cstatus = $self->read_hardware_status_nolock();
+
+ my $stats = {};
+ for my $node (keys $cstatus->%*) {
+ $stats->{$node} = { $cstatus->{$node}->%{qw(cpus memory)} };
+ }
+
+ return $stats;
+}
+
1;