]> git.proxmox.com Git - pve-ha-manager.git/commitdiff
crm: read new crm commands and save them into crm master status
authorDietmar Maurer <dietmar@proxmox.com>
Sun, 15 Feb 2015 15:46:11 +0000 (16:46 +0100)
committerDietmar Maurer <dietmar@proxmox.com>
Sun, 15 Feb 2015 15:46:11 +0000 (16:46 +0100)
PVE/HA/Manager.pm

index 532c383868793692dca524a80e186a211bc66185..b932b4eec6a37ed6519de956186f1d7b74ffbb4b 100644 (file)
@@ -128,6 +128,41 @@ sub read_lrm_status {
     return $res;
 }
 
+# read new crm commands and save them into crm master status
+sub update_crm_commands {
+    my ($self) = @_;
+
+    my ($haenv, $ms, $ns, $ss) = ($self->{haenv}, $self->{ms}, $self->{ns}, $self->{ss});
+
+    my $cmdlist = $haenv->read_crm_commands();
+    
+    foreach my $cmd (split(/\n/, $cmdlist)) {
+       chomp $cmd;
+
+       if ($cmd =~ m/^migrate\s+(\S+)\s+(\S+)$/) {
+           my ($sid, $node) = ($1, $2); 
+           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 { 
+                       $haenv->log('info', "got crm command: $cmd");
+                       $ss->{$sid}->{cmd} = [ 'migrate', $node];
+                   }
+               }
+           } else {
+               $haenv->log('err', "crm command error - no such service: $cmd");
+           }
+
+       } else {
+           $haenv->log('err', "unable to parse crm command: $cmd");
+       }
+    }
+
+}
+
 sub manage {
     my ($self) = @_;
 
@@ -154,6 +189,8 @@ sub manage {
        $ss->{$sid} = { state => 'started', node => $sc->{$sid}->{node}};
     }
 
+    $self->update_crm_commands();
+
     for (;;) {
        my $repeat = 0;