Commit 5c1b7462 authored by Dietmar Maurer's avatar Dietmar Maurer

fix bug #97: execute 'clusvcadm' commands for HA managed CTs

parent 6800ed38
......@@ -923,6 +923,16 @@ __PACKAGE__->register_method({
return $res;
}});
my $vm_is_ha_managed = sub {
my ($vmid) = @_;
my $cc = PVE::Cluster::cfs_read_file('cluster.conf');
if (PVE::Cluster::cluster_conf_lookup_pvevm($cc, 0, $vmid, 1)) {
return 1;
}
return 0;
};
__PACKAGE__->register_method({
name => 'vm_status',
path => '{vmid}/status/current',
......@@ -950,12 +960,7 @@ __PACKAGE__->register_method({
my $vmstatus = PVE::OpenVZ::vmstatus($param->{vmid});
my $status = $vmstatus->{$param->{vmid}};
my $cc = PVE::Cluster::cfs_read_file('cluster.conf');
if (PVE::Cluster::cluster_conf_lookup_pvevm($cc, 0, $param->{vmid}, 1)) {
$status->{ha} = 1;
} else {
$status->{ha} = 0;
}
$status->{ha} = &$vm_is_ha_managed($param->{vmid});
return $status;
}});
......@@ -1037,19 +1042,40 @@ __PACKAGE__->register_method({
die "CT $vmid already running\n" if PVE::OpenVZ::check_running($vmid);
my $realcmd = sub {
my $upid = shift;
if (&$vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
my $hacmd = sub {
my $upid = shift;
my $service = "pvevm:$vmid";
my $cmd = ['clusvcadm', '-e', $service, '-m', $node];
print "Executing HA start for CT $vmid\n";
PVE::Tools::run_command($cmd);
return;
};
return $rpcenv->fork_worker('hastart', $vmid, $authuser, $hacmd);
} else {
my $realcmd = sub {
my $upid = shift;
syslog('info', "starting CT $vmid: $upid\n");
syslog('info', "starting CT $vmid: $upid\n");
my $cmd = ['vzctl', 'start', $vmid];
my $cmd = ['vzctl', 'start', $vmid];
run_command($cmd);
run_command($cmd);
return;
};
return;
};
return $rpcenv->fork_worker('vzstart', $vmid, $authuser, $realcmd);
return $rpcenv->fork_worker('vzstart', $vmid, $authuser, $realcmd);
}
}});
__PACKAGE__->register_method({
......@@ -1085,20 +1111,39 @@ __PACKAGE__->register_method({
die "CT $vmid not running\n" if !PVE::OpenVZ::check_running($vmid);
my $realcmd = sub {
my $upid = shift;
if (&$vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
syslog('info', "stoping CT $vmid: $upid\n");
my $hacmd = sub {
my $upid = shift;
my $cmd = ['vzctl', 'stop', $vmid, '--fast'];
run_command($cmd);
return;
};
my $service = "pvevm:$vmid";
my $upid = $rpcenv->fork_worker('vzstop', $vmid, $authuser, $realcmd);
my $cmd = ['clusvcadm', '-d', $service];
return $upid;
print "Executing HA stop for CT $vmid\n";
PVE::Tools::run_command($cmd);
return;
};
return $rpcenv->fork_worker('hastop', $vmid, $authuser, $hacmd);
} else {
my $realcmd = sub {
my $upid = shift;
syslog('info', "stoping CT $vmid: $upid\n");
my $cmd = ['vzctl', 'stop', $vmid, '--fast'];
run_command($cmd);
return;
};
return $rpcenv->fork_worker('vzstop', $vmid, $authuser, $realcmd);
}
}});
__PACKAGE__->register_method({
......@@ -1329,17 +1374,36 @@ __PACKAGE__->register_method({
if !$param->{online};
}
my $realcmd = sub {
my $upid = shift;
if (&$vm_is_ha_managed($vmid) && $rpcenv->{type} ne 'ha') {
PVE::OpenVZMigrate->migrate($target, $targetip, $vmid, $param);
my $hacmd = sub {
my $upid = shift;
return;
};
my $service = "pvevm:$vmid";
my $upid = $rpcenv->fork_worker('vzmigrate', $vmid, $authuser, $realcmd);
my $cmd = ['clusvcadm', '-M', $service, '-m', $target];
return $upid;
print "Executing HA migrate for CT $vmid to node $target\n";
PVE::Tools::run_command($cmd);
return;
};
return $rpcenv->fork_worker('hamigrate', $vmid, $authuser, $hacmd);
} else {
my $realcmd = sub {
my $upid = shift;
PVE::OpenVZMigrate->migrate($target, $targetip, $vmid, $param);
return;
};
return $rpcenv->fork_worker('vzmigrate', $vmid, $authuser, $realcmd);
}
}});
1;
pve-manager (2.0-48) unstable; urgency=low
* fix bug #97: execute 'clusvcadm' commands for HA managed CTs
-- Proxmox Support Team <support@proxmox.com> Tue, 27 Mar 2012 10:59:33 +0200
pve-manager (2.0-47) unstable; urgency=low
* fix bug 114: do not display 'nothing selected' after logout
......
......@@ -2,7 +2,7 @@ RELEASE=2.0
VERSION=2.0
PACKAGE=pve-manager
PACKAGERELEASE=47
PACKAGERELEASE=48
BINDIR=${DESTDIR}/usr/bin
PERLLIBDIR=${DESTDIR}/usr/share/perl5
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment