From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id C1DB0BB92 for ; Fri, 8 Apr 2022 09:41:26 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id BA25CBB5E for ; Fri, 8 Apr 2022 09:40:56 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id A8DDFBB55 for ; Fri, 8 Apr 2022 09:40:55 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7E46A45986 for ; Fri, 8 Apr 2022 09:40:55 +0200 (CEST) Date: Fri, 08 Apr 2022 09:40:48 +0200 From: Fabian =?iso-8859-1?q?Gr=FCnbichler?= To: Proxmox VE development discussion References: <20220322073412.30562-1-h.laimer@proxmox.com> <20220322073412.30562-2-h.laimer@proxmox.com> In-Reply-To: <<20220322073412.30562-2-h.laimer@proxmox.com> MIME-Version: 1.0 User-Agent: astroid/0.15.0 (https://github.com/astroidmail/astroid) Message-Id: <1649402342.wob3khqu37.astroid@nora.none> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-SPAM-LEVEL: Spam detection results: 0 AWL 0.176 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record T_SCC_BODY_TEXT_LINE -0.01 - Subject: Re: [pve-devel] [PATCH pve-cluster 1/3] jobs: move base plugin from pve-manager X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 08 Apr 2022 07:41:26 -0000 On March 22, 2022 8:34 am, Hannes Laimer wrote: > Signed-off-by: Hannes Laimer > --- > data/PVE/Jobs/Makefile | 11 ++++ > data/PVE/Jobs/Plugin.pm | 101 +++++++++++++++++++++++++++++++++++++ > data/PVE/Makefile | 2 +- > debian/pve-cluster.install | 1 + AIUI Thomas would like this to be the start of a new package for=20 node-specific things that can't live in pve-manager, and not be part of=20 the main pve-cluster package. other than that this patch looks good to me! > 4 files changed, 114 insertions(+), 1 deletion(-) > create mode 100644 data/PVE/Jobs/Makefile > create mode 100644 data/PVE/Jobs/Plugin.pm >=20 > diff --git a/data/PVE/Jobs/Makefile b/data/PVE/Jobs/Makefile > new file mode 100644 > index 0000000..4320369 > --- /dev/null > +++ b/data/PVE/Jobs/Makefile > @@ -0,0 +1,11 @@ > +PVEDIR=3D${DESTDIR}/usr/share/perl5/PVE > + > +SOURCES=3DPlugin.pm > + > +.PHONY: install > +install: ${SOURCES} > + install -d -m 0755 ${PVEDIR}/Jobs > + for f in ${SOURCES}; do install -D -m 0644 $$f ${PVEDIR}/Jobs/$$f; done > + > +.PHONY: clean > +clean: > diff --git a/data/PVE/Jobs/Plugin.pm b/data/PVE/Jobs/Plugin.pm > new file mode 100644 > index 0000000..6098360 > --- /dev/null > +++ b/data/PVE/Jobs/Plugin.pm > @@ -0,0 +1,101 @@ > +package PVE::Jobs::Plugin; > + > +use strict; > +use warnings; > + > +use PVE::Cluster qw(cfs_register_file); > + > +use base qw(PVE::SectionConfig); > + > +cfs_register_file( > + 'jobs.cfg', > + sub { __PACKAGE__->parse_config(@_); }, > + sub { __PACKAGE__->write_config(@_); } > +); > + > +my $defaultData =3D { > + propertyList =3D> { > + type =3D> { description =3D> "Section type." }, > + id =3D> { > + description =3D> "The ID of the VZDump job.", > + type =3D> 'string', > + format =3D> 'pve-configid', > + maxLength =3D> 64, > + }, > + enabled =3D> { > + description =3D> "Determines if the job is enabled.", > + type =3D> 'boolean', > + default =3D> 1, > + optional =3D> 1, > + }, > + schedule =3D> { > + description =3D> "Backup schedule. The format is a subset of `syste= md` calendar events.", > + type =3D> 'string', format =3D> 'pve-calendar-event', > + maxLength =3D> 128, > + }, > + comment =3D> { > + optional =3D> 1, > + type =3D> 'string', > + description =3D> "Description for the Job.", > + maxLength =3D> 512, > + }, > + }, > +}; > + > +sub private { > + return $defaultData; > +} > + > +sub parse_config { > + my ($class, $filename, $raw) =3D @_; > + > + my $cfg =3D $class->SUPER::parse_config($filename, $raw); > + > + foreach my $id (sort keys %{$cfg->{ids}}) { > + my $data =3D $cfg->{ids}->{$id}; > + > + $data->{id} =3D $id; > + $data->{enabled} //=3D 1; > + > + if (defined($data->{comment})) { > + $data->{comment} =3D PVE::Tools::decode_text($data->{comment}); > + } > + } > + > + return $cfg; > +} > + > +# call the plugin specific decode/encode code > +sub decode_value { > + my ($class, $type, $key, $value) =3D @_; > + > + my $plugin =3D __PACKAGE__->lookup($type); > + return $plugin->decode_value($type, $key, $value); > +} > + > +sub encode_value { > + my ($class, $type, $key, $value) =3D @_; > + > + my $plugin =3D __PACKAGE__->lookup($type); > + return $plugin->encode_value($type, $key, $value); > +} > + > +sub write_config { > + my ($class, $filename, $cfg) =3D @_; > + > + for my $job (values $cfg->{ids}->%*) { > + if (defined($job->{comment})) { > + $job->{comment} =3D PVE::Tools::encode_text($job->{comment}); > + } > + } > + > + $class->SUPER::write_config($filename, $cfg); > +} > + > +sub run { > + my ($class, $cfg) =3D @_; > + # implement in subclass > + die "not implemented"; > +} > + > +1; > diff --git a/data/PVE/Makefile b/data/PVE/Makefile > index 8ea5383..eecf9f9 100644 > --- a/data/PVE/Makefile > +++ b/data/PVE/Makefile > @@ -10,7 +10,7 @@ PVE_VENDORARCH=3D${DESTDIR}/${PERL_VENDORARCH}/auto/PVE= /IPCC > =20 > PERL_DOC_INC_DIRS:=3D.. > =20 > -SUBDIRS=3DCluster CLI API2 > +SUBDIRS=3DCluster CLI API2 Jobs > SOURCES=3DIPCC.pm Cluster.pm Corosync.pm RRD.pm DataCenterConfig.pm SSHI= nfo.pm > =20 > all: > diff --git a/debian/pve-cluster.install b/debian/pve-cluster.install > index f66cd06..eb15b55 100644 > --- a/debian/pve-cluster.install > +++ b/debian/pve-cluster.install > @@ -3,6 +3,7 @@ usr/bin/create_pmxcfs_db > usr/bin/pmxcfs > usr/lib/ > usr/share/man/man8/pmxcfs.8 > +usr/share/perl5/PVE/Jobs/Plugin.pm > usr/share/perl5/PVE/Cluster.pm > usr/share/perl5/PVE/Cluster/IPCConst.pm > usr/share/perl5/PVE/IPCC.pm > --=20 > 2.30.2 >=20 >=20 >=20 > _______________________________________________ > pve-devel mailing list > pve-devel@lists.proxmox.com > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel >=20 >=20 >=20