1 package PVE
::Storage
::PBSPlugin
;
3 # Plugin to access Proxmox Backup Server
8 use Fcntl
qw(F_GETFD F_SETFD FD_CLOEXEC);
11 use MIME
::Base64
qw(decode_base64);
12 use POSIX
qw(mktime strftime ENOENT);
15 use PVE
::APIClient
::LWP
;
16 use PVE
::JSONSchema
qw(get_standard_option);
19 use PVE
::Storage
::Plugin
;
20 use PVE
::Tools
qw(run_command file_read_firstline trim dir_glob_regex dir_glob_foreach $IPV6RE);
22 use base
qw(PVE::Storage::Plugin);
32 content
=> [ {backup
=> 1, none
=> 1}, { backup
=> 1 }],
39 description
=> "Proxmox Backup Server datastore name.",
42 # openssl s_client -connect <host>:8007 2>&1 |openssl x509 -fingerprint -sha256
43 fingerprint
=> get_standard_option
('fingerprint-sha256'),
45 description
=> "Encryption key. Use 'autogen' to generate one automatically without passphrase.",
49 description
=> "Base64-encoded, PEM-formatted public RSA key. Used to encrypt a copy of the encryption-key which will be added to each encrypted backup.",
53 description
=> "For non default port.",
64 server
=> { fixed
=> 1 },
65 datastore
=> { fixed
=> 1 },
66 port
=> { optional
=> 1 },
67 nodes
=> { optional
=> 1},
68 disable
=> { optional
=> 1},
69 content
=> { optional
=> 1},
70 username
=> { optional
=> 1 },
71 password
=> { optional
=> 1 },
72 'encryption-key' => { optional
=> 1 },
73 'master-pubkey' => { optional
=> 1 },
74 maxfiles
=> { optional
=> 1 },
75 'prune-backups' => { optional
=> 1 },
76 'max-protected-backups' => { optional
=> 1 },
77 fingerprint
=> { optional
=> 1 },
83 sub pbs_password_file_name
{
84 my ($scfg, $storeid) = @_;
86 return "/etc/pve/priv/storage/${storeid}.pw";
89 sub pbs_set_password
{
90 my ($scfg, $storeid, $password) = @_;
92 my $pwfile = pbs_password_file_name
($scfg, $storeid);
93 mkdir "/etc/pve/priv/storage";
95 PVE
::Tools
::file_set_contents
($pwfile, "$password\n");
98 sub pbs_delete_password
{
99 my ($scfg, $storeid) = @_;
101 my $pwfile = pbs_password_file_name
($scfg, $storeid);
106 sub pbs_get_password
{
107 my ($scfg, $storeid) = @_;
109 my $pwfile = pbs_password_file_name
($scfg, $storeid);
111 return PVE
::Tools
::file_read_firstline
($pwfile);
114 sub pbs_encryption_key_file_name
{
115 my ($scfg, $storeid) = @_;
117 return "/etc/pve/priv/storage/${storeid}.enc";
120 sub pbs_set_encryption_key
{
121 my ($scfg, $storeid, $key) = @_;
123 my $pwfile = pbs_encryption_key_file_name
($scfg, $storeid);
124 mkdir "/etc/pve/priv/storage";
126 PVE
::Tools
::file_set_contents
($pwfile, "$key\n");
129 sub pbs_delete_encryption_key
{
130 my ($scfg, $storeid) = @_;
132 my $pwfile = pbs_encryption_key_file_name
($scfg, $storeid);
134 if (!unlink $pwfile) {
135 return if $! == ENOENT
;
136 die "failed to delete encryption key! $!\n";
138 delete $scfg->{'encryption-key'};
141 sub pbs_get_encryption_key
{
142 my ($scfg, $storeid) = @_;
144 my $pwfile = pbs_encryption_key_file_name
($scfg, $storeid);
146 return PVE
::Tools
::file_get_contents
($pwfile);
149 # Returns a file handle if there is an encryption key, or `undef` if there is not. Dies on error.
150 sub pbs_open_encryption_key
{
151 my ($scfg, $storeid) = @_;
153 my $encryption_key_file = pbs_encryption_key_file_name
($scfg, $storeid);
156 if (!open($keyfd, '<', $encryption_key_file)) {
157 return undef if $! == ENOENT
;
158 die "failed to open encryption key: $encryption_key_file: $!\n";
164 sub pbs_master_pubkey_file_name
{
165 my ($scfg, $storeid) = @_;
167 return "/etc/pve/priv/storage/${storeid}.master.pem";
170 sub pbs_set_master_pubkey
{
171 my ($scfg, $storeid, $key) = @_;
173 my $pwfile = pbs_master_pubkey_file_name
($scfg, $storeid);
174 mkdir "/etc/pve/priv/storage";
176 PVE
::Tools
::file_set_contents
($pwfile, "$key\n");
179 sub pbs_delete_master_pubkey
{
180 my ($scfg, $storeid) = @_;
182 my $pwfile = pbs_master_pubkey_file_name
($scfg, $storeid);
184 if (!unlink $pwfile) {
185 return if $! == ENOENT
;
186 die "failed to delete master public key! $!\n";
188 delete $scfg->{'master-pubkey'};
191 sub pbs_get_master_pubkey
{
192 my ($scfg, $storeid) = @_;
194 my $pwfile = pbs_master_pubkey_file_name
($scfg, $storeid);
196 return PVE
::Tools
::file_get_contents
($pwfile);
199 # Returns a file handle if there is a master key, or `undef` if there is not. Dies on error.
200 sub pbs_open_master_pubkey
{
201 my ($scfg, $storeid) = @_;
203 my $master_pubkey_file = pbs_master_pubkey_file_name
($scfg, $storeid);
206 if (!open($keyfd, '<', $master_pubkey_file)) {
207 return undef if $! == ENOENT
;
208 die "failed to open master public key: $master_pubkey_file: $!\n";
215 my ($storeid, $btype, $bid, $btime) = @_;
217 my $time_str = strftime
("%FT%TZ", gmtime($btime));
218 my $volname = "backup/${btype}/${bid}/${time_str}";
220 return "${storeid}:${volname}";
223 # essentially the inverse of print_volid
224 sub api_param_from_volname
{
225 my ($class, $volname) = @_;
227 my $name = ($class->parse_volname($volname))[1];
229 my ($btype, $bid, $timestr) = split('/', $name);
231 my @tm = (POSIX
::strptime
($timestr, "%FT%TZ"));
232 # expect sec, min, hour, mday, mon, year
233 die "error parsing time from '$volname'" if grep { !defined($_) } @tm[0..5];
237 local $ENV{TZ
} = 'UTC'; # $timestr is UTC
239 # Fill in isdst to avoid undef warning. No daylight saving time for UTC.
242 my $since_epoch = mktime
(@tm) or die "error converting time from '$volname'\n";
243 $btime = int($since_epoch);
247 'backup-type' => $btype,
249 'backup-time' => $btime,
253 my $USE_CRYPT_PARAMS = {
259 my $USE_MASTER_KEY = {
263 my sub do_raw_client_cmd
{
264 my ($scfg, $storeid, $client_cmd, $param, %opts) = @_;
266 my $use_crypto = $USE_CRYPT_PARAMS->{$client_cmd};
267 my $use_master = $USE_MASTER_KEY->{$client_cmd};
269 my $client_exe = '/usr/bin/proxmox-backup-client';
270 die "executable not found '$client_exe'! Proxmox backup client not installed?\n"
273 my $repo = PVE
::PBSClient
::get_repository
($scfg);
275 my $userns_cmd = delete $opts{userns_cmd
};
279 push @$cmd, @$userns_cmd if defined($userns_cmd);
281 push @$cmd, $client_exe, $client_cmd;
283 # This must live in the top scope to not get closed before the `run_command`
284 my ($keyfd, $master_fd);
286 if (defined($keyfd = pbs_open_encryption_key
($scfg, $storeid))) {
287 my $flags = fcntl($keyfd, F_GETFD
, 0)
288 // die "failed to get file descriptor flags: $!\n";
289 fcntl($keyfd, F_SETFD
, $flags & ~FD_CLOEXEC
)
290 or die "failed to remove FD_CLOEXEC from encryption key file descriptor\n";
291 push @$cmd, '--crypt-mode=encrypt', '--keyfd='.fileno($keyfd);
292 if ($use_master && defined($master_fd = pbs_open_master_pubkey
($scfg, $storeid))) {
293 my $flags = fcntl($master_fd, F_GETFD
, 0)
294 // die "failed to get file descriptor flags: $!\n";
295 fcntl($master_fd, F_SETFD
, $flags & ~FD_CLOEXEC
)
296 or die "failed to remove FD_CLOEXEC from master public key file descriptor\n";
297 push @$cmd, '--master-pubkey-fd='.fileno($master_fd);
300 push @$cmd, '--crypt-mode=none';
304 push @$cmd, @$param if defined($param);
306 push @$cmd, "--repository", $repo;
308 local $ENV{PBS_PASSWORD
} = pbs_get_password
($scfg, $storeid);
310 local $ENV{PBS_FINGERPRINT
} = $scfg->{fingerprint
};
312 # no ascii-art on task logs
313 local $ENV{PROXMOX_OUTPUT_NO_BORDER
} = 1;
314 local $ENV{PROXMOX_OUTPUT_NO_HEADER
} = 1;
316 if (my $logfunc = $opts{logfunc
}) {
317 $logfunc->("run: " . join(' ', @$cmd));
320 run_command
($cmd, %opts);
323 # FIXME: External perl code should NOT have access to this.
325 # There should be separate functions to
330 sub run_raw_client_cmd
{
331 my ($scfg, $storeid, $client_cmd, $param, %opts) = @_;
332 return do_raw_client_cmd
($scfg, $storeid, $client_cmd, $param, %opts);
336 my ($scfg, $storeid, $client_cmd, $param, $no_output) = @_;
339 my $outfunc = sub { $json_str .= "$_[0]\n" };
341 $param = [] if !defined($param);
342 $param = [ $param ] if !ref($param);
344 $param = [@$param, '--output-format=json'] if !$no_output;
346 do_raw_client_cmd
($scfg, $storeid, $client_cmd, $param,
347 outfunc
=> $outfunc, errmsg
=> 'proxmox-backup-client failed');
349 return undef if $no_output;
351 my $res = decode_json
($json_str);
356 # Storage implementation
358 sub extract_vzdump_config
{
359 my ($class, $scfg, $volname, $storeid) = @_;
361 my ($vtype, $name, $vmid, undef, undef, undef, $format) = $class->parse_volname($volname);
364 my $outfunc = sub { $config .= "$_[0]\n" };
367 if ($format eq 'pbs-vm') {
368 $config_name = 'qemu-server.conf';
369 } elsif ($format eq 'pbs-ct') {
370 $config_name = 'pct.conf';
372 die "unable to extract configuration for backup format '$format'\n";
375 do_raw_client_cmd
($scfg, $storeid, 'restore', [ $name, $config_name, '-' ],
376 outfunc
=> $outfunc, errmsg
=> 'proxmox-backup-client failed');
382 my ($class, $scfg, $storeid, $keep, $vmid, $type, $dryrun, $logfunc) = @_;
384 $logfunc //= sub { print "$_[1]\n" };
386 my $backups = $class->list_volumes($storeid, $scfg, $vmid, ['backup']);
388 $type = 'vm' if defined($type) && $type eq 'qemu';
389 $type = 'ct' if defined($type) && $type eq 'lxc';
391 my $backup_groups = {};
392 foreach my $backup (@{$backups}) {
393 (my $backup_type = $backup->{format
}) =~ s/^pbs-//;
395 next if defined($type) && $backup_type ne $type;
397 my $backup_group = "$backup_type/$backup->{vmid}";
398 $backup_groups->{$backup_group} = 1;
403 my $keep_all = delete $keep->{'keep-all'};
406 foreach my $opt (keys %{$keep}) {
407 next if $keep->{$opt} == 0;
408 push @param, "--$opt";
409 push @param, "$keep->{$opt}";
411 } else { # no need to pass anything to PBS
412 $keep = { 'keep-all' => 1 };
415 push @param, '--dry-run' if $dryrun;
420 foreach my $backup_group (keys %{$backup_groups}) {
421 $logfunc->('info', "running 'proxmox-backup-client prune' for '$backup_group'")
424 my $res = run_client_cmd
($scfg, $storeid, 'prune', [ $backup_group, @param ]);
426 foreach my $backup (@{$res}) {
427 die "result from proxmox-backup-client is not as expected\n"
428 if !defined($backup->{'backup-time'})
429 || !defined($backup->{'backup-type'})
430 || !defined($backup->{'backup-id'})
431 || !defined($backup->{'keep'});
433 my $ctime = $backup->{'backup-time'};
434 my $type = $backup->{'backup-type'};
435 my $vmid = $backup->{'backup-id'};
436 my $volid = print_volid
($storeid, $type, $vmid, $ctime);
438 my $mark = $backup->{keep
} ?
'keep' : 'remove';
439 $mark = 'protected' if $backup->{protected
};
441 push @{$prune_list}, {
444 type
=> $type eq 'vm' ?
'qemu' : 'lxc',
451 $logfunc->('err', "prune '$backup_group': $err\n");
455 die "error pruning backups - check log\n" if $failed;
460 my $autogen_encryption_key = sub {
461 my ($scfg, $storeid) = @_;
462 my $encfile = pbs_encryption_key_file_name
($scfg, $storeid);
464 rename $encfile, "$encfile.old";
466 my $cmd = ['proxmox-backup-client', 'key', 'create', '--kdf', 'none', $encfile];
467 run_command
($cmd, errmsg
=> 'failed to create encryption key');
468 return PVE
::Tools
::file_get_contents
($encfile);
472 my ($class, $storeid, $scfg, %param) = @_;
476 if (defined(my $password = $param{password
})) {
477 pbs_set_password
($scfg, $storeid, $password);
479 pbs_delete_password
($scfg, $storeid);
482 if (defined(my $encryption_key = $param{'encryption-key'})) {
484 if ($encryption_key eq 'autogen') {
485 $res->{'encryption-key'} = $autogen_encryption_key->($scfg, $storeid);
486 $decoded_key = decode_json
($res->{'encryption-key'});
488 $decoded_key = eval { decode_json
($encryption_key) };
489 if ($@ || !exists($decoded_key->{data
})) {
490 die "Value does not seems like a valid, JSON formatted encryption key!\n";
492 pbs_set_encryption_key
($scfg, $storeid, $encryption_key);
493 $res->{'encryption-key'} = $encryption_key;
495 $scfg->{'encryption-key'} = $decoded_key->{fingerprint
} || 1;
497 pbs_delete_encryption_key
($scfg, $storeid);
500 if (defined(my $master_key = delete $param{'master-pubkey'})) {
501 die "'master-pubkey' can only be used together with 'encryption-key'\n"
502 if !defined($scfg->{'encryption-key'});
504 my $decoded = decode_base64
($master_key);
505 pbs_set_master_pubkey
($scfg, $storeid, $decoded);
506 $scfg->{'master-pubkey'} = 1;
508 pbs_delete_master_pubkey
($scfg, $storeid);
515 my ($class, $storeid, $scfg, %param) = @_;
519 if (exists($param{password
})) {
520 if (defined($param{password
})) {
521 pbs_set_password
($scfg, $storeid, $param{password
});
523 pbs_delete_password
($scfg, $storeid);
527 if (exists($param{'encryption-key'})) {
528 if (defined(my $encryption_key = delete($param{'encryption-key'}))) {
530 if ($encryption_key eq 'autogen') {
531 $res->{'encryption-key'} = $autogen_encryption_key->($scfg, $storeid);
532 $decoded_key = decode_json
($res->{'encryption-key'});
534 $decoded_key = eval { decode_json
($encryption_key) };
535 if ($@ || !exists($decoded_key->{data
})) {
536 die "Value does not seems like a valid, JSON formatted encryption key!\n";
538 pbs_set_encryption_key
($scfg, $storeid, $encryption_key);
539 $res->{'encryption-key'} = $encryption_key;
541 $scfg->{'encryption-key'} = $decoded_key->{fingerprint
} || 1;
543 pbs_delete_encryption_key
($scfg, $storeid);
544 delete $scfg->{'encryption-key'};
548 if (exists($param{'master-pubkey'})) {
549 if (defined(my $master_key = delete($param{'master-pubkey'}))) {
550 my $decoded = decode_base64
($master_key);
552 pbs_set_master_pubkey
($scfg, $storeid, $decoded);
553 $scfg->{'master-pubkey'} = 1;
555 pbs_delete_master_pubkey
($scfg, $storeid);
563 my ($class, $storeid, $scfg) = @_;
565 pbs_delete_password
($scfg, $storeid);
566 pbs_delete_encryption_key
($scfg, $storeid);
567 pbs_delete_master_pubkey
($scfg, $storeid);
573 my ($class, $volname) = @_;
575 if ($volname =~ m!^backup/([^\s_]+)/([^\s_]+)/([0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}Z)$!) {
579 my $format = "pbs-$btype";
581 my $name = "$btype/$bid/$btime";
583 if ($bid =~ m/^\d+$/) {
584 return ('backup', $name, $bid, undef, undef, undef, $format);
586 return ('backup', $name, undef, undef, undef, undef, $format);
590 die "unable to parse PBS volume name '$volname'\n";
594 my ($class, $scfg, $volname, $storeid, $snapname) = @_;
596 die "volume snapshot is not possible on pbs storage"
597 if defined($snapname);
599 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
601 my $repo = PVE
::PBSClient
::get_repository
($scfg);
603 # artificial url - we currently do not use that anywhere
604 my $path = "pbs://$repo/$name";
606 return ($path, $vmid, $vtype);
610 my ($class, $storeid, $scfg, $volname) = @_;
612 die "can't create base images in pbs storage\n";
616 my ($class, $scfg, $storeid, $volname, $vmid, $snap) = @_;
618 die "can't clone images in pbs storage\n";
622 my ($class, $storeid, $scfg, $vmid, $fmt, $name, $size) = @_;
624 die "can't allocate space in pbs storage\n";
628 my ($class, $storeid, $scfg, $volname, $isBase) = @_;
630 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
632 run_client_cmd
($scfg, $storeid, "forget", [ $name ], 1);
639 my ($class, $storeid, $scfg, $vmid, $vollist, $cache) = @_;
646 my sub snapshot_files_encrypted
{
652 for my $file (@$files) {
653 my $fn = $file->{filename
};
654 next if $fn eq 'client.log.blob' || $fn eq 'index.json.blob';
656 my $crypt = $file->{'crypt-mode'};
658 $all = 0 if !$crypt || $crypt ne 'encrypt';
659 $any ||= defined($crypt) && $crypt eq 'encrypt';
665 my ($class, $storeid, $scfg, $vmid, $content_types) = @_;
669 return $res if !grep { $_ eq 'backup' } @$content_types;
671 my $data = run_client_cmd
($scfg, $storeid, "snapshots");
673 foreach my $item (@$data) {
674 my $btype = $item->{"backup-type"};
675 my $bid = $item->{"backup-id"};
676 my $epoch = $item->{"backup-time"};
677 my $size = $item->{size
} // 1;
679 next if !($btype eq 'vm' || $btype eq 'ct');
680 next if $bid !~ m/^\d+$/;
681 next if defined($vmid) && $bid ne $vmid;
683 my $volid = print_volid
($storeid, $btype, $bid, $epoch);
687 format
=> "pbs-$btype",
692 subtype
=> $btype eq 'vm' ?
'qemu' : 'lxc', # convert to PVE backup type
695 $info->{verification
} = $item->{verification
} if defined($item->{verification
});
696 $info->{notes
} = $item->{comment
} if defined($item->{comment
});
697 $info->{protected
} = 1 if $item->{protected
};
698 if (defined($item->{fingerprint
})) {
699 $info->{encrypted
} = $item->{fingerprint
};
700 } elsif (snapshot_files_encrypted
($item->{files
})) {
701 $info->{encrypted
} = '1';
711 my ($class, $storeid, $scfg, $cache) = @_;
719 my $res = run_client_cmd
($scfg, $storeid, "status");
722 $total = $res->{total
};
723 $used = $res->{used
};
724 $free = $res->{avail
};
730 return ($total, $free, $used, $active);
733 # TODO: use a client with native rust/proxmox-backup bindings to profit from
734 # API schema checks and types
735 my sub pbs_api_connect
{
736 my ($scfg, $password) = @_;
740 my $user = $scfg->{username
} // 'root@pam';
742 if (my $tokenid = PVE
::AccessControl
::pve_verify_tokenid
($user, 1)) {
743 $params->{apitoken
} = "PBSAPIToken=${tokenid}:${password}";
745 $params->{password
} = $password;
746 $params->{username
} = $user;
749 if (my $fp = $scfg->{fingerprint
}) {
750 $params->{cached_fingerprints
}->{uc($fp)} = 1;
753 my $conn = PVE
::APIClient
::LWP-
>new(
755 host
=> $scfg->{server
},
756 port
=> $scfg->{port
} // 8007,
757 timeout
=> 7, # cope with a 401 (3s api delay) and high latency
758 cookie_name
=> 'PBSAuthCookie',
764 # can also be used for not (yet) added storages, pass $scfg with
768 # port (optional default to 8007)
769 # fingerprint (optional for trusted certs)
771 sub scan_datastores
{
772 my ($scfg, $password) = @_;
774 my $conn = pbs_api_connect
($scfg, $password);
776 my $response = eval { $conn->get('/api2/json/admin/datastore', {}) };
777 die "error fetching datastores - $@" if $@;
782 sub activate_storage
{
783 my ($class, $storeid, $scfg, $cache) = @_;
785 my $password = pbs_get_password
($scfg, $storeid);
787 my $datastores = eval { scan_datastores
($scfg, $password) };
788 die "$storeid: $@" if $@;
790 my $datastore = $scfg->{datastore
};
792 for my $ds (@$datastores) {
793 if ($ds->{store
} eq $datastore) {
798 die "$storeid: Cannot find datastore '$datastore', check permissions and existence!\n";
801 sub deactivate_storage
{
802 my ($class, $storeid, $scfg, $cache) = @_;
806 sub activate_volume
{
807 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
809 die "volume snapshot is not possible on pbs device" if $snapname;
814 sub deactivate_volume
{
815 my ($class, $storeid, $scfg, $volname, $snapname, $cache) = @_;
817 die "volume snapshot is not possible on pbs device" if $snapname;
822 # FIXME remove on the next APIAGE reset.
823 # Deprecated, use get_volume_attribute instead.
824 sub get_volume_notes
{
825 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
827 my (undef, $name, undef, undef, undef, undef, $format) = $class->parse_volname($volname);
829 my $data = run_client_cmd
($scfg, $storeid, "snapshot", [ "notes", "show", $name ]);
831 return $data->{notes
};
834 # FIXME remove on the next APIAGE reset.
835 # Deprecated, use update_volume_attribute instead.
836 sub update_volume_notes
{
837 my ($class, $scfg, $storeid, $volname, $notes, $timeout) = @_;
839 my (undef, $name, undef, undef, undef, undef, $format) = $class->parse_volname($volname);
841 run_client_cmd
($scfg, $storeid, "snapshot", [ "notes", "update", $name, $notes ], 1);
846 sub get_volume_attribute
{
847 my ($class, $scfg, $storeid, $volname, $attribute) = @_;
849 if ($attribute eq 'notes') {
850 return $class->get_volume_notes($scfg, $storeid, $volname);
853 if ($attribute eq 'protected') {
854 my $param = $class->api_param_from_volname($volname);
856 my $password = pbs_get_password
($scfg, $storeid);
857 my $conn = pbs_api_connect
($scfg, $password);
858 my $datastore = $scfg->{datastore
};
860 my $res = eval { $conn->get("/api2/json/admin/datastore/$datastore/$attribute", $param); };
862 return if $err->{code
} == 404; # not supported
871 sub update_volume_attribute
{
872 my ($class, $scfg, $storeid, $volname, $attribute, $value) = @_;
874 if ($attribute eq 'notes') {
875 return $class->update_volume_notes($scfg, $storeid, $volname, $value);
878 if ($attribute eq 'protected') {
879 my $param = $class->api_param_from_volname($volname);
880 $param->{$attribute} = $value;
882 my $password = pbs_get_password
($scfg, $storeid);
883 my $conn = pbs_api_connect
($scfg, $password);
884 my $datastore = $scfg->{datastore
};
886 eval { $conn->put("/api2/json/admin/datastore/$datastore/$attribute", $param); };
888 die "Server is not recent enough to support feature '$attribute'\n"
889 if $err->{code
} == 404;
895 die "attribute '$attribute' is not supported for storage type '$scfg->{type}'\n";
898 sub volume_size_info
{
899 my ($class, $scfg, $storeid, $volname, $timeout) = @_;
901 my ($vtype, $name, undef, undef, undef, undef, $format) = $class->parse_volname($volname);
903 my $data = run_client_cmd
($scfg, $storeid, "files", [ $name ]);
906 foreach my $info (@$data) {
907 if ($info->{size
} && $info->{size
} =~ /^(\d+)$/) { # untaints
914 return wantarray ?
($size, $format, $used, undef) : $size;
918 my ($class, $scfg, $storeid, $volname, $size, $running) = @_;
919 die "volume resize is not possible on pbs device";
922 sub volume_snapshot
{
923 my ($class, $scfg, $storeid, $volname, $snap) = @_;
924 die "volume snapshot is not possible on pbs device";
927 sub volume_snapshot_rollback
{
928 my ($class, $scfg, $storeid, $volname, $snap) = @_;
929 die "volume snapshot rollback is not possible on pbs device";
932 sub volume_snapshot_delete
{
933 my ($class, $scfg, $storeid, $volname, $snap) = @_;
934 die "volume snapshot delete is not possible on pbs device";
937 sub volume_has_feature
{
938 my ($class, $scfg, $feature, $storeid, $volname, $snapname, $running) = @_;