[pve-devel] [pve-guest-common 1/2] get_jobid
Fabian Grünbichler
f.gruenbichler at proxmox.com
Fri Jun 9 12:07:28 CEST 2017
On Fri, Jun 09, 2017 at 11:43:34AM +0200, Dietmar Maurer wrote:
>
>
> > On June 9, 2017 at 11:17 AM Fabian Grünbichler <f.gruenbichler at proxmox.com>
> > wrote:
> >
> >
> > On Fri, Jun 09, 2017 at 08:19:47AM +0200, Wolfgang Link wrote:
> > > ---
> > > PVE/ReplicationConfig.pm | 14 ++++++++++++++
> > > 1 file changed, 14 insertions(+)
> > >
> > > diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
> > > index 01e7206..b4f0fe9 100644
> > > --- a/PVE/ReplicationConfig.pm
> > > +++ b/PVE/ReplicationConfig.pm
> > > @@ -209,6 +209,20 @@ sub check_for_existing_jobs {
> > > return undef;
> > > }
> > >
> > > +sub get_jobid {
> > > + my ($cfg, $vmid, $target) = @_;
> > > +
> > > + foreach my $id (keys %{$cfg->{ids}}) {
> > > + my $data = $cfg->{ids}->{$id};
> > > +
> > > + if ($data->{target} eq $target) {
> > > + return $id;
> > > + }
> > > + }
> > > +
> > > + return undef;
> > > +}
> >
> > doesn't this return the first job which has this target node? and not
> > the only job which has this guest ID and target node?
>
> We may also have different replication job types in future, and not all
> of them have a 'target' property...
hmm.. maybe a more abstract method to retrieve jobs (or job IDs) of a
given type with given property key/value pairs?
get_jobids {
my ($cfg, $vmid, $type, %property_filter)
or we get all jobs for the given guest and type, and filter at the
caller side?
More information about the pve-devel
mailing list