Re: [pve-devel] [PATCH pve-network] allow [ ,;] for ip lists

2020-06-24 Thread Alexandre DERUMIER
>>why not use PVE::Tools::split_list ? it's our standard helper for these 
>>kind of things, and also correctly trims whitespace and has support for 
>>\0-separated lists ;

I have take it from ceph code ;)


/usr/share/perl5/PVE/CephConfig.pm:my $monhosts = [ split (/[ ,;]+/, 
$config->{global}->{mon_host} // "") ];
/usr/share/perl5/PVE/API2/Ceph/MON.pm:  $monhost =~ s/(^|[ 
,;]*)\[$vectorpart_re(?:,$vectorpart_re)*\](?:[ ,;]+|$)/$1/;
/usr/share/perl5/PVE/API2/Ceph/MON.pm:  $monhost =~ s/(^|[ 
,;]+)\Q$addr\E(?::\d+)?(?:[ ,;]+|$)/$1/;
/usr/share/perl5/PVE/API2/Ceph/MON.pm:  $monhost =~ s/(^|[ 
,;]+)\Q$addr\E(?:[ ,;]+|$)/$1/;
/usr/share/perl5/PVE/API2/Ceph/MON.pm:  $monhost =~ s/[ ,;]+$//;


I'll look to use the PVE::Tools::split_list.


- Mail original -
De: "Fabian Grünbichler" 
À: "pve-devel" 
Envoyé: Mercredi 24 Juin 2020 10:23:14
Objet: Re: [pve-devel] [PATCH pve-network] allow [ ,;] for ip lists

why not use PVE::Tools::split_list ? it's our standard helper for these 
kind of things, and also correctly trims whitespace and has support for 
\0-separated lists ;) 

On June 12, 2020 6:14 pm, Alexandre Derumier wrote: 
> Signed-off-by: Alexandre Derumier  
> --- 
> PVE/Network/SDN/Controllers/EvpnPlugin.pm | 4 ++-- 
> PVE/Network/SDN/Zones/EvpnPlugin.pm | 2 +- 
> PVE/Network/SDN/Zones/VxlanPlugin.pm | 2 +- 
> 3 files changed, 4 insertions(+), 4 deletions(-) 
> 
> diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
> b/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
> index 79ecaeb..8db2bed 100644 
> --- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
> +++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
> @@ -47,11 +47,11 @@ sub options { 
> sub generate_controller_config { 
> my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_; 
> 
> - my @peers = split(',', $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'}; 
> + my @peers = split(/[ ,;]+/, $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'}; 
> 
> my $asn = $plugin_config->{asn}; 
> my $gatewaynodes = $plugin_config->{'gateway-nodes'}; 
> - my @gatewaypeers = split(',', $plugin_config->{'gateway-external-peers'}) 
> if $plugin_config->{'gateway-external-peers'}; 
> + my @gatewaypeers = split(/[ ,;]+/, 
> $plugin_config->{'gateway-external-peers'}) if 
> $plugin_config->{'gateway-external-peers'}; 
> 
> return if !$asn; 
> 
> diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm 
> b/PVE/Network/SDN/Zones/EvpnPlugin.pm 
> index 95fbb64..dba3ffc 100644 
> --- a/PVE/Network/SDN/Zones/EvpnPlugin.pm 
> +++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm 
> @@ -52,7 +52,7 @@ sub generate_sdn_config { 
> die "missing vxlan tag" if !$tag; 
> warn "vlan-aware vnet can't be enabled with evpn plugin" if 
> $vnet->{vlanaware}; 
> 
> - my @peers = split(',', $controller->{'peers'}); 
> + my @peers = split(/[ ,;]+/, $controller->{'peers'}); 
> my ($ifaceip, $iface) = 
> PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers); 
> 
> my $mtu = 1450; 
> diff --git a/PVE/Network/SDN/Zones/VxlanPlugin.pm 
> b/PVE/Network/SDN/Zones/VxlanPlugin.pm 
> index bc585c6..f2c2eec 100644 
> --- a/PVE/Network/SDN/Zones/VxlanPlugin.pm 
> +++ b/PVE/Network/SDN/Zones/VxlanPlugin.pm 
> @@ -50,7 +50,7 @@ sub generate_sdn_config { 
> my $ipv6 = $vnet->{ipv6}; 
> my $mac = $vnet->{mac}; 
> my $multicastaddress = $plugin_config->{'multicast-address'}; 
> - my @peers = split(',', $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'}; 
> + my @peers = split(/[ ,;]+/, $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'}; 
> my $vxlan_iface = "vxlan_$vnetid"; 
> 
> die "missing vxlan tag" if !$tag; 
> -- 
> 2.20.1 
> 
> ___ 
> pve-devel mailing list 
> pve-devel@pve.proxmox.com 
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 
> 
> 

___ 
pve-devel mailing list 
pve-devel@pve.proxmox.com 
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


Re: [pve-devel] [PATCH pve-network] allow [ ,;] for ip lists

2020-06-24 Thread Fabian Grünbichler
why not use PVE::Tools::split_list ? it's our standard helper for these 
kind of things, and also correctly trims whitespace and has support for 
\0-separated lists ;)

On June 12, 2020 6:14 pm, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier 
> ---
>  PVE/Network/SDN/Controllers/EvpnPlugin.pm | 4 ++--
>  PVE/Network/SDN/Zones/EvpnPlugin.pm   | 2 +-
>  PVE/Network/SDN/Zones/VxlanPlugin.pm  | 2 +-
>  3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
> b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
> index 79ecaeb..8db2bed 100644
> --- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
> +++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
> @@ -47,11 +47,11 @@ sub options {
>  sub generate_controller_config {
>  my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
>  
> -my @peers = split(',', $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'};
> +my @peers = split(/[ ,;]+/, $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'};
>  
>  my $asn = $plugin_config->{asn};
>  my $gatewaynodes = $plugin_config->{'gateway-nodes'};
> -my @gatewaypeers = split(',', 
> $plugin_config->{'gateway-external-peers'}) if 
> $plugin_config->{'gateway-external-peers'};
> +my @gatewaypeers = split(/[ ,;]+/, 
> $plugin_config->{'gateway-external-peers'}) if 
> $plugin_config->{'gateway-external-peers'};
>  
>  return if !$asn;
>  
> diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm 
> b/PVE/Network/SDN/Zones/EvpnPlugin.pm
> index 95fbb64..dba3ffc 100644
> --- a/PVE/Network/SDN/Zones/EvpnPlugin.pm
> +++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm
> @@ -52,7 +52,7 @@ sub generate_sdn_config {
>  die "missing vxlan tag" if !$tag;
>  warn "vlan-aware vnet can't be enabled with evpn plugin" if 
> $vnet->{vlanaware};
>  
> -my @peers = split(',', $controller->{'peers'});
> +my @peers = split(/[ ,;]+/, $controller->{'peers'});
>  my ($ifaceip, $iface) = 
> PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers);
>  
>  my $mtu = 1450;
> diff --git a/PVE/Network/SDN/Zones/VxlanPlugin.pm 
> b/PVE/Network/SDN/Zones/VxlanPlugin.pm
> index bc585c6..f2c2eec 100644
> --- a/PVE/Network/SDN/Zones/VxlanPlugin.pm
> +++ b/PVE/Network/SDN/Zones/VxlanPlugin.pm
> @@ -50,7 +50,7 @@ sub generate_sdn_config {
>  my $ipv6 = $vnet->{ipv6};
>  my $mac = $vnet->{mac};
>  my $multicastaddress = $plugin_config->{'multicast-address'};
> -my @peers = split(',', $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'};
> +my @peers = split(/[ ,;]+/, $plugin_config->{'peers'}) if 
> $plugin_config->{'peers'};
>  my $vxlan_iface = "vxlan_$vnetid";
>  
>  die "missing vxlan tag" if !$tag;
> -- 
> 2.20.1
> 
> ___
> pve-devel mailing list
> pve-devel@pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


[pve-devel] [PATCH pve-network] allow [ ,;] for ip lists

2020-06-12 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 4 ++--
 PVE/Network/SDN/Zones/EvpnPlugin.pm   | 2 +-
 PVE/Network/SDN/Zones/VxlanPlugin.pm  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index 79ecaeb..8db2bed 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -47,11 +47,11 @@ sub options {
 sub generate_controller_config {
 my ($class, $plugin_config, $controller, $id, $uplinks, $config) = @_;
 
-my @peers = split(',', $plugin_config->{'peers'}) if 
$plugin_config->{'peers'};
+my @peers = split(/[ ,;]+/, $plugin_config->{'peers'}) if 
$plugin_config->{'peers'};
 
 my $asn = $plugin_config->{asn};
 my $gatewaynodes = $plugin_config->{'gateway-nodes'};
-my @gatewaypeers = split(',', $plugin_config->{'gateway-external-peers'}) 
if $plugin_config->{'gateway-external-peers'};
+my @gatewaypeers = split(/[ ,;]+/, 
$plugin_config->{'gateway-external-peers'}) if 
$plugin_config->{'gateway-external-peers'};
 
 return if !$asn;
 
diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm 
b/PVE/Network/SDN/Zones/EvpnPlugin.pm
index 95fbb64..dba3ffc 100644
--- a/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -52,7 +52,7 @@ sub generate_sdn_config {
 die "missing vxlan tag" if !$tag;
 warn "vlan-aware vnet can't be enabled with evpn plugin" if 
$vnet->{vlanaware};
 
-my @peers = split(',', $controller->{'peers'});
+my @peers = split(/[ ,;]+/, $controller->{'peers'});
 my ($ifaceip, $iface) = 
PVE::Network::SDN::Zones::Plugin::find_local_ip_interface_peers(\@peers);
 
 my $mtu = 1450;
diff --git a/PVE/Network/SDN/Zones/VxlanPlugin.pm 
b/PVE/Network/SDN/Zones/VxlanPlugin.pm
index bc585c6..f2c2eec 100644
--- a/PVE/Network/SDN/Zones/VxlanPlugin.pm
+++ b/PVE/Network/SDN/Zones/VxlanPlugin.pm
@@ -50,7 +50,7 @@ sub generate_sdn_config {
 my $ipv6 = $vnet->{ipv6};
 my $mac = $vnet->{mac};
 my $multicastaddress = $plugin_config->{'multicast-address'};
-my @peers = split(',', $plugin_config->{'peers'}) if 
$plugin_config->{'peers'};
+my @peers = split(/[ ,;]+/, $plugin_config->{'peers'}) if 
$plugin_config->{'peers'};
 my $vxlan_iface = "vxlan_$vnetid";
 
 die "missing vxlan tag" if !$tag;
-- 
2.20.1

___
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel