my $set_text = PVE::Tools::file_read_firstline($filename) // '';
my $cpuset = $this->new();
-
+
my $members = $cpuset->{members};
my $count = 0;
my ($self, @members) = @_;
my $count = 0;
-
+
foreach my $cpu (@members) {
next if $self->{members}->{$cpu};
$self->{members}->{$cpu} = 1;
my ($self, @members) = @_;
my $count = 0;
-
+
foreach my $cpu (@members) {
next if !$self->{members}->{$cpu};
delete $self->{members}->{$cpu};
my ($self) = @_;
return sort { $a <=> $b } keys %{$self->{members}};
-}
+}
sub size {
my ($self) = @_;
foreach my $id (keys %$members2) {
return 0 if !$members1->{$id};
}
-
+
return 1;
}
# * allow to restart while workers are still runningl
# (option 'leave_children_open_on_reload')
# * run as different user using setuid/setgid
-
+
use strict;
use warnings;
use English;
for my $sig (qw(CHLD HUP INT TERM QUIT)) {
$SIG{$sig} = 'DEFAULT'; # restore default handler
- # AnyEvent signals only works if $SIG{XX} is
+ # AnyEvent signals only works if $SIG{XX} is
# undefined (perl event loop)
delete $SIG{$sig}; # so that we can handle events with AnyEvent
}
if (my $fd = $self->{env_pve_lock_fd}) {
$self->{daemon_lock_fh} = IO::Handle->new_from_fd($fd, "a");
-
+
} else {
$waittime = 5;
syslog('info' , "starting server");
}
- POSIX::setsid();
+ POSIX::setsid();
open STDERR, '>&STDOUT' || die "can't close STDERR\n";
}
};
- eval {
+ eval {
if ($self->{max_workers}) {
my $old_sig_chld = $SIG{CHLD};
local $SIG{CHLD} = sub {
};
# now loop forever (until we receive terminate signal)
- for (;;) {
+ for (;;) {
&$start_workers($self);
sleep(5);
&$terminate_old_workers($self);
} else {
$self->run();
- }
+ }
};
my $err = $@;
eval {
my $class = ref($this) || $this;
- $self = bless {
+ $self = bless {
name => $name,
pidfile => "/var/run/${name}.pid",
workers => {},
die "unknown daemon option '$opt'\n";
}
}
-
+
# untaint
$self->{cmdline} = [map { /^(.*)$/ } @$cmdline];
return 0 if !$pid_str;
return 0 if $pid_str !~ m/^(\d+)$/; # untaint
-
+
my $pid = int($1);
return $pid;
} else {
return 0;
}
-};
+};
sub running {
my ($self) = @_;
}
return undef;
- }});
+ }});
}
my $reload_daemon = sub {
if ($self->{env_restart_pve_daemon}) {
$self->start();
} else {
- my ($running, $pid) = $self->running();
+ my ($running, $pid) = $self->running();
if (!$running) {
$self->start();
} else {
}
return undef;
- }});
+ }});
}
sub register_reload_command {
&$reload_daemon($self, 1);
return undef;
- }});
+ }});
}
sub register_stop_command {
code => sub {
my ($param) = @_;
-
+
if (&$init_ppid()) {
$self->stop();
} else {
}
return undef;
- }});
+ }});
}
sub register_status_command {
additionalProperties => 0,
properties => {},
},
- returns => {
+ returns => {
type => 'string',
enum => ['stopped', 'running'],
},
if (defined($sockfd = $ENV{"PVE_DAEMON_SOCKET_$port"}) &&
$self->{env_restart_pve_daemon}) {
- die "unable to parse socket fd '$sockfd'\n"
+ die "unable to parse socket fd '$sockfd'\n"
if $sockfd !~ m/^(\d+)$/;
$sockfd = $1; # untaint
$socket = IO::Socket::IP->new;
- $socket->fdopen($sockfd, 'w') ||
+ $socket->fdopen($sockfd, 'w') ||
die "cannot fdopen file descriptor '$sockfd' - $!\n";
$socket->fcntl(Fcntl::F_SETFD(), Fcntl::FD_CLOEXEC);
use strict;
use warnings;
-use Storable qw(dclone);
+use Storable qw(dclone);
use HTTP::Status qw(:constants);
use overload '""' => sub {local $@; shift->stringify};
use overload 'cmp' => sub {
my ($a, $b) = @_;
- local $@;
+ local $@;
return "$a" cmp "$b"; # compare as string
};
};
foreach my $p (keys %param) {
- next if defined($self->{$p});
+ next if defined($self->{$p});
my $v = $param{$p};
$self->{$p} = ref($v) ? dclone($v) : $v;
}
sub raise {
my $exc = PVE::Exception->new(@_);
-
+
my ($pkg, $filename, $line) = caller;
$exc->{filename} = $filename;
my $param = { code => HTTP_FORBIDDEN };
my $msg = "Permission check failed";
-
+
$msg .= " ($what)" if $what;
my $exc = PVE::Exception->new("$msg\n", %$param);
-
+
my ($pkg, $filename, $line) = caller;
$exc->{filename} = $filename;
$param->{usage} = $usage if $usage;
my $exc = PVE::Exception->new("Parameter verification failed.\n", %$param);
-
+
my ($pkg, $filename, $line) = caller;
$exc->{filename} = $filename;
sub stringify {
my $self = shift;
-
+
my $msg = $self->{code} ? "$self->{code} $self->{msg}" : $self->{msg};
if ($msg !~ m/\n$/) {
sub PROPAGATE {
my ($self, $file, $line) = @_;
- push @{$self->{propagate}}, [$file, $line];
+ push @{$self->{propagate}}, [$file, $line];
return $self;
}
$cp->{$k} = $v;
}
$ccache->{$filename} = $cp;
- }
+ }
return ($ccache->{$filename}, $filename);
}
}
-
+
$filename = $ccachemap->{$filename} if defined ($ccachemap->{$filename});
die "file '$filename' not added :ERROR" if !defined ($ccache->{$filename});
-
+
return ($ccache->{$filename}, $filename);
}
if (!rename($tmpname, $realname)) {
my $msg = "close (rename) atomic file '$filename' failed: $!\n";
unlink $tmpname;
- die $msg;
+ die $msg;
}
my $diff;
my $code = sub {
$fd = IO::File->new ($filename, "r");
-
+
my $new = &$update($filename, $fd, $data, @args);
if (defined($new)) {
my $parser;
my ($ccinfo, $filename) = ccache_info($fileid);
-
+
$parser = $ccinfo->{parser};
-
+
my $fd;
my $shadow;
if (!$fd) {
$ccinfo->{version} = undef;
- $ccinfo->{data} = undef;
+ $ccinfo->{data} = undef;
$ccinfo->{diff} = undef;
return undef if !$acp;
}
$ret->{data} = $ccinfo->{data};
}
$ret->{changes} = $ccinfo->{diff};
-
+
return $full ? $ret : $ret->{data};
}
$ret->{changes} = $ccinfo->{diff};
return $full ? $ret : $ret->{data};
-}
+}
sub parse_ccache_options {
my ($ccinfo, %options) = @_;
$ccinfo->{update} = $update;
parse_ccache_options($ccinfo, %options);
-
+
if ($options{shadow}) {
$shadowfiles->{$filename} = $options{shadow};
}
my $uid = "$dir/$regex";
die "regular expression '$uid' already added :ERROR" if defined ($ccacheregex->{$uid});
-
+
my $ccinfo = {};
$ccinfo->{dir} = $dir;
foreach my $uid (keys %$ccacheregex) {
my $ccinfo = $ccacheregex->{$uid};
- $dirhash->{$ccinfo->{dir}}->{_regex} = 1;
+ $dirhash->{$ccinfo->{dir}}->{_regex} = 1;
}
$inotify_pid = $$;
syslog ('err', "got 'unmount' event on '$name' - disabling inotify");
$inotify = undef;
}
- if ($e->IN_IGNORED) {
+ if ($e->IN_IGNORED) {
syslog ('err', "got 'ignored' event on '$name' - disabling inotify");
$inotify = undef;
}
next if $dir ne $ccinfo->{dir};
my $re = $ccinfo->{regex};
if (my $fd = IO::Dir->new ($dir)) {
- while (defined(my $de = $fd->read)) {
+ while (defined(my $de = $fd->read)) {
if ($de =~ m/^$re$/) {
my $fn = "$dir/$de";
$versions->{$fn}++; # init with version
return $hostname;
}
-register_file('hostname', "/etc/hostname",
- \&read_etc_hostname,
+register_file('hostname', "/etc/hostname",
+ \&read_etc_hostname,
\&write_etc_hostname);
sub read_etc_hosts {
next if $line =~ m/^(search|domain|nameserver)\s+/;
$data .= $line
}
-
+
return $data;
}
-register_file('resolvconf', "/etc/resolv.conf",
- \&read_etc_resolv_conf, undef,
+register_file('resolvconf', "/etc/resolv.conf",
+ \&read_etc_resolv_conf, undef,
\&update_etc_resolv_conf);
sub read_etc_timezone {
}
-register_file('timezone', "/etc/timezone",
- \&read_etc_timezone,
+register_file('timezone', "/etc/timezone",
+ \&read_etc_timezone,
\&write_etc_timezone);
sub read_active_workers {
return [] if !$fh;
- my $res = [];
+ my $res = [];
while (defined (my $line = <$fh>)) {
if ($line =~ m/^(\S+)\s(0|1)(\s([0-9A-Za-z]{8})(\s(\s*\S.*))?)?$/) {
my $upid = $1;
PVE::Tools::safe_print($filename, $fh, $raw) if $raw;
}
-register_file('active', "/var/log/pve/tasks/active",
+register_file('active', "/var/log/pve/tasks/active",
\&read_active_workers,
\&write_active_workers);
'active-backup' => 1,
'balance-slb' => 1,
'lacp-balance-slb' => 1,
- 'lacp-balance-tcp' => 1,
+ 'lacp-balance-tcp' => 1,
};
#sub get_bond_modes {
}
# we try to keep order inside the file
- my $priority = 2; # 1 is reserved for lo
+ my $priority = 2; # 1 is reserved for lo
SECTION: while (defined ($line = <$fh>)) {
chomp ($line);
next if $line =~ m/^\s*#/;
-
+
if ($line =~ m/^\s*auto\s+(.*)$/) {
my @aa = split (/\s+/, $1);
}
$done->{bridge_vlan_aware} = 1;
$done->{bridge_vids} = 1;
-
+
} elsif ($d->{type} eq 'bond') {
$d->{slaves} =~ s/[;,\s]+/ /g;
}
$done->{'bond_xmit_hash_policy'} = 1;
} elsif ($d->{type} eq 'vlan') {
- die "$iface: wrong vlan-protocol $d->{'vlan-protocol'}\n"
+ die "$iface: wrong vlan-protocol $d->{'vlan-protocol'}\n"
if $d->{'vlan-protocol'} && $d->{'vlan-protocol'} ne '802.1ad' && $d->{'vlan-protocol'} ne '802.1q';
-
+
} elsif ($d->{type} eq 'vxlan') {
foreach my $k (qw(vxlan-id vxlan-svcnodeip vxlan-physdev vxlan-local-tunnelip)) {
my $d = $ifaces->{$iface};
if (my $uplinkid = $d->{'uplink-id'}) {
die "iface '$iface' - uplink-id $uplinkid is only allowed on physical and linux bond interfaces\n"
- if $d->{type} ne 'eth' && $d->{type} ne 'bond';
+ if $d->{type} ne 'eth' && $d->{type} ne 'bond';
die "iface '$iface' - uplink-id $uplinkid is already assigned on '$uplinks->{$uplinkid}'\n"
if $uplinks->{$uplinkid};
return 'undefined';
}
-register_file('initiatorname', "/etc/iscsi/initiatorname.iscsi",
+register_file('initiatorname', "/etc/iscsi/initiatorname.iscsi",
\&read_iscsi_initiatorname);
sub read_apt_auth {
$raw =~ s/^\s+//;
-
+
my @tokens = split(/\s+/, $raw);
my $data = {};
my $raw = &$format_apt_auth_data($data);
die "write failed: $!" unless print $fh "$raw\n";
-
+
return $data;
}
return &$format_apt_auth_data($orig);
}
-register_file('apt-auth', "/etc/apt/auth.conf",
+register_file('apt-auth', "/etc/apt/auth.conf",
\&read_apt_auth, \&write_apt_auth,
\&update_apt_auth, perm => 0640);
use base 'Exporter';
our @EXPORT_OK = qw(
-register_standard_option
+register_standard_option
get_standard_option
);
-# Note: This class implements something similar to JSON schema, but it is not 100% complete.
+# Note: This class implements something similar to JSON schema, but it is not 100% complete.
# see: http://tools.ietf.org/html/draft-zyp-json-schema-02
# see: http://json-schema.org/
sub register_standard_option {
my ($name, $schema) = @_;
- die "standard option '$name' already registered\n"
+ die "standard option '$name' already registered\n"
if $standard_options->{$name};
$standard_options->{$name} = $schema;
register_standard_option('pve-storage-id', {
description => "The storage identifier.",
type => 'string', format => 'pve-storage-id',
-});
+});
register_standard_option('pve-config-digest', {
description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
sub register_format {
my ($format, $code) = @_;
- die "JSON schema format '$format' already registered\n"
+ die "JSON schema format '$format' already registered\n"
if $format_list->{$format};
$format_list->{$format} = $code;
register_format('pve-configid', \&pve_verify_configid);
sub pve_verify_configid {
my ($id, $noerr) = @_;
-
+
if ($id !~ m/^[a-z][a-z0-9_]+$/i) {
return undef if $noerr;
- die "invalid configuration ID '$id'\n";
+ die "invalid configuration ID '$id'\n";
}
return $id;
}
register_format('pve-iface', \&pve_verify_iface);
sub pve_verify_iface {
my ($id, $noerr) = @_;
-
+
if ($id !~ m/^[a-z][a-z0-9_]{1,20}([:\.]\d+)?$/i) {
return undef if $noerr;
- die "invalid network interface name '$id'\n";
+ die "invalid network interface name '$id'\n";
}
return $id;
}
register_standard_option('spice-proxy', {
description => "SPICE proxy server. This can be used by the client to specify the proxy server. All nodes in a cluster runs 'spiceproxy', so it is up to the client to choose one. By default, we return the node where the VM is currently running. As reasonable setting is to use same node you use to connect to the API (This is window.location.hostname for the JS GUI).",
type => 'string', format => 'address',
-});
+});
register_standard_option('remote-viewer-config', {
description => "Returned values can be directly passed to the 'remote-viewer' application.",
return if $format eq 'regex';
if ($format =~ m/^(.*)-a?list$/) {
-
+
my $code = $format_list->{$1};
die "undefined format '$format'\n" if !$code;
return parse_property_string($code, $value, $path) if ref($code) eq 'HASH';
&$code($value);
}
-}
+}
sub parse_size {
my ($value) = @_;
my ($errors, $path, $msg) = @_;
$path = '_root' if !$path;
-
+
if ($errors->{$path}) {
$errors->{$path} = join ('\n', $errors->{$path}, $msg);
} else {
my $value = shift;
# see 'man perlretut'
- return $value =~ /^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/;
+ return $value =~ /^[+-]?(\d+\.\d+|\d+\.|\.\d+|\d+)([eE][+-]?\d+)?$/;
}
sub is_integer {
if (!defined($value)) {
return 1 if $type eq 'null';
- die "internal error"
+ die "internal error"
}
if (my $tt = ref($type)) {
foreach my $t (@$type) {
my $tmperr = {};
check_type($path, $t, $value, $tmperr);
- return 1 if !scalar(%$tmperr);
+ return 1 if !scalar(%$tmperr);
}
my $ttext = join ('|', @$type);
- add_error($errors, $path, "type check ('$ttext') failed");
+ add_error($errors, $path, "type check ('$ttext') failed");
return undef;
} elsif ($tt eq 'HASH') {
my $tmperr = {};
check_prop($value, $type, $path, $tmperr);
- return 1 if !scalar(%$tmperr);
- add_error($errors, $path, "type check failed");
+ return 1 if !scalar(%$tmperr);
+ add_error($errors, $path, "type check failed");
return undef;
} else {
die "internal error - got reference type '$tt'";
}
}
}
- }
+ }
return undef;
}
#print "TEST: " . Dumper($value) . "\n", Dumper($requires) ;
check_prop($value, $requires, $path, $errors);
} elsif (!defined($value->{$requires})) {
- add_error($errors, $path ? "$path.$requires" : $requires,
+ add_error($errors, $path ? "$path.$requires" : $requires,
"missing property - '$newpath' requires this property");
}
}
}
}
}
- return;
+ return;
} elsif ($schema->{properties} || $schema->{additionalProperties}) {
check_object($path, defined($schema->{properties}) ? $schema->{properties} : {},
$value, $schema->{additionalProperties}, $errors);
return;
}
}
-
+
if (is_number($value)) {
if (defined (my $max = $schema->{maximum})) {
- if ($value > $max) {
+ if ($value > $max) {
add_error($errors, $path, "value must have a maximum value of $max");
return;
}
}
if (defined (my $min = $schema->{minimum})) {
- if ($value < $min) {
+ if ($value < $min) {
add_error($errors, $path, "value must have a minimum value of $min");
return;
}
} elsif ($schema) {
check_prop($instance, $schema, '', $errors);
}
-
+
if (scalar(%$errors)) {
raise $errmsg, code => HTTP_BAD_REQUEST, errors => $errors;
}
optional => 1,
minimum => 0,
default => 0,
- },
+ },
maxLength => {
type => "integer",
description => "When the instance value is a string, this indicates maximum length of the string.",
description => "For CLI context, this defines the maximal width to print before truncating",
optional => 1,
},
- }
+ }
};
my $default_schema = Storable::dclone($default_schema_noref);
path => {},
parameters => {},
returns => {},
- }
+ }
},
},
method => {
},
protected => {
type => 'boolean',
- description => "Method needs special privileges - only pvedaemon can execute it",
+ description => "Method needs special privileges - only pvedaemon can execute it",
optional => 1,
},
download => {
optional => 1,
},
user => {
- description => "A simply way to allow access for 'all' authenticated users. Value 'world' is used to allow access without credentials.",
- type => 'string',
+ description => "A simply way to allow access for 'all' authenticated users. Value 'world' is used to allow access without credentials.",
+ type => 'string',
enum => ['all', 'world'],
optional => 1,
},
check => {
description => "Array of permission checks (prefix notation).",
- type => 'array',
- optional => 1
+ type => 'array',
+ optional => 1
},
},
},
match_name => {},
match_re => {},
fragmentDelimiter => { optional => 1 }
- }
+ }
},
- },
+ },
},
};
sub validate_schema {
- my ($schema) = @_;
+ my ($schema) = @_;
my $errmsg = "internal error - unable to verify schema\n";
validate($schema, $default_schema, $errmsg);
my $errmsg = "internal error - unable to verify method info\n";
validate($info, $method_schema, $errmsg);
-
+
validate_schema($info->{parameters}) if $info->{parameters};
validate_schema($info->{returns}) if $info->{returns};
}
# run a self test on load
-# make sure we can verify the default schema
+# make sure we can verify the default schema
validate_schema($default_schema_noref);
validate_schema($method_schema);
return $found;
}
-# a way to parse command line parameters, using a
+# a way to parse command line parameters, using a
# schema to configure Getopt::Long
sub get_options {
my ($schema, $args, $arg_param, $fixed_param, $param_mapping_hash) = @_;
}
}
}
- }
+ }
}
foreach my $p (keys %$fixed_param) {
my ($schema, $filename, $raw) = @_;
# do fast check (avoid validate_schema($schema))
- die "got strange schema" if !$schema->{type} ||
+ die "got strange schema" if !$schema->{type} ||
!$schema->{properties} || $schema->{type} ne 'object';
my $cfg = {};
if ($line =~ m/^(\S+?):\s*(.*)$/) {
my $key = $1;
my $value = $2;
- if ($schema->{properties}->{$key} &&
+ if ($schema->{properties}->{$key} &&
$schema->{properties}->{$key}->{type} eq 'boolean') {
$value = parse_boolean($value) // $value;
foreach my $k (keys %$errors) {
warn "parse error in '$filename' - '$k': $errors->{$k}\n";
delete $cfg->{$k};
- }
+ }
return $cfg;
}
my ($schema, $filename, $cfg) = @_;
# do fast check (avoid validate_schema($schema))
- die "got strange schema" if !$schema->{type} ||
+ die "got strange schema" if !$schema->{type} ||
!$schema->{properties} || $schema->{type} ne 'object';
validate($cfg, $schema, "validation error in '$filename'\n");
} else {
system("/sbin/bridge vlan add dev $iface vid 2-4094") == 0 ||
die "unable to add default vlan tags to interface $iface\n" if !$trunks;
- }
+ }
if ($trunks) {
my @trunks_array = split /;/, $trunks;
- foreach my $trunk (@trunks_array) {
+ foreach my $trunk (@trunks_array) {
system("/sbin/bridge vlan add dev $iface vid $trunk") == 0 ||
die "unable to add vlan $trunk to interface $iface\n";
}
my $bridgemtu = &$read_bridge_mtu($bridge);
- eval {
+ eval {
disable_ipv6($iface);
PVE::Tools::run_command(['/sbin/ip', 'link', 'set', $iface, 'up', 'promisc', 'on', 'mtu', $bridgemtu]);
};
# set the same mtu for ovs int port
PVE::Tools::run_command(['/sbin/ip', 'link', 'set', $ovsintport, 'mtu', $bridgemtu]);
-
+
&$bridge_add_interface($fwbr, $ovsintport);
};
my ($iface) = @_;
my ($vmid, $devid) = &$parse_tap_device_name($iface, 1);
- return if !defined($vmid);
+ return if !defined($vmid);
my ($fwbr, $vethfw, $vethfwpeer, $ovsintport) = &$compute_fwbr_names($vmid, $devid);
# cleanup old port config from any openvswitch bridge
iface_set_master($iface, undef);
}
-
+
&$cleanup_firewall_bridge($iface);
#cleanup old port config from any openvswitch bridge
eval {run_command("/usr/bin/ovs-vsctl del-port $iface", outfunc => sub {}, errfunc => sub {}) };
return if $br0 eq $br1;
- my $br_configs = [ 'ageing_time', 'stp_state', 'priority', 'forward_delay',
+ my $br_configs = [ 'ageing_time', 'stp_state', 'priority', 'forward_delay',
'hello_time', 'max_age', 'multicast_snooping', 'multicast_querier'];
foreach my $sysname (@$br_configs) {
sub activate_bridge_vlan_slave {
my ($bridgevlan, $iface, $tag) = @_;
my $ifacevlan = "${iface}.$tag";
-
+
# create vlan on $iface is not already exist
if (! -d "/sys/class/net/$ifacevlan") {
system("/sbin/ip link add link $iface name $ifacevlan type vlan id $tag") == 0 ||
# for processes spanned by other processes.
# kill(0, pid) return succes for zombies.
# So we read the status form /proc/$pid/stat instead
-
+
my $info = read_proc_pid_stat($pid);
-
+
return $info && (!$pstart || ($info->{starttime} eq $pstart)) && ($info->{status} ne 'Z') ? $info : undef;
}
while (my $line = <$fh>) {
if ($line =~ m/^(\S+):\s+(\d+)\s*kB/i) {
$d->{lc ($1)} = $2 * 1024;
- }
+ }
}
close($fh);
$data->{$k} = ref($d) ? clone($d) : $d;
}
}
- }
+ }
$res->{info}->{$info->{method}} = $data;
};
}
my $path_lookup = $method_path_lookup->{$self};
die "$errprefix no path" if !defined($info->{path});
-
+
foreach my $comp (split(/\/+/, $info->{path})) {
die "$errprefix path compoment has zero length\n" if $comp eq '';
my ($name, $regex);
}
if ($regex) {
- $path_lookup->{regex} = {} if !defined($path_lookup->{regex});
+ $path_lookup->{regex} = {} if !defined($path_lookup->{regex});
my $old_name = $path_lookup->{regex}->{match_name};
die "$errprefix found changed regex match name\n"
if defined($old_re) && ($old_re ne $regex);
$path_lookup->{regex}->{match_name} = $name;
$path_lookup->{regex}->{match_re} = $regex;
-
+
die "$errprefix path match error - regex and fixed items\n"
if defined($path_lookup->{folders});
$path_lookup = $path_lookup->{regex};
-
+
} else {
- $path_lookup->{folders}->{$name} = {} if !defined($path_lookup->{folders}->{$name});
+ $path_lookup->{folders}->{$name} = {} if !defined($path_lookup->{folders}->{$name});
die "$errprefix path match error - regex and fixed items\n"
if defined($path_lookup->{regex});
}
}
- die "$errprefix duplicate method definition\n"
+ die "$errprefix duplicate method definition\n"
if defined($path_lookup->{$method});
if ($method eq 'SUBCLASS') {
my ($this) = @_;
# also see "man perldiag"
-
+
my $sub = $AUTOLOAD;
(my $method = $sub) =~ s/.*:://;
} else {
die "internal error";
}
-
+
return undef if !$path_lookup;
if (my $info = $path_lookup->{SUBCLASS}) {
if (defined($fd)) {
# we only support the empty string '' (match whole URI)
- die "unsupported fragmentDelimiter '$fd'"
+ die "unsupported fragmentDelimiter '$fd'"
if $fd ne '';
$stack = [ join ('/', @$stack) ] if scalar(@$stack) > 1;
#
# $info ... method info
# $prefix ... usually something like "$exename $cmd" ('pvesm add')
-# $arg_param ... list of parameters we want to get as ordered arguments
+# $arg_param ... list of parameters we want to get as ordered arguments
# on the command line (or single parameter name for lists)
# $fixed_param ... do not generate and info about those parameters
# $format:
$args .= " " if $args;
$args .= "--$base <$type_text>"
}
- }
+ }
if ($format eq 'asciidoc') {
$out .= "*${prefix}*";
my $raw = '';
$style //= 'config';
-
+
my $idx_param = {}; # -vlan\d+ -scsi\d+
foreach my $k (sort keys %$prop) {
next if !(ref($prop_fmt) && (ref($prop_fmt) eq 'HASH'));
$raw .= dump_properties($prop_fmt, $format, 'config-sub')
-
+
}
return $raw;
my $ec = ref($err);
die $err if !$ec || $ec ne "PVE::Exception" || !$err->is_param_exc();
-
+
$err->{usage} = $self->usage_str($name, $prefix, $arg_param, $fixed_param, 'short', $param_cb, $formatter_properties);
die $err;
our @EXPORT = qw(syslog initlog);
my $log_tag = "unknown";
-
+
# never log to console - thats too slow, and
# it corrupts the DBD database connection!
sub initlog {
my ($tag, $facility) = @_;
- if ($tag) {
+ if ($tag) {
$tag = basename($tag);
$tag = encode("ascii", decode_utf8($tag));