my $print_content = sub {
my ($list) = @_;
- my $maxlenname = 0;
+ my ($maxlenname, $maxsize) = (0, 0);
foreach my $info (@$list) {
-
my $volid = $info->{volid};
my $sidlen = length ($volid);
$maxlenname = $sidlen if $sidlen > $maxlenname;
+ $maxsize = $info->{size} if ($info->{size} // 0) > $maxsize;
}
+ my $sizemaxdigits = length($maxsize);
+
+ my $basefmt = "%-${maxlenname}s %-7s %-9s %${sizemaxdigits}s";
+ printf "$basefmt %s\n", "Volid", "Format", "Type", "Size", "VMID";
foreach my $info (@$list) {
next if !$info->{vmid};
my $volid = $info->{volid};
- printf "%-${maxlenname}s %5s %10d %d\n", $volid,
- $info->{format}, $info->{size}, $info->{vmid};
+ printf "$basefmt %d\n", $volid, $info->{format}, $info->{content}, $info->{size}, $info->{vmid};
}
foreach my $info (sort { $a->{format} cmp $b->{format} } @$list) {
next if $info->{vmid};
my $volid = $info->{volid};
- printf "%-${maxlenname}s %5s %10d\n", $volid,
- $info->{format}, $info->{size};
+ printf "$basefmt\n", $volid, $info->{format}, $info->{content}, $info->{size};
}
};
my ($cidr, $ip, $subnet) = ($1, $2, $3);
if ($subnet) { # got real CIDR notation, not just IP
my $ips = PVE::Network::get_local_ip_from_cidr($cidr);
- die "Unable to get single local IP address in network '$cidr'\n"
- if scalar(@$ips) != 1;
- $ip = @$ips[0];
+ die "Unable to get any local IP address in network '$cidr'\n"
+ if scalar(@$ips) < 1;
+ die "Got multiple local IP address in network '$cidr'\n"
+ if scalar(@$ips) > 1;
+
+ $ip = $ips->[0];
}
my $family = PVE::Tools::get_host_address_family($ip);
my $port = PVE::Tools::next_migrate_port($family, $ip);
type => 'array',
items => {
type => "object",
- properties => {
+ properties => {
volname => {
description => "The volume name.",
type => 'string',