[pve-devel] [PatchV3 guest-common 5/6] Add function: swap source and target in replication config
Wolfgang Bumiller
w.bumiller at proxmox.com
Tue May 8 10:36:28 CEST 2018
On Tue, May 08, 2018 at 08:30:00AM +0200, Wolfgang Link wrote:
> ---
> PVE/ReplicationConfig.pm | 17 +++++++++++++++++
> 1 file changed, 17 insertions(+)
>
> diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
> index b6cd514..a696a81 100644
> --- a/PVE/ReplicationConfig.pm
> +++ b/PVE/ReplicationConfig.pm
> @@ -258,6 +258,23 @@ sub delete_job {
> lock($code);
> }
>
> +sub swap_source_target {
> + my ($jobid) = @_;
> +
> + my $cfg;
> +
> + my $code = sub {
> + $cfg = __PACKAGE__->new();
Please use a variable for $cfg->{ids}->{$jobid} here and replace that
common pattern below.
> + my $tmp = $cfg->{ids}->{$jobid}->{source};
> + $cfg->{ids}->{$jobid}->{source} = $cfg->{ids}->{$jobid}->{target};
> + $cfg->{ids}->{$jobid}->{target} = $tmp;
> + $cfg->write();
> + };
> +
> + lock($code);
> + return $cfg->{ids}->{$jobid};
> +}
> +
> package PVE::ReplicationConfig::Cluster;
>
> use base qw(PVE::ReplicationConfig);
> --
> 2.11.0
More information about the pve-devel
mailing list