[DRBD-user] drbdmanage API error message format

Philipp Marek philipp.marek at linbit.com
Fri Jun 19 11:03:50 CEST 2015

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


Hi Dietmar,

> what is the correct way to format the returned error codes? I
> checked the code for the cinder plugin:
> 
> https://github.com/LINBIT/cinder/blob/drbd-for-nova/cinder/volume/drivers/drbdmanagedrv.py
> 
> Inside _check_result(), I found the following:
> 
>           seen_error = _("Received error string: %s") % (fmt % arg)
> 
> It uses the python format code (fmt % arg) to create the final 
> error message. This looks reasonable with python, but I want to use 
> perl, and there is no 100% compatible formater in perl.
> 
> Any suggestion how to implement that with perl?


How about that?

    my $format = "Resource %(res)s has size %(size)sKB.";
    my $args = { 'res' => "resource_0", 'size' => "20411" };

    my $loc_fmt = _($format);

    my @args = ();
    push @args, $args->{$1} // "" while $loc_fmt =~ s,\%\((\w+)\),%,;

    $loc_error = sprintf($loc_fmt, @args);




More information about the drbd-user mailing list