]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
treewide trailing whitespace cleanup
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 14 Mar 2019 12:18:03 +0000 (13:18 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 14 Mar 2019 12:18:06 +0000 (13:18 +0100)
generated by: find . -name '*.pm' -exec sed -i 's/\s*$//g' {} \;

As I touched almost any file here anyway I'm not scared to appear in
git blame ;-) also it has support to suppress whitespace changes.

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
17 files changed:
src/PVE/API2/HA/Groups.pm
src/PVE/API2/HA/Resources.pm
src/PVE/API2/HA/Status.pm
src/PVE/HA/CRM.pm
src/PVE/HA/Config.pm
src/PVE/HA/Env.pm
src/PVE/HA/Groups.pm
src/PVE/HA/LRM.pm
src/PVE/HA/Manager.pm
src/PVE/HA/NodeStatus.pm
src/PVE/HA/Resources.pm
src/PVE/HA/Sim/Hardware.pm
src/PVE/HA/Sim/RTEnv.pm
src/PVE/HA/Sim/RTHardware.pm
src/PVE/HA/Sim/TestEnv.pm
src/PVE/HA/Sim/TestHardware.pm
src/PVE/HA/Tools.pm

index 820e89365ece8373eed6d7482c7c9dae8a407294..f08ab014cd4776424c88b84ffeb5132a7c989171 100644 (file)
@@ -21,7 +21,7 @@ my $api_copy_config = sub {
     my ($cfg, $group) = @_;
 
     die "no such ha group '$group'\n" if !$cfg->{ids}->{$group};
-    
+
     my $group_cfg = dclone($cfg->{ids}->{$group});
     $group_cfg->{group} = $group;
     $group_cfg->{digest} = $cfg->{digest};
@@ -33,7 +33,7 @@ my $api_copy_config = sub {
 };
 
 __PACKAGE__->register_method ({
-    name => 'index', 
+    name => 'index',
     path => '',
     method => 'GET',
     description => "Get HA groups.",
@@ -109,10 +109,10 @@ __PACKAGE__->register_method ({
        # create /etc/pve/ha directory
        PVE::Cluster::check_cfs_quorum();
        mkdir("/etc/pve/ha");
-       
+
        my $group = extract_param($param, 'group');
        my $type = 'group';
-       
+
        if (my $param_type = extract_param($param, 'type')) {
            # useless, but do it anyway
            die "types does not match\n" if $param_type ne $type;
@@ -230,7 +230,7 @@ __PACKAGE__->register_method ({
                my $rcfg = PVE::HA::Config::read_resources_config();
                foreach my $sid (keys %{$rcfg->{ids}}) {
                    my $sg = $rcfg->{ids}->{$sid}->{group};
-                   die "ha group is used by service '$sid'\n" 
+                   die "ha group is used by service '$sid'\n"
                        if ($sg && $sg eq $group);
                }
 
index 8be655903afc1b41fae282507352dface73acdcf..1ffdf2ef488f75833b140a71285275152105489a 100644 (file)
@@ -171,7 +171,7 @@ __PACKAGE__->register_method ({
        # create /etc/pve/ha directory
        PVE::Cluster::check_cfs_quorum();
        mkdir("/etc/pve/ha");
-       
+
        my ($sid, $type, $name) = PVE::HA::Config::parse_sid(extract_param($param, 'sid'));
 
        if (my $param_type = extract_param($param, 'type')) {
@@ -346,7 +346,7 @@ __PACKAGE__->register_method ({
        check_service_state($sid);
 
        PVE::HA::Config::queue_crm_commands("migrate $sid $param->{node}");
-           
+
        return undef;
     }});
 
@@ -381,7 +381,7 @@ __PACKAGE__->register_method ({
        check_service_state($sid);
 
        PVE::HA::Config::queue_crm_commands("relocate $sid $param->{node}");
-           
+
        return undef;
     }});
 
index d21c174db92696a04eb377801edd2229aca20b0d..ff37fc0664828d12de852c358bc6a69136a3f73c 100644 (file)
@@ -30,8 +30,8 @@ my $timestamp_to_status = sub {
 };
 
 __PACKAGE__->register_method ({
-    name => 'index', 
-    path => '', 
+    name => 'index',
+    path => '',
     method => 'GET',
     permissions => { user => 'all' },
     description => "Directory index.",
@@ -49,7 +49,7 @@ __PACKAGE__->register_method ({
     },
     code => sub {
        my ($param) = @_;
-    
+
        my $result = [
            { name => 'current' },
            { name => 'manager_status' },
@@ -59,7 +59,7 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'status', 
+    name => 'status',
     path => 'current',
     method => 'GET',
     description => "Get HA manger status.",
@@ -116,13 +116,13 @@ __PACKAGE__->register_method ({
            next if $req_state eq 'freeze';
            $active_count->{$sd->{node}}++;
        }
-       
+
        foreach my $node (sort keys %{$status->{node_status}}) {
            my $lrm_status = PVE::HA::Config::read_lrm_status($node);
            my $id = "lrm:$node";
            if (!$lrm_status->{timestamp}) {
-               push @$res, { id => $id, type => 'lrm',  node => $node, 
-                             status => "$node (unable to read lrm status)"}; 
+               push @$res, { id => $id, type => 'lrm',  node => $node,
+                             status => "$node (unable to read lrm status)"};
            } else {
                my $status_str = &$timestamp_to_status($ctime, $lrm_status->{timestamp});
                if ($status_str eq 'active') {
@@ -141,8 +141,8 @@ __PACKAGE__->register_method ({
 
                my $time_str = localtime($lrm_status->{timestamp});
                my $status_text = "$node ($status_str, $time_str)";
-               push @$res, { id => $id, type => 'lrm',  node => $node, 
-                             status => $status_text, timestamp => $lrm_status->{timestamp} }; 
+               push @$res, { id => $id, type => 'lrm',  node => $node,
+                             status => $status_text, timestamp => $lrm_status->{timestamp} };
            }
        }
 
@@ -189,7 +189,7 @@ __PACKAGE__->register_method ({
     }});
 
 __PACKAGE__->register_method ({
-    name => 'manager_status', 
+    name => 'manager_status',
     path => 'manager_status',
     method => 'GET',
     description => "Get full HA manger status, including LRM status.",
@@ -205,14 +205,14 @@ __PACKAGE__->register_method ({
        my ($param) = @_;
 
        my $status = PVE::HA::Config::read_manager_status();
-       
+
        my $data = { manager_status => $status };
 
        $data->{quorum} = {
            node => $nodename,
            quorate => PVE::Cluster::check_cfs_quorum(1),
        };
-       
+
        foreach my $node (sort keys %{$status->{node_status}}) {
            my $lrm_status = PVE::HA::Config::read_lrm_status($node);
            $data->{lrm_status}->{$node} = $lrm_status;
index a6557d354deb78e15b56d70f2de17ebec111253e..3c8ced53466d26029dee213812581121aa2be218 100644 (file)
@@ -32,7 +32,7 @@ sub new {
     }, $class;
 
     $self->set_local_status({ state => 'wait_for_quorum' });
-    
+
     return $self;
 }
 
@@ -60,7 +60,7 @@ sub set_local_status {
 
     my $old = $self->{status};
 
-    # important: only update if if really changed 
+    # important: only update if if really changed
     return if $old->{state} eq $new->{state};
 
     $haenv->log('info', "status change $old->{state} => $new->{state}");
@@ -90,7 +90,7 @@ sub get_protected_ha_manager_lock {
     my $starttime = $haenv->get_time();
 
     for (;;) {
-       
+
        if ($haenv->get_ha_manager_lock()) {
            if ($self->{ha_manager_wd}) {
                $haenv->watchdog_update($self->{ha_manager_wd});
@@ -100,7 +100,7 @@ sub get_protected_ha_manager_lock {
            }
            return 1;
        }
-           
+
        last if ++$count > 5; # try max 5 time
 
        my $delay = $haenv->get_time() - $starttime;
@@ -108,7 +108,7 @@ sub get_protected_ha_manager_lock {
 
        $haenv->sleep(1);
     }
-    
+
     return 0;
 }
 
@@ -167,7 +167,7 @@ sub work {
     my $status = $self->get_local_status();
     my $state = $status->{state};
 
-    # do state changes first 
+    # do state changes first
 
     if ($state eq 'wait_for_quorum') {
 
@@ -203,7 +203,7 @@ sub work {
            $self->set_local_status({ state => 'lost_manager_lock'});
        }
     }
-   
+
     $status = $self->get_local_status();
     $state = $status->{state};
 
@@ -214,7 +214,7 @@ sub work {
        return 0 if $self->{shutdown_request};
 
        $haenv->sleep(5);
-          
+
     } elsif ($state eq 'master') {
 
        my $manager = $self->{manager};
@@ -269,7 +269,7 @@ sub work {
        $haenv->sleep_until($startime + $max_time);
 
     } elsif ($state eq 'lost_manager_lock') {
-       
+
        if ($self->{ha_manager_wd}) {
            $haenv->watchdog_close($self->{ha_manager_wd});
            delete $self->{ha_manager_wd};
index 611ac49599c5780443c000938ec3fd1831635133..98a9a32bb89dfff097910740f48ba41e592a502e 100644 (file)
@@ -15,17 +15,17 @@ my $ha_resources_config = "ha/resources.cfg";
 my $crm_commands_filename = "ha/crm_commands";
 my $ha_fence_config = "ha/fence.cfg";
 
-cfs_register_file($crm_commands_filename, 
+cfs_register_file($crm_commands_filename,
                  sub { my ($fn, $raw) = @_; return defined($raw) ? $raw : ''; },
                  sub { my ($fn, $raw) = @_; return $raw; });
-cfs_register_file($ha_groups_config, 
+cfs_register_file($ha_groups_config,
                  sub { PVE::HA::Groups->parse_config(@_); },
                  sub { PVE::HA::Groups->write_config(@_); });
-cfs_register_file($ha_resources_config, 
+cfs_register_file($ha_resources_config,
                  sub { PVE::HA::Resources->parse_config(@_); },
                  sub { PVE::HA::Resources->write_config(@_); });
-cfs_register_file($manager_status_filename, 
-                 \&json_reader, 
+cfs_register_file($manager_status_filename,
+                 \&json_reader,
                  \&json_writer);
 cfs_register_file($ha_fence_config,
                  \&PVE::HA::FenceConfig::parse_config,
@@ -64,7 +64,7 @@ sub write_lrm_status {
 
     my $filename = "/etc/pve/nodes/$node/lrm_status";
 
-    PVE::HA::Tools::write_json_to_file($filename, $status_obj); 
+    PVE::HA::Tools::write_json_to_file($filename, $status_obj);
 }
 
 sub parse_groups_config {
@@ -75,7 +75,7 @@ sub parse_groups_config {
 
 sub parse_resources_config {
     my ($filename, $raw) = @_;
-    
+
     return PVE::HA::Resources->parse_config($filename, $raw);
 }
 
index a173deba47f57de3fb7e9f7721b8fe6311e81094..bb37486f46dbf6c8182758754df751b0220edc81 100644 (file)
@@ -211,7 +211,7 @@ sub loop_start_hook {
 
 sub loop_end_hook {
     my ($self, @args) = @_;
-    
+
     return $self->{plug}->loop_end_hook(@args);
 }
 
index 40666f6ec50900cf0b54ff974ae24efa7556467d..9bf3bd5f5c99d867382caeae8c8cc73209c9aa7c 100644 (file)
@@ -21,19 +21,19 @@ my $defaultData = {
        restricted => {
            description => "Resources bound to restricted groups may only run on nodes defined by the group.",
            verbose_description => "Resources bound to restricted groups may only run on nodes defined by the group. The resource will be placed in the stopped state if no group node member is online. Resources on unrestricted groups may run on any cluster node if all group members are offline, but they will migrate back as soon as a group member comes online. One can implement a 'preferred node' behavior using an unrestricted group with only one member.",
-           type => 'boolean', 
+           type => 'boolean',
            optional => 1,
            default => 0,
        },
        nofailback => {
            description => "The CRM tries to run services on the node with the highest priority. If a node with higher priority comes online, the CRM migrates the service to that node. Enabling nofailback prevents that behavior.",
-           type => 'boolean', 
+           type => 'boolean',
            optional => 1,
-           default => 0,           
+           default => 0,
        },
-       comment => { 
+       comment => {
            description => "Description.",
-           type => 'string', 
+           type => 'string',
            optional => 1,
            maxLength => 4096,
        },
@@ -77,11 +77,11 @@ sub decode_value {
 
 sub encode_value {
     my ($class, $type, $key, $value) = @_;
-    
+
     if ($key eq 'nodes') {
         return join(',', keys(%$value));
     }
-    
+
     return $value;
 }
 
index 417619b5d16852880da783f1fa34330f47c122dd..84ea0aea536900437e20e082fc41ff584ddce538 100644 (file)
@@ -37,7 +37,7 @@ sub new {
        cluster_state_update => 0,
     }, $class;
 
-    $self->set_local_status({ state =>         'wait_for_agent_lock' });   
+    $self->set_local_status({ state =>         'wait_for_agent_lock' });
 
     return $self;
 }
@@ -127,7 +127,7 @@ sub set_local_status {
 
     my $old = $self->{status};
 
-    # important: only update if if really changed 
+    # important: only update if if really changed
     return if $old->{state} eq $new->{state};
 
     $haenv->log('info', "status change $old->{state} => $new->{state}");
@@ -143,14 +143,14 @@ sub update_lrm_status {
     my $haenv = $self->{haenv};
 
     return 0 if !$haenv->quorate();
-    
-    my $lrm_status = { 
+
+    my $lrm_status = {
        state => $self->{status}->{state},
        mode => $self->{mode},
        results => $self->{results},
        timestamp => $haenv->get_time(),
     };
-    
+
     eval { $haenv->write_lrm_status($lrm_status); };
     if (my $err = $@) {
        $haenv->log('err', "unable to write lrm status file - $err");
@@ -184,7 +184,7 @@ sub get_protected_ha_agent_lock {
     my $starttime = $haenv->get_time();
 
     for (;;) {
-       
+
        if ($haenv->get_ha_agent_lock()) {
            if ($self->{ha_agent_wd}) {
                $haenv->watchdog_update($self->{ha_agent_wd});
@@ -194,7 +194,7 @@ sub get_protected_ha_agent_lock {
            }
            return 1;
        }
-           
+
        last if ++$count > 5; # try max 5 time
 
        my $delay = $haenv->get_time() - $starttime;
@@ -202,13 +202,13 @@ sub get_protected_ha_agent_lock {
 
        $haenv->sleep(1);
     }
-    
+
     return 0;
 }
 
 sub active_service_count {
     my ($self) = @_;
-    
+
     my $haenv = $self->{haenv};
 
     my $nodename = $haenv->nodename();
@@ -216,7 +216,7 @@ sub active_service_count {
     my $ss = $self->{service_status};
 
     my $count = 0;
-    
+
     foreach my $sid (keys %$ss) {
        my $sd = $ss->{$sid};
        next if !$sd->{node};
@@ -230,7 +230,7 @@ sub active_service_count {
 
        $count++;
     }
-    
+
     return $count;
 }
 
@@ -266,15 +266,15 @@ sub work {
            return $self->{shutdown_request} ? 0 : 1;
        }
     }
-    
+
     my $status = $self->get_local_status();
     my $state = $status->{state};
 
     $self->update_service_status();
 
     my $fence_request = PVE::HA::Tools::count_fenced_services($self->{service_status}, $haenv->nodename());
-    
-    # do state changes first 
+
+    # do state changes first
 
     my $ctime = $haenv->get_time();
 
@@ -287,7 +287,7 @@ sub work {
                $self->set_local_status({ state => 'active' });
            }
        }
-       
+
     } elsif ($state eq 'lost_agent_lock') {
 
        if (!$fence_request && $haenv->quorate()) {
@@ -298,9 +298,9 @@ sub work {
 
     } elsif ($state eq 'active') {
 
-       if ($fence_request) {           
+       if ($fence_request) {
            $haenv->log('err', "node need to be fenced - releasing agent_lock\n");
-           $self->set_local_status({ state => 'lost_agent_lock'});     
+           $self->set_local_status({ state => 'lost_agent_lock'});
        } elsif (!$self->get_protected_ha_agent_lock()) {
            $self->set_local_status({ state => 'lost_agent_lock'});
        }
@@ -314,11 +314,11 @@ sub work {
     if ($state eq 'wait_for_agent_lock') {
 
        return 0 if $self->{shutdown_request};
-       
+
        $self->update_lrm_status();
-       
+
        $haenv->sleep(5);
-          
+
     } elsif ($state eq 'active') {
 
        my $startime = $haenv->get_time();
@@ -389,13 +389,13 @@ sub work {
        }
 
        $self->update_lrm_status();
-       
+
        return 0 if $shutdown;
 
        $haenv->sleep_until($startime + $max_time);
 
     } elsif ($state eq 'lost_agent_lock') {
-       
+
        # Note: watchdog is active an will triger soon!
 
        # so we hope to get the lock back soon!
@@ -405,7 +405,7 @@ sub work {
            my $service_count = $self->active_service_count();
 
            if ($service_count > 0) {
-               $haenv->log('err', "get shutdown request in state 'lost_agent_lock' - " . 
+               $haenv->log('err', "get shutdown request in state 'lost_agent_lock' - " .
                            "detected $service_count running services");
 
            } else {
@@ -416,7 +416,7 @@ sub work {
                    $haenv->watchdog_close($self->{ha_agent_wd});
                    delete $self->{ha_agent_wd};
                }
-               
+
                return 0;
            }
        }
@@ -470,8 +470,8 @@ sub run_workers {
                        if (my $err = $@) {
                            $haenv->log('err', $err);
                            POSIX::_exit(-1);
-                       }  
-                       POSIX::_exit($res); 
+                       }
+                       POSIX::_exit($res);
                    } else {
                        $count++;
                        $w->{pid} = $pid;
@@ -576,7 +576,7 @@ sub check_active_workers {
            }
        }
     }
-    
+
     return $count;
 }
 
@@ -614,7 +614,7 @@ sub resource_command_finished {
     my $exit_code = -1;
 
     if ($status == -1) {
-       $haenv->log('err', "resource agent $sid finished - failed to execute");    
+       $haenv->log('err', "resource agent $sid finished - failed to execute");
     }  elsif (my $sig = ($status & 127)) {
        $haenv->log('err', "resource agent $sid finished - got signal $sig");
     } else {
index cc13ab1929a78ab77d929500bbe9e7710dd94177..a6c9b8e76bd1884c40120b2d23220e01ffebd34e 100644 (file)
@@ -43,9 +43,9 @@ sub flush_master_status {
     $ms->{node_status} = $ns->{status};
     $ms->{service_status} = $ss;
     $ms->{timestamp} = $haenv->get_time();
-    
+
     $haenv->write_manager_status($ms);
-} 
+}
 
 sub get_service_group {
     my ($groups, $online_node_usage, $service_conf) = @_;
@@ -57,7 +57,7 @@ sub get_service_group {
     }
 
     # overwrite default if service is bound to a specific group
-    $group =  $groups->{ids}->{$service_conf->{group}} if $service_conf->{group} && 
+    $group =  $groups->{ids}->{$service_conf->{group}} if $service_conf->{group} &&
        $groups->{ids}->{$service_conf->{group}};
 
     return $group;
@@ -118,7 +118,7 @@ sub select_service_node {
        }
     }
 
-    my @nodes = sort { 
+    my @nodes = sort {
        $online_node_usage->{$a} <=> $online_node_usage->{$b} || $a cmp $b
     } keys %{$pri_groups->{$top_pri}};
 
@@ -152,7 +152,7 @@ my $uid_counter = 0;
 
 sub compute_new_uuid {
     my ($state) = @_;
-    
+
     $uid_counter++;
     return md5_base64($state . $$ . time() . $uid_counter);
 }
@@ -183,7 +183,7 @@ sub recompute_online_node_usage {
        my $sd = $self->{ss}->{$sid};
        my $state = $sd->{state};
        if (defined($online_node_usage->{$sd->{node}})) {
-           if (($state eq 'started') || ($state eq 'request_stop') || 
+           if (($state eq 'started') || ($state eq 'request_stop') ||
                ($state eq 'fence') || ($state eq 'freeze') || ($state eq 'error')) {
                $online_node_usage->{$sd->{node}}++;
            } elsif (($state eq 'migrate') || ($state eq 'relocate')) {
@@ -299,7 +299,7 @@ my $recover_fenced_service = sub {
     }
 };
 
-# read LRM status for all nodes 
+# read LRM status for all nodes
 sub read_lrm_status {
     my ($self) = @_;
 
@@ -317,7 +317,7 @@ sub read_lrm_status {
        }
     }
 
-    
+
     return ($results, $modes);
 }
 
@@ -333,14 +333,14 @@ sub update_crm_commands {
        chomp $cmd;
 
        if ($cmd =~ m/^(migrate|relocate)\s+(\S+)\s+(\S+)$/) {
-           my ($task, $sid, $node) = ($1, $2, $3); 
+           my ($task, $sid, $node) = ($1, $2, $3);
            if (my $sd = $ss->{$sid}) {
                if (!$ns->node_is_online($node)) {
                    $haenv->log('err', "crm command error - node not online: $cmd");
                } else {
                    if ($node eq $sd->{node}) {
                        $haenv->log('info', "ignore crm command - service already on target node: $cmd");
-                   } else { 
+                   } else {
                        $haenv->log('info', "got crm command: $cmd");
                        $ss->{$sid}->{cmd} = [ $task, $node];
                    }
@@ -404,7 +404,7 @@ sub manage {
 
     for (;;) {
        my $repeat = 0;
-       
+
        $self->recompute_online_node_usage();
 
        foreach my $sid (sort keys %$ss) {
@@ -558,7 +558,7 @@ sub next_state_stopped {
        # this can happen if we fence a node with active migrations
        # hack: modify $sd (normally this should be considered read-only)
        $haenv->log('info', "fixup service '$sid' location ($sd->{node} => $cd->{node})");
-       $sd->{node} = $cd->{node}; 
+       $sd->{node} = $cd->{node};
     }
 
     if ($sd->{cmd}) {
@@ -576,7 +576,7 @@ sub next_state_stopped {
                return;
            }
        } else {
-           $haenv->log('err', "unknown command '$cmd' for service '$sid'"); 
+           $haenv->log('err', "unknown command '$cmd' for service '$sid'");
        }
     }
 
@@ -630,7 +630,7 @@ sub next_state_started {
        }
        return;
     }
-       
+
     if ($cd->{state} eq 'disabled' || $cd->{state} eq 'stopped') {
        &$change_service_state($self, $sid, 'request_stop');
        return;
@@ -652,7 +652,7 @@ sub next_state_started {
                    &$change_service_state($self, $sid, $cmd, node => $sd->{node}, target => $target);
                }
            } else {
-               $haenv->log('err', "unknown command '$cmd' for service '$sid'"); 
+               $haenv->log('err', "unknown command '$cmd' for service '$sid'");
            }
        } else {
 
index 7e6e317262abe6a094bcd5aae841bd94d19ca403..940d90363f7dbfc9107e71d1fb22011c5da61703 100644 (file)
@@ -32,7 +32,7 @@ my $valid_node_states = {
 sub get_node_state {
     my ($self, $node) = @_;
 
-    $self->{status}->{$node} = 'unknown' 
+    $self->{status}->{$node} = 'unknown'
        if !$self->{status}->{$node};
 
     return $self->{status}->{$node};
index 4d5544227f450bcb86dd072b2481c7654397bc49..7c373bcab0ce281cfab1ff5ee455ffa3a917c798 100644 (file)
@@ -95,7 +95,7 @@ sub format_section_header {
     my ($class, $type, $sectionId) = @_;
 
     my (undef, $name) = split(':', $sectionId, 2);
-    
+
     return "$type: $name\n";
 }
 
index 59b6591dd8ef0560e5ab762bd7e836aeab733383..8bd5cbdcc09d46eda5965df4ea7379e8708dcb5f 100644 (file)
@@ -9,7 +9,7 @@ package PVE::HA::Sim::Hardware;
 use strict;
 use warnings;
 use POSIX qw(strftime EINTR);
-use JSON; 
+use JSON;
 use IO::File;
 use Fcntl qw(:DEFAULT :flock);
 use File::Copy;
@@ -53,7 +53,7 @@ sub read_lrm_status {
 
     my $filename = "$self->{statusdir}/lrm_status_$node";
 
-    return PVE::HA::Tools::read_json_from_file($filename, {});  
+    return PVE::HA::Tools::read_json_from_file($filename, {});
 }
 
 sub write_lrm_status {
@@ -61,7 +61,7 @@ sub write_lrm_status {
 
     my $filename = "$self->{statusdir}/lrm_status_$node";
 
-    PVE::HA::Tools::write_json_to_file($filename, $status_obj); 
+    PVE::HA::Tools::write_json_to_file($filename, $status_obj);
 }
 
 sub read_hardware_status_nolock {
@@ -87,7 +87,7 @@ sub read_service_config {
     my ($self) = @_;
 
     my $filename = "$self->{statusdir}/service_config";
-    my $conf = PVE::HA::Tools::read_json_from_file($filename); 
+    my $conf = PVE::HA::Tools::read_json_from_file($filename);
 
     foreach my $sid (keys %$conf) {
        my $d = $conf->{$sid};
@@ -187,9 +187,9 @@ sub change_service_location {
 
     die "no such service '$sid'\n" if !$conf->{$sid};
 
-    die "current_node for '$sid' does not match ($current_node != $conf->{$sid}->{node})\n" 
+    die "current_node for '$sid' does not match ($current_node != $conf->{$sid}->{node})\n"
        if $current_node ne $conf->{$sid}->{node};
-    
+
     $conf->{$sid}->{node} = $new_node;
 
     $self->write_service_config($conf);
@@ -262,7 +262,7 @@ sub queue_crm_commands {
     my ($self, $cmd) = @_;
 
     my $code = sub { $self->queue_crm_commands_nolock($cmd); };
+
     $self->global_lock($code);
 
     return undef;
@@ -282,7 +282,7 @@ sub read_crm_commands {
 
        return $data;
     };
+
     return $self->global_lock($code);
 }
 
@@ -300,7 +300,7 @@ sub read_service_status {
     my ($self, $node) = @_;
 
     my $filename = "$self->{statusdir}/service_status_$node";
-    return PVE::HA::Tools::read_json_from_file($filename); 
+    return PVE::HA::Tools::read_json_from_file($filename);
 }
 
 sub write_service_status {
@@ -312,7 +312,7 @@ sub write_service_status {
     # fixme: add test if a service runs on two nodes!!!
 
     return $res;
-} 
+}
 
 my $default_group_config = <<__EOD;
 group: prefer_node1
@@ -395,7 +395,7 @@ sub new {
 
        if (-f "$testdir/service_status_$node") {
            copy("$testdir/service_status_$node", "$statusdir/service_status_$node");
-       } else {        
+       } else {
            $self->write_service_status($node, {});
        }
     }
@@ -459,11 +459,11 @@ sub global_lock {
 
     eval { $res = &$code($fh, @param) };
     my $err = $@;
-    
+
     close($fh);
 
     die $err if $err;
-    
+
     return $res;
 }
 
@@ -486,7 +486,7 @@ my $compute_node_info = sub {
     }
 
     my $quorate = ($online_count > int($node_count/2)) ? 1 : 0;
-                  
+
     if (!$quorate) {
        foreach my $node (keys %$cstatus) {
            my $d = $cstatus->{$node};
@@ -699,7 +699,7 @@ my $modify_watchog = sub {
     my $update_cmd = sub {
 
        my $filename = "$self->{statusdir}/watchdog_status";
+
        my ($res, $wdstatus);
 
        if (-f $filename) {
@@ -708,7 +708,7 @@ my $modify_watchog = sub {
        } else {
            $wdstatus = {};
        }
-       
+
        ($wdstatus, $res) = &$code($wdstatus);
 
        PVE::Tools::file_set_contents($filename, encode_json($wdstatus));
@@ -731,7 +731,7 @@ sub watchdog_reset_nolock {
        foreach my $id (keys %$wdstatus) {
            delete $wdstatus->{$id} if $wdstatus->{$id}->{node} eq $node;
        }
-       
+
        PVE::Tools::file_set_contents($filename, encode_json($wdstatus));
     }
 }
@@ -756,7 +756,7 @@ sub watchdog_check {
                delete $wdstatus->{$wfh};
            }
        }
-       
+
        return ($wdstatus, $res);
     };
 
@@ -822,7 +822,7 @@ sub watchdog_update {
        my $tdiff = $ctime - $wd->{update_time};
 
        die "watchdog expired" if $tdiff > $watchdog_timeout;
-       
+
        $wd->{update_time} = $ctime;
 
        return ($wdstatus);
index 7f13d0be2b14ce9a9e17bd7a520df265e5daeba8..7d6621ed597fa0ff1c70a53148495264748c780b 100644 (file)
@@ -3,7 +3,7 @@ package PVE::HA::Sim::RTEnv;
 use strict;
 use warnings;
 use POSIX qw(strftime EINTR);
-use JSON; 
+use JSON;
 use IO::File;
 use Fcntl qw(:DEFAULT :flock);
 
@@ -13,7 +13,7 @@ use base qw(PVE::HA::Sim::Env);
 
 sub new {
     my ($this, $nodename, $hardware, $log_id) = @_;
-    
+
     my $class = ref($this) || $this;
 
     my $self = $class->SUPER::new($nodename, $hardware, $log_id);
@@ -34,7 +34,7 @@ sub log {
 
     my $time = $self->get_time();
 
-    printf("%-5s %10s %12s: $msg\n", $level, strftime("%H:%M:%S", localtime($time)), 
+    printf("%-5s %10s %12s: $msg\n", $level, strftime("%H:%M:%S", localtime($time)),
           "$self->{nodename}/$self->{log_id}");
 }
 
@@ -66,7 +66,7 @@ sub loop_end_hook {
     my ($self) = @_;
 
     my $delay = $self->get_time() - $self->{loop_start};
+
     die "loop take too long ($delay seconds)\n" if $delay > 30;
 }
 
index ee1b55f86048af4096253fac5d2d02af4a3071e2..043ec3f54731a9395cb9626613b9fd143ed9937f 100644 (file)
@@ -65,7 +65,7 @@ sub log {
 
     $id = 'hardware' if !$id;
 
-    my $text = sprintf("%-5s %10s %12s: $msg\n", $level, 
+    my $text = sprintf("%-5s %10s %12s: $msg\n", $level,
                       strftime("%H:%M:%S", localtime($time)), $id);
 
     $self->append_text($text);
@@ -74,10 +74,10 @@ sub log {
 # fixme: duplicate code in Env?
 sub read_manager_status {
     my ($self) = @_;
-    
+
     my $filename = "$self->{statusdir}/manager_status";
 
-    return PVE::HA::Tools::read_json_from_file($filename, {});  
+    return PVE::HA::Tools::read_json_from_file($filename, {});
 }
 
 sub fork_daemon {
@@ -88,10 +88,10 @@ sub fork_daemon {
     my $pid = fork();
     die "fork failed" if ! defined($pid);
 
-    if ($pid == 0) { 
+    if ($pid == 0) {
 
        close($lockfh) if defined($lockfh); # unlock global lock
-       
+
        POSIX::close($psync[0]);
 
        my $outfh = $psync[1];
@@ -100,7 +100,7 @@ sub fork_daemon {
        close STDIN;
        POSIX::close(0) if $fd != 0;
 
-       die "unable to redirect STDIN - $!" 
+       die "unable to redirect STDIN - $!"
            if !open(STDIN, "</dev/null");
 
        # redirect STDOUT
@@ -108,7 +108,7 @@ sub fork_daemon {
        close STDOUT;
        POSIX::close (1) if $fd != 1;
 
-       die "unable to redirect STDOUT - $!" 
+       die "unable to redirect STDOUT - $!"
            if !open(STDOUT, ">&", $outfh);
 
        STDOUT->autoflush (1);
@@ -118,9 +118,9 @@ sub fork_daemon {
        close STDERR;
        POSIX::close(2) if $fd != 2;
 
-       die "unable to redirect STDERR - $!" 
+       die "unable to redirect STDERR - $!"
            if !open(STDERR, ">&1");
-       
+
        STDERR->autoflush(1);
 
        if ($type eq 'crm') {
@@ -162,11 +162,11 @@ sub fork_daemon {
            }
            return 1;
        } else {
-           POSIX::close($fd);  
+           POSIX::close($fd);
            return 0;
        }
     });
-       
+
     return $pid;
 }
 
@@ -269,8 +269,8 @@ sub set_power_state {
     my $d = $self->{nodes}->{$node} || die "no such node '$node'";
 
     my $action = $d->{power_btn}->get_active() ? 'on' : 'off';
-    
-    $self->sim_hardware_cmd("power $node $action"); 
+
+    $self->sim_hardware_cmd("power $node $action");
 }
 
 sub set_network_state {
@@ -279,14 +279,14 @@ sub set_network_state {
     my $d = $self->{nodes}->{$node} || die "no such node '$node'";
 
     my $action = $d->{network_btn}->get_active() ? 'on' : 'off';
-    
-    $self->sim_hardware_cmd("network $node $action"); 
+
+    $self->sim_hardware_cmd("network $node $action");
 }
 
 sub create_node_control {
     my ($self) = @_;
 
-    my $ngrid = Gtk3::Grid->new(); 
+    my $ngrid = Gtk3::Grid->new();
     $ngrid->set_row_spacing(2);
     $ngrid->set_column_spacing(5);
     $ngrid->set('margin-left', 5);
@@ -301,7 +301,7 @@ sub create_node_control {
     $w->set_size_request(150, -1);
     $w->set_alignment (0, 0.5);
     $ngrid->attach($w, 3, 0, 1, 1);
-   
+
     my $row = 1;
 
     my @nodes = sort keys %{$self->{nodes}};
@@ -482,7 +482,7 @@ sub show_migrate_dialog {
     my $target = '';
     $w->signal_connect('notify::active' => sub {
        my $w = shift;
-               
+
        my $sel = $w->get_active();
        return if $sel < 0;
 
@@ -490,7 +490,7 @@ sub show_migrate_dialog {
     });
     $grid->attach($w, 1, 0, 1, 1);
 
-    my $relocate_btn = Gtk3::CheckButton->new_with_label("stop service (relocate)"); 
+    my $relocate_btn = Gtk3::CheckButton->new_with_label("stop service (relocate)");
     $grid->attach($relocate_btn, 1, 1, 1, 1);
 
     my $contarea = $dialog->get_content_area();
@@ -609,7 +609,7 @@ sub new_service_gui_entry {
 sub create_service_control {
     my ($self) = @_;
 
-    my $sgrid = Gtk3::Grid->new(); 
+    my $sgrid = Gtk3::Grid->new();
     $sgrid->set_row_spacing(2);
     $sgrid->set_column_spacing(5);
     $sgrid->set('margin', 5);
@@ -708,8 +708,8 @@ sub create_main_window {
 
     my $vbox = Gtk3::VBox->new(0, 0);
     $grid->attach($vbox, 1, 0, 1, 1);
-    
-    my $ngrid = $self->create_node_control(); 
+
+    my $ngrid = $self->create_node_control();
     $vbox->pack_start($ngrid, 0, 0, 0);
 
     my $sep = Gtk3::HSeparator->new;
index 9220513767c29a07de0f8c21a727b1004e2f1df4..6718d8c2ca7625cf4b009b4d251209726f147e6a 100644 (file)
@@ -3,7 +3,7 @@ package PVE::HA::Sim::TestEnv;
 use strict;
 use warnings;
 use POSIX qw(strftime EINTR);
-use JSON; 
+use JSON;
 use IO::File;
 use Fcntl qw(:DEFAULT :flock);
 
@@ -13,7 +13,7 @@ use base qw(PVE::HA::Sim::Env);
 
 sub new {
     my ($this, $nodename, $hardware, $log_id) = @_;
-    
+
     my $class = ref($this) || $this;
 
     my $self = $class->SUPER::new($nodename, $hardware, $log_id);
@@ -47,7 +47,7 @@ sub log {
 
     my $line = sprintf("%-5s %5d %12s: $msg\n", $level, $time, "$self->{nodename}/$self->{log_id}");
     print $line;
-    
+
     $self->{logfh}->print($line);
     $self->{logfh}->flush();
 }
index 8b2ab71f0e08b8179d67f1e77dac64f9e93e5a0e..b4123387554f9aa97ca4280fbddc29a680754201 100644 (file)
@@ -9,7 +9,7 @@ package PVE::HA::Sim::TestHardware;
 use strict;
 use warnings;
 use POSIX qw(strftime EINTR);
-use JSON; 
+use JSON;
 use IO::File;
 use Fcntl qw(:DEFAULT :flock);
 use File::Copy;
@@ -45,10 +45,10 @@ sub new {
 
        my $d = $self->{nodes}->{$node};
 
-       $d->{crm_env} = 
+       $d->{crm_env} =
            PVE::HA::Env->new('PVE::HA::Sim::TestEnv', $node, $self, 'crm');
 
-       $d->{lrm_env} = 
+       $d->{lrm_env} =
            PVE::HA::Env->new('PVE::HA::Sim::TestEnv', $node, $self, 'lrm');
 
        $d->{crm} = undef; # create on power on
@@ -115,7 +115,7 @@ sub run {
 
     my $last_command_time = 0;
     my $next_cmd_at = 0;
-       
+
     for (;;) {
 
        my $starttime = $self->get_time();
@@ -133,7 +133,7 @@ sub run {
        foreach my $node (@nodes) {
 
            my $d = $self->{nodes}->{$node};
-           
+
            if (my $crm = $d->{crm}) {
 
                my $exit_crm = !$crm->do_one_iteration();
@@ -196,8 +196,8 @@ sub run {
            }
        }
 
-       
-       $self->{cur_time} = $starttime + $looptime 
+
+       $self->{cur_time} = $starttime + $looptime
            if ($self->{cur_time} - $starttime) < $looptime;
 
        die "simulation end\n" if $self->{cur_time} > $max_sim_time;
@@ -210,7 +210,7 @@ sub run {
        }
 
        next if $self->{cur_time} < $next_cmd_at;
+
        # apply new comand after 5 loop iterations
 
        if (($self->{loop_count} % 5) == 0) {
index ba118d0173cf31a0a06f3fc14d6430b862ae1fc8..eabe6bd23e06bd1ef9dcfb151ba8a09fe773e0d9 100644 (file)
@@ -41,7 +41,7 @@ sub pve_verify_ha_resource_id {
 PVE::JSONSchema::register_standard_option('pve-ha-resource-id', {
     description => "HA resource ID. This consists of a resource type followed by a resource specific name, separated with colon (example: vm:100 / ct:100).",
     typetext => "<type>:<name>",
-    type => 'string', format => 'pve-ha-resource-id',                                   
+    type => 'string', format => 'pve-ha-resource-id',
 });
 
 PVE::JSONSchema::register_format('pve-ha-resource-or-vm-id', \&pve_verify_ha_resource_or_vm_id);
@@ -58,7 +58,7 @@ sub pve_verify_ha_resource_or_vm_id {
 PVE::JSONSchema::register_standard_option('pve-ha-resource-or-vm-id', {
     description => "HA resource ID. This consists of a resource type followed by a resource specific name, separated with colon (example: vm:100 / ct:100). For virtual machines and containers, you can simply use the VM or CT id as a shortcut (example: 100).",
     typetext => "<type>:<name>",
-    type => 'string', format => 'pve-ha-resource-or-vm-id',                                     
+    type => 'string', format => 'pve-ha-resource-or-vm-id',
 });
 
 PVE::JSONSchema::register_format('pve-ha-group-node', \&pve_verify_ha_group_node);
@@ -111,7 +111,7 @@ sub count_fenced_services {
     my ($ss, $node) = @_;
 
     my $count = 0;
-    
+
     foreach my $sid (keys %$ss) {
        my $sd = $ss->{$sid};
        next if !$sd->{node};
@@ -123,7 +123,7 @@ sub count_fenced_services {
            next;
        }
     }
-    
+
     return $count;
 }