[pve-devel] [PATCH pve-client] Add copy-common.sh, move code to PVE/APIClient.
René Jochum
r.jochum at proxmox.com
Wed Jun 13 12:04:17 CEST 2018
---
Makefile | 18 ++++++-------
PVE/{ => APIClient}/CLIHandler.pm | 29 +++++++++++----------
PVE/APIClient/Commands/GuestStatus.pm | 8 +++---
PVE/APIClient/Commands/config.pm | 4 +--
PVE/APIClient/Commands/lxc.pm | 1 -
PVE/APIClient/Commands/remote.pm | 4 +--
PVE/APIClient/Config.pm | 2 +-
PVE/{ => APIClient}/Exception.pm | 10 +++----
PVE/APIClient/Helpers.pm | 2 +-
PVE/{ => APIClient}/JSONSchema.pm | 10 +++----
PVE/{ => APIClient}/PTY.pm | 9 ++++++-
PVE/{ => APIClient}/RESTHandler.pm | 49 +++++++++++++++++++----------------
PVE/{ => APIClient}/SafeSyslog.pm | 2 +-
PVE/{ => APIClient}/SectionConfig.pm | 10 +++----
PVE/{ => APIClient}/Tools.pm | 2 +-
copy-common.sh | 19 ++++++++++++++
16 files changed, 104 insertions(+), 75 deletions(-)
rename PVE/{ => APIClient}/CLIHandler.pm (94%)
rename PVE/{ => APIClient}/Exception.pm (89%)
rename PVE/{ => APIClient}/JSONSchema.pm (99%)
rename PVE/{ => APIClient}/PTY.pm (97%)
rename PVE/{ => APIClient}/RESTHandler.pm (93%)
rename PVE/{ => APIClient}/SafeSyslog.pm (95%)
rename PVE/{ => APIClient}/SectionConfig.pm (97%)
rename PVE/{ => APIClient}/Tools.pm (99%)
create mode 100755 copy-common.sh
diff --git a/Makefile b/Makefile
index b37b3fe..3aed49b 100644
--- a/Makefile
+++ b/Makefile
@@ -21,16 +21,16 @@ deb ${DEB}:
lintian ${DEB}
install: pve-api-definition.dat
- install -d -m 0755 ${LIB_DIR}/PVE
+ install -d -m 0755 ${LIB_DIR}/PVE/APIClient
# install library tools from pve-common
- install -m 0644 PVE/Tools.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/SafeSyslog.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/Exception.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/JSONSchema.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/RESTHandler.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/CLIHandler.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/PTY.pm ${LIB_DIR}/PVE
- install -m 0644 PVE/SectionConfig.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/Tools.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/SafeSyslog.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/Exception.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/JSONSchema.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/RESTHandler.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/CLIHandler.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/PTY.pm ${LIB_DIR}/PVE
+ install -m 0644 PVE/APIClient/SectionConfig.pm ${LIB_DIR}/PVE
# install pveclient
install -D -m 0644 PVE/APIClient/Helpers.pm ${LIB_DIR}/PVE/APIClient/Helpers.pm
install -D -m 0644 PVE/APIClient/Config.pm ${LIB_DIR}/PVE/APIClient/Config.pm
diff --git a/PVE/CLIHandler.pm b/PVE/APIClient/CLIHandler.pm
similarity index 94%
rename from PVE/CLIHandler.pm
rename to PVE/APIClient/CLIHandler.pm
index 514906a..03d9951 100644
--- a/PVE/CLIHandler.pm
+++ b/PVE/APIClient/CLIHandler.pm
@@ -1,13 +1,14 @@
-package PVE::CLIHandler;
+package PVE::APIClient::CLIHandler;
use strict;
use warnings;
-use PVE::SafeSyslog;
-use PVE::Exception qw(raise raise_param_exc);
-use PVE::RESTHandler;
+use PVE::APIClient::SafeSyslog;
+use PVE::APIClient::Exception qw(raise raise_param_exc);
+use PVE::APIClient::RESTHandler;
-use base qw(PVE::RESTHandler);
+
+use base qw(PVE::APIClient::RESTHandler);
# $cmddef defines which (sub)commands are available in a specific CLI class.
# A real command is always an array consisting of its class, name, array of
@@ -22,13 +23,13 @@ use base qw(PVE::RESTHandler);
#
# Examples:
# $cmddef = {
-# command => [ 'PVE::API2::Class', 'command', [ 'arg1', 'arg2' ], { node => $nodename } ],
+# command => [ 'PVE::APIClient::API2::Class', 'command', [ 'arg1', 'arg2' ], { node => $nodename } ],
# do => {
-# this => [ 'PVE::API2::OtherClass', 'method', [ 'arg1' ], undef, sub {
+# this => [ 'PVE::APIClient::API2::OtherClass', 'method', [ 'arg1' ], undef, sub {
# my ($res) = @_;
# print "$res\n";
# }],
-# that => [ 'PVE::API2::OtherClass', 'subroutine' [] ],
+# that => [ 'PVE::APIClient::API2::OtherClass', 'subroutine' [] ],
# },
# dothat => { alias => 'do that' },
# }
@@ -131,7 +132,7 @@ sub generate_usage_str {
$cli_handler_class->can('string_param_file_mapping');
my ($subcmd, $def, undef, undef, $cmdstr) = resolve_cmd($cmd);
- die "no such command '$cmd->[0]'\n" if !defined($def) && ref($cmd) eq 'ARRAY';
+ $abort->("unknown command '$cmdstr'") if !defined($def) && ref($cmd) eq 'ARRAY';
my $generate;
$generate = sub {
@@ -189,7 +190,7 @@ __PACKAGE__->register_method ({
parameters => {
additionalProperties => 0,
properties => {
- 'extra-args' => PVE::JSONSchema::get_standard_option('extra-args', {
+ 'extra-args' => PVE::APIClient::JSONSchema::get_standard_option('extra-args', {
description => 'Shows help for a specific command',
completion => $complete_command_names,
}),
@@ -309,7 +310,7 @@ my $print_bash_completion = sub {
my $cmdline = substr($ENV{COMP_LINE}, 0, $ENV{COMP_POINT});
print STDERR "\nCMDLINE: $ENV{COMP_LINE}\n" if $debug;
- my $args = PVE::Tools::split_args($cmdline);
+ my $args = PVE::APIClient::Tools::split_args($cmdline);
shift @$args; # no need for program name
my $print_result = sub {
foreach my $p (@_) {
@@ -400,7 +401,7 @@ sub verify_api {
my ($class) = @_;
# simply verify all registered methods
- PVE::RESTHandler::validate_method_schemas();
+ PVE::APIClient::RESTHandler::validate_method_schemas();
}
my $get_exe_name = sub {
@@ -476,7 +477,7 @@ my $handle_cmd = sub {
# call verifyapi before setup_environment(), don't execute any real code in
# this case
if ($cmd eq 'verifyapi') {
- PVE::RESTHandler::validate_method_schemas();
+ PVE::APIClient::RESTHandler::validate_method_schemas();
return;
}
@@ -513,7 +514,7 @@ my $handle_simple_cmd = sub {
print STDERR "$str\n\n";
return;
} elsif ($args->[0] eq 'verifyapi') {
- PVE::RESTHandler::validate_method_schemas();
+ PVE::APIClient::RESTHandler::validate_method_schemas();
return;
}
}
diff --git a/PVE/APIClient/Commands/GuestStatus.pm b/PVE/APIClient/Commands/GuestStatus.pm
index 50730db..4a50164 100644
--- a/PVE/APIClient/Commands/GuestStatus.pm
+++ b/PVE/APIClient/Commands/GuestStatus.pm
@@ -43,8 +43,8 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
- my $remote = PVE::Tools::extract_param($param, 'remote');
- my $vmid = PVE::Tools::extract_param($param, 'vmid');
+ my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
+ my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
$guest_status_command->($remote, $vmid, 'start', $param);
@@ -67,8 +67,8 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
- my $remote = PVE::Tools::extract_param($param, 'remote');
- my $vmid = PVE::Tools::extract_param($param, 'vmid');
+ my $remote = PVE::APIClient::Tools::extract_param($param, 'remote');
+ my $vmid = PVE::APIClient::Tools::extract_param($param, 'vmid');
$guest_status_command->($remote, $vmid, 'stop', $param);
diff --git a/PVE/APIClient/Commands/config.pm b/PVE/APIClient/Commands/config.pm
index 4015ad8..6f24e2c 100644
--- a/PVE/APIClient/Commands/config.pm
+++ b/PVE/APIClient/Commands/config.pm
@@ -5,7 +5,7 @@ use warnings;
use Data::Dumper;
use PVE::JSONSchema qw(get_standard_option);
-use PVE::Tools qw(extract_param);
+use PVE::APIClient::Tools qw(extract_param);
use PVE::APIClient::Config;
use PVE::CLIHandler;
@@ -60,7 +60,7 @@ __PACKAGE__->register_method ({
if ($delete) {
my $options = $plugin->private()->{options}->{'defaults'};
- foreach my $k (PVE::Tools::split_list($delete)) {
+ foreach my $k (PVE::APIClient::Tools::split_list($delete)) {
my $d = $options->{$k} ||
die "no such option '$k'\n";
die "unable to delete required option '$k'\n"
diff --git a/PVE/APIClient/Commands/lxc.pm b/PVE/APIClient/Commands/lxc.pm
index 4e76f70..d535188 100644
--- a/PVE/APIClient/Commands/lxc.pm
+++ b/PVE/APIClient/Commands/lxc.pm
@@ -11,7 +11,6 @@ use MIME::Base64;
use Digest::SHA;
use HTTP::Response;
-use PVE::Tools;
use PVE::JSONSchema qw(get_standard_option);
use PVE::CLIHandler;
use PVE::PTY;
diff --git a/PVE/APIClient/Commands/remote.pm b/PVE/APIClient/Commands/remote.pm
index 0f465ea..0c3d17a 100644
--- a/PVE/APIClient/Commands/remote.pm
+++ b/PVE/APIClient/Commands/remote.pm
@@ -4,7 +4,7 @@ use strict;
use warnings;
use PVE::JSONSchema qw(get_standard_option);
-use PVE::Tools qw(extract_param);
+use PVE::APIClient::Tools qw(extract_param);
use PVE::APIClient::Config;
use PVE::CLIHandler;
@@ -127,7 +127,7 @@ __PACKAGE__->register_method ({
if ($delete) {
my $options = $plugin->private()->{options}->{'remote'};
- foreach my $k (PVE::Tools::split_list($delete)) {
+ foreach my $k (PVE::APIClient::Tools::APIClient::split_list($delete)) {
my $d = $options->{$k} ||
die "no such option '$k'\n";
die "unable to delete required option '$k'\n"
diff --git a/PVE/APIClient/Config.pm b/PVE/APIClient/Config.pm
index 166a629..7189d8e 100644
--- a/PVE/APIClient/Config.pm
+++ b/PVE/APIClient/Config.pm
@@ -6,7 +6,7 @@ use JSON;
use PVE::JSONSchema;
use PVE::SectionConfig;
-use PVE::Tools qw(file_get_contents file_set_contents);
+use PVE::APIClient::Tools qw(file_get_contents file_set_contents);
use base qw(PVE::SectionConfig);
diff --git a/PVE/Exception.pm b/PVE/APIClient/Exception.pm
similarity index 89%
rename from PVE/Exception.pm
rename to PVE/APIClient/Exception.pm
index fa6b73a..9e42bc9 100644
--- a/PVE/Exception.pm
+++ b/PVE/APIClient/Exception.pm
@@ -1,7 +1,7 @@
-package PVE::Exception;
+package PVE::APIClient::Exception;
# a way to add more information to exceptions (see man perlfunc (die))
-# use PVE::Exception qw(raise);
+# use PVE::APIClient::Exception qw(raise);
# raise ("my error message", code => 400, errors => { param1 => "err1", ...} );
use strict;
@@ -42,7 +42,7 @@ sub new {
sub raise {
- my $exc = PVE::Exception->new(@_);
+ my $exc = PVE::APIClient::Exception->new(@_);
my ($pkg, $filename, $line) = caller;
@@ -61,7 +61,7 @@ sub raise_perm_exc {
$msg .= " ($what)" if $what;
- my $exc = PVE::Exception->new("$msg\n", %$param);
+ my $exc = PVE::APIClient::Exception->new("$msg\n", %$param);
my ($pkg, $filename, $line) = caller;
@@ -87,7 +87,7 @@ sub raise_param_exc {
$param->{usage} = $usage if $usage;
- my $exc = PVE::Exception->new("Parameter verification failed.\n", %$param);
+ my $exc = PVE::APIClient::Exception->new("Parameter verification failed.\n", %$param);
my ($pkg, $filename, $line) = caller;
diff --git a/PVE/APIClient/Helpers.pm b/PVE/APIClient/Helpers.pm
index 28fd1c4..1ea8a5e 100644
--- a/PVE/APIClient/Helpers.pm
+++ b/PVE/APIClient/Helpers.pm
@@ -175,7 +175,7 @@ sub extract_path_info {
$test_path_properties->([$0, @ARGV]);
} elsif ($cmd eq 'bashcomplete') {
my $cmdline = substr($ENV{COMP_LINE}, 0, $ENV{COMP_POINT});
- my $args = PVE::Tools::split_args($cmdline);
+ my $args = PVE::APIClient::Tools::split_args($cmdline);
$test_path_properties->($args);
}
}
diff --git a/PVE/JSONSchema.pm b/PVE/APIClient/JSONSchema.pm
similarity index 99%
rename from PVE/JSONSchema.pm
rename to PVE/APIClient/JSONSchema.pm
index f014dc3..0c88b63 100644
--- a/PVE/JSONSchema.pm
+++ b/PVE/APIClient/JSONSchema.pm
@@ -1,4 +1,4 @@
-package PVE::JSONSchema;
+package PVE::APIClient::JSONSchema;
use strict;
use warnings;
@@ -7,8 +7,8 @@ use Getopt::Long;
use Encode::Locale;
use Encode;
use Devel::Cycle -quiet; # todo: remove?
-use PVE::Tools qw(split_list $IPV6RE $IPV4RE);
-use PVE::Exception qw(raise);
+use PVE::APIClient::Tools qw(split_list $IPV6RE $IPV4RE);
+use PVE::APIClient::Exception qw(raise);
use HTTP::Status qw(:constants);
use Net::IP qw(:PROC);
use Data::Dumper;
@@ -146,7 +146,7 @@ sub pve_verify_configid {
return $id;
}
-PVE::JSONSchema::register_format('pve-storage-id', \&parse_storage_id);
+PVE::APIClient::JSONSchema::register_format('pve-storage-id', \&parse_storage_id);
sub parse_storage_id {
my ($storeid, $noerr) = @_;
@@ -466,7 +466,7 @@ sub pve_parse_startup_order {
return $res;
}
-PVE::JSONSchema::register_standard_option('pve-startup-order', {
+PVE::APIClient::JSONSchema::register_standard_option('pve-startup-order', {
description => "Startup and shutdown behavior. Order is a non-negative number defining the general startup order. Shutdown in done with reverse ordering. Additionally you can set the 'up' or 'down' delay in seconds, which specifies a delay to wait before the next VM is started or stopped.",
optional => 1,
type => 'string', format => 'pve-startup-order',
diff --git a/PVE/PTY.pm b/PVE/APIClient/PTY.pm
similarity index 97%
rename from PVE/PTY.pm
rename to PVE/APIClient/PTY.pm
index 23d76c0..ee5010c 100644
--- a/PVE/PTY.pm
+++ b/PVE/APIClient/PTY.pm
@@ -1,4 +1,4 @@
-package PVE::PTY;
+package PVE::APIClient::PTY;
use strict;
use warnings;
@@ -228,6 +228,13 @@ sub read_password($;$$) {
return $password;
}
+sub get_confirmed_password {
+ my $pw1 = read_password('Enter new password: ');
+ my $pw2 = read_password('Retype new password: ');
+ die "passwords do not match\n" if $pw1 ne $pw2;
+ return $pw1;
+}
+
# Class functions
sub new {
diff --git a/PVE/RESTHandler.pm b/PVE/APIClient/RESTHandler.pm
similarity index 93%
rename from PVE/RESTHandler.pm
rename to PVE/APIClient/RESTHandler.pm
index 5e70503..ef30ba9 100644
--- a/PVE/RESTHandler.pm
+++ b/PVE/APIClient/RESTHandler.pm
@@ -1,12 +1,12 @@
-package PVE::RESTHandler;
+package PVE::APIClient::RESTHandler;
use strict;
no strict 'refs'; # our autoload requires this
use warnings;
-use PVE::SafeSyslog;
-use PVE::Exception qw(raise raise_param_exc);
-use PVE::JSONSchema;
-use PVE::Tools;
+use PVE::APIClient::SafeSyslog;
+use PVE::APIClient::Exception qw(raise raise_param_exc);
+use PVE::APIClient::JSONSchema;
+use PVE::APIClient::Tools;
use HTTP::Status qw(:constants :is status_message);
use Text::Wrap;
use Clone qw(clone);
@@ -45,7 +45,7 @@ sub api_clone_schema {
# NOTE: add typetext property for more complex types, to
# make the web api viewer code simpler
if (!(defined($tmp->{enum}) || defined($tmp->{pattern}))) {
- my $typetext = PVE::JSONSchema::schema_get_type_text($tmp);
+ my $typetext = PVE::APIClient::JSONSchema::schema_get_type_text($tmp);
if ($tmp->{type} && ($tmp->{type} ne $typetext)) {
$tmp->{typetext} = $typetext;
}
@@ -58,7 +58,7 @@ sub api_clone_schema {
}
sub api_dump_full {
- my ($tree, $index, $class, $prefix) = @_;
+ my ($tree, $index, $class, $prefix, $raw_dump) = @_;
$prefix = '' if !$prefix;
@@ -70,7 +70,7 @@ sub api_dump_full {
$path =~ s/\/+$//;
if ($info->{subclass}) {
- api_dump_full($tree, $index, $info->{subclass}, $path);
+ api_dump_full($tree, $index, $info->{subclass}, $path, $raw_dump);
} else {
next if !$path;
@@ -110,12 +110,15 @@ sub api_dump_full {
$k eq "path";
my $d = $info->{$k};
-
- if ($k eq 'parameters') {
- $data->{$k} = api_clone_schema($d);
- } else {
- $data->{$k} = ref($d) ? clone($d) : $d;
+ if ($raw_dump) {
+ $data->{$k} = $d;
+ } else {
+ if ($k eq 'parameters') {
+ $data->{$k} = api_clone_schema($d);
+ } else {
+ $data->{$k} = ref($d) ? clone($d) : $d;
+ }
}
}
$res->{info}->{$info->{method}} = $data;
@@ -173,12 +176,12 @@ sub api_dump_remove_refs {
}
sub api_dump {
- my ($class, $prefix) = @_;
+ my ($class, $prefix, $raw_dump) = @_;
my $tree = [];
my $index = {};
- api_dump_full($tree, $index, $class);
+ api_dump_full($tree, $index, $class, $prefix, $raw_dump);
api_dump_cleanup_tree($tree);
return $tree;
};
@@ -189,7 +192,7 @@ sub validate_method_schemas {
my $ma = $method_registry->{$class};
foreach my $info (@$ma) {
- PVE::JSONSchema::validate_method_info($info);
+ PVE::APIClient::JSONSchema::validate_method_info($info);
}
}
}
@@ -402,7 +405,7 @@ sub handle {
if (my $schema = $info->{parameters}) {
# warn "validate ". Dumper($param}) . "\n" . Dumper($schema);
- PVE::JSONSchema::validate($param, $schema);
+ PVE::APIClient::JSONSchema::validate($param, $schema);
# untaint data (already validated)
my $extra = delete $param->{'extra-args'};
while (my ($key, $val) = each %$param) {
@@ -415,7 +418,7 @@ sub handle {
# todo: this is only to be safe - disable?
if (my $schema = $info->{returns}) {
- PVE::JSONSchema::validate($result, $schema, "Result verification failed\n");
+ PVE::APIClient::JSONSchema::validate($result, $schema, "Result verification failed\n");
}
return $result;
@@ -444,7 +447,7 @@ my $get_property_description = sub {
chomp $descr;
- my $type_text = PVE::JSONSchema::schema_get_type_text($phash, $style);
+ my $type_text = PVE::APIClient::JSONSchema::schema_get_type_text($phash, $style);
if ($hidepw && $name eq 'password') {
$type_text = '';
@@ -552,7 +555,7 @@ my $compute_param_mapping_hash = sub {
($name, $func, $desc, $interactive) = @$item;
} else {
$name = $item;
- $func = sub { return PVE::Tools::file_get_contents($_[0]) };
+ $func = sub { return PVE::APIClient::Tools::file_get_contents($_[0]) };
}
$desc //= '<filepath>';
$res->{$name} = { desc => $desc, func => $func, interactive => $interactive };
@@ -708,7 +711,7 @@ sub dump_properties {
next if !$prop_fmt;
if (ref($prop_fmt) ne 'HASH') {
- $prop_fmt = PVE::JSONSchema::get_format($prop_fmt);
+ $prop_fmt = PVE::APIClient::JSONSchema::get_format($prop_fmt);
}
next if !(ref($prop_fmt) && (ref($prop_fmt) eq 'HASH'));
@@ -740,7 +743,7 @@ sub cli_handler {
my $res;
eval {
my $param_mapping_hash = $compute_param_mapping_hash->($param_mapping_func->($name)) if $param_mapping_func;
- my $param = PVE::JSONSchema::get_options($info->{parameters}, $args, $arg_param, $fixed_param, $read_password_func, $param_mapping_hash);
+ my $param = PVE::APIClient::JSONSchema::get_options($info->{parameters}, $args, $arg_param, $fixed_param, $read_password_func, $param_mapping_hash);
if (defined($param_mapping_hash)) {
&$replace_file_names_with_contents($param, $param_mapping_hash);
@@ -751,7 +754,7 @@ sub cli_handler {
if (my $err = $@) {
my $ec = ref($err);
- die $err if !$ec || $ec ne "PVE::Exception" || !$err->is_param_exc();
+ die $err if !$ec || $ec ne "PVE::APIClient::Exception" || !$err->is_param_exc();
$err->{usage} = $self->usage_str($name, $prefix, $arg_param, $fixed_param, 'short', $read_password_func, $param_mapping_func);
diff --git a/PVE/SafeSyslog.pm b/PVE/APIClient/SafeSyslog.pm
similarity index 95%
rename from PVE/SafeSyslog.pm
rename to PVE/APIClient/SafeSyslog.pm
index 63b37f8..3b31c86 100644
--- a/PVE/SafeSyslog.pm
+++ b/PVE/APIClient/SafeSyslog.pm
@@ -1,4 +1,4 @@
-package PVE::SafeSyslog;
+package PVE::APIClient::SafeSyslog;
use strict;
use warnings;
diff --git a/PVE/SectionConfig.pm b/PVE/APIClient/SectionConfig.pm
similarity index 97%
rename from PVE/SectionConfig.pm
rename to PVE/APIClient/SectionConfig.pm
index cc03aea..28224e8 100644
--- a/PVE/SectionConfig.pm
+++ b/PVE/APIClient/SectionConfig.pm
@@ -1,10 +1,10 @@
-package PVE::SectionConfig;
+package PVE::APIClient::SectionConfig;
use strict;
use warnings;
use Digest::SHA;
-use PVE::Exception qw(raise_param_exc);
-use PVE::JSONSchema qw(get_standard_option);
+use PVE::APIClient::Exception qw(raise_param_exc);
+use PVE::APIClient::JSONSchema qw(get_standard_option);
use Data::Dumper;
@@ -251,7 +251,7 @@ sub check_value {
if (!$skipSchemaCheck) {
my $errors = {};
- PVE::JSONSchema::check_prop($value, $schema, '', $errors);
+ PVE::APIClient::JSONSchema::check_prop($value, $schema, '', $errors);
if (scalar(keys %$errors)) {
die "$errors->{$key}\n" if $errors->{$key};
die "$errors->{_root}\n" if $errors->{_root};
@@ -491,7 +491,7 @@ sub write_config {
sub assert_if_modified {
my ($cfg, $digest) = @_;
- PVE::Tools::assert_if_modified($cfg->{digest}, $digest);
+ PVE::APIClient::Tools::assert_if_modified($cfg->{digest}, $digest);
}
1;
diff --git a/PVE/Tools.pm b/PVE/APIClient/Tools.pm
similarity index 99%
rename from PVE/Tools.pm
rename to PVE/APIClient/Tools.pm
index cd55932..754ecb5 100644
--- a/PVE/Tools.pm
+++ b/PVE/APIClient/Tools.pm
@@ -1,4 +1,4 @@
-package PVE::Tools;
+package PVE::APIClient::Tools;
use strict;
use warnings;
diff --git a/copy-common.sh b/copy-common.sh
new file mode 100755
index 0000000..8f062a6
--- /dev/null
+++ b/copy-common.sh
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+FILES=(
+ "CLIHandler.pm"
+ "Exception.pm"
+ "JSONSchema.pm"
+ "PTY.pm"
+ "RESTHandler.pm"
+ "SafeSyslog.pm"
+ "SectionConfig.pm"
+)
+
+for i in "${FILES[@]}"; do
+ cp ../pve-common/src/PVE/$i PVE/APIClient/
+ sed -i 's/PVE::/PVE::APIClient::/g' PVE/APIClient/$i;
+done
+
+# Remove INotify from CLIHandler.pm
+sed -i 's/use PVE::APIClient::INotify;//' PVE/APIClient/CLIHandler.pm
\ No newline at end of file
--
2.11.0
More information about the pve-devel
mailing list