whitespace cleanup

Signed-off-by: Tim Marx <t.marx@proxmox.com>
This commit is contained in:
Tim Marx 2019-06-19 12:08:36 +02:00 committed by Thomas Lamprecht
parent c54f9a758d
commit 60e049c231
5 changed files with 74 additions and 74 deletions

View File

@ -16,9 +16,9 @@ use PVE::VZDump;
use base qw(PVE::RESTHandler); use base qw(PVE::RESTHandler);
cfs_register_file ('vzdump.cron', cfs_register_file ('vzdump.cron',
\&parse_vzdump_cron_config, \&parse_vzdump_cron_config,
\&write_vzdump_cron_config); \&write_vzdump_cron_config);
PVE::JSONSchema::register_format('pve-day-of-week', \&verify_day_of_week); PVE::JSONSchema::register_format('pve-day-of-week', \&verify_day_of_week);
sub verify_day_of_week { sub verify_day_of_week {
@ -64,7 +64,7 @@ sub parse_dow {
if ($day =~ m/^(mon|tue|wed|thu|fri|sat|sun)-(mon|tue|wed|thu|fri|sat|sun)$/i) { if ($day =~ m/^(mon|tue|wed|thu|fri|sat|sun)-(mon|tue|wed|thu|fri|sat|sun)$/i) {
for (my $i = $dowmap->{lc($1)}; $i <= $dowmap->{lc($2)}; $i++) { for (my $i = $dowmap->{lc($1)}; $i <= $dowmap->{lc($2)}; $i++) {
my $r = $rdowmap->{$i}; my $r = $rdowmap->{$i};
$res->{$r} = 1; $res->{$r} = 1;
} }
} elsif ($day =~ m/^(mon|tue|wed|thu|fri|sat|sun|[0-7])$/i) { } elsif ($day =~ m/^(mon|tue|wed|thu|fri|sat|sun|[0-7])$/i) {
$day = $rdowmap->{$day} if $day =~ m/\d/; $day = $rdowmap->{$day} if $day =~ m/\d/;
@ -91,7 +91,7 @@ sub parse_vzdump_cron_config {
my $ejobs = []; # mailfomerd lines my $ejobs = []; # mailfomerd lines
my $jid = 1; # we start at 1 my $jid = 1; # we start at 1
my $digest = Digest::SHA::sha1_hex(defined($raw) ? $raw : ''); my $digest = Digest::SHA::sha1_hex(defined($raw) ? $raw : '');
while ($raw && $raw =~ s/^(.*?)(\n|$)//) { while ($raw && $raw =~ s/^(.*?)(\n|$)//) {
@ -174,7 +174,7 @@ sub write_vzdump_cron_config {
} else { } else {
die "unable to parse job start time\n"; die "unable to parse job start time\n";
} }
$job->{quiet} = 1; # we do not want messages from cron $job->{quiet} = 1; # we do not want messages from cron
my $cmd = PVE::VZDump::command_line($job); my $cmd = PVE::VZDump::command_line($job);
@ -191,8 +191,8 @@ sub write_vzdump_cron_config {
} }
__PACKAGE__->register_method({ __PACKAGE__->register_method({
name => 'index', name => 'index',
path => '', path => '',
method => 'GET', method => 'GET',
description => "List vzdump backup schedule.", description => "List vzdump backup schedule.",
permissions => { permissions => {
@ -226,8 +226,8 @@ __PACKAGE__->register_method({
}}); }});
__PACKAGE__->register_method({ __PACKAGE__->register_method({
name => 'create_job', name => 'create_job',
path => '', path => '',
method => 'POST', method => 'POST',
protected => 1, protected => 1,
description => "Create new vzdump backup job.", description => "Create new vzdump backup job.",
@ -288,8 +288,8 @@ __PACKAGE__->register_method({
}}); }});
__PACKAGE__->register_method({ __PACKAGE__->register_method({
name => 'read_job', name => 'read_job',
path => '{id}', path => '{id}',
method => 'GET', method => 'GET',
description => "Read vzdump backup job definition.", description => "Read vzdump backup job definition.",
permissions => { permissions => {
@ -327,8 +327,8 @@ __PACKAGE__->register_method({
}}); }});
__PACKAGE__->register_method({ __PACKAGE__->register_method({
name => 'delete_job', name => 'delete_job',
path => '{id}', path => '{id}',
method => 'DELETE', method => 'DELETE',
description => "Delete vzdump backup job definition.", description => "Delete vzdump backup job definition.",
permissions => { permissions => {
@ -380,8 +380,8 @@ __PACKAGE__->register_method({
}}); }});
__PACKAGE__->register_method({ __PACKAGE__->register_method({
name => 'update_job', name => 'update_job',
path => '{id}', path => '{id}',
method => 'PUT', method => 'PUT',
protected => 1, protected => 1,
description => "Update vzdump backup job definition.", description => "Update vzdump backup job definition.",

View File

@ -18,7 +18,7 @@ use Data::Dumper; # fixme: remove
use base qw(PVE::RESTHandler); use base qw(PVE::RESTHandler);
__PACKAGE__->register_method ({ __PACKAGE__->register_method ({
name => 'vzdump', name => 'vzdump',
path => '', path => '',
method => 'POST', method => 'POST',
description => "Create backup.", description => "Create backup.",
@ -68,7 +68,7 @@ __PACKAGE__->register_method ({
# silent exit if we run on wrong node # silent exit if we run on wrong node
return 'OK' if $param->{node} && $param->{node} ne $nodename; return 'OK' if $param->{node} && $param->{node} ne $nodename;
my $cmdline = PVE::VZDump::command_line($param); my $cmdline = PVE::VZDump::command_line($param);
# convert string lists to arrays # convert string lists to arrays
@ -144,8 +144,8 @@ __PACKAGE__->register_method ({
PVE::VZDump::run_command(undef, "ionice -c2 -n$param->{ionice} -p $$"); PVE::VZDump::run_command(undef, "ionice -c2 -n$param->{ionice} -p $$");
} }
} }
$vzdump->exec_backup($rpcenv, $user); $vzdump->exec_backup($rpcenv, $user);
}; };
open STDOUT, '>/dev/null' if $param->{quiet} && !$param->{stdout}; open STDOUT, '>/dev/null' if $param->{quiet} && !$param->{stdout};
open STDERR, '>/dev/null' if $param->{quiet}; open STDERR, '>/dev/null' if $param->{quiet};

View File

@ -16,7 +16,7 @@ use PVE::SafeSyslog;
my $hwaddress; my $hwaddress;
sub get_hwaddress { sub get_hwaddress {
return $hwaddress if defined ($hwaddress); return $hwaddress if defined ($hwaddress);
my $fn = '/etc/ssh/ssh_host_rsa_key.pub'; my $fn = '/etc/ssh/ssh_host_rsa_key.pub';
@ -69,7 +69,7 @@ sub extract_vm_stats {
my $entry = { my $entry = {
id => "$data->{type}/$vmid", id => "$data->{type}/$vmid",
vmid => $vmid + 0, vmid => $vmid + 0,
node => $data->{node}, node => $data->{node},
type => $data->{type}, type => $data->{type},
status => 'unknown', status => 'unknown',
@ -92,7 +92,7 @@ sub extract_vm_stats {
$entry->{netout} = ($d->[10] || 0) + 0; $entry->{netout} = ($d->[10] || 0) + 0;
$entry->{diskread} = ($d->[11] || 0) + 0; $entry->{diskread} = ($d->[11] || 0) + 0;
$entry->{diskwrite} = ($d->[12] || 0) + 0; $entry->{diskwrite} = ($d->[12] || 0) + 0;
} elsif ($d = $rrd->{"pve2.3-vm/$vmid"}) { } elsif ($d = $rrd->{"pve2.3-vm/$vmid"}) {
$entry->{uptime} = ($d->[0] || 0) + 0; $entry->{uptime} = ($d->[0] || 0) + 0;
@ -120,12 +120,12 @@ sub extract_storage_stats {
my $entry = { my $entry = {
id => "storage/$node/$storeid", id => "storage/$node/$storeid",
storage => $storeid, storage => $storeid,
node => $node, node => $node,
type => 'storage', type => 'storage',
status => 'unknown', status => 'unknown',
shared => $scfg->{shared} || 0, shared => $scfg->{shared} || 0,
}; };
if (my $d = $rrd->{"pve2-storage/$node/$storeid"}) { if (my $d = $rrd->{"pve2-storage/$node/$storeid"}) {
$entry->{maxdisk} = ($d->[1] || 0) + 0; $entry->{maxdisk} = ($d->[1] || 0) + 0;
@ -164,14 +164,14 @@ sub run_spiceterm {
my $nodename = PVE::INotify::nodename(); my $nodename = PVE::INotify::nodename();
my $family = PVE::Tools::get_host_address_family($nodename); my $family = PVE::Tools::get_host_address_family($nodename);
my $port = PVE::Tools::next_spice_port($family); my $port = PVE::Tools::next_spice_port($family);
my ($ticket, undef, $remote_viewer_config) = my ($ticket, undef, $remote_viewer_config) =
PVE::AccessControl::remote_viewer_config($authuser, $vmid, $node, $proxy, $title, $port); PVE::AccessControl::remote_viewer_config($authuser, $vmid, $node, $proxy, $title, $port);
my $timeout = 40; my $timeout = 40;
my $cmd = ['/usr/bin/spiceterm', '--port', $port, '--addr', 'localhost', my $cmd = ['/usr/bin/spiceterm', '--port', $port, '--addr', 'localhost',
'--timeout', $timeout, '--authpath', $authpath, '--timeout', $timeout, '--authpath', $authpath,
'--permissions', $permissions]; '--permissions', $permissions];
my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg'); my $dcconf = PVE::Cluster::cfs_read_file('datacenter.cfg');

View File

@ -218,11 +218,11 @@ sub storage_info {
my $cfg = PVE::Storage::config(); my $cfg = PVE::Storage::config();
my $scfg = PVE::Storage::storage_config($cfg, $storage); my $scfg = PVE::Storage::storage_config($cfg, $storage);
my $type = $scfg->{type}; my $type = $scfg->{type};
die "can't use storage type '$type' for backup\n" die "can't use storage type '$type' for backup\n"
if (!($type eq 'dir' || $type eq 'nfs' || $type eq 'glusterfs' if (!($type eq 'dir' || $type eq 'nfs' || $type eq 'glusterfs'
|| $type eq 'cifs' || $type eq 'cephfs')); || $type eq 'cifs' || $type eq 'cephfs'));
die "can't use storage '$storage' for backups - wrong content type\n" die "can't use storage '$storage' for backups - wrong content type\n"
if (!$scfg->{content}->{backup}); if (!$scfg->{content}->{backup});
PVE::Storage::activate_storage($cfg, $storage); PVE::Storage::activate_storage($cfg, $storage);
@ -249,7 +249,7 @@ sub format_size {
} else { } else {
my $gb = $mb / 1024; my $gb = $mb / 1024;
return sprintf ("%.2fGB", $gb); return sprintf ("%.2fGB", $gb);
} }
} }
sub format_time { sub format_time {
@ -569,7 +569,7 @@ sub new {
$errors .= "dumpdir '$opts->{dumpdir}' does not exist" $errors .= "dumpdir '$opts->{dumpdir}' does not exist"
if ! -d $opts->{dumpdir}; if ! -d $opts->{dumpdir};
} else { } else {
die "internal error"; die "internal error";
} }
if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) { if ($opts->{tmpdir} && ! -d $opts->{tmpdir}) {
@ -620,9 +620,9 @@ sub getlock {
my ($self, $upid) = @_; my ($self, $upid) = @_;
my $fh; my $fh;
my $maxwait = $self->{opts}->{lockwait} || $self->{lockwait}; my $maxwait = $self->{opts}->{lockwait} || $self->{lockwait};
die "missimg UPID" if !$upid; # should not happen die "missimg UPID" if !$upid; # should not happen
if (!open (SERVER_FLCK, ">>$lockfile")) { if (!open (SERVER_FLCK, ">>$lockfile")) {
@ -641,7 +641,7 @@ sub getlock {
eval { eval {
alarm ($maxwait * 60); alarm ($maxwait * 60);
local $SIG{ALRM} = sub { alarm (0); die "got timeout\n"; }; local $SIG{ALRM} = sub { alarm (0); die "got timeout\n"; };
if (!flock (SERVER_FLCK, LOCK_EX)) { if (!flock (SERVER_FLCK, LOCK_EX)) {
@ -653,9 +653,9 @@ sub getlock {
alarm (0); alarm (0);
}; };
alarm (0); alarm (0);
my $err = $@; my $err = $@;
if ($err) { if ($err) {
debugmsg ('err', "can't acquire lock '$lockfile' - $err", undef, 1); debugmsg ('err', "can't acquire lock '$lockfile' - $err", undef, 1);
die "can't acquire lock '$lockfile' - $err"; die "can't acquire lock '$lockfile' - $err";
@ -732,17 +732,17 @@ sub get_backup_file_list {
return $bklist; return $bklist;
} }
sub exec_backup_task { sub exec_backup_task {
my ($self, $task) = @_; my ($self, $task) = @_;
my $opts = $self->{opts}; my $opts = $self->{opts};
my $vmid = $task->{vmid}; my $vmid = $task->{vmid};
my $plugin = $task->{plugin}; my $plugin = $task->{plugin};
my $vmstarttime = time (); my $vmstarttime = time ();
my $logfd; my $logfd;
my $cleanup = {}; my $cleanup = {};
@ -803,11 +803,11 @@ sub exec_backup_task {
$task->{vmtype} = $vmtype; $task->{vmtype} = $vmtype;
if ($opts->{tmpdir}) { if ($opts->{tmpdir}) {
$task->{tmpdir} = "$opts->{tmpdir}/vzdumptmp$$"; $task->{tmpdir} = "$opts->{tmpdir}/vzdumptmp$$";
} else { } else {
# dumpdir is posix? then use it as temporary dir # dumpdir is posix? then use it as temporary dir
my $info = get_mount_info($opts->{dumpdir}); my $info = get_mount_info($opts->{dumpdir});
if ($vmtype eq 'qemu' || if ($vmtype eq 'qemu' ||
grep ($_ eq $info->{fstype}, @posix_filesystems)) { grep ($_ eq $info->{fstype}, @posix_filesystems)) {
$task->{tmpdir} = "$opts->{dumpdir}/$basename.tmp"; $task->{tmpdir} = "$opts->{dumpdir}/$basename.tmp";
} else { } else {
@ -858,7 +858,7 @@ sub exec_backup_task {
debugmsg ('info', $err, $logfd); debugmsg ('info', $err, $logfd);
debugmsg ('info', "trying 'suspend' mode instead", $logfd); debugmsg ('info', "trying 'suspend' mode instead", $logfd);
$mode = 'suspend'; # so prepare is called again below $mode = 'suspend'; # so prepare is called again below
%$task = %saved_task; %$task = %saved_task;
} }
} }
@ -886,7 +886,7 @@ sub exec_backup_task {
$plugin->stop_vm ($task, $vmid); $plugin->stop_vm ($task, $vmid);
$cleanup->{restart} = 1; $cleanup->{restart} = 1;
} }
} elsif ($mode eq 'suspend') { } elsif ($mode eq 'suspend') {
@ -916,7 +916,7 @@ sub exec_backup_task {
$self->run_hook_script('post-restart', $task, $logfd); $self->run_hook_script('post-restart', $task, $logfd);
$log_vm_online_again->(); $log_vm_online_again->();
} }
} elsif ($mode eq 'snapshot') { } elsif ($mode eq 'snapshot') {
$self->run_hook_script ('backup-start', $task, $logfd); $self->run_hook_script ('backup-start', $task, $logfd);
@ -951,8 +951,8 @@ sub exec_backup_task {
# assemble archive image # assemble archive image
$plugin->assemble ($task, $vmid); $plugin->assemble ($task, $vmid);
# produce archive # produce archive
if ($opts->{stdout}) { if ($opts->{stdout}) {
debugmsg ('info', "sending archive to stdout", $logfd); debugmsg ('info', "sending archive to stdout", $logfd);
@ -969,7 +969,7 @@ sub exec_backup_task {
# determine size # determine size
$task->{size} = (-s $task->{tarfile}) || 0; $task->{size} = (-s $task->{tarfile}) || 0;
my $cs = format_size ($task->{size}); my $cs = format_size ($task->{size});
debugmsg ('info', "archive file size: $cs", $logfd); debugmsg ('info', "archive file size: $cs", $logfd);
# purge older backup # purge older backup
@ -1009,8 +1009,8 @@ sub exec_backup_task {
eval { $plugin->set_logfd (undef); }; eval { $plugin->set_logfd (undef); };
warn $@ if $@; warn $@ if $@;
if ($cleanup->{resume} || $cleanup->{restart}) { if ($cleanup->{resume} || $cleanup->{restart}) {
eval { eval {
$self->run_hook_script ('pre-restart', $task, $logfd); $self->run_hook_script ('pre-restart', $task, $logfd);
if ($cleanup->{resume}) { if ($cleanup->{resume}) {
debugmsg ('info', "resume vm", $logfd); debugmsg ('info', "resume vm", $logfd);
@ -1057,7 +1057,7 @@ sub exec_backup_task {
} }
close ($logfd) if $logfd; close ($logfd) if $logfd;
if ($task->{tmplog} && $task->{logfile}) { if ($task->{tmplog} && $task->{logfile}) {
system {'cp'} 'cp', $task->{tmplog}, $task->{logfile}; system {'cp'} 'cp', $task->{tmplog}, $task->{logfile};
} }
@ -1075,7 +1075,7 @@ sub exec_backup {
debugmsg ('info', "starting new backup job: $self->{cmdline}", undef, 1); debugmsg ('info', "starting new backup job: $self->{cmdline}", undef, 1);
debugmsg ('info', "skip external VMs: " . join(', ', @{$self->{skiplist}})) debugmsg ('info', "skip external VMs: " . join(', ', @{$self->{skiplist}}))
if scalar(@{$self->{skiplist}}); if scalar(@{$self->{skiplist}});
my $tasklist = []; my $tasklist = [];
if ($opts->{all}) { if ($opts->{all}) {
@ -1145,7 +1145,7 @@ sub exec_backup {
die $err if $err; die $err if $err;
die "job errors\n" if $errcount; die "job errors\n" if $errcount;
unlink $pidfile; unlink $pidfile;
} }
@ -1197,7 +1197,7 @@ sub stop_running_backups {
my $task = PVE::Tools::upid_decode($upid); my $task = PVE::Tools::upid_decode($upid);
if (PVE::ProcFSTools::check_process_running($task->{pid}, $task->{pstart}) && if (PVE::ProcFSTools::check_process_running($task->{pid}, $task->{pstart}) &&
PVE::ProcFSTools::read_proc_starttime($task->{pid}) == $task->{pstart}) { PVE::ProcFSTools::read_proc_starttime($task->{pid}) == $task->{pstart}) {
kill(15, $task->{pid}); kill(15, $task->{pid});
# wait max 15 seconds to shut down (else, do nothing for now) # wait max 15 seconds to shut down (else, do nothing for now)

View File

@ -66,9 +66,9 @@ Ext.define('PVE.dc.BackupEdit', {
var store = new Ext.data.Store({ var store = new Ext.data.Store({
model: 'PVEResources', model: 'PVEResources',
sorters: { sorters: {
property: 'vmid', property: 'vmid',
order: 'ASC' order: 'ASC'
} }
}); });
@ -79,16 +79,16 @@ Ext.define('PVE.dc.BackupEdit', {
selModel: sm, selModel: sm,
disabled: true, disabled: true,
columns: [ columns: [
{ {
header: 'ID', header: 'ID',
dataIndex: 'vmid', dataIndex: 'vmid',
width: 60 width: 60
}, },
{ {
header: gettext('Node'), header: gettext('Node'),
dataIndex: 'node' dataIndex: 'node'
}, },
{ {
header: gettext('Status'), header: gettext('Status'),
dataIndex: 'uptime', dataIndex: 'uptime',
renderer: function(value) { renderer: function(value) {
@ -99,13 +99,13 @@ Ext.define('PVE.dc.BackupEdit', {
} }
} }
}, },
{ {
header: gettext('Name'), header: gettext('Name'),
dataIndex: 'name', dataIndex: 'name',
flex: 1 flex: 1
}, },
{ {
header: gettext('Type'), header: gettext('Type'),
dataIndex: 'type' dataIndex: 'type'
} }
] ]
@ -201,7 +201,7 @@ Ext.define('PVE.dc.BackupEdit', {
onGetValues: function(values) { onGetValues: function(values) {
if (!values.node) { if (!values.node) {
if (!me.isCreate) { if (!me.isCreate) {
Proxmox.Utils.assemble_field_data(values, { 'delete': 'node' }); Proxmox.Utils.assemble_field_data(values, { 'delete': 'node' });
} }
delete values.node; delete values.node;
} }
@ -255,7 +255,7 @@ Ext.define('PVE.dc.BackupEdit', {
var list = vmidField.getValue(); var list = vmidField.getValue();
update_vmid_selection(list, value); update_vmid_selection(list, value);
}); });
var reload = function() { var reload = function() {
store.load({ store.load({
params: { type: 'vm' }, params: { type: 'vm' },
@ -392,7 +392,7 @@ Ext.define('PVE.dc.BackupView', {
}, },
remove_btn, remove_btn,
edit_btn edit_btn
], ],
columns: [ columns: [
{ {
header: gettext('Enabled'), header: gettext('Enabled'),
@ -499,14 +499,14 @@ Ext.define('PVE.dc.BackupView', {
itemdblclick: run_editor itemdblclick: run_editor
} }
}); });
me.callParent(); me.callParent();
} }
}, function() { }, function() {
Ext.define('pve-cluster-backup', { Ext.define('pve-cluster-backup', {
extend: 'Ext.data.Model', extend: 'Ext.data.Model',
fields: [ fields: [
'id', 'starttime', 'dow', 'id', 'starttime', 'dow',
'storage', 'node', 'vmid', 'exclude', 'storage', 'node', 'vmid', 'exclude',
'mailto', 'mailto',