die "got undefined drbd result\n" if !$rc;
foreach my $res (@$rc) {
- my ($code, $msg, $details) = @$res;
+ my ($code, $format, $details) = @$res;
- return undef if $code == 0;
+ next if $code == 0;
- $msg = "drbd error: got error code $code" if !$msg;
+ my $msg;
+ if (defined($format)) {
+ my @args = ();
+ push @args, $details->{$1} // ""
+ while $format =~ s,\%\((\w+)\),%,;
+
+ $msg = sprintf($format, @args);
+
+ } else {
+ $msg = "drbd error: got error code $code";
+ }
+
chomp $msg;
-
- # fixme: add error details?
- #print Dumper($details);
-
die "drbd error: $msg\n";
}
my ($class, $volname) = @_;
if ($volname =~ m/^(vm-(\d+)-[a-z][a-z0-9\-\_\.]*[a-z0-9]+)$/) {
- return ('images', $1, $2);
+ return ('images', $1, $2, undef, undef, undef, 'raw');
}
die "unable to parse lvm volume name '$volname'\n";
}
sub filesystem_path {
- my ($class, $scfg, $volname) = @_;
+ my ($class, $scfg, $volname, $snapname) = @_;
+
+ die "drbd snapshot is not implemented\n" if defined($snapname);
my ($vtype, $name, $vmid) = $class->parse_volname($volname);