[pve-devel] [PATCH v2 storage 2/3] rbd: use pve-storage-portal-dns-list for monhost

Wolfgang Bumiller w.bumiller at proxmox.com
Thu Jul 7 11:20:57 CEST 2016


Forgot the changelog (this is the only changed patch):

* Changed from address-list to pve-storage-portal-dns-list since
  address-list doesn't allow specifying ports.
* With the above change support for ipv6-dot-port notation is added as
  well.

On Thu, Jul 07, 2016 at 11:18:15AM +0200, Wolfgang Bumiller wrote:
> This way we get parameter verification on monitor addresses
> as well as the ability to pass multiple `--monhost`
> arguments to `pvesm add`.
> 
> Since our '-list' schemas default to using commas we now
> need to properly support these, so all uses of the monhost
> property now replace all of semicolon, space or comma into
> the currently required character.
> This should fix the issues reported by Alwin Antreich on the
> pve-user list.
> 
> Since this schema supports both ipv6+port notations we need
> to make sure we convert to the bracket enclosed variant.
> Added a helper for this.
> ---
>  PVE/Storage/RBDPlugin.pm | 22 ++++++++++++++++------
>  1 file changed, 16 insertions(+), 6 deletions(-)
> 
> diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
> index ced9af0..ca3c284 100644
> --- a/PVE/Storage/RBDPlugin.pm
> +++ b/PVE/Storage/RBDPlugin.pm
> @@ -3,6 +3,7 @@ package PVE::Storage::RBDPlugin;
>  use strict;
>  use warnings;
>  use IO::File;
> +use Net::IP;
>  use PVE::Tools qw(run_command trim);
>  use PVE::Storage::Plugin;
>  use PVE::JSONSchema qw(get_standard_option);
> @@ -25,11 +26,21 @@ my $add_pool_to_disk = sub {
>      return "$pool/$disk";
>  };
>  
> +my $hostlist = sub {
> +    my ($list_text, $separator) = @_;
> +    my @monhostlist = PVE::Tools::split_list($list_text);
> +    return join($separator, map {
> +	my ($host, $port) = PVE::Tools::parse_host_and_port($_);
> +	$port = defined($port) ? ":$port" : '';
> +	$host = "[$host]" if Net::IP::ip_is_ipv6($host);
> +	"${host}${port}"
> +    } @monhostlist);
> +};
> +
>  my $rbd_cmd = sub {
>      my ($scfg, $storeid, $op, @options) = @_;
>  
> -    my $monhost = $scfg->{monhost};
> -    $monhost =~ s/;/,/g;
> +    my $monhost = $hostlist->($scfg->{monhost}, ',');
>  
>      my $keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
>      my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
> @@ -55,8 +66,7 @@ my $rbd_cmd = sub {
>  my $rados_cmd = sub {
>      my ($scfg, $storeid, $op, @options) = @_;
>  
> -    my $monhost = $scfg->{monhost};
> -    $monhost =~ s/;/,/g;
> +    my $monhost = $hostlist->($scfg->{monhost}, ',');
>  
>      my $keyring = "/etc/pve/priv/ceph/${storeid}.keyring";
>      my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
> @@ -248,7 +258,7 @@ sub properties {
>      return {
>  	monhost => {
>  	    description => "Monitors daemon ips.",
> -	    type => 'string',
> +	    type => 'string', format => 'pve-storage-portal-dns-list',
>  	},
>  	pool => {
>  	    description => "Pool.",
> @@ -302,7 +312,7 @@ sub path {
>      my $pool =  $scfg->{pool} ? $scfg->{pool} : 'rbd';
>      return ("/dev/rbd/$pool/$name", $vmid, $vtype) if $scfg->{krbd};
>  
> -    my $monhost = $scfg->{monhost};
> +    my $monhost = $hostlist->($scfg->{monhost}, ';');
>      $monhost =~ s/:/\\:/g;
>  
>      my $username =  $scfg->{username} ? $scfg->{username} : 'admin';
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 



More information about the pve-devel mailing list