* [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources
@ 2025-10-14 9:47 Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 1/9] sim: add command to set static service stats Maximiliano Sandoval
` (8 more replies)
0 siblings, 9 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
This series allows to:
- Set the cluster resource scheduler
- Set a node's static resources on creation and edit them after the fact
- Persist the current state of the simulator for future runs
- We sneak at the end a commit to add the build dir to .gitignore, please feel
free to not apply it if this is unwanted.
The next step would be to allow adding/removing nodes and setting/editing their
resource stats, but that can go in a follow-up.
Suggested-by: Daniel Kral <d.kral@proxmox.com>
Maximiliano Sandoval (9):
sim: add command to set static service stats
sim: add UI to set resource stats for new guests
sim: allow editing static resources of resource
sim: add helper to store datacenter configuration
sim: allow configuring datacenter configuration
sim: add method to persist current state
sim: add button to persist state to header bar
sim: set default cpu count and memory on new nodes
gitignore: ignore build directory
.gitignore | 1 +
src/PVE/HA/Sim/Hardware.pm | 102 ++++++++++++++++-
src/PVE/HA/Sim/RTHardware.pm | 207 +++++++++++++++++++++++++++++++++--
3 files changed, 300 insertions(+), 10 deletions(-)
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 1/9] sim: add command to set static service stats
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 2/9] sim: add UI to set resource stats for new guests Maximiliano Sandoval
` (7 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
This will allow testing different cluster resource schedulers.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 9e8c799..4d84eeb 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -178,6 +178,25 @@ sub set_service_state {
return $conf;
}
+sub set_static_service_stats {
+ my ($self, $sid, $new_stats) = @_;
+
+ my $stats = $self->read_static_service_stats();
+ die "no such service '$sid'" if !$stats->{$sid};
+
+ if (my $memory = $new_stats->{maxmemory}) {
+ print "setting $sid memory to $memory\n" if $memory != $stats->{$sid}->{maxmemory};
+ $stats->{$sid}->{maxmemory} = $memory;
+ }
+
+ if (my $cpu = $new_stats->{maxcpu}) {
+ print "setting $sid memory to $cpu\n" if $cpu != $stats->{$sid}->{maxcpu};
+ $stats->{$sid}->{maxcpu} = $cpu;
+ }
+
+ $self->write_static_service_stats($stats);
+}
+
sub add_service {
my ($self, $sid, $opts, $running) = @_;
@@ -397,6 +416,14 @@ sub read_static_service_stats {
return $stats;
}
+sub write_static_service_stats {
+ my ($self, $stats) = @_;
+
+ my $filename = "$self->{statusdir}/static_service_stats";
+ eval { PVE::HA::Tools::write_json_to_file($filename, $stats) };
+ $self->log('error', "writing static service stats failed - $@") if $@;
+}
+
sub new {
my ($this, $testdir) = @_;
@@ -611,6 +638,7 @@ sub get_cfs_state {
# service <sid> stop <timeout>
# service <sid> lock/unlock [lockname]
# service <sid> add <node> [<request-state=started>] [<running=0>]
+# service <sid> set-static-stats <maxcpu> <maxmemory>
# service <sid> delete
sub sim_hardware_cmd {
my ($self, $cmdstr, $logid) = @_;
@@ -760,6 +788,15 @@ sub sim_hardware_cmd {
$params[2] || 0,
);
+ } elsif ($action eq 'set-static-stats') {
+ die "sim_hardware_cmd: missing maxcpu for '$action' command" if !$params[0];
+ die "sim_hardware_cmd: missing maxmemory for '$action' command" if !$params[1];
+
+ $self->set_static_service_stats(
+ $sid,
+ { maxcpu => $params[0], maxmemory => $params[1] },
+ );
+
} elsif ($action eq 'delete') {
$self->delete_service($sid);
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 2/9] sim: add UI to set resource stats for new guests
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 1/9] sim: add command to set static service stats Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource Maximiliano Sandoval
` (6 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Adds a dialog which allow setting the maxmemory and maxcpu of an
existing HA service.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/RTHardware.pm | 43 +++++++++++++++++++++++++++++++++++-
1 file changed, 42 insertions(+), 1 deletion(-)
diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 0dfe0b2..28c756e 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -24,6 +24,9 @@ use PVE::HA::LRM;
use PVE::HA::Sim::RTEnv;
use base qw(PVE::HA::Sim::Hardware);
+my $DEFAULT_MAXMEM = 4096;
+my $DEFAULT_MAXCPU = 4;
+
sub new {
my ($this, $testdir) = @_;
@@ -434,8 +437,41 @@ sub show_service_add_dialog {
$node_cb->set_active(0);
$grid->attach($node_cb, 2, 1, 1, 1);
+ my $cpu_label = Gtk3::Label->new('CPU Count');
+ $cpu_label->set_hexpand(1);
+ $cpu_label->set_xalign(0);
+
+ my $cpu_count_spin = Gtk3::SpinButton->new_with_range(1.0, 1024, 1.0);
+ $cpu_count_spin->set_value($DEFAULT_MAXCPU);
+
+ my $cpu_box = Gtk3::Box->new('horizontal', 6);
+ $cpu_box->add($cpu_label);
+ $cpu_box->add($cpu_count_spin);
+
+ my $memory_label = Gtk3::Label->new('Memory (MiB)');
+ $memory_label->set_hexpand(1);
+ $memory_label->set_xalign(0);
+
+ # There is an arbitrary limit of 10 TiB
+ my $memory_spin = Gtk3::SpinButton->new_with_range(1.0, 10485760.0, 1.0);
+ $memory_spin->set_value($DEFAULT_MAXMEM);
+
+ my $memory_box = Gtk3::Box->new('horizontal', 6);
+ $memory_box->add($memory_label);
+ $memory_box->add($memory_spin);
+
+ my $vbox = Gtk3::Box->new('vertical', 6);
+ $vbox->set_margin_start(6);
+ $vbox->set_margin_end(6);
+ $vbox->set_margin_top(6);
+ $vbox->set_margin_bottom(6);
+ $vbox->add($grid);
+ $vbox->add($cpu_box);
+ $vbox->add($memory_box);
+ $vbox->show_all();
+
my $contarea = $dialog->get_content_area();
- $contarea->add($grid);
+ $contarea->add($vbox);
$dialog->show_all();
my $res = $dialog->run();
@@ -443,6 +479,11 @@ sub show_service_add_dialog {
if (defined($res) && $res eq 'ok') {
my $sid = "$service_type:$service_id";
$self->sim_hardware_cmd("service $sid add $service_node", 'command');
+
+ my $maxcpu = $cpu_count_spin->get_value();
+ my $maxmemory = $memory_spin->get_value();
+ $self->sim_hardware_cmd("service $sid set-static-stats $maxcpu $maxmemory", 'command');
+
$self->add_service_to_gui($sid);
}
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 1/9] sim: add command to set static service stats Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 2/9] sim: add UI to set resource stats for new guests Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 10:00 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 4/9] sim: add helper to store datacenter configuration Maximiliano Sandoval
` (5 subsequent siblings)
8 siblings, 1 reply; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/RTHardware.pm | 82 +++++++++++++++++++++++++++++++++++-
1 file changed, 80 insertions(+), 2 deletions(-)
diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 28c756e..e46cb91 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -490,6 +490,75 @@ sub show_service_add_dialog {
$dialog->destroy();
}
+sub show_service_edit_dialog {
+ my ($self, $sid) = @_;
+
+ my $stats = $self->read_static_service_stats();
+ my $resource_stats = $stats->{$sid}
+ // { maxcpu => $DEFAULT_MAXCPU, maxmemory => $DEFAULT_MAXMEM };
+
+ my $cpu_label = Gtk3::Label->new('CPU Count');
+ $cpu_label->set_hexpand(1);
+ $cpu_label->set_xalign(0);
+
+ my $cpu_count_spin = Gtk3::SpinButton->new_with_range(1.0, 1024, 1.0);
+ $cpu_count_spin->set_value($resource_stats->{maxcpu});
+
+ my $cpu_box = Gtk3::Box->new('horizontal', 6);
+ $cpu_box->add($cpu_label);
+ $cpu_box->add($cpu_count_spin);
+
+ my $memory_label = Gtk3::Label->new('Memory (MiB)');
+ $memory_label->set_hexpand(1);
+ $memory_label->set_xalign(0);
+
+ # There is an arbitrary limit of 10 TiB
+ my $memory_spin = Gtk3::SpinButton->new_with_range(1.0, 10485760.0, 1.0);
+ $memory_spin->set_value($resource_stats->{maxmemory});
+
+ my $memory_box = Gtk3::Box->new('horizontal', 6);
+ $memory_box->add($memory_label);
+ $memory_box->add($memory_spin);
+
+ my $vbox = Gtk3::Box->new('vertical', 6);
+ $vbox->add($cpu_box);
+ $vbox->add($memory_box);
+
+ my $dialog = Gtk3::Dialog->new();
+
+ $dialog->set_title("Migrate $sid");
+ $dialog->set_modal(1);
+ $dialog->set_transient_for($self->{main_window});
+
+ $dialog->add_button("_OK", 'ok');
+
+ my $content_area = $dialog->get_content_area();
+ $content_area->add($vbox);
+ $vbox->set_margin_start(12);
+ $vbox->set_margin_end(12);
+ $vbox->set_margin_top(12);
+ $vbox->set_margin_bottom(12);
+
+ $dialog->show_all();
+
+ $dialog->signal_connect(
+ 'response' => sub {
+ my ($dialog, $response) = @_;
+
+ if ($response eq 'ok') {
+ $self->set_static_service_stats(
+ $sid,
+ {
+ maxcpu => $cpu_count_spin->get_value(),
+ maxmemory => $memory_spin->get_value(),
+ },
+ );
+ }
+ $dialog->close();
+ },
+ );
+}
+
sub show_service_delete_dialog {
my ($self, $sid) = @_;
@@ -659,8 +728,17 @@ sub new_service_gui_entry {
$sgrid->attach($w, 4, $row, 1, 1);
$self->{service_gui}->{$sid}->{status_label} = $w;
+ my $edit_button = Gtk3::Button->new_from_icon_name('document-edit', 1);
+ $edit_button->set_tooltip_text('Edit static resources');
+ $sgrid->attach($edit_button, 5, $row, 1, 1);
+ $edit_button->signal_connect(
+ clicked => sub {
+ $self->show_service_edit_dialog($sid);
+ },
+ );
+
$w = Gtk3::Button->new_from_icon_name('edit-delete', 1);
- $sgrid->attach($w, 5, $row, 1, 1);
+ $sgrid->attach($w, 6, $row, 1, 1);
$w->signal_connect(
clicked => sub {
$self->show_service_delete_dialog($sid);
@@ -699,7 +777,7 @@ sub create_service_control {
}
$w = Gtk3::Button->new_from_icon_name('list-add', 1);
- $sgrid->attach($w, 5, $row, 1, 1);
+ $sgrid->attach($w, 6, $row, 1, 1);
$w->signal_connect(
clicked => sub {
$self->show_service_add_dialog();
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 4/9] sim: add helper to store datacenter configuration
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
` (2 preceding siblings ...)
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 5/9] sim: allow configuring " Maximiliano Sandoval
` (4 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 4d84eeb..a0ce563 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -538,6 +538,13 @@ sub read_datacenter_conf {
return PVE::HA::Tools::read_json_from_file($filename, {});
}
+sub write_datacenter_conf {
+ my ($self, $conf) = @_;
+
+ my $filename = "$self->{statusdir}/datacenter.cfg";
+ PVE::HA::Tools::write_json_to_file($filename, $conf);
+}
+
sub global_lock {
my ($self, $code, @param) = @_;
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 5/9] sim: allow configuring datacenter configuration
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
` (3 preceding siblings ...)
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 4/9] sim: add helper to store datacenter configuration Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 6/9] sim: add method to persist current state Maximiliano Sandoval
` (3 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/RTHardware.pm | 60 +++++++++++++++++++++++++++++++++++-
1 file changed, 59 insertions(+), 1 deletion(-)
diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index e46cb91..5b7c765 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -290,6 +290,56 @@ sub set_network_state {
$self->sim_hardware_cmd("network $node $action");
}
+sub create_datacenter_control {
+ my ($self) = @_;
+
+ my $active = 0;
+ my $initial_conf = $self->read_datacenter_conf();
+ if (my $crs = $initial_conf->{crs}) {
+ if (my $ha = $crs->{ha}) {
+ $active = 1 if $ha eq 'static';
+ }
+ }
+
+ my $crs_types = ['basic', 'static'];
+
+ my $label = Gtk3::Label->new('Cluster Resource Scheduler');
+ $label->set_hexpand(1);
+ $label->set_xalign(0.0);
+
+ my $crs_combo = Gtk3::ComboBoxText->new();
+ $crs_combo->set_valign('center');
+ foreach my $type (@$crs_types) {
+ $crs_combo->append_text($type);
+ }
+ $crs_combo->set_active($active);
+ $crs_combo->signal_connect(
+ 'notify::active' => sub {
+ my $combo = shift;
+
+ my $active = $combo->get_active();
+ return if $active < 0;
+
+ my $ha_type = $crs_types->[$active];
+
+ my $conf = $self->read_datacenter_conf();
+ $conf->{crs}->{ha} = $ha_type;
+ $self->write_datacenter_conf($conf);
+ },
+ );
+
+ my $hbox = Gtk3::Box->new('horizontal', 0);
+ $hbox->set_margin_start(6);
+ $hbox->set_margin_end(6);
+ $hbox->set_margin_top(6);
+ $hbox->set_margin_bottom(6);
+ $hbox->add($label);
+ $hbox->add($crs_combo);
+ $hbox->show_all();
+
+ return $hbox;
+}
+
sub create_node_control {
my ($self) = @_;
@@ -854,10 +904,18 @@ sub create_main_window {
my $vbox = Gtk3::VBox->new(0, 0);
$grid->attach($vbox, 1, 0, 1, 1);
+ my $datacenter_control = $self->create_datacenter_control();
+ $vbox->pack_start($datacenter_control, 0, 0, 0);
+
+ my $sep = Gtk3::Separator->new('horizontal');
+ $sep->set('margin-top', 10);
+ $sep->set_vexpand(0);
+ $vbox->pack_start($sep, 0, 0, 0);
+
my $ngrid = $self->create_node_control();
$vbox->pack_start($ngrid, 0, 0, 0);
- my $sep = Gtk3::HSeparator->new;
+ $sep = Gtk3::Separator->new('horizontal');
$sep->set('margin-top', 10);
$vbox->pack_start($sep, 0, 0, 0);
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 6/9] sim: add method to persist current state
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
` (4 preceding siblings ...)
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 5/9] sim: allow configuring " Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 7/9] sim: add button to persist state to header bar Maximiliano Sandoval
` (2 subsequent siblings)
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
This method is essentially `new()` but in reverse.
This allows us to save the current state in the simulator and start from
it instead of using the default state.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 52 ++++++++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index a0ce563..0747dde 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -507,6 +507,58 @@ sub new {
return $self;
}
+sub save_state {
+ my ($self, $testdir) = @_;
+
+ die "missing testdir" if !$testdir;
+
+ die "testdir '$testdir' does not exist or is not a directory!\n"
+ if !-d $testdir;
+
+ my $statusdir = $self->{statusdir};
+ my $cstatus = $self->read_hardware_status_nolock();
+
+ foreach my $node (sort keys %$cstatus) {
+ if (-f "$statusdir/service_status_$node") {
+ copy("$statusdir/service_status_$node", "$testdir/service_status_$node");
+ }
+ }
+
+ if (-f "$statusdir/static_service_stats") {
+ copy("$statusdir/static_service_stats", "$testdir/static_service_stats");
+ }
+
+ if (-f "$statusdir/datacenter.cfg") {
+ copy("$statusdir/datacenter.cfg", "$testdir/datacenter.cfg");
+ }
+
+ if (-f "$statusdir/fence.cfg") {
+ copy("$statusdir/fence.cfg", "$testdir/fence.cfg");
+ }
+
+ if (-f "$statusdir/hardware_status") {
+ copy("$statusdir/hardware_status", "$testdir/hardware_status");
+ }
+
+ if (-f "$statusdir/service_config") {
+ copy("$statusdir/service_config", "$testdir/service_config");
+ }
+
+ if (-f "$statusdir/groups") {
+ copy("$statusdir/groups", "$testdir/groups");
+ }
+
+ if (-f "$statusdir/rules_config") {
+ copy("$statusdir/rules_config", "$testdir/rules_config");
+ }
+
+ if (-f "$statusdir/manager_status") {
+ copy("$statusdir/manager_status", "$testdir/manager_status");
+ }
+
+ print "current state saved\n";
+}
+
sub get_time {
my ($self) = @_;
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 7/9] sim: add button to persist state to header bar
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
` (5 preceding siblings ...)
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 6/9] sim: add method to persist current state Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 8/9] sim: set default cpu count and memory on new nodes Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 9/9] gitignore: ignore build directory Maximiliano Sandoval
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/RTHardware.pm | 22 +++++++++++++++++++---
1 file changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index 5b7c765..a9bba4b 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -48,7 +48,7 @@ sub new {
$d->{lrm_env} = PVE::HA::Env->new('PVE::HA::Sim::RTEnv', $node, $self, 'lrm');
}
- $self->create_main_window();
+ $self->create_main_window($testdir);
return $self;
}
@@ -886,10 +886,26 @@ sub create_log_view {
}
sub create_main_window {
- my ($self) = @_;
+ my ($self, $testdir) = @_;
+
+ my $title = 'Proxmox HA Simulator';
my $window = Gtk3::Window->new();
- $window->set_title("Proxmox HA Simulator");
+ $window->set_title($title);
+
+ my $save_button = Gtk3::Button->new('Save');
+ $save_button->signal_connect(
+ clicked => sub {
+ $self->save_state($testdir);
+ },
+ );
+
+ my $header_bar = Gtk3::HeaderBar->new();
+ $header_bar->pack_end($save_button);
+ $header_bar->set_title($title);
+ $header_bar->set_show_close_button(1);
+
+ $window->set_titlebar($header_bar);
$window->signal_connect(destroy => sub { Gtk3::main_quit(); });
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 8/9] sim: set default cpu count and memory on new nodes
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
` (6 preceding siblings ...)
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 7/9] sim: add button to persist state to header bar Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 9/9] gitignore: ignore build directory Maximiliano Sandoval
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Otherwise when switching to the static crs a warning would be thrown.
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
src/PVE/HA/Sim/Hardware.pm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/PVE/HA/Sim/Hardware.pm b/src/PVE/HA/Sim/Hardware.pm
index 0747dde..2b63f5a 100644
--- a/src/PVE/HA/Sim/Hardware.pm
+++ b/src/PVE/HA/Sim/Hardware.pm
@@ -471,9 +471,9 @@ sub new {
|| die "Copy failed: $!\n";
} else {
my $cstatus = {
- node1 => { power => 'off', network => 'off' },
- node2 => { power => 'off', network => 'off' },
- node3 => { power => 'off', network => 'off' },
+ node1 => { power => 'off', network => 'off', cpus => 24, memory => 131072 },
+ node2 => { power => 'off', network => 'off', cpus => 24, memory => 131072 },
+ node3 => { power => 'off', network => 'off', cpus => 24, memory => 131072 },
};
$self->write_hardware_status_nolock($cstatus);
}
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* [pve-devel] [PATCH ha-manager 9/9] gitignore: ignore build directory
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
` (7 preceding siblings ...)
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 8/9] sim: set default cpu count and memory on new nodes Maximiliano Sandoval
@ 2025-10-14 9:47 ` Maximiliano Sandoval
8 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 9:47 UTC (permalink / raw)
To: pve-devel
Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
---
.gitignore | 1 +
1 file changed, 1 insertion(+)
diff --git a/.gitignore b/.gitignore
index 35de63f..0a6dc7e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,3 +7,4 @@
/src/test/fence_cfgs/*.cfg.commands
/src/test/fence_cfgs/*.cfg.write
/src/test/rules_cfgs/*.cfg.output
+/pve-ha-manager-[0-9]*/
--
2.47.3
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource Maximiliano Sandoval
@ 2025-10-14 10:00 ` Maximiliano Sandoval
0 siblings, 0 replies; 11+ messages in thread
From: Maximiliano Sandoval @ 2025-10-14 10:00 UTC (permalink / raw)
To: pve-devel
Maximiliano Sandoval <m.sandoval@proxmox.com> writes:
> Signed-off-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
> ---
> src/PVE/HA/Sim/RTHardware.pm | 82 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 80 insertions(+), 2 deletions(-)
>
> diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
> index 28c756e..e46cb91 100644
> --- a/src/PVE/HA/Sim/RTHardware.pm
> +++ b/src/PVE/HA/Sim/RTHardware.pm
> @@ -490,6 +490,75 @@ sub show_service_add_dialog {
> $dialog->destroy();
> }
>
> +sub show_service_edit_dialog {
> + my ($self, $sid) = @_;
> +
> + my $stats = $self->read_static_service_stats();
> + my $resource_stats = $stats->{$sid}
> + // { maxcpu => $DEFAULT_MAXCPU, maxmemory => $DEFAULT_MAXMEM };
> +
> + my $cpu_label = Gtk3::Label->new('CPU Count');
> + $cpu_label->set_hexpand(1);
> + $cpu_label->set_xalign(0);
> +
> + my $cpu_count_spin = Gtk3::SpinButton->new_with_range(1.0, 1024, 1.0);
> + $cpu_count_spin->set_value($resource_stats->{maxcpu});
> +
> + my $cpu_box = Gtk3::Box->new('horizontal', 6);
> + $cpu_box->add($cpu_label);
> + $cpu_box->add($cpu_count_spin);
> +
> + my $memory_label = Gtk3::Label->new('Memory (MiB)');
> + $memory_label->set_hexpand(1);
> + $memory_label->set_xalign(0);
> +
> + # There is an arbitrary limit of 10 TiB
> + my $memory_spin = Gtk3::SpinButton->new_with_range(1.0, 10485760.0, 1.0);
> + $memory_spin->set_value($resource_stats->{maxmemory});
> +
> + my $memory_box = Gtk3::Box->new('horizontal', 6);
> + $memory_box->add($memory_label);
> + $memory_box->add($memory_spin);
> +
> + my $vbox = Gtk3::Box->new('vertical', 6);
> + $vbox->add($cpu_box);
> + $vbox->add($memory_box);
> +
> + my $dialog = Gtk3::Dialog->new();
> +
> + $dialog->set_title("Migrate $sid");
This should be Edit instead.
> + $dialog->set_modal(1);
> + $dialog->set_transient_for($self->{main_window});
> +
> + $dialog->add_button("_OK", 'ok');
> +
> + my $content_area = $dialog->get_content_area();
> + $content_area->add($vbox);
> + $vbox->set_margin_start(12);
> + $vbox->set_margin_end(12);
> + $vbox->set_margin_top(12);
> + $vbox->set_margin_bottom(12);
> +
> + $dialog->show_all();
> +
> + $dialog->signal_connect(
> + 'response' => sub {
> + my ($dialog, $response) = @_;
> +
> + if ($response eq 'ok') {
> + $self->set_static_service_stats(
> + $sid,
> + {
> + maxcpu => $cpu_count_spin->get_value(),
> + maxmemory => $memory_spin->get_value(),
> + },
> + );
> + }
> + $dialog->close();
> + },
> + );
> +}
> +
> sub show_service_delete_dialog {
> my ($self, $sid) = @_;
>
> @@ -659,8 +728,17 @@ sub new_service_gui_entry {
> $sgrid->attach($w, 4, $row, 1, 1);
> $self->{service_gui}->{$sid}->{status_label} = $w;
>
> + my $edit_button = Gtk3::Button->new_from_icon_name('document-edit', 1);
> + $edit_button->set_tooltip_text('Edit static resources');
> + $sgrid->attach($edit_button, 5, $row, 1, 1);
> + $edit_button->signal_connect(
> + clicked => sub {
> + $self->show_service_edit_dialog($sid);
> + },
> + );
> +
> $w = Gtk3::Button->new_from_icon_name('edit-delete', 1);
> - $sgrid->attach($w, 5, $row, 1, 1);
> + $sgrid->attach($w, 6, $row, 1, 1);
> $w->signal_connect(
> clicked => sub {
> $self->show_service_delete_dialog($sid);
> @@ -699,7 +777,7 @@ sub create_service_control {
> }
>
> $w = Gtk3::Button->new_from_icon_name('list-add', 1);
> - $sgrid->attach($w, 5, $row, 1, 1);
> + $sgrid->attach($w, 6, $row, 1, 1);
> $w->signal_connect(
> clicked => sub {
> $self->show_service_add_dialog();
--
Maximiliano
_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2025-10-14 10:00 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-10-14 9:47 [pve-devel] [PATCH ha-manager 0/9] allow setting crs and service static resources Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 1/9] sim: add command to set static service stats Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 2/9] sim: add UI to set resource stats for new guests Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 3/9] sim: allow editing static resources of resource Maximiliano Sandoval
2025-10-14 10:00 ` Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 4/9] sim: add helper to store datacenter configuration Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 5/9] sim: allow configuring " Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 6/9] sim: add method to persist current state Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 7/9] sim: add button to persist state to header bar Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 8/9] sim: set default cpu count and memory on new nodes Maximiliano Sandoval
2025-10-14 9:47 ` [pve-devel] [PATCH ha-manager 9/9] gitignore: ignore build directory Maximiliano Sandoval
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.