[pve-devel] [PATCH pve-guest-common] PVE::ReplicationConfig - use new ID format "<vmid>-<num>"
Dietmar Maurer
dietmar at proxmox.com
Fri Jun 2 12:27:19 CEST 2017
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/ReplicationConfig.pm | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
index 092c497..923995e 100644
--- a/PVE/ReplicationConfig.pm
+++ b/PVE/ReplicationConfig.pm
@@ -22,8 +22,8 @@ cfs_register_file($replication_cfg_filename,
PVE::JSONSchema::register_standard_option('pve-replication-id', {
description => "Replication Job ID.",
- type => 'string', format => 'pve-configid',
- maxLength => 32, # keep short to reduce snapshot name length
+ type => 'string',
+ pattern => '[1-9][0-9]{2,8}-\d{1,9}',
});
my $defaultData = {
@@ -73,12 +73,16 @@ sub private {
sub parse_section_header {
my ($class, $line) = @_;
- if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
- my ($type, $id) = (lc($1), $2);
+ if ($line =~ m/^(\S+):\s*(\d+)-(\d+)\s*$/) {
+ my ($type, $guest, $subid) = (lc($1), int($2), int($3));
+ my $id = "$guest-$subid"; # use parsed integers
my $errmsg = undef; # set if you want to skip whole section
- eval { PVE::JSONSchema::pve_verify_configid($id); };
+ eval {
+ die "invalid replication job id '$id'\n" if $subid < 1;
+ PVE::JSONSchema::pve_verify_vmid($guest);
+ };
$errmsg = $@ if $@;
- my $config = {};
+ my $config = { guest => $guest };
return ($type, $id, $errmsg, $config);
}
return undef;
--
2.11.0
More information about the pve-devel
mailing list