From: Thomas Lamprecht Date: Tue, 17 Nov 2020 09:30:53 +0000 (+0100) Subject: pbs config: whitespace and wording cleanups X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=e8a18e4ba67d5b978a9d94c3e805e9fc3566dccd;p=pmg-api.git pbs config: whitespace and wording cleanups Signed-off-by: Thomas Lamprecht --- diff --git a/src/PMG/PBSConfig.pm b/src/PMG/PBSConfig.pm index 36479ce..122ae99 100644 --- a/src/PMG/PBSConfig.pm +++ b/src/PMG/PBSConfig.pm @@ -16,7 +16,6 @@ my $inotify_file_id = 'pmg-pbs.conf'; my $secret_dir = '/etc/pmg/pbs'; my $config_filename = "${secret_dir}/pbs.conf"; - my %prune_option = ( optional => 1, type => 'integer', minimum => '0', @@ -30,28 +29,28 @@ my %prune_properties = ( }, 'keep-hourly' => { %prune_option, - description => 'Keep backups for the last different hours. If there is more' . - 'than one backup for a single hour, only the latest one is kept.' + description => 'Keep backups for the last different hours. If there is' + .' more than one backup for a single hour, only the latest one is kept.' }, 'keep-daily' => { %prune_option, - description => 'Keep backups for the last different days. If there is more' . - 'than one backup for a single day, only the latest one is kept.' + description => 'Keep backups for the last different days. If there is' + .' more than one backup for a single day, only the latest one is kept.' }, 'keep-weekly' => { %prune_option, - description => 'Keep backups for the last different weeks. If there is more' . - 'than one backup for a single week, only the latest one is kept.' + description => 'Keep backups for the last different weeks. If there is' + .'more than one backup for a single week, only the latest one is kept.' }, 'keep-monthly' => { %prune_option, - description => 'Keep backups for the last different months. If there is more' . - 'than one backup for a single month, only the latest one is kept.' + description => 'Keep backups for the last different months. If there is' + .' more than one backup for a single month, only the latest one is kept.' }, 'keep-yearly' => { %prune_option, - description => 'Keep backups for the last different years. If there is more' . - 'than one backup for a single year, only the latest one is kept.' + description => 'Keep backups for the last different years. If there is' + .' more than one backup for a single year, only the latest one is kept.' }, ); @@ -68,26 +67,27 @@ my $defaultData = { sub properties { return { datastore => { - description => "Proxmox backup server datastore name.", + description => "Proxmox Backup Server datastore name.", type => 'string', }, server => { - description => "Proxmox backup server address.", + description => "Proxmox Backup Server address.", type => 'string', format => 'address', maxLength => 256, }, disable => { - description => "Flag to disable/deactivate the entry.", + description => "Flag to disable (deactivate) the entry.", type => 'boolean', optional => 1, }, password => { - description => "Password for the user on the Proxmox backup server.", + description => "Password or API token secret for the user on the" + ." Proxmox Backup Server.", type => 'string', optional => 1, }, username => get_standard_option('pmg-email-address', { - description => "Username on the Proxmox backup server" + description => "Username or API token ID on the Proxmox Backup Server" }), fingerprint => get_standard_option('fingerprint-sha256'), %prune_properties, @@ -125,9 +125,7 @@ sub prune_options { my $remote_cfg = $self->{ids}->{$remote}; my $res = {}; - foreach my $keep_opt (keys %prune_properties) { - if (defined($remote_cfg->{$keep_opt})) { $res->{$keep_opt} = $remote_cfg->{$keep_opt}; } @@ -153,18 +151,17 @@ sub write { PVE::INotify::write_file($inotify_file_id, $self); } -my $lockfile = "/var/lock/pmgpbsconfig.lck"; - sub lock_config { my ($code, $errmsg) = @_; + my $lockfile = "/var/lock/pmgpbsconfig.lck"; + my $p = PVE::Tools::lock_file($lockfile, undef, $code); if (my $err = $@) { $errmsg ? die "$errmsg: $err" : die $err; } } - __PACKAGE__->register(); __PACKAGE__->init(); @@ -186,10 +183,13 @@ sub write_pmg_pbs_conf { PVE::Tools::safe_print($filename, $fh, $raw); } -PVE::INotify::register_file($inotify_file_id, $config_filename, - \&read_pmg_pbs_conf, - \&write_pmg_pbs_conf, - undef, - always_call_parser => 1); +PVE::INotify::register_file( + $inotify_file_id, + $config_filename, + \&read_pmg_pbs_conf, + \&write_pmg_pbs_conf, + undef, + always_call_parser => 1 +); 1;