Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ServiceActions: Unescape daemon names #279

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/main/perl/ServiceActions.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use parent qw(CAF::Object Exporter);
use CAF::Service;
use CAF::Object qw(SUCCESS);
use EDG::WP4::CCM::Path qw(unescape);

use Readonly;

Expand Down Expand Up @@ -113,8 +114,9 @@ sub add
$msg = " $msg" if $msg;

my @acts;
foreach my $daemon (sort keys %{$pairs || {}}) {
my $action = $pairs->{$daemon};
foreach my $escdaemon (sort keys %{$pairs || {}}) {
my $daemon = unescape($escdaemon);
my $action = $pairs->{$escdaemon};
if (grep {$_ eq $action} @SERVICE_ACTIONS) {
$self->{actions}->{$action} ||= {};
$self->{actions}->{$action}->{$daemon} = 1;
Expand Down
5 changes: 5 additions & 0 deletions src/test/perl/serviceactions.t
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,9 @@ ok(command_history_ok(["systemctl reload daemon2.service"], ['daemon1']),
"run runs expected commands wrong (no daemon1)");


my $sa4 = CAF::ServiceActions->new(log => $obj);
$sa4->add({daemon_40instance_2eservice => 'restart'});
is_deeply($sa4->{actions}, {restart => {'[email protected]' => 1}}, "add correctly unescapes instanced name");


done_testing;