fix bug 158: move openvz scripts inside ocf resource agent
This commit is contained in:
parent
49254f9023
commit
991f0a61c0
@ -6,6 +6,7 @@
|
||||
# Copyright (C) 2011 Proxmox Server Solutions GmbH
|
||||
|
||||
use strict;
|
||||
use File::Copy;
|
||||
use PVE::Tools;
|
||||
use PVE::ProcFSTools;
|
||||
use PVE::Cluster;
|
||||
@ -150,6 +151,35 @@ sub upid_wait {
|
||||
}
|
||||
}
|
||||
|
||||
sub copy_scripts {
|
||||
my ($vmid, $oldconfig, $newconfig) = @_;
|
||||
|
||||
my $oldcfgdir = dirname($oldconfig);
|
||||
my $newcfgdir = dirname($newconfig);
|
||||
|
||||
my $newfiles = [];
|
||||
my $oldfiles = [];
|
||||
eval {
|
||||
foreach my $s (PVE::OpenVZ::SCRIPT_EXT) {
|
||||
my $scriptfn = "${vmid}.$s";
|
||||
my $oldfn = "$oldcfgdir/$scriptfn";
|
||||
next if ! -f $oldfn;
|
||||
my $dstfn = "$newcfgdir/$scriptfn";
|
||||
push @$oldfiles, $oldfn;
|
||||
push @$newfiles, $dstfn;
|
||||
copy($oldfn, $dstfn) || die "copy '$oldfn' to '$dstfn' failed - $!\n";
|
||||
}
|
||||
};
|
||||
if (my $err = $@) {
|
||||
foreach my $fn (@$newfiles) {
|
||||
unlink($fn);
|
||||
}
|
||||
die $err;
|
||||
}
|
||||
|
||||
return ($newfiles, $oldfiles);
|
||||
}
|
||||
|
||||
my $cmd = shift || '';
|
||||
my $migratetarget = shift if $cmd eq 'migrate';
|
||||
|
||||
@ -164,18 +194,34 @@ if ($cmd eq 'start') {
|
||||
|
||||
if ($status->{node} ne $nodename) {
|
||||
ocf_log('info', "Move config for $status->{name} to local node");
|
||||
my ($oldconfig, $newconfig);
|
||||
my ($oldconfig, $newconfig, $oldfiles, $newfiles);
|
||||
if ($status->{type} eq 'qemu') {
|
||||
$oldconfig = PVE::QemuServer::config_file($status->{vmid}, $status->{node});
|
||||
$newconfig = PVE::QemuServer::config_file($status->{vmid}, $nodename);
|
||||
} else {
|
||||
$oldconfig = PVE::OpenVZ::config_file($status->{vmid}, $status->{node});
|
||||
$newconfig = PVE::OpenVZ::config_file($status->{vmid}, $nodename);
|
||||
|
||||
eval { ($newfiles, $oldfiles) = copy_scripts($status->{vmid}, $oldconfig, $newconfig); };
|
||||
if (my $err = $@) {
|
||||
ocf_log('err', "unable to move config scripts: $err");
|
||||
exit(OCF_ERR_GENERIC);
|
||||
}
|
||||
}
|
||||
if (!rename($oldconfig, $newconfig)) {
|
||||
ocf_log('err', "unable to move config file from '$oldconfig' to '$newconfig' - $!");
|
||||
if ($newfiles) {
|
||||
foreach my $fn (@$newfiles) {
|
||||
unlink($fn);
|
||||
}
|
||||
}
|
||||
exit(OCF_ERR_GENERIC);
|
||||
}
|
||||
if ($oldfiles) {
|
||||
foreach my $fn (@$oldfiles) {
|
||||
unlink($fn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $upid;
|
||||
|
6
debian/changelog.Debian
vendored
6
debian/changelog.Debian
vendored
@ -1,3 +1,9 @@
|
||||
pve-manager (2.0-59) unstable; urgency=low
|
||||
|
||||
* fix bug 158: move openvz scripts inside ocf resource agent
|
||||
|
||||
-- Proxmox Support Team <support@proxmox.com> Thu, 12 Apr 2012 11:04:38 +0200
|
||||
|
||||
pve-manager (2.0-58) unstable; urgency=low
|
||||
|
||||
* fix bug #141: allow to create backup job without compression
|
||||
|
@ -2,7 +2,7 @@ RELEASE=2.0
|
||||
|
||||
VERSION=2.0
|
||||
PACKAGE=pve-manager
|
||||
PACKAGERELEASE=58
|
||||
PACKAGERELEASE=59
|
||||
|
||||
BINDIR=${DESTDIR}/usr/bin
|
||||
PERLLIBDIR=${DESTDIR}/usr/share/perl5
|
||||
|
Loading…
Reference in New Issue
Block a user