Re: [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params

2020-12-03 Thread Thomas Lamprecht
On 02.12.20 10:21, Dominik Csapak wrote:
> moved and generalized from pve-storage, since we'll need it
> in more places
> 
> Signed-off-by: Dominik Csapak 
> ---
>  src/PVE/Tools.pm | 24 
>  1 file changed, 24 insertions(+)
> 
> diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> index 4b445ea..bda236a 100644
> --- a/src/PVE/Tools.pm
> +++ b/src/PVE/Tools.pm
> @@ -48,6 +48,7 @@ template_replace
>  safe_print
>  trim
>  extract_param
> +extract_sensitive_params
>  file_copy
>  get_host_arch
>  O_PATH
> @@ -807,6 +808,29 @@ sub extract_param {
>  return $res;
>  }
>  

can we have some short comment about what this does and when/why it can be 
useful here

> +sub extract_sensitive_params :prototype($$$) {
> +my ($param, $sensitive_list, $delete_list) = @_;
> +
> +my $sensitive;

I know auto vivification and such things exist, but I'd feel more comfortable
to set above explicitly to and empty hash {} .

> +
> +my %delete = map { $_ => 1 } ($delete_list || [])->@*;
> +
> +# always extract sensitive keys, so they don't get written to the 
> www-data readable scfg

not only for scfg anymore, would drop that comment actually completely, that's 
rather
something for a method comment (see above)

> +for my $opt (@$sensitive_list) {
> + # First handle deletions as explicitly setting `undef`, afterwards new 
> values may override
> + # it.

I know this is just copied, but there's no actual reason for setting to undef 
vs.
using delete encoded in that comment, it's just merely describing what one sees
when reading the code anyhow..

@Wolfgang, you as original author (pve-storage commit 72385de9e23df) why did you
used undef vs. delete?

> + if (exists($delete{$opt})) {
> + $sensitive->{$opt} = undef;
> + }
> +
> + if (defined(my $value = extract_param($param, $opt))) {
> + $sensitive->{$opt} = $value;
> + }
> +}
> +
> +return $sensitive;
> +}
> +
>  # Note: we use this to wait until vncterm/spiceterm is ready
>  sub wait_for_vnc_port {
>  my ($port, $family, $timeout) = @_;
> 




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



[pve-devel] [PATCH qemu-server] fix backpu/restore with ipv6/ports for pbs

2020-12-03 Thread Dominik Csapak
by copying the 'get_server_with_port' from PVE::Storage::PBSPlugin
here and using it for generating the server

Signed-off-by: Dominik Csapak 
---
ideally we would make the get_server_with_port sub in pve-storage
public and use it here (like we do e.g. in container with
'run_raw_client_cmd') or even push that stuff into
PVE::PBSClient module in comment to reuse that here and in pve-storage

but to avoid the dependency bumps and fix it fast, this
should be enough for now

 PVE/QemuServer.pm| 14 +-
 PVE/VZDump/QemuServer.pm |  3 ++-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4989938..7170230 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6050,6 +6050,18 @@ sub rescan {
 }
 }
 
+sub pbs_get_server_with_port {
+my ($scfg) = @_;
+
+my $server = $scfg->{server};
+$server = "[$server]" if $server =~ /^$IPV6RE$/;
+
+if (my $port = $scfg->{port}) {
+   $server .= ":$port" if $port != 8007;
+}
+return $server;
+}
+
 sub restore_proxmox_backup_archive {
 my ($archive, $vmid, $user, $options) = @_;
 
@@ -6058,7 +6070,7 @@ sub restore_proxmox_backup_archive {
 my ($storeid, $volname) = PVE::Storage::parse_volume_id($archive);
 my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
 
-my $server = $scfg->{server};
+my $server = pbs_get_server_with_port($scfg);
 my $datastore = $scfg->{datastore};
 my $username = $scfg->{username} // 'root@pam';
 my $fingerprint = $scfg->{fingerprint};
diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
index 5003676..57436e6 100644
--- a/PVE/VZDump/QemuServer.pm
+++ b/PVE/VZDump/QemuServer.pm
@@ -473,7 +473,8 @@ sub archive_pbs {
 
 my $starttime = time();
 
-my $server = $scfg->{server};
+my $server = PVE::QemuServer::pbs_get_server_with_port($scfg);
+
 my $datastore = $scfg->{datastore};
 my $username = $scfg->{username} // 'root@pam';
 my $fingerprint = $scfg->{fingerprint};
-- 
2.20.1



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



Re: [pve-devel] [PATCH manager 1/7] api: cluster/metricserver: prevent simultaneosly setting and deleting of property

2020-12-03 Thread Thomas Lamprecht
On 02.12.20 10:21, Dominik Csapak wrote:
> like we do in other apis of section configs (e.g. storage)
> 
> Signed-off-by: Dominik Csapak 
> ---
>  PVE/API2/Cluster/MetricServer.pm | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/PVE/API2/Cluster/MetricServer.pm 
> b/PVE/API2/Cluster/MetricServer.pm
> index 9a14985e..ec3c7b75 100644
> --- a/PVE/API2/Cluster/MetricServer.pm
> +++ b/PVE/API2/Cluster/MetricServer.pm
> @@ -213,6 +213,8 @@ __PACKAGE__->register_method ({
>   my $d = $options->{$k} || die "no such option '$k'\n";
>   die "unable to delete required option '$k'\n" if 
> !$d->{optional};
>   die "unable to delete fixed option '$k'\n" if $d->{fixed};
> + die "cannot set and delete property '$k' at the same 
> time!\n"
> + if defined($opts->{$k});
>  
>   delete $data->{$k};
>   }
> 

That counts as API change, strictly speaking.. For container and VMs we order
deletions before setting the value, and the one from container is the last
one which got some actual thoughts and discussion going on, IIRC, albeit not
to sure if about that exact behavior (as it was probably pre-existing).

It'd be good to at least decide for one behavior and try making that universal,
as else this is confusing..



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



Re: [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params

2020-12-03 Thread Wolfgang Bumiller


> On 12/03/2020 9:47 AM Thomas Lamprecht  wrote:
> 
>  
> On 02.12.20 10:21, Dominik Csapak wrote:
> > moved and generalized from pve-storage, since we'll need it
> > in more places
> > 
> > Signed-off-by: Dominik Csapak 
> > ---
> >  src/PVE/Tools.pm | 24 
> >  1 file changed, 24 insertions(+)
> > 
> > diff --git a/src/PVE/Tools.pm b/src/PVE/Tools.pm
> > index 4b445ea..bda236a 100644
> > --- a/src/PVE/Tools.pm
> > +++ b/src/PVE/Tools.pm
> > @@ -48,6 +48,7 @@ template_replace
> >  safe_print
> >  trim
> >  extract_param
> > +extract_sensitive_params
> >  file_copy
> >  get_host_arch
> >  O_PATH
> > @@ -807,6 +808,29 @@ sub extract_param {
> >  return $res;
> >  }
> >  
> 
> can we have some short comment about what this does and when/why it can be 
> useful here
> 
> > +sub extract_sensitive_params :prototype($$$) {
> > +my ($param, $sensitive_list, $delete_list) = @_;
> > +
> > +my $sensitive;
> 
> I know auto vivification and such things exist, but I'd feel more comfortable
> to set above explicitly to and empty hash {} .
> 
> > +
> > +my %delete = map { $_ => 1 } ($delete_list || [])->@*;
> > +
> > +# always extract sensitive keys, so they don't get written to the 
> > www-data readable scfg
> 
> not only for scfg anymore, would drop that comment actually completely, 
> that's rather
> something for a method comment (see above)
> 
> > +for my $opt (@$sensitive_list) {
> > +   # First handle deletions as explicitly setting `undef`, afterwards new 
> > values may override
> > +   # it.
> 
> I know this is just copied, but there's no actual reason for setting to undef 
> vs.
> using delete encoded in that comment, it's just merely describing what one 
> sees
> when reading the code anyhow..
> 
> @Wolfgang, you as original author (pve-storage commit 72385de9e23df) why did 
> you
> used undef vs. delete?

The update hooks in pve-storage don't get the deletion-list passed on as 
parameter,
so I translated into putting `undef` into the parameter list.


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



[pve-devel] [PATCH V2 pve-network 1/7] evpn: frr: use datacenter default profile (lower timeouts)

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/Controllers/EvpnPlugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index e59c142..b997cca 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -288,7 +288,7 @@ sub write_controller_config {
 push @{$final_config}, "log syslog informational";
 push @{$final_config}, "ip forwarding";
 push @{$final_config}, "ipv6 forwarding";
-push @{$final_config}, "frr defaults traditional";
+push @{$final_config}, "frr defaults datacenter";
 push @{$final_config}, "service integrated-vtysh-config";
 push @{$final_config}, "hostname $nodename";
 push @{$final_config}, "!";
-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 0/7] various cleanups

2020-12-03 Thread Alexandre Derumier
changelog v2:

- add more bugfix

Alexandre Derumier (7):
  evpn: frr: use datacenter default profile (lower timeouts)
  get_local_vnets: display vnet alias in comments
  use canonical ipv6 address (RFC 5952) everywhere
  ipam : pve: don't register hostname/description
  zones: evpn: fix exitnodes for snat
  zones: plugin : readd encode/decode value
  subnets: api : add missing param in on_update_hook for update

 PVE/API2/Network/SDN/Subnets.pm   |  2 +-
 PVE/Network/SDN.pm| 25 +++-
 PVE/Network/SDN/Controllers/EvpnPlugin.pm |  5 ++--
 PVE/Network/SDN/Dns/PowerdnsPlugin.pm |  3 +--
 PVE/Network/SDN/Ipams/PVEPlugin.pm| 15 
 PVE/Network/SDN/Subnets.pm|  9 +++-
 PVE/Network/SDN/Zones/EvpnPlugin.pm   |  9 
 PVE/Network/SDN/Zones/Plugin.pm   | 28 +++
 8 files changed, 53 insertions(+), 43 deletions(-)

-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 2/7] get_local_vnets: display vnet alias in comments

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN.pm | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index c0c5672..ed891de 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -188,6 +188,8 @@ sub get_local_vnets {
 
my $vnet = PVE::Network::SDN::Vnets::sdn_vnets_config($vnets_cfg, 
$vnetid);
my $zoneid = $vnet->{zone};
+   my $comments = $vnet->{alias};
+
my $privs = [ 'SDN.Audit', 'SDN.Allocate' ];
 
next if !$zoneid;
@@ -196,7 +198,7 @@ sub get_local_vnets {
my $zone_config = 
PVE::Network::SDN::Zones::sdn_zones_config($zones_cfg, $zoneid);
 
next if defined($zone_config->{nodes}) && 
!$zone_config->{nodes}->{$nodename};
-   $vnets->{$vnetid} = { type => 'vnet', active => '1' };
+   $vnets->{$vnetid} = { type => 'vnet', active => '1', comments => 
$comments };
 }
 
 return $vnets;
-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 4/7] ipam : pve: don't register hostname/description

2020-12-03 Thread Alexandre Derumier
we already have this informations in vm/ct config,
and we are limited in space in pmxcfs

Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/Ipams/PVEPlugin.pm | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/PVE/Network/SDN/Ipams/PVEPlugin.pm 
b/PVE/Network/SDN/Ipams/PVEPlugin.pm
index a2e7d86..4925274 100644
--- a/PVE/Network/SDN/Ipams/PVEPlugin.pm
+++ b/PVE/Network/SDN/Ipams/PVEPlugin.pm
@@ -98,10 +98,7 @@ sub add_ip {
 
die "IP '$ip' already exist\n" if defined($dbsubnet->{ips}->{$ip});
 
-   $dbsubnet->{ips}->{$ip} = {
-   hostname => $hostname,
-   description => $description,
-   };
+   $dbsubnet->{ips}->{$ip} = {};
 
write_db($db);
 });
@@ -144,10 +141,7 @@ sub add_next_freeip {
 
die "can't find free ip in subnet '$cidr'\n" if !$freeip;
 
-   $dbsubnet->{ips}->{$freeip} = {
-   hostname => $hostname,
-   description => $description,
-   };
+   $dbsubnet->{ips}->{$freeip} = {};
 
write_db($db);
 });
-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 7/7] subnets: api : add missing param in on_update_hook for update

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/API2/Network/SDN/Subnets.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/API2/Network/SDN/Subnets.pm b/PVE/API2/Network/SDN/Subnets.pm
index a3bc10b..07ef2e1 100644
--- a/PVE/API2/Network/SDN/Subnets.pm
+++ b/PVE/API2/Network/SDN/Subnets.pm
@@ -240,7 +240,7 @@ __PACKAGE__->register_method ({
raise_param_exc({ ipam => "you can't change ipam"}) if 
$opts->{ipam} && $scfg->{ipam} && $opts->{ipam} ne $scfg->{ipam};
 
my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($cfg, 
$id);
-   PVE::Network::SDN::SubnetPlugin->on_update_hook($zone, $id, 
$subnet);
+   PVE::Network::SDN::SubnetPlugin->on_update_hook($zone, $id, 
$subnet, $scfg);
 
PVE::Network::SDN::Subnets::write_config($cfg);
 
-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 5/7] zones: evpn: fix exitnodes for snat

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

diff --git a/PVE/Network/SDN/Controllers/EvpnPlugin.pm 
b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
index b997cca..6927921 100644
--- a/PVE/Network/SDN/Controllers/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Controllers/EvpnPlugin.pm
@@ -144,7 +144,8 @@ sub generate_controller_zone_config {
push(@{$config->{frr}->{router}->{"bgp $asn vrf 
$vrf"}->{"address-family"}->{"l2vpn evpn"}}, "route-target export 
$autortas:$vrfvxlan");
 }
 
-my $is_gateway = grep { $_ eq $local_node } 
PVE::Tools::split_list($exitnodes);
+my $is_gateway = $exitnodes->{$local_node};
+
 if ($is_gateway) {
 
@controller_config = ();
diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm 
b/PVE/Network/SDN/Zones/EvpnPlugin.pm
index d833641..e6ee839 100644
--- a/PVE/Network/SDN/Zones/EvpnPlugin.pm
+++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm
@@ -100,12 +100,11 @@ sub generate_sdn_config {
push @iface_config, "address $gateway/$mask" if 
!defined($address->{$gateway});
$address->{$gateway} = 1;
}
+
if ($subnet->{snat}) {
-   my $gatewaynodes = $controller->{'gateway-nodes'};
-   my $is_evpn_gateway = "";
-   foreach my $evpn_gatewaynode 
(PVE::Tools::split_list($gatewaynodes)) {
-   $is_evpn_gateway = 1 if $evpn_gatewaynode eq $local_node;
-   }
+
+   my $is_evpn_gateway = $plugin_config->{'exitnodes'}->{$local_node};
+
 #find outgoing interface
 my ($outip, $outiface) = 
PVE::Network::SDN::Zones::Plugin::get_local_route_ip('8.8.8.8');
 if ($outip && $outiface && $is_evpn_gateway) {
-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 3/7] use canonical ipv6 address (RFC 5952) everywhere

2020-12-03 Thread Alexandre Derumier
we want only 1 format for ipam database

Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN/Dns/PowerdnsPlugin.pm | 3 +--
 PVE/Network/SDN/Ipams/PVEPlugin.pm| 5 +++--
 PVE/Network/SDN/Subnets.pm| 9 -
 3 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/PVE/Network/SDN/Dns/PowerdnsPlugin.pm 
b/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
index b00432e..3fbd595 100644
--- a/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
+++ b/PVE/Network/SDN/Dns/PowerdnsPlugin.pm
@@ -7,8 +7,7 @@ use PVE::Cluster;
 use PVE::Tools;
 use JSON;
 use Net::IP;
-use NetAddr::IP;
-
+use NetAddr::IP qw(:lower);
 use base('PVE::Network::SDN::Dns::Plugin');
 
 sub type {
diff --git a/PVE/Network/SDN/Ipams/PVEPlugin.pm 
b/PVE/Network/SDN/Ipams/PVEPlugin.pm
index e4c9ef7..a2e7d86 100644
--- a/PVE/Network/SDN/Ipams/PVEPlugin.pm
+++ b/PVE/Network/SDN/Ipams/PVEPlugin.pm
@@ -6,7 +6,8 @@ use PVE::INotify;
 use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_register_file 
cfs_lock_file);
 use PVE::Tools;
 use JSON;
-use NetAddr::IP;
+use NetAddr::IP qw(:lower);
+
 use Net::IP;
 use Digest::SHA;
 
@@ -134,7 +135,7 @@ sub add_next_freeip {
while(1) {
$iplist++;
last if $iplist eq $broadcast;
-   my $ip = $iplist->addr();
+   my $ip = $iplist->canon();
next if defined($dbsubnet->{ips}->{$ip});
$freeip = $ip;
last;
diff --git a/PVE/Network/SDN/Subnets.pm b/PVE/Network/SDN/Subnets.pm
index 74a538c..81970a1 100644
--- a/PVE/Network/SDN/Subnets.pm
+++ b/PVE/Network/SDN/Subnets.pm
@@ -5,6 +5,7 @@ use warnings;
 
 use Net::Subnet qw(subnet_matcher);
 use Net::IP;
+use NetAddr::IP qw(:lower);
 
 use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file);
 use PVE::Network::SDN::Dns;
@@ -213,6 +214,9 @@ sub add_ip {
 
 return if !$subnet || !$ip; 
 
+my $ipaddr = new NetAddr::IP($ip);
+$ip = $ipaddr->canon();
+
 my $ipamid = $zone->{ipam};
 my $dns = $zone->{dns};
 my $dnszone = $zone->{dnszone};
@@ -255,7 +259,10 @@ sub add_ip {
 sub del_ip {
 my ($zone, $subnetid, $subnet, $ip, $hostname) = @_;
 
-return if !$subnet;
+return if !$subnet || !$ip;
+
+my $ipaddr = new NetAddr::IP($ip);
+$ip = $ipaddr->canon();
 
 my $ipamid = $zone->{ipam};
 my $dns = $zone->{dns};
-- 
2.20.1


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



[pve-devel] [PATCH V2 pve-network 6/7] zones: plugin : readd encode/decode value

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 PVE/Network/SDN.pm  | 21 -
 PVE/Network/SDN/Zones/Plugin.pm | 28 
 2 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index ed891de..256a7c8 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -6,8 +6,6 @@ use warnings;
 use Data::Dumper;
 use JSON;
 
-use PVE::JSONSchema;
-
 use PVE::Network::SDN::Vnets;
 use PVE::Network::SDN::Zones;
 use PVE::Network::SDN::Controllers;
@@ -218,25 +216,6 @@ sub generate_controller_config {
 PVE::Network::SDN::Controllers::reload_controller() if $reload;
 }
 
-
-sub decode_value {
-my ($type, $key, $value) = @_;
-
-if ($key eq 'nodes') {
-my $res = {};
-
-foreach my $node (PVE::Tools::split_list($value)) {
-if (PVE::JSONSchema::pve_verify_node_name($node)) {
-$res->{$node} = 1;
-}
-}
-
-return $res;
-}
-
-   return $value;
-}
-
 sub encode_value {
 my ($type, $key, $value) = @_;
 
diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm
index ebb5c7e..9db2791 100644
--- a/PVE/Network/SDN/Zones/Plugin.pm
+++ b/PVE/Network/SDN/Zones/Plugin.pm
@@ -69,6 +69,34 @@ sub parse_section_header {
 return undef;
 }
 
+sub decode_value {
+my ($class, $type, $key, $value) = @_;
+
+if ($key eq 'nodes' || $key eq 'exitnodes') {
+   my $res = {};
+
+   foreach my $node (PVE::Tools::split_list($value)) {
+   if (PVE::JSONSchema::pve_verify_node_name($node)) {
+   $res->{$node} = 1;
+   }
+   }
+
+   return $res;
+}
+
+return $value;
+}
+
+sub encode_value {
+my ($class, $type, $key, $value) = @_;
+
+if ($key eq 'nodes' || $key eq 'exitnodes') {
+   return join(',', keys(%$value));
+}
+
+return $value;
+}
+
 sub generate_sdn_config {
 my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, 
$controller_cfg, $subnet_cfg, $interfaces_config, $config) = @_;
 
-- 
2.20.1


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



Re: [pve-devel] [PATCH qemu-server] fix backpu/restore with ipv6/ports for pbs

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 09:43, Dominik Csapak wrote:
> by copying the 'get_server_with_port' from PVE::Storage::PBSPlugin
> here and using it for generating the server
> 
> Signed-off-by: Dominik Csapak 
> ---
> ideally we would make the get_server_with_port sub in pve-storage
> public and use it here (like we do e.g. in container with
> 'run_raw_client_cmd') or even push that stuff into

we actually want to remove all run_raw_client_cmd usage, because it has no
checks and is pretty raw - a clean interface would be much nicer..



> PVE::PBSClient module in comment to reuse that here and in pve-storage
> 
> but to avoid the dependency bumps and fix it fast, this
> should be enough for now
> 

I know I said to try to avoid the need for dependency bumps if possible, so
this one is one me.

>  PVE/QemuServer.pm| 14 +-
>  PVE/VZDump/QemuServer.pm |  3 ++-
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
> index 4989938..7170230 100644
> --- a/PVE/QemuServer.pm
> +++ b/PVE/QemuServer.pm
> @@ -6050,6 +6050,18 @@ sub rescan {
>  }
>  }
>  
> +sub pbs_get_server_with_port {
> +my ($scfg) = @_;
> +
> +my $server = $scfg->{server};
> +$server = "[$server]" if $server =~ /^$IPV6RE$/;
> +
> +if (my $port = $scfg->{port}) {
> + $server .= ":$port" if $port != 8007;
> +}
> +return $server;
> +}
> +
>  sub restore_proxmox_backup_archive {
>  my ($archive, $vmid, $user, $options) = @_;
>  
> @@ -6058,7 +6070,7 @@ sub restore_proxmox_backup_archive {
>  my ($storeid, $volname) = PVE::Storage::parse_volume_id($archive);
>  my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
>  
> -my $server = $scfg->{server};
> +my $server = pbs_get_server_with_port($scfg);
>  my $datastore = $scfg->{datastore};
>  my $username = $scfg->{username} // 'root@pam';
>  my $fingerprint = $scfg->{fingerprint};

a few lines below, just out of context we see the sole use for all this 
extracting:

my $repo = "$username\@$server:$datastore";

So how about adding a get_repo sub to storage, or the PBSClient in pve-common
(if we have a documented datastructure like scfg to get the info sanely from).

> diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
> index 5003676..57436e6 100644
> --- a/PVE/VZDump/QemuServer.pm
> +++ b/PVE/VZDump/QemuServer.pm
> @@ -473,7 +473,8 @@ sub archive_pbs {
>  
>  my $starttime = time();
>  
> -my $server = $scfg->{server};
> +my $server = PVE::QemuServer::pbs_get_server_with_port($scfg);
> +
>  my $datastore = $scfg->{datastore};
>  my $username = $scfg->{username} // 'root@pam';
>  my $fingerprint = $scfg->{fingerprint};
> 




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



Re: [pve-devel] [PATCH common 1/1] tools: add extract_sensitive_params

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 10:16, Wolfgang Bumiller wrote:
>> On 12/03/2020 9:47 AM Thomas Lamprecht  wrote:
>> On 02.12.20 10:21, Dominik Csapak wrote:
>>> +for my $opt (@$sensitive_list) {
>>> +   # First handle deletions as explicitly setting `undef`, afterwards new 
>>> values may override
>>> +   # it.
>>
>> I know this is just copied, but there's no actual reason for setting to 
>> undef vs.
>> using delete encoded in that comment, it's just merely describing what one 
>> sees
>> when reading the code anyhow..
>>
>> @Wolfgang, you as original author (pve-storage commit 72385de9e23df) why did 
>> you
>> used undef vs. delete?
> 
> The update hooks in pve-storage don't get the deletion-list passed on as 
> parameter,
> so I translated into putting `undef` into the parameter list.
> 

OK, then  that would be a much better comment here as it gives an
actual reason, something like

# delete by setting to undef so that add/update hooks can know about it



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



Re: [pve-devel] [PATCH qemu-server] fix backpu/restore with ipv6/ports for pbs

2020-12-03 Thread Dominik Csapak

On 12/3/20 10:27 AM, Thomas Lamprecht wrote:

On 03.12.20 09:43, Dominik Csapak wrote:

by copying the 'get_server_with_port' from PVE::Storage::PBSPlugin
here and using it for generating the server

Signed-off-by: Dominik Csapak 
---
ideally we would make the get_server_with_port sub in pve-storage
public and use it here (like we do e.g. in container with
'run_raw_client_cmd') or even push that stuff into


we actually want to remove all run_raw_client_cmd usage, because it has no
checks and is pretty raw - a clean interface would be much nicer..



ok, makes sense





PVE::PBSClient module in comment to reuse that here and in pve-storage

but to avoid the dependency bumps and fix it fast, this
should be enough for now



I know I said to try to avoid the need for dependency bumps if possible, so
this one is one me.


no problem :)




  PVE/QemuServer.pm| 14 +-
  PVE/VZDump/QemuServer.pm |  3 ++-
  2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4989938..7170230 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -6050,6 +6050,18 @@ sub rescan {
  }
  }
  
+sub pbs_get_server_with_port {

+my ($scfg) = @_;
+
+my $server = $scfg->{server};
+$server = "[$server]" if $server =~ /^$IPV6RE$/;
+
+if (my $port = $scfg->{port}) {
+   $server .= ":$port" if $port != 8007;
+}
+return $server;
+}
+
  sub restore_proxmox_backup_archive {
  my ($archive, $vmid, $user, $options) = @_;
  
@@ -6058,7 +6070,7 @@ sub restore_proxmox_backup_archive {

  my ($storeid, $volname) = PVE::Storage::parse_volume_id($archive);
  my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
  
-my $server = $scfg->{server};

+my $server = pbs_get_server_with_port($scfg);
  my $datastore = $scfg->{datastore};
  my $username = $scfg->{username} // 'root@pam';
  my $fingerprint = $scfg->{fingerprint};


a few lines below, just out of context we see the sole use for all this 
extracting:

my $repo = "$username\@$server:$datastore";

So how about adding a get_repo sub to storage, or the PBSClient in pve-common
(if we have a documented datastructure like scfg to get the info sanely from).


well afaics, we use everywhere the same section config options
(server,fingerprint,datastore,etc.) except there is no 'port'
setting in pmg (put this code here handles it ok, and we can add it no 
problem)

is that enough, or how else would you document it (or make
sure users know what to put in here)?

would a simple comment above the helper be enough? or should we
try to refactor those section config options across products?

so i'd simply add a 'build_repository' sub to pve-commons pbsclient module,
and use that everywhere we need that
is that ok?




diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
index 5003676..57436e6 100644
--- a/PVE/VZDump/QemuServer.pm
+++ b/PVE/VZDump/QemuServer.pm
@@ -473,7 +473,8 @@ sub archive_pbs {
  
  my $starttime = time();
  
-my $server = $scfg->{server};

+my $server = PVE::QemuServer::pbs_get_server_with_port($scfg);
+
  my $datastore = $scfg->{datastore};
  my $username = $scfg->{username} // 'root@pam';
  my $fingerprint = $scfg->{fingerprint};








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



Re: [pve-devel] [PATCH qemu-server] fix backpu/restore with ipv6/ports for pbs

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 10:40, Dominik Csapak wrote:
>>
>> a few lines below, just out of context we see the sole use for all this 
>> extracting:
>>
>> my $repo = "$username\@$server:$datastore";
>>
>> So how about adding a get_repo sub to storage, or the PBSClient in pve-common
>> (if we have a documented datastructure like scfg to get the info sanely 
>> from).
> 
> well afaics, we use everywhere the same section config options
> (server,fingerprint,datastore,etc.) except there is no 'port'
> setting in pmg (put this code here handles it ok, and we can add it no 
> problem)
> is that enough, or how else would you document it (or make
> sure users know what to put in here)?
> 
> would a simple comment above the helper be enough? or should we
> try to refactor those section config options across products?

yeah a short comment and maybe the structure of known keys in the $cfg
variable should be enough for us - I do not see this changing soon.

I did something like that for the pve-storage "scan_datastores" sub:
https://git.proxmox.com/?p=pve-storage.git;a=commitdiff;h=8b62ac6a0ce0d4757ce25082123d18434f5b3a58

> 
> so i'd simply add a 'build_repository' sub to pve-commons pbsclient module,
> and use that everywhere we need that
> is that ok?

Personally I'd went for "get_repository", build sounds a bit strange to me,
albeit it is not wrong (this has big bike shedding potential, so no hard
feelings from me).



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


[pve-devel] [PATCH v9 pve-manager 14/18] sdn: browser: add onlinehelp

2020-12-03 Thread Alexandre Derumier
(needed, or the panel don't load)

Signed-off-by: Alexandre Derumier 
---
 www/manager6/sdn/Browser.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/www/manager6/sdn/Browser.js b/www/manager6/sdn/Browser.js
index 1415f966..e5ffc0e8 100644
--- a/www/manager6/sdn/Browser.js
+++ b/www/manager6/sdn/Browser.js
@@ -2,6 +2,8 @@ Ext.define('PVE.sdn.Browser', {
 extend: 'PVE.panel.Config',
 alias: 'widget.PVE.sdn.Browser',
 
+onlineHelp: 'chapter_pvesdn',
+
 initComponent: function() {
 var me = this;
 
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 01/18] sdn: vnetedit: add subnets && remove ip/mac

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/sdn/VnetEdit.js | 29 +++--
 www/manager6/sdn/VnetView.js | 18 +++---
 2 files changed, 6 insertions(+), 41 deletions(-)

diff --git a/www/manager6/sdn/VnetEdit.js b/www/manager6/sdn/VnetEdit.js
index aa40b41f..09e2f3bf 100644
--- a/www/manager6/sdn/VnetEdit.js
+++ b/www/manager6/sdn/VnetEdit.js
@@ -64,34 +64,11 @@ Ext.define('PVE.sdn.VnetInputPanel', {
},
{
xtype: 'textfield',
-   name: 'mac',
-   fieldLabel: gettext('MAC Address'),
-   vtype: 'MacAddress',
-   skipEmptyText: true,
+   name: 'subnets',
+   fieldLabel: gettext('Subnets'),
allowBlank: true,
-   emptyText: 'auto',
},
-],
-advancedItems: [
-   {
-   xtype: 'textfield',
-   name: 'ipv4',
-   vtype: 'IPCIDRAddress',
-   fieldLabel: 'IPv4/CIDR', // do not localize
-   emptyText: 'Optional anycast addr. for BGP',
-   skipEmptyText: true,
-   allowBlank: true,
-   },
-   {
-   xtype: 'textfield',
-   name: 'ipv6',
-   vtype: 'IP6CIDRAddress',
-   fieldLabel: 'IPv6/CIDR', // do not localize
-   emptyText: 'Optional anycast addr. for BGP',
-   skipEmptyText: true,
-   allowBlank: true,
-   },
-],
+]
 });
 
 Ext.define('PVE.sdn.VnetEdit', {
diff --git a/www/manager6/sdn/VnetView.js b/www/manager6/sdn/VnetView.js
index e73632d1..604a2d1a 100644
--- a/www/manager6/sdn/VnetView.js
+++ b/www/manager6/sdn/VnetView.js
@@ -98,20 +98,10 @@ Ext.define('PVE.sdn.VnetView', {
dataIndex: 'vlanaware',
},
{
-   header: 'IPv4/CIDR',
+   header: 'Subnets',
flex: 1,
-   dataIndex: 'ipv4',
+   dataIndex: 'subnets',
},
-   {
-   header: 'IPv6/CIDR',
-   flex: 1,
-   dataIndex: 'ipv6',
-   },
-   {
-   header: 'MAC',
-   flex: 1,
-   dataIndex: 'mac',
-   }
],
listeners: {
activate: reload,
@@ -127,9 +117,7 @@ Ext.define('PVE.sdn.VnetView', {
extend: 'Ext.data.Model',
fields: [
'alias',
-   'ipv4',
-   'ipv6',
-   'mac',
+   'subnets',
'tag',
'type',
'vnet',
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 10/18] subnets: move ipam/dns in advanced section, and use "pve" as default ipam

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Utils.js  | 3 ++-
 www/manager6/sdn/SubnetEdit.js | 6 --
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 8c939536..5440b972 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -809,7 +809,8 @@ Ext.define('PVE.Utils', { utilities: {
pve: {
name: 'PVE',
ipanel: 'PVEIpamInputPanel',
-   faIcon: 'th'
+   faIcon: 'th',
+   hideAdd: true
},
netbox: {
name: 'Netbox',
diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index d8c61dd6..653c8ae5 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -46,12 +46,14 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
checked: false,
fieldLabel: 'SNAT'
},
+],
+advancedItems: [
 {
 xtype: 'pveSDNIpamSelector',
 fieldLabel: gettext('Ipam'),
 name: 'ipam',
-value: '',
-allowBlank: true,
+value: 'pve',
+allowBlank: false,
 },
 {
 xtype: 'pveSDNDnsSelector',
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 08/18] add vnet option to subnets and remove subnets list from vnet

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile|  1 +
 www/manager6/form/SDNVnetSelector.js | 68 
 www/manager6/sdn/SubnetEdit.js   |  7 +++
 www/manager6/sdn/SubnetView.js   |  5 ++
 www/manager6/sdn/VnetEdit.js |  8 +---
 www/manager6/sdn/VnetView.js | 22 +
 6 files changed, 83 insertions(+), 28 deletions(-)
 create mode 100644 www/manager6/form/SDNVnetSelector.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index fa809089..5bd062b0 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -52,6 +52,7 @@ JSSRC=
\
form/QemuBiosSelector.js\
form/SDNControllerSelector.js   \
form/SDNZoneSelector.js \
+   form/SDNVnetSelector.js \
form/SDNIpamSelector.js \
form/SDNDnsSelector.js  \
form/ScsiHwSelector.js  \
diff --git a/www/manager6/form/SDNVnetSelector.js 
b/www/manager6/form/SDNVnetSelector.js
new file mode 100644
index ..0f9a6613
--- /dev/null
+++ b/www/manager6/form/SDNVnetSelector.js
@@ -0,0 +1,68 @@
+Ext.define('PVE.form.SDNVnetSelector', {
+extend: 'Proxmox.form.ComboGrid',
+alias: ['widget.pveSDNVnetSelector'],
+
+allowBlank: false,
+valueField: 'vnet',
+displayField: 'vnet',
+
+initComponent: function() {
+   var me = this;
+
+   var store = new Ext.data.Store({
+   model: 'pve-sdn-vnet',
+sorters: {
+property: 'vnet',
+order: 'DESC'
+},
+   });
+
+   Ext.apply(me, {
+   store: store,
+   autoSelect: false,
+listConfig: {
+   columns: [
+   {
+   header: gettext('Vnet'),
+   sortable: true,
+   dataIndex: 'vnet',
+   flex: 1
+   },
+   {
+   header: gettext('Alias'),
+   flex: 1,
+   dataIndex: 'alias',
+   },
+   {
+   header: gettext('Tag'),
+   flex: 1,
+   dataIndex: 'tag',
+   }
+   ]
+   }
+   });
+
+me.callParent();
+
+   store.load();
+}
+
+}, function() {
+
+Ext.define('pve-sdn-vnet', {
+   extend: 'Ext.data.Model',
+   fields: [
+   'alias',
+   'tag',
+   'type',
+   'vnet',
+   'zone',
+   ],
+   proxy: {
+type: 'proxmox',
+   url: "/api2/json/cluster/sdn/vnets"
+   },
+   idProperty: 'vnet'
+});
+
+});
diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index ac9a40ea..8badc34a 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -32,6 +32,13 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
allowBlank: false,
fieldLabel: gettext('Subnet'),
},
+{
+xtype: 'pveSDNVnetSelector',
+fieldLabel: gettext('Vnet'),
+name: 'vnet',
+value: '',
+allowBlank: true,
+},
{
xtype: 'textfield',
name: 'gateway',
diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView.js
index 95a468bc..012d127b 100644
--- a/www/manager6/sdn/SubnetView.js
+++ b/www/manager6/sdn/SubnetView.js
@@ -73,6 +73,11 @@ Ext.define('PVE.sdn.SubnetView', {
flex: 2,
dataIndex: 'cidr'
},
+   {
+   header: gettext('Vnet'),
+   flex: 1,
+   dataIndex: 'vnet',
+   },
{
header: gettext('Gateway'),
flex: 1,
diff --git a/www/manager6/sdn/VnetEdit.js b/www/manager6/sdn/VnetEdit.js
index 09e2f3bf..03e539ab 100644
--- a/www/manager6/sdn/VnetEdit.js
+++ b/www/manager6/sdn/VnetEdit.js
@@ -61,13 +61,7 @@ Ext.define('PVE.sdn.VnetInputPanel', {
uncheckedValue: 0,
checked: false,
fieldLabel: gettext('VLAN Aware')
-   },
-   {
-   xtype: 'textfield',
-   name: 'subnets',
-   fieldLabel: gettext('Subnets'),
-   allowBlank: true,
-   },
+   }
 ]
 });
 
diff --git a/www/manager6/sdn/VnetView.js b/www/manager6/sdn/VnetView.js
index 604a2d1a..eefb6e42 100644
--- a/www/manager6/sdn/VnetView.js
+++ b/www/manager6/sdn/VnetView.js
@@ -96,12 +96,7 @@ Ext.define('PVE.sdn.VnetView', {
header: gettext('VLAN Aware'),
flex: 1,
dataIndex: 'vlanaware',
-   },
-   {
-

[pve-devel] [PATCH v9 pve-manager 03/18] add sdn ipams

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile |   5 +
 www/manager6/Utils.js |  25 +
 www/manager6/dc/Config.js |   8 ++
 www/manager6/form/SDNIpamSelector.js  |  52 ++
 www/manager6/sdn/IpamView.js  | 131 ++
 www/manager6/sdn/SubnetEdit.js|   7 ++
 www/manager6/sdn/SubnetView.js|   7 +-
 www/manager6/sdn/ipams/Base.js|  73 ++
 www/manager6/sdn/ipams/NetboxEdit.js  |  47 +
 www/manager6/sdn/ipams/PhpIpamEdit.js |  53 +++
 10 files changed, 407 insertions(+), 1 deletion(-)
 create mode 100644 www/manager6/form/SDNIpamSelector.js
 create mode 100644 www/manager6/sdn/IpamView.js
 create mode 100644 www/manager6/sdn/ipams/Base.js
 create mode 100644 www/manager6/sdn/ipams/NetboxEdit.js
 create mode 100644 www/manager6/sdn/ipams/PhpIpamEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 60a2894e..669b3cc7 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -52,6 +52,7 @@ JSSRC=
\
form/QemuBiosSelector.js\
form/SDNControllerSelector.js   \
form/SDNZoneSelector.js \
+   form/SDNIpamSelector.js \
form/ScsiHwSelector.js  \
form/SecurityGroupSelector.js   \
form/SnapshotSelector.js\
@@ -231,6 +232,10 @@ JSSRC= 
\
sdn/ZoneView.js \
sdn/controllers/Base.js \
sdn/controllers/EvpnEdit.js \
+sdn/IpamView.js \
+sdn/ipams/Base.js   \
+sdn/ipams/NetboxEdit.js \
+sdn/ipams/PhpIpamEdit.js\
sdn/zones/Base.js   \
sdn/zones/EvpnEdit.js   \
sdn/zones/QinQEdit.js   \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index b70592b4..9791215f 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -801,6 +801,23 @@ Ext.define('PVE.Utils', { utilities: {
},
 },
 
+sdnipamSchema: {
+   ipam: {
+name: 'ipam',
+hideAdd: true
+   },
+   netbox: {
+   name: 'Netbox',
+   ipanel: 'NetboxInputPanel',
+   faIcon: 'th'
+   },
+   phpipam: {
+   name: 'PhpIpam',
+   ipanel: 'PhpIpamInputPanel',
+   faIcon: 'th'
+   },
+},
+
 format_sdnvnet_type: function(value, md, record) {
var schema = PVE.Utils.sdnvnetSchema[value];
if (schema) {
@@ -825,6 +842,14 @@ Ext.define('PVE.Utils', { utilities: {
return Proxmox.Utils.unknownText;
 },
 
+format_sdnipam_type: function(value, md, record) {
+   var schema = PVE.Utils.sdnipamSchema[value];
+   if (schema) {
+   return schema.name;
+   }
+   return Proxmox.Utils.unknownText;
+},
+
 format_storage_type: function(value, md, record) {
if (value === 'rbd') {
value = (!record || record.get('monhost') ? 'rbd' : 'pveceph');
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 6f4756de..081be7fb 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -184,6 +184,14 @@ Ext.define('PVE.dc.Config', {
hidden: true,
iconCls: 'fa fa-network-wired',
itemId: 'sdnsubnet'
+   },
+   {
+   xtype: 'pveSDNIpamView',
+   groups: ['sdn'],
+   title: gettext('Ipams'),
+   hidden: true,
+   iconCls: 'fa fa-network-wired',
+   itemId: 'sdnipam'
});
}
 
diff --git a/www/manager6/form/SDNIpamSelector.js 
b/www/manager6/form/SDNIpamSelector.js
new file mode 100644
index ..5520d0fe
--- /dev/null
+++ b/www/manager6/form/SDNIpamSelector.js
@@ -0,0 +1,52 @@
+Ext.define('PVE.form.SDNIpamSelector', {
+extend: 'Proxmox.form.ComboGrid',
+alias: ['widget.pveSDNIpamSelector'],
+
+allowBlank: false,
+valueField: 'ipam',
+displayField: 'ipam',
+
+initComponent: function() {
+   var me = this;
+
+   var store = new Ext.data.Store({
+   model: 'pve-sdn-ipam',
+sorters: {
+property: 'ipam',
+order: 'DESC'
+},
+   });
+
+   Ext.apply(me, {
+   store: store,
+   autoSelect: false,
+listConfig: {
+   columns: [
+   {
+   header: gettext('Ipam'),
+   sortable:

[pve-devel] [PATCH v9 pve-manager 09/18] add vnet panel with vnet + subnets split view

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile  |  5 +--
 www/manager6/dc/Config.js  | 10 +-
 www/manager6/sdn/SubnetEdit.js | 13 +++
 www/manager6/sdn/SubnetView.js | 62 ++
 www/manager6/sdn/VnetPanel.js  | 39 +
 www/manager6/sdn/VnetView.js   | 14 ++--
 6 files changed, 100 insertions(+), 43 deletions(-)
 create mode 100644 www/manager6/sdn/VnetPanel.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 5bd062b0..d30b6529 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -228,8 +228,9 @@ JSSRC=  
\
sdn/StatusView.js   \
sdn/VnetEdit.js \
sdn/VnetView.js \
-   sdn/SubnetEdit.js   \
-   sdn/SubnetView.js   \
+   sdn/VnetPanel.js\
+   sdn/SubnetEdit.js   \
+   sdn/SubnetView.js   \
sdn/ZoneContentView.js  \
sdn/ZoneView.js \
sdn/controllers/Base.js \
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index b48eac3c..48238a4e 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -170,21 +170,13 @@ Ext.define('PVE.dc.Config', {
itemId: 'sdnzone'
},
{
-   xtype: 'pveSDNVnetView',
+   xtype: 'pveSDNVnet',
groups: ['sdn'],
title: gettext('Vnets'),
hidden: true,
iconCls: 'fa fa-network-wired',
itemId: 'sdnvnet'
},
-   {
-   xtype: 'pveSDNSubnetView',
-   groups: ['sdn'],
-   title: gettext('Subnets'),
-   hidden: true,
-   iconCls: 'fa fa-network-wired',
-   itemId: 'sdnsubnet'
-   },
{
xtype: 'pveSDNIpamView',
groups: ['sdn'],
diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index 8badc34a..d8c61dd6 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -32,13 +32,6 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
allowBlank: false,
fieldLabel: gettext('Subnet'),
},
-{
-xtype: 'pveSDNVnetSelector',
-fieldLabel: gettext('Vnet'),
-name: 'vnet',
-value: '',
-allowBlank: true,
-},
{
xtype: 'textfield',
name: 'gateway',
@@ -107,16 +100,18 @@ Ext.define('PVE.sdn.SubnetEdit', {
 
 width: 350,
 
+base_url: undefined,
+
 initComponent: function() {
var me = this;
 
me.isCreate = me.subnet === undefined;
 
if (me.isCreate) {
-   me.url = '/api2/extjs/cluster/sdn/subnets';
+   me.url = me.base_url;
me.method = 'POST';
} else {
-   me.url = '/api2/extjs/cluster/sdn/subnets/' + me.subnet;
+   me.url = me.base_url + '/' + me.subnet;
me.method = 'PUT';
}
 
diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView.js
index 012d127b..96240617 100644
--- a/www/manager6/sdn/SubnetView.js
+++ b/www/manager6/sdn/SubnetView.js
@@ -5,21 +5,38 @@ Ext.define('PVE.sdn.SubnetView', {
 stateful: true,
 stateId: 'grid-sdn-subnet',
 
+base_url: undefined,
+
+remove_btn: undefined,
+
+setBaseUrl: function(url) {
+var me = this;
+
+me.base_url = url;
+
+if (url === undefined) {
+me.store.removeAll();
+} else {
+me.remove_btn.baseurl = url + '/';
+me.store.setProxy({
+type: 'proxmox',
+url: '/api2/json/' + url
+});
+
+me.store.load();
+}
+},
+
 initComponent : function() {
let me = this;
 
-   let store = new Ext.data.Store({
-   model: 'pve-sdn-subnet',
-   proxy: {
-type: 'proxmox',
-   url: "/api2/json/cluster/sdn/subnets"
-   },
-   sorters: {
-   property: 'subnet',
-   order: 'DESC'
-   }
-   });
-   let reload = () => store.load();
+var store = new Ext.data.Store({
+model: 'pve-sdn-subnet'
+});
+
+var reload = function() {
+store.load();
+};
 
let sm = Ext.create('Ext.selection.RowModel', {});
 
@@ -29,6 +46,7 @@ Ext.define('PVE.sdn.SubnetView', {
let win = Ext.create('PVE.sdn.SubnetEdit',{
autoShow: tru

[pve-devel] [PATCH v9 pve-manager 06/18] add sdn dns

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile|   4 +
 www/manager6/Utils.js|  20 
 www/manager6/dc/Config.js|   8 ++
 www/manager6/form/SDNDnsSelector.js  |  52 +++
 www/manager6/sdn/DnsView.js  | 131 +++
 www/manager6/sdn/dns/Base.js |  73 +++
 www/manager6/sdn/dns/PowerdnsEdit.js |  52 +++
 7 files changed, 340 insertions(+)
 create mode 100644 www/manager6/form/SDNDnsSelector.js
 create mode 100644 www/manager6/sdn/DnsView.js
 create mode 100644 www/manager6/sdn/dns/Base.js
 create mode 100644 www/manager6/sdn/dns/PowerdnsEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 58bf2186..fa809089 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -53,6 +53,7 @@ JSSRC=
\
form/SDNControllerSelector.js   \
form/SDNZoneSelector.js \
form/SDNIpamSelector.js \
+   form/SDNDnsSelector.js  \
form/ScsiHwSelector.js  \
form/SecurityGroupSelector.js   \
form/SnapshotSelector.js\
@@ -237,6 +238,9 @@ JSSRC=  
\
 sdn/ipams/NetboxEdit.js \
 sdn/ipams/PVEIpamEdit.js\
 sdn/ipams/PhpIpamEdit.js\
+sdn/DnsView.js \
+sdn/dns/Base.js   \
+sdn/dns/PowerdnsEdit.js \
sdn/zones/Base.js   \
sdn/zones/EvpnEdit.js   \
sdn/zones/QinQEdit.js   \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 4637929d..8c939536 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -823,6 +823,18 @@ Ext.define('PVE.Utils', { utilities: {
},
 },
 
+sdndnsSchema: {
+   dns: {
+name: 'dns',
+hideAdd: true
+   },
+   powerdns: {
+   name: 'powerdns',
+   ipanel: 'PowerdnsInputPanel',
+   faIcon: 'th'
+   },
+},
+
 format_sdnvnet_type: function(value, md, record) {
var schema = PVE.Utils.sdnvnetSchema[value];
if (schema) {
@@ -855,6 +867,14 @@ Ext.define('PVE.Utils', { utilities: {
return Proxmox.Utils.unknownText;
 },
 
+format_sdndns_type: function(value, md, record) {
+   var schema = PVE.Utils.sdndnsSchema[value];
+   if (schema) {
+   return schema.name;
+   }
+   return Proxmox.Utils.unknownText;
+},
+
 format_storage_type: function(value, md, record) {
if (value === 'rbd') {
value = (!record || record.get('monhost') ? 'rbd' : 'pveceph');
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 081be7fb..b48eac3c 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -192,6 +192,14 @@ Ext.define('PVE.dc.Config', {
hidden: true,
iconCls: 'fa fa-network-wired',
itemId: 'sdnipam'
+   },
+   {
+   xtype: 'pveSDNDnsView',
+   groups: ['sdn'],
+   title: gettext('Dns'),
+   hidden: true,
+   iconCls: 'fa fa-network-wired',
+   itemId: 'sdndns'
});
}
 
diff --git a/www/manager6/form/SDNDnsSelector.js 
b/www/manager6/form/SDNDnsSelector.js
new file mode 100644
index ..7abb1f01
--- /dev/null
+++ b/www/manager6/form/SDNDnsSelector.js
@@ -0,0 +1,52 @@
+Ext.define('PVE.form.SDNDnsSelector', {
+extend: 'Proxmox.form.ComboGrid',
+alias: ['widget.pveSDNDnsSelector'],
+
+allowBlank: false,
+valueField: 'dns',
+displayField: 'dns',
+
+initComponent: function() {
+   var me = this;
+
+   var store = new Ext.data.Store({
+   model: 'pve-sdn-dns',
+sorters: {
+property: 'dns',
+order: 'DESC'
+},
+   });
+
+   Ext.apply(me, {
+   store: store,
+   autoSelect: false,
+listConfig: {
+   columns: [
+   {
+   header: gettext('dns'),
+   sortable: true,
+   dataIndex: 'dns',
+   flex: 1
+   },
+   ]
+   }
+   });
+
+me.callParent();
+
+   store.load();
+}
+
+}, function() {
+
+Ext.define('pve-sdn-dns', {
+   extend: 'Ext.data.Model',
+   fields: [ 'dns' ],
+   proxy: {
+type: 'proxmox',
+   url: "/api2/json/cluster/sdn/dns"
+   },
+  

[pve-devel] [PATCH v9 pve-manager 15/18] sdn: evpn improvments

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile|  1 +
 www/manager6/Utils.js|  5 ++
 www/manager6/sdn/ControllerView.js   |  9 
 www/manager6/sdn/controllers/BgpEdit.js  | 62 
 www/manager6/sdn/controllers/EvpnEdit.js | 16 +-
 www/manager6/sdn/zones/Base.js   |  5 ++
 www/manager6/sdn/zones/EvpnEdit.js   |  7 +++
 7 files changed, 91 insertions(+), 14 deletions(-)
 create mode 100644 www/manager6/sdn/controllers/BgpEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 5b702d4b..60850b3e 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -236,6 +236,7 @@ JSSRC=  
\
 sdn/OptionsPanel.js\
sdn/controllers/Base.js \
sdn/controllers/EvpnEdit.js \
+   sdn/controllers/BgpEdit.js  \
 sdn/IpamView.js \
 sdn/ipams/Base.js   \
 sdn/ipams/NetboxEdit.js \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 98cb8ca1..89706c32 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -828,6 +828,11 @@ Ext.define('PVE.Utils', { utilities: {
ipanel: 'EvpnInputPanel',
faIcon: 'crosshairs'
},
+   bgp: {
+   name: 'bgp',
+   ipanel: 'BgpInputPanel',
+   faIcon: 'crosshairs'
+   },
 },
 
 sdnipamSchema: {
diff --git a/www/manager6/sdn/ControllerView.js 
b/www/manager6/sdn/ControllerView.js
index e4730be0..9e400f7f 100644
--- a/www/manager6/sdn/ControllerView.js
+++ b/www/manager6/sdn/ControllerView.js
@@ -133,6 +133,15 @@ Ext.define('PVE.sdn.ControllerView', {
 return PVE.Utils.render_sdn_pending(rec, value, 
'type', 1);
 }
},
+   {
+   header: gettext('Node'),
+   flex: 1,
+   sortable: true,
+   dataIndex: 'node',
+renderer: function(value, metaData, rec) {
+return PVE.Utils.render_sdn_pending(rec, value, 
'node', 1);
+}
+   },
 {
 header: gettext('Pending'),
 flex: 3,
diff --git a/www/manager6/sdn/controllers/BgpEdit.js 
b/www/manager6/sdn/controllers/BgpEdit.js
new file mode 100644
index ..2af7a7bd
--- /dev/null
+++ b/www/manager6/sdn/controllers/BgpEdit.js
@@ -0,0 +1,62 @@
+Ext.define('PVE.sdn.controllers.BgpInputPanel', {
+extend: 'PVE.panel.SDNControllerBase',
+
+onlineHelp: 'pvesdn_controller_plugin_evpn',
+
+initComponent : function() {
+   var me = this;
+
+   me.items = [
+   {
+   xtype: me.isCreate ? 'textfield' : 'displayfield',
+   name: 'controller',
+   maxLength: 8,
+   value: me.controllerid || '',
+   fieldLabel: 'ID',
+   allowBlank: false
+   },
+   {
+   xtype: 'proxmoxintegerfield',
+   name: 'asn',
+   minValue: 1,
+   maxValue: 4294967295,
+   value: 65000,
+   fieldLabel: 'ASN #',
+   allowBlank: false
+   },
+   {
+   xtype: 'textfield',
+   name: 'peers',
+   fieldLabel: gettext('Peers'),
+   allowBlank: false
+   },
+   {
+   xtype: 'proxmoxcheckbox',
+   name: 'ebgp',
+   uncheckedValue: 0,
+   checked: false,
+   fieldLabel: 'EBGP'
+   },
+   {
+   xtype: 'pveNodeSelector',
+   name: 'node',
+   fieldLabel: gettext('Node'),
+   multiSelect: false,
+   autoSelect: false,
+   allowBlank: false
+   },
+
+   ];
+
+   me.advancedItems = [
+
+   {
+   xtype: 'textfield',
+   name: 'loopback',
+   fieldLabel: gettext('Loopback Interface'),
+   },
+   ];
+
+   me.callParent();
+}
+});
diff --git a/www/manager6/sdn/controllers/EvpnEdit.js 
b/www/manager6/sdn/controllers/EvpnEdit.js
index 125a8fc7..5aa924f0 100644
--- a/www/manager6/sdn/controllers/EvpnEdit.js
+++ b/www/manager6/sdn/controllers/EvpnEdit.js
@@ -29,20 +29,8 @@ Ext.define('PVE.sdn.controllers.EvpnInputPanel', {
name: 'peers',
fieldLabel: gettext('Peers'),
allowBlank: false
-   },
-   {
-   xtype: 'textfield',
-   name: 'gateway-external-peers',
-   fieldLabel: gettext('External Gateway Peers'),
-   allowBlank: true
-   },
-   {
-   xtyp

[pve-devel] [PATCH v9 pve-manager 05/18] sdn: subnets: ipam is optional

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/sdn/SubnetEdit.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index c9c6475b..2afa1a27 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -51,7 +51,7 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
 fieldLabel: gettext('Ipam'),
 name: 'ipam',
 value: '',
-allowBlank: false,
+allowBlank: true,
 },
 ]
 });
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 04/18] sdn: add PVEIpam

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile |  1 +
 www/manager6/Utils.js |  5 
 www/manager6/sdn/ipams/PVEIpamEdit.js | 34 +++
 3 files changed, 40 insertions(+)
 create mode 100644 www/manager6/sdn/ipams/PVEIpamEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 669b3cc7..58bf2186 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -235,6 +235,7 @@ JSSRC=  
\
 sdn/IpamView.js \
 sdn/ipams/Base.js   \
 sdn/ipams/NetboxEdit.js \
+sdn/ipams/PVEIpamEdit.js\
 sdn/ipams/PhpIpamEdit.js\
sdn/zones/Base.js   \
sdn/zones/EvpnEdit.js   \
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 9791215f..4637929d 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -806,6 +806,11 @@ Ext.define('PVE.Utils', { utilities: {
 name: 'ipam',
 hideAdd: true
},
+   pve: {
+   name: 'PVE',
+   ipanel: 'PVEIpamInputPanel',
+   faIcon: 'th'
+   },
netbox: {
name: 'Netbox',
ipanel: 'NetboxInputPanel',
diff --git a/www/manager6/sdn/ipams/PVEIpamEdit.js 
b/www/manager6/sdn/ipams/PVEIpamEdit.js
new file mode 100644
index ..43d040e0
--- /dev/null
+++ b/www/manager6/sdn/ipams/PVEIpamEdit.js
@@ -0,0 +1,34 @@
+Ext.define('PVE.sdn.ipams.PVEIpamInputPanel', {
+extend: 'PVE.panel.SDNIpamBase',
+
+//onlineHelp: 'pvesdn_ipam_plugin_pve', // FIXME uncomment once doc-gen is 
updated
+
+onGetValues: function(values) {
+var me = this;
+
+if (me.isCreate) {
+values.type = me.type;
+} else {
+delete values.ipam;
+}
+
+return values;
+},
+
+initComponent : function() {
+   var me = this;
+
+me.items = [
+   {
+xtype: me.isCreate ? 'textfield' : 'displayfield',
+name: 'ipam',
+maxLength: 10,
+value: me.zone || '',
+fieldLabel: 'ID',
+allowBlank: false
+  },
+   ];
+
+   me.callParent();
+}
+});
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 00/18] sdn: add subnets management

2020-12-03 Thread Alexandre Derumier
Changelogv2:

- add ipams gui

Changelogv3:

- add internal pve ipam form
- ipam is optional for subnets

Changelogv4:
- add dns 

changelogv5:

- move subnets to vnet split panel (like ipsets)
- move controllers, ipams, dns to a new options panel

changelogv6:

- display pending grid 
- move dns/ipams options from subnets to zone
- various cleanup/bugfix

changelogv7:

- add new bgp controller plugin
- rework evpn controller plugin

changelogv8:

- update onlinehelp links to last pve-docs patches
- cleanup zoneview panel grid

changelogv9:
- add pending state column with hover tip

Alexandre Derumier (18):
  sdn: vnetedit: add subnets && remove ip/mac
  add sdn subnets
  add sdn ipams
  sdn: add PVEIpam
  sdn: subnets: ipam is optional
  add sdn dns
  subnets: add dns fields
  add vnet option to subnets and remove subnets list from vnet
  add vnet panel with vnet + subnets split view
  subnets: move ipam/dns in advanced section, and use "pve" as default
ipam
  sdn: add options panel + move controller/ipam/dns view
  sdn: display pending values
  move ipams && dns options to zone
  sdn: browser: add onlinehelp
  sdn: evpn improvments
  sdn: update onlinehelp links
  sdn : zone content view: add alias && resize column
  sdn: add pending state column with hover tip

 www/manager6/Makefile|  16 +++
 www/manager6/Utils.js| 104 ++
 www/manager6/dc/Config.js|  18 +--
 www/manager6/form/SDNDnsSelector.js  |  52 +++
 www/manager6/form/SDNIpamSelector.js |  52 +++
 www/manager6/form/SDNVnetSelector.js |  68 +
 www/manager6/sdn/Browser.js  |   2 +
 www/manager6/sdn/ControllerView.js   |  44 +-
 www/manager6/sdn/DnsView.js  | 132 ++
 www/manager6/sdn/IpamView.js | 133 ++
 www/manager6/sdn/OptionsPanel.js |  41 ++
 www/manager6/sdn/SubnetEdit.js   | 104 ++
 www/manager6/sdn/SubnetView.js   | 169 +++
 www/manager6/sdn/VnetEdit.js |  43 +-
 www/manager6/sdn/VnetPanel.js|  39 ++
 www/manager6/sdn/VnetView.js |  81 ++-
 www/manager6/sdn/ZoneContentView.js  |  13 +-
 www/manager6/sdn/ZoneView.js |  78 +--
 www/manager6/sdn/controllers/BgpEdit.js  |  62 +
 www/manager6/sdn/controllers/EvpnEdit.js |  16 +--
 www/manager6/sdn/dns/Base.js |  73 ++
 www/manager6/sdn/dns/PowerdnsEdit.js |  52 +++
 www/manager6/sdn/ipams/Base.js   |  73 ++
 www/manager6/sdn/ipams/NetboxEdit.js |  47 +++
 www/manager6/sdn/ipams/PVEIpamEdit.js|  34 +
 www/manager6/sdn/ipams/PhpIpamEdit.js|  53 +++
 www/manager6/sdn/zones/Base.js   |  36 +
 www/manager6/sdn/zones/EvpnEdit.js   |   7 +
 www/manager6/sdn/zones/SimpleEdit.js |   1 -
 29 files changed, 1530 insertions(+), 113 deletions(-)
 create mode 100644 www/manager6/form/SDNDnsSelector.js
 create mode 100644 www/manager6/form/SDNIpamSelector.js
 create mode 100644 www/manager6/form/SDNVnetSelector.js
 create mode 100644 www/manager6/sdn/DnsView.js
 create mode 100644 www/manager6/sdn/IpamView.js
 create mode 100644 www/manager6/sdn/OptionsPanel.js
 create mode 100644 www/manager6/sdn/SubnetEdit.js
 create mode 100644 www/manager6/sdn/SubnetView.js
 create mode 100644 www/manager6/sdn/VnetPanel.js
 create mode 100644 www/manager6/sdn/controllers/BgpEdit.js
 create mode 100644 www/manager6/sdn/dns/Base.js
 create mode 100644 www/manager6/sdn/dns/PowerdnsEdit.js
 create mode 100644 www/manager6/sdn/ipams/Base.js
 create mode 100644 www/manager6/sdn/ipams/NetboxEdit.js
 create mode 100644 www/manager6/sdn/ipams/PVEIpamEdit.js
 create mode 100644 www/manager6/sdn/ipams/PhpIpamEdit.js

-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 02/18] add sdn subnets

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile  |   2 +
 www/manager6/dc/Config.js  |   8 +++
 www/manager6/sdn/SubnetEdit.js |  95 +
 www/manager6/sdn/SubnetView.js | 107 +
 4 files changed, 212 insertions(+)
 create mode 100644 www/manager6/sdn/SubnetEdit.js
 create mode 100644 www/manager6/sdn/SubnetView.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 9e6e56ef..60a2894e 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -225,6 +225,8 @@ JSSRC=  
\
sdn/StatusView.js   \
sdn/VnetEdit.js \
sdn/VnetView.js \
+   sdn/SubnetEdit.js   \
+   sdn/SubnetView.js   \
sdn/ZoneContentView.js  \
sdn/ZoneView.js \
sdn/controllers/Base.js \
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 2fdba743..6f4756de 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -176,6 +176,14 @@ Ext.define('PVE.dc.Config', {
hidden: true,
iconCls: 'fa fa-network-wired',
itemId: 'sdnvnet'
+   },
+   {
+   xtype: 'pveSDNSubnetView',
+   groups: ['sdn'],
+   title: gettext('Subnets'),
+   hidden: true,
+   iconCls: 'fa fa-network-wired',
+   itemId: 'sdnsubnet'
});
}
 
diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
new file mode 100644
index ..e165ff73
--- /dev/null
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -0,0 +1,95 @@
+Ext.define('PVE.sdn.SubnetInputPanel', {
+extend: 'Proxmox.panel.InputPanel',
+mixins: ['Proxmox.Mixin.CBind'],
+
+onGetValues: function(values) {
+   let me = this;
+
+   if (me.isCreate) {
+   values.type = 'subnet';
+   values.subnet = values.cidr;
+   delete values.cidr;
+   }
+
+   if (!values.gateway) {
+   delete values.gateway;
+   }
+   if (!values.snat) {
+   delete values.snat;
+   }
+
+   return values;
+},
+
+items: [
+   {
+   xtype: 'pmxDisplayEditField',
+   name: 'cidr',
+   cbind: {
+   editable: '{isCreate}',
+   },
+   flex: 1,
+   allowBlank: false,
+   fieldLabel: gettext('Subnet'),
+   },
+   {
+   xtype: 'textfield',
+   name: 'gateway',
+   vtype: 'IP64Address',
+   fieldLabel: gettext('Gateway'),
+   allowBlank: true,
+   },
+   {
+   xtype: 'proxmoxcheckbox',
+   name: 'snat',
+   uncheckedValue: 0,
+   checked: false,
+   fieldLabel: 'SNAT'
+   },
+]
+});
+
+Ext.define('PVE.sdn.SubnetEdit', {
+extend: 'Proxmox.window.Edit',
+
+subject: gettext('Subnet'),
+
+subnet: undefined,
+
+width: 350,
+
+initComponent: function() {
+   var me = this;
+
+   me.isCreate = me.subnet === undefined;
+
+   if (me.isCreate) {
+   me.url = '/api2/extjs/cluster/sdn/subnets';
+   me.method = 'POST';
+   } else {
+   me.url = '/api2/extjs/cluster/sdn/subnets/' + me.subnet;
+   me.method = 'PUT';
+   }
+
+   let ipanel = Ext.create('PVE.sdn.SubnetInputPanel', {
+   isCreate: me.isCreate,
+   });
+
+   Ext.apply(me, {
+   items: [
+   ipanel,
+   ],
+   });
+
+   me.callParent();
+
+   if (!me.isCreate) {
+   me.load({
+   success: function(response, options) {
+   let values = response.result.data;
+   ipanel.setValues(values);
+   },
+   });
+   }
+},
+});
diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView.js
new file mode 100644
index ..e5cc03b7
--- /dev/null
+++ b/www/manager6/sdn/SubnetView.js
@@ -0,0 +1,107 @@
+Ext.define('PVE.sdn.SubnetView', {
+extend: 'Ext.grid.GridPanel',
+alias: 'widget.pveSDNSubnetView',
+
+stateful: true,
+stateId: 'grid-sdn-subnet',
+
+initComponent : function() {
+   let me = this;
+
+   let store = new Ext.data.Store({
+   model: 'pve-sdn-subnet',
+   proxy: {
+type: 'proxmox',
+   url: "/api2/json/cluster/sdn/subnets"
+   },
+   sorters: {
+   property: 'subnet',
+   order: 'DESC'
+   }
+   });
+   let reload = () => store.load();
+
+   let sm = Ext.create('Ext.selection.RowModel', {});
+
+let run_e

[pve-devel] [PATCH v9 pve-manager 07/18] subnets: add dns fields

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/sdn/SubnetEdit.js | 35 ++
 1 file changed, 35 insertions(+)

diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index 2afa1a27..ac9a40ea 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -53,6 +53,41 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
 value: '',
 allowBlank: true,
 },
+{
+xtype: 'pveSDNDnsSelector',
+fieldLabel: gettext('Dns server'),
+name: 'dns',
+value: '',
+allowBlank: true,
+},
+   {
+   xtype: 'proxmoxtextfield',
+   name: 'dnszone',
+   skipEmptyText: true,
+   fieldLabel: gettext('DNS zone'),
+   allowBlank: true
+   },
+   {
+   xtype: 'proxmoxtextfield',
+   name: 'dnszoneprefix',
+   skipEmptyText: true,
+   fieldLabel: gettext('DNS zone prefix'),
+   allowBlank: true
+   },
+{
+xtype: 'pveSDNDnsSelector',
+fieldLabel: gettext('Reverse Dns server'),
+name: 'reversedns',
+value: '',
+allowBlank: true,
+},
+   {
+   xtype: 'proxmoxtextfield',
+   name: 'reversednszone',
+   skipEmptyText: true,
+   fieldLabel: gettext('Reverse DNS zone'),
+   allowBlank: true
+   },
 ]
 });
 
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 11/18] sdn: add options panel + move controller/ipam/dns view

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Makefile  |  1 +
 www/manager6/dc/Config.js  | 24 +++--
 www/manager6/sdn/ControllerView.js |  1 +
 www/manager6/sdn/DnsView.js|  1 +
 www/manager6/sdn/IpamView.js   |  2 ++
 www/manager6/sdn/OptionsPanel.js   | 41 ++
 6 files changed, 50 insertions(+), 20 deletions(-)
 create mode 100644 www/manager6/sdn/OptionsPanel.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index d30b6529..5b702d4b 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -233,6 +233,7 @@ JSSRC=  
\
sdn/SubnetView.js   \
sdn/ZoneContentView.js  \
sdn/ZoneView.js \
+sdn/OptionsPanel.js\
sdn/controllers/Base.js \
sdn/controllers/EvpnEdit.js \
 sdn/IpamView.js \
diff --git a/www/manager6/dc/Config.js b/www/manager6/dc/Config.js
index 48238a4e..d242aef2 100644
--- a/www/manager6/dc/Config.js
+++ b/www/manager6/dc/Config.js
@@ -153,14 +153,6 @@ Ext.define('PVE.dc.Config', {
itemId: 'sdn',
expandedOnInit: true
},
-   {
-   xtype: 'pveSDNControllerView',
-   groups: ['sdn'],
-   title: gettext('Controllers'),
-   hidden: true,
-   iconCls: 'fa fa-crosshairs',
-   itemId: 'sdncontroller'
-   },
{
xtype: 'pveSDNZoneView',
groups: ['sdn'],
@@ -178,20 +170,12 @@ Ext.define('PVE.dc.Config', {
itemId: 'sdnvnet'
},
{
-   xtype: 'pveSDNIpamView',
-   groups: ['sdn'],
-   title: gettext('Ipams'),
-   hidden: true,
-   iconCls: 'fa fa-network-wired',
-   itemId: 'sdnipam'
-   },
-   {
-   xtype: 'pveSDNDnsView',
+   xtype: 'pveSDNOptions',
groups: ['sdn'],
-   title: gettext('Dns'),
+   title: gettext('Options'),
hidden: true,
-   iconCls: 'fa fa-network-wired',
-   itemId: 'sdndns'
+   iconCls: 'fa fa-gear',
+   itemId: 'sdnoptions'
});
}
 
diff --git a/www/manager6/sdn/ControllerView.js 
b/www/manager6/sdn/ControllerView.js
index 0d991af3..4fdcdecd 100644
--- a/www/manager6/sdn/ControllerView.js
+++ b/www/manager6/sdn/ControllerView.js
@@ -125,6 +125,7 @@ Ext.define('PVE.sdn.ControllerView', {
}
});
 
+   store.load();
me.callParent();
 }
 });
diff --git a/www/manager6/sdn/DnsView.js b/www/manager6/sdn/DnsView.js
index 6d47e38f..2459327e 100644
--- a/www/manager6/sdn/DnsView.js
+++ b/www/manager6/sdn/DnsView.js
@@ -126,6 +126,7 @@ Ext.define('PVE.sdn.DnsView', {
}
});
 
+   store.load();
me.callParent();
 }
 });
diff --git a/www/manager6/sdn/IpamView.js b/www/manager6/sdn/IpamView.js
index 605f44c7..4635b2ab 100644
--- a/www/manager6/sdn/IpamView.js
+++ b/www/manager6/sdn/IpamView.js
@@ -126,6 +126,8 @@ Ext.define('PVE.sdn.IpamView', {
}
});
 
+   store.load();
me.callParent();
+
 }
 });
diff --git a/www/manager6/sdn/OptionsPanel.js b/www/manager6/sdn/OptionsPanel.js
new file mode 100644
index ..d9145299
--- /dev/null
+++ b/www/manager6/sdn/OptionsPanel.js
@@ -0,0 +1,41 @@
+Ext.define('PVE.sdn.Options', {
+extend: 'Ext.panel.Panel',
+alias: 'widget.pveSDNOptions',
+
+title: 'Options',
+
+layout: {
+type: 'vbox',
+align: 'stretch'
+},
+
+//onlineHelp: 'pvesdn_config_vnet',
+
+   initComponent: function() {
+var me = this;
+
+me.items = [
+   {
+xtype: 'pveSDNControllerView',
+title: gettext('Controllers'),
+border: 0,
+collapsible: true,
+padding: '0 0 20 0'
+},
+   {
+xtype: 'pveSDNIpamView',
+title: gettext('Ipams'),
+border: 0,
+collapsible: true,
+padding: '0 0 20 0'
+},{
+xtype: 'pveSDNDnsView',
+flex: 1,
+collapsible: true,
+title: gettext('Dns'),
+border: 0,
+}];
+
+me.callParent();
+}
+});
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 16/18] sdn: update onlinehelp links

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/sdn/ControllerView.js | 2 +-
 www/manager6/sdn/OptionsPanel.js   | 2 +-
 www/manager6/sdn/ZoneView.js   | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/www/manager6/sdn/ControllerView.js 
b/www/manager6/sdn/ControllerView.js
index 9e400f7f..10c9c446 100644
--- a/www/manager6/sdn/ControllerView.js
+++ b/www/manager6/sdn/ControllerView.js
@@ -2,7 +2,7 @@ Ext.define('PVE.sdn.ControllerView', {
 extend: 'Ext.grid.GridPanel',
 alias: ['widget.pveSDNControllerView'],
 
-onlineHelp: 'pvesdn_controller_plugins',
+onlineHelp: 'pvesdn_config_controllers',
 
 stateful: true,
 stateId: 'grid-sdn-controller',
diff --git a/www/manager6/sdn/OptionsPanel.js b/www/manager6/sdn/OptionsPanel.js
index d9145299..781c44b0 100644
--- a/www/manager6/sdn/OptionsPanel.js
+++ b/www/manager6/sdn/OptionsPanel.js
@@ -9,7 +9,7 @@ Ext.define('PVE.sdn.Options', {
 align: 'stretch'
 },
 
-//onlineHelp: 'pvesdn_config_vnet',
+   onlineHelp: 'pvesdn_config_controllers',
 
initComponent: function() {
 var me = this;
diff --git a/www/manager6/sdn/ZoneView.js b/www/manager6/sdn/ZoneView.js
index d842654a..ae44f95f 100644
--- a/www/manager6/sdn/ZoneView.js
+++ b/www/manager6/sdn/ZoneView.js
@@ -2,7 +2,7 @@ Ext.define('PVE.sdn.ZoneView', {
 extend: 'Ext.grid.GridPanel',
 alias: ['widget.pveSDNZoneView'],
 
-onlineHelp: 'pvesdn_zone_plugins',
+onlineHelp: 'pvesdn_config_zone',
 
 stateful: true,
 stateId: 'grid-sdn-zone',
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 17/18] sdn : zone content view: add alias && resize column

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/sdn/ZoneContentView.js | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/www/manager6/sdn/ZoneContentView.js 
b/www/manager6/sdn/ZoneContentView.js
index 20a5fe1e..7069e52a 100644
--- a/www/manager6/sdn/ZoneContentView.js
+++ b/www/manager6/sdn/ZoneContentView.js
@@ -57,18 +57,25 @@ Ext.define('PVE.sdn.ZoneContentView', {
columns: [
{
header: 'VNet',
-   flex: 1,
+   width: 100,
sortable: true,
dataIndex: 'vnet'
},
+   {
+   header: 'Alias',
+   width: 300,
+   sortable: true,
+   dataIndex: 'alias'
+   },
{
header: gettext('Status'),
-   width: 20,
+   width: 100,
+   sortable: true,
dataIndex: 'status',
},
{
header: gettext('Details'),
-   width: 20,
+   flex: 1,
dataIndex: 'statusmsg',
},
],
-- 
2.20.1


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



[pve-devel] [PATCH v9 pve-manager 18/18] sdn: add pending state column with hover tip

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Utils.js  | 71 +++---
 www/manager6/sdn/ControllerView.js | 17 +++
 www/manager6/sdn/SubnetView.js | 12 -
 www/manager6/sdn/VnetView.js   |  8 
 www/manager6/sdn/ZoneView.js   | 27 +++-
 5 files changed, 75 insertions(+), 60 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 89706c32..5a6267fe 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -176,32 +176,51 @@ Ext.define('PVE.Utils', { utilities: {
 },
 
 render_sdn_pending: function(rec,value,key, index) {
-if (rec.data.state === 'deleted') {
-if (value === undefined) {
-return ' ';
-} else {
-return ''+ value 
+'';
-}
-
-} else if (rec.data.state === 'new') {
-if(index === undefined) {
-value = rec.data.pending[key];
-}
-if (value === undefined || value === null) {
-value = ' ';
-}
-return '' + value + '';
-} else if (rec.data.state === 'changed') {
-if (value === undefined || value === null) {
-value = '';
-}
-if (rec.data.pending[key] === undefined || rec.data.pending[key] 
=== null) {
-rec.data.pending[key] = value;
-}
-   return ''+ value 
+'' + '' + rec.data.pending[key] + '';
-} else {
-return value;
-}
+   if (rec.data.state === undefined || rec.data.state === null) {
+   return value;
+   }
+
+   if (rec.data.state === 'deleted') {
+   if (value === undefined) {
+   return ' ';
+   } else {
+   return ''+ value 
+'';
+   }
+   } else {
+
+   if (rec.data.pending[key] !== undefined && rec.data.pending[key] 
!== null) {
+   if (rec.data.pending[key] === 'deleted') {
+   return ' ';
+   } else {
+   return rec.data.pending[key];
+   }
+   } else {
+   return value;
+   }
+   }
+   return value;
+},
+
+render_sdn_pending_state: function(rec,value) {
+
+   if (value === undefined || value === null) {
+   return ' ';
+   }
+
+   let icon = ``;
+
+   if (value === 'deleted') {
+   return '' + icon + value + '';
+   }
+
+   let tip = 'Pending apply: ';
+
+   for (const [key, keyvalue] of Object.entries(rec.data.pending)) {
+   if (((rec.data[key] !== undefined && rec.data.pending[key] !== 
rec.data[key]) || rec.data[key] === undefined)) {
+   tip = tip + `${key}: ${keyvalue} `;
+   }
+   }
+   return ''+ icon + value + '';
 },
 
 render_ceph_health: function(healthObj) {
diff --git a/www/manager6/sdn/ControllerView.js 
b/www/manager6/sdn/ControllerView.js
index 10c9c446..7981eba9 100644
--- a/www/manager6/sdn/ControllerView.js
+++ b/www/manager6/sdn/ControllerView.js
@@ -143,19 +143,12 @@ Ext.define('PVE.sdn.ControllerView', {
 }
},
 {
-header: gettext('Pending'),
-flex: 3,
-dataIndex: 'pending',
+header: gettext('State'),
+   width: 100,
+dataIndex: 'state',
 renderer: function(value, metaData, rec) {
-if(value !== undefined ) {
-delete value.controller;
-delete value.type;
-   if(!Ext.Object.isEmpty(value)){
-   return JSON.stringify(value);
-   }
-}
-return '';
-}
+return PVE.Utils.render_sdn_pending_state(rec, value);
+   }
 }
],
listeners: {
diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView.js
index bff047fb..9a85bbbc 100644
--- a/www/manager6/sdn/SubnetView.js
+++ b/www/manager6/sdn/SubnetView.js
@@ -129,8 +129,16 @@ Ext.define('PVE.sdn.SubnetView', {
dataIndex: 'dnszoneprefix',
 renderer: function(value, metaData, rec) {
 return PVE.Utils.render_sdn_pending(rec, value, 
'dnszoneprefix');
-}
-   },
+   }
+},
+   {
+   header: gettext('State'),
+   width: 100,
+   dataIndex: 'state',
+   renderer: function(value, metaData, rec) {
+   return PVE.Utils.render_sdn_pending_state(rec, value);
+   }
+   }
 
],
listeners

[pve-devel] [PATCH v9 pve-manager 13/18] move ipams && dns options to zone

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Utils.js|  4 +--
 www/manager6/sdn/SubnetEdit.js   | 39 +-
 www/manager6/sdn/SubnetView.js   | 23 ++-
 www/manager6/sdn/VnetEdit.js | 10 ++-
 www/manager6/sdn/ZoneView.js | 42 ++--
 www/manager6/sdn/zones/Base.js   | 31 
 www/manager6/sdn/zones/SimpleEdit.js |  1 -
 7 files changed, 78 insertions(+), 72 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 257af3fd..98cb8ca1 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -178,7 +178,7 @@ Ext.define('PVE.Utils', { utilities: {
 render_sdn_pending: function(rec,value,key, index) {
 if (rec.data.state === 'deleted') {
 if (value === undefined) {
-return '';
+return ' ';
 } else {
 return ''+ value 
+'';
 }
@@ -188,7 +188,7 @@ Ext.define('PVE.Utils', { utilities: {
 value = rec.data.pending[key];
 }
 if (value === undefined || value === null) {
-value = '';
+value = ' ';
 }
 return '' + value + '';
 } else if (rec.data.state === 'changed') {
diff --git a/www/manager6/sdn/SubnetEdit.js b/www/manager6/sdn/SubnetEdit.js
index 653c8ae5..83c6961c 100644
--- a/www/manager6/sdn/SubnetEdit.js
+++ b/www/manager6/sdn/SubnetEdit.js
@@ -46,50 +46,13 @@ Ext.define('PVE.sdn.SubnetInputPanel', {
checked: false,
fieldLabel: 'SNAT'
},
-],
-advancedItems: [
-{
-xtype: 'pveSDNIpamSelector',
-fieldLabel: gettext('Ipam'),
-name: 'ipam',
-value: 'pve',
-allowBlank: false,
-},
-{
-xtype: 'pveSDNDnsSelector',
-fieldLabel: gettext('Dns server'),
-name: 'dns',
-value: '',
-allowBlank: true,
-},
-   {
-   xtype: 'proxmoxtextfield',
-   name: 'dnszone',
-   skipEmptyText: true,
-   fieldLabel: gettext('DNS zone'),
-   allowBlank: true
-   },
{
xtype: 'proxmoxtextfield',
name: 'dnszoneprefix',
skipEmptyText: true,
fieldLabel: gettext('DNS zone prefix'),
allowBlank: true
-   },
-{
-xtype: 'pveSDNDnsSelector',
-fieldLabel: gettext('Reverse Dns server'),
-name: 'reversedns',
-value: '',
-allowBlank: true,
-},
-   {
-   xtype: 'proxmoxtextfield',
-   name: 'reversednszone',
-   skipEmptyText: true,
-   fieldLabel: gettext('Reverse DNS zone'),
-   allowBlank: true
-   },
+   }
 ]
 });
 
diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView.js
index 0c04ddf1..bff047fb 100644
--- a/www/manager6/sdn/SubnetView.js
+++ b/www/manager6/sdn/SubnetView.js
@@ -124,30 +124,13 @@ Ext.define('PVE.sdn.SubnetView', {
 }
},
{
-   header: 'Ipam',
+   header: gettext('Dns prefix'),
flex: 1,
-   dataIndex: 'ipam',
+   dataIndex: 'dnszoneprefix',
 renderer: function(value, metaData, rec) {
-return PVE.Utils.render_sdn_pending(rec, value, 
'ipam');
+return PVE.Utils.render_sdn_pending(rec, value, 
'dnszoneprefix');
 }
},
-{
-header: gettext('Pending'),
-flex: 3,
-dataIndex: 'pending',
-renderer: function(value, metaData, rec) {
-if(value !== undefined ) {
-delete value.cidr;
-delete value.gateway;
-delete value.snat;
-delete value.ipam;
-   if(!Ext.Object.isEmpty(value)){
-   return JSON.stringify(value);
-   }
-}
-return '';
-}
-},
 
],
listeners: {
diff --git a/www/manager6/sdn/VnetEdit.js b/www/manager6/sdn/VnetEdit.js
index 03e539ab..af5d6cde 100644
--- a/www/manager6/sdn/VnetEdit.js
+++ b/www/manager6/sdn/VnetEdit.js
@@ -9,14 +9,8 @@ Ext.define('PVE.sdn.VnetInputPanel', {
values.type = 'vnet';
}
 
-   if (!values.ipv6) {
-   delete values.ipv6;
-   }
-   if (!values.ipv4) {
-   delete values.ipv4;
-   }
-   if (!values.mac) {
-   delete values.mac;
+   if (!values.vlanaware) {
+   delete valu

[pve-devel] [PATCH v9 pve-manager 12/18] sdn: display pending values

2020-12-03 Thread Alexandre Derumier
Signed-off-by: Alexandre Derumier 
---
 www/manager6/Utils.js  | 29 ++
 www/manager6/sdn/ControllerView.js | 39 +---
 www/manager6/sdn/SubnetView.js | 49 +++---
 www/manager6/sdn/VnetView.js   | 31 +--
 www/manager6/sdn/ZoneView.js   | 47 +---
 5 files changed, 181 insertions(+), 14 deletions(-)

diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index 5440b972..257af3fd 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -175,6 +175,35 @@ Ext.define('PVE.Utils', { utilities: {
'HEALTH_ERR':'critical'
 },
 
+render_sdn_pending: function(rec,value,key, index) {
+if (rec.data.state === 'deleted') {
+if (value === undefined) {
+return '';
+} else {
+return ''+ value 
+'';
+}
+
+} else if (rec.data.state === 'new') {
+if(index === undefined) {
+value = rec.data.pending[key];
+}
+if (value === undefined || value === null) {
+value = '';
+}
+return '' + value + '';
+} else if (rec.data.state === 'changed') {
+if (value === undefined || value === null) {
+value = '';
+}
+if (rec.data.pending[key] === undefined || rec.data.pending[key] 
=== null) {
+rec.data.pending[key] = value;
+}
+   return ''+ value 
+'' + '' + rec.data.pending[key] + '';
+} else {
+return value;
+}
+},
+
 render_ceph_health: function(healthObj) {
var state = {
iconCls: PVE.Utils.get_health_icon(),
diff --git a/www/manager6/sdn/ControllerView.js 
b/www/manager6/sdn/ControllerView.js
index 4fdcdecd..e4730be0 100644
--- a/www/manager6/sdn/ControllerView.js
+++ b/www/manager6/sdn/ControllerView.js
@@ -31,7 +31,7 @@ Ext.define('PVE.sdn.ControllerView', {
model: 'pve-sdn-controller',
proxy: {
 type: 'proxmox',
-   url: "/api2/json/cluster/sdn/controllers"
+   url: "/api2/json/cluster/sdn/controllers?pending=1"
},
sorters: {
property: 'controller',
@@ -45,6 +45,16 @@ Ext.define('PVE.sdn.ControllerView', {
 
var sm = Ext.create('Ext.selection.RowModel', {});
 
+   var set_button_status = function() {
+   var rec = me.selModel.getSelection()[0];
+
+   if (!rec || rec.data.state === 'deleted') {
+   edit_btn.disable();
+   remove_btn.disable();
+   return;
+   }
+   };
+
var run_editor = function() {
var rec = sm.getSelection()[0];
if (!rec) {
@@ -109,19 +119,40 @@ Ext.define('PVE.sdn.ControllerView', {
header: 'ID',
flex: 2,
sortable: true,
-   dataIndex: 'controller'
+   dataIndex: 'controller',
+renderer: function(value, metaData, rec) {
+return PVE.Utils.render_sdn_pending(rec, value, 
'controller', 1);
+}
},
{
header: gettext('Type'),
flex: 1,
sortable: true,
dataIndex: 'type',
-   renderer: PVE.Utils.format_sdncontroller_type
+renderer: function(value, metaData, rec) {
+return PVE.Utils.render_sdn_pending(rec, value, 
'type', 1);
+}
},
+{
+header: gettext('Pending'),
+flex: 3,
+dataIndex: 'pending',
+renderer: function(value, metaData, rec) {
+if(value !== undefined ) {
+delete value.controller;
+delete value.type;
+   if(!Ext.Object.isEmpty(value)){
+   return JSON.stringify(value);
+   }
+}
+return '';
+}
+}
],
listeners: {
activate: reload,
-   itemdblclick: run_editor
+   itemdblclick: run_editor,
+selectionchange: set_button_status
}
});
 
diff --git a/www/manager6/sdn/SubnetView.js b/www/manager6/sdn/SubnetView.js
index 96240617..0c04ddf1 100644
--- a/www/manager6/sdn/SubnetView.js
+++ b/www/manager6/sdn/SubnetView.js
@@ -20,7 +20,7 @@ Ext.define('PVE.sdn.SubnetView', {
 me.remove_btn.baseurl = url + '/';
 me.store.setProxy({
 type: 'proxmox',
-url: '/api2/json/' + url
+url: '/

[pve-devel] [PATCH common/storage/qemu-server] refactor pbs repo url generation

2020-12-03 Thread Dominik Csapak
moves it to pve-commons PBSClient and change qemu-server and pve-storage
to use it

this fixes issues with ipv6/ports in qemu-server pbs backups/restores

pve-common:

Dominik Csapak (1):
  PBSClient: add get_repository to generate repository urls from configs

 src/PVE/PBSClient.pm | 36 +++-
 1 file changed, 31 insertions(+), 5 deletions(-)

pve-storage:

Dominik Csapak (1):
  PBSPlugin: use get_repository from PVE::PBSClient

 PVE/Storage/PBSPlugin.pm | 25 +
 1 file changed, 5 insertions(+), 20 deletions(-)

qemu-server:

Dominik Csapak (1):
  use get_repository from PVE::PBSClient

 PVE/QemuServer.pm| 6 ++
 PVE/VZDump/QemuServer.pm | 7 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

-- 
2.20.1



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



[pve-devel] [PATCH storage 1/1] PBSPlugin: use get_repository from PVE::PBSClient

2020-12-03 Thread Dominik Csapak
Signed-off-by: Dominik Csapak 
---
 PVE/Storage/PBSPlugin.pm | 25 +
 1 file changed, 5 insertions(+), 20 deletions(-)

diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm
index 43bd72f..4d00472 100644
--- a/PVE/Storage/PBSPlugin.pm
+++ b/PVE/Storage/PBSPlugin.pm
@@ -13,6 +13,7 @@ use POSIX qw(strftime ENOENT);
 use PVE::APIClient::LWP;
 use PVE::JSONSchema qw(get_standard_option);
 use PVE::Network;
+use PVE::PBSClient;
 use PVE::Storage::Plugin;
 use PVE::Tools qw(run_command file_read_firstline trim dir_glob_regex 
dir_glob_foreach $IPV6RE);
 
@@ -161,18 +162,6 @@ sub print_volid {
 return "${storeid}:${volname}";
 }
 
-my sub get_server_with_port {
-my ($scfg) = @_;
-
-my $server = $scfg->{server};
-$server = "[$server]" if $server =~ /^$IPV6RE$/;
-
-if (my $port = $scfg->{port}) {
-   $server .= ":$port" if $port != 8007;
-}
-return $server;
-}
-
 my $USE_CRYPT_PARAMS = {
 backup => 1,
 restore => 1,
@@ -188,9 +177,7 @@ my sub do_raw_client_cmd {
 die "executable not found '$client_exe'! Proxmox backup client not 
installed?\n"
if ! -x $client_exe;
 
-my $server = get_server_with_port($scfg);
-my $datastore = $scfg->{datastore};
-my $username = $scfg->{username} // 'root@pam';
+my $repo = PVE::PBSClient::get_repository($scfg);
 
 my $userns_cmd = delete $opts{userns_cmd};
 
@@ -216,7 +203,7 @@ my sub do_raw_client_cmd {
 
 push @$cmd, @$param if defined($param);
 
-push @$cmd, "--repository", "$username\@$server:$datastore";
+push @$cmd, "--repository", $repo;
 
 local $ENV{PBS_PASSWORD} = pbs_get_password($scfg, $storeid);
 
@@ -484,12 +471,10 @@ sub path {
 
 my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
-my $server = get_server_with_port($scfg);
-my $datastore = $scfg->{datastore};
-my $username = $scfg->{username} // 'root@pam';
+my $repo = PVE::PBSClient::get_repository($scfg);
 
 # artifical url - we currently do not use that anywhere
-my $path = "pbs://$username\@$server:$datastore/$name";
+my $path = "pbs://$repo/$name";
 
 return ($path, $vmid, $vtype);
 }
-- 
2.20.1



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



[pve-devel] [PATCH common 1/1] PBSClient: add get_repository to generate repository urls from configs

2020-12-03 Thread Dominik Csapak
we can use this everywhere we need to have a repository url

Signed-off-by: Dominik Csapak 
---
 src/PVE/PBSClient.pm | 36 +++-
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/src/PVE/PBSClient.pm b/src/PVE/PBSClient.pm
index 44e3176..f05471c 100644
--- a/src/PVE/PBSClient.pm
+++ b/src/PVE/PBSClient.pm
@@ -10,7 +10,35 @@ use JSON;
 use POSIX qw(strftime ENOENT);
 
 use PVE::JSONSchema qw(get_standard_option);
-use PVE::Tools qw(run_command file_set_contents file_get_contents 
file_read_firstline);
+use PVE::Tools qw(run_command file_set_contents file_get_contents 
file_read_firstline $IPV6RE);
+
+# returns a repository string suitable for proxmox-backup-client, pbs-restore, 
etc.
+# $scfg must have the following structure:
+# {
+# datastore
+# server
+# port(optional defaults to 8007)
+# username(optional defaults to 'root@pam')
+# }
+sub get_repository {
+my ($scfg) = @_;
+
+my $server = $scfg->{server};
+die "no server given\n" if !defined($server);
+
+$server = "[$server]" if $server =~ /^$IPV6RE$/;
+
+if (my $port = $scfg->{port}) {
+   $server .= ":$port" if $port != 8007;
+}
+
+my $datastore = $scfg->{datastore};
+die "no datastore given\n" if !defined($datastore);
+
+my $username = $scfg->{username} // 'root@pam';
+
+return "$username\@$server:$datastore";
+}
 
 sub new {
 my ($class, $scfg, $storeid, $sdir) = @_;
@@ -116,9 +144,7 @@ my sub do_raw_client_cmd {
if ! -x $client_exe;
 
 my $scfg = $self->{scfg};
-my $server = $scfg->{server};
-my $datastore = $scfg->{datastore};
-my $username = $scfg->{username} // 'root@pam';
+my $repo = get_repository($scfg);
 
 my $userns_cmd = delete $opts{userns_cmd};
 
@@ -144,7 +170,7 @@ my sub do_raw_client_cmd {
 
 push @$cmd, @$param if defined($param);
 
-push @$cmd, "--repository", "$username\@$server:$datastore";
+push @$cmd, "--repository", $repo;
 
 local $ENV{PBS_PASSWORD} = $self->get_password();
 
-- 
2.20.1



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



[pve-devel] [PATCH qemu-server 1/1] use get_repository from PVE::PBSClient

2020-12-03 Thread Dominik Csapak
this fixes the issue that we did not generate the correct repository
url for pbs storages that contained an ipv6 address or a port

Signed-off-by: Dominik Csapak 
---
 PVE/QemuServer.pm| 6 ++
 PVE/VZDump/QemuServer.pm | 7 ++-
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4989938..70c14ba 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -34,6 +34,7 @@ use PVE::GuestHelpers qw(safe_string_ne safe_num_ne 
safe_boolean_ne);
 use PVE::INotify;
 use PVE::JSONSchema qw(get_standard_option parse_property_string);
 use PVE::ProcFSTools;
+use PVE::PBSClient;
 use PVE::RPCEnvironment;
 use PVE::Storage;
 use PVE::SysFSTools;
@@ -6058,13 +6059,10 @@ sub restore_proxmox_backup_archive {
 my ($storeid, $volname) = PVE::Storage::parse_volume_id($archive);
 my $scfg = PVE::Storage::storage_config($storecfg, $storeid);
 
-my $server = $scfg->{server};
-my $datastore = $scfg->{datastore};
-my $username = $scfg->{username} // 'root@pam';
 my $fingerprint = $scfg->{fingerprint};
 my $keyfile = 
PVE::Storage::PBSPlugin::pbs_encryption_key_file_name($storecfg, $storeid);
 
-my $repo = "$username\@$server:$datastore";
+my $repo = PVE::PBSClient::get_repository($scfg);
 
 # This is only used for `pbs-restore`!
 my $password = PVE::Storage::PBSPlugin::pbs_get_password($scfg, $storeid);
diff --git a/PVE/VZDump/QemuServer.pm b/PVE/VZDump/QemuServer.pm
index 5003676..b322701 100644
--- a/PVE/VZDump/QemuServer.pm
+++ b/PVE/VZDump/QemuServer.pm
@@ -14,6 +14,7 @@ use PVE::Cluster qw(cfs_read_file);
 use PVE::INotify;
 use PVE::IPCC;
 use PVE::JSONSchema;
+use PVE::PBSClient;
 use PVE::QMPClient;
 use PVE::Storage::Plugin;
 use PVE::Storage::PBSPlugin;
@@ -473,12 +474,8 @@ sub archive_pbs {
 
 my $starttime = time();
 
-my $server = $scfg->{server};
-my $datastore = $scfg->{datastore};
-my $username = $scfg->{username} // 'root@pam';
 my $fingerprint = $scfg->{fingerprint};
-
-my $repo = "$username\@$server:$datastore";
+my $repo = PVE::PBSClient::get_repository($scfg);
 my $password = PVE::Storage::PBSPlugin::pbs_get_password($scfg, 
$opts->{storage});
 my $keyfile = PVE::Storage::PBSPlugin::pbs_encryption_key_file_name($scfg, 
$opts->{storage});
 
-- 
2.20.1



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



[pve-devel] [PATCH storage] pbs: fix token auth with PVE::APIClient

2020-12-03 Thread Wolfgang Bumiller
Signed-off-by: Wolfgang Bumiller 
---
 PVE/Storage/PBSPlugin.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/Storage/PBSPlugin.pm b/PVE/Storage/PBSPlugin.pm
index 43bd72f..bc777f5 100644
--- a/PVE/Storage/PBSPlugin.pm
+++ b/PVE/Storage/PBSPlugin.pm
@@ -624,7 +624,7 @@ my sub pbs_api_connect {
 my $user = $scfg->{username} // 'root@pam';
 
 if (my $tokenid = PVE::AccessControl::pve_verify_tokenid($user, 1)) {
-   $params->{apitoken} = "PBSAPIToken=${tokenid}=${password}";
+   $params->{apitoken} = "PBSAPIToken=${tokenid}:${password}";
 } else {
$params->{password} = $password;
$params->{username} = $user;
-- 
2.20.1



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



[pve-devel] [PATCH manager] pvestatd: fix container cpuset scheduling

2020-12-03 Thread Dominik Csapak
Since pve-container commit

c48a25452dccca37b3915e49b7618f6880aeafb1

the code to get the cpuset controller path lives in pve-commons PVE::CGroup.
Use that and improve the logging in case some error happens in the future.
Such an error will only be logged once per pvestatd run,
so it does not spam the log.

Signed-off-by: Dominik Csapak 
---
 PVE/Service/pvestatd.pm | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 5e533ca3..7193388c 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -20,7 +20,7 @@ use PVE::Storage;
 use PVE::QemuServer;
 use PVE::QemuServer::Monitor;
 use PVE::LXC;
-use PVE::LXC::CGroup;
+use PVE::CGroup;
 use PVE::LXC::Config;
 use PVE::RPCEnvironment;
 use PVE::API2::Subscription;
@@ -257,7 +257,11 @@ my $NO_REBALANCE;
 sub rebalance_lxc_containers {
 # Make sure we can find the cpuset controller path:
 return if $NO_REBALANCE;
-my $cpuset_base = eval { PVE::LXC::CGroup::cpuset_controller_path() };
+my $cpuset_base = eval { PVE::CGroup::cpuset_controller_path() };
+if (my $err = $@) {
+   syslog('info', "could not get cpuset controller path: $err");
+}
+
 if (!defined($cpuset_base)) {
$NO_REBALANCE = 1;
return;
-- 
2.20.1



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



Re: [pve-devel] [PATCH manager] pvestatd: fix container cpuset scheduling

2020-12-03 Thread Aaron Lauterer

Tested-By: Aaron Lauterer 

On 12/3/20 4:01 PM, Dominik Csapak wrote:

Since pve-container commit

c48a25452dccca37b3915e49b7618f6880aeafb1

the code to get the cpuset controller path lives in pve-commons PVE::CGroup.
Use that and improve the logging in case some error happens in the future.
Such an error will only be logged once per pvestatd run,
so it does not spam the log.

Signed-off-by: Dominik Csapak 
---
  PVE/Service/pvestatd.pm | 8 ++--
  1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm
index 5e533ca3..7193388c 100755
--- a/PVE/Service/pvestatd.pm
+++ b/PVE/Service/pvestatd.pm
@@ -20,7 +20,7 @@ use PVE::Storage;
  use PVE::QemuServer;
  use PVE::QemuServer::Monitor;
  use PVE::LXC;
-use PVE::LXC::CGroup;
+use PVE::CGroup;
  use PVE::LXC::Config;
  use PVE::RPCEnvironment;
  use PVE::API2::Subscription;
@@ -257,7 +257,11 @@ my $NO_REBALANCE;
  sub rebalance_lxc_containers {
  # Make sure we can find the cpuset controller path:
  return if $NO_REBALANCE;
-my $cpuset_base = eval { PVE::LXC::CGroup::cpuset_controller_path() };
+my $cpuset_base = eval { PVE::CGroup::cpuset_controller_path() };
+if (my $err = $@) {
+   syslog('info', "could not get cpuset controller path: $err");
+}
+
  if (!defined($cpuset_base)) {
$NO_REBALANCE = 1;
return;




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



[pve-devel] applied: [PATCH manager] pvestatd: fix container cpuset scheduling

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 16:01, Dominik Csapak wrote:
> Since pve-container commit
> 
> c48a25452dccca37b3915e49b7618f6880aeafb1
> 
> the code to get the cpuset controller path lives in pve-commons PVE::CGroup.
> Use that and improve the logging in case some error happens in the future.
> Such an error will only be logged once per pvestatd run,
> so it does not spam the log.

That was worded confusingly for me, I thought you mean "once per pvestatd update
loop run", but it is actually only the first loop (which I like more ^^)

> 
> Signed-off-by: Dominik Csapak 
> ---
>  PVE/Service/pvestatd.pm | 8 ++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
>

applied, thanks!



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



Re: [pve-devel] [PATCH manager] pvestatd: fix container cpuset scheduling

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 16:35, Aaron Lauterer wrote:
> Tested-By: Aaron Lauterer 

saw this to late for adding it into the commit message, still thanks for
the feedback though!


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



[pve-devel] applied: [PATCH common 1/1] PBSClient: add get_repository to generate repository urls from configs

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 12:43, Dominik Csapak wrote:
> we can use this everywhere we need to have a repository url
> 
> Signed-off-by: Dominik Csapak 
> ---
>  src/PVE/PBSClient.pm | 36 +++-
>  1 file changed, 31 insertions(+), 5 deletions(-)
> 
>

applied, thanks!


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



[pve-devel] applied: [PATCH common 1/1] tools: add extract_sensitive_params

2020-12-03 Thread Thomas Lamprecht
On 02.12.20 10:21, Dominik Csapak wrote:
> moved and generalized from pve-storage, since we'll need it
> in more places
> 
> Signed-off-by: Dominik Csapak 
> ---
>  src/PVE/Tools.pm | 24 
>  1 file changed, 24 insertions(+)
> 
>

applied, with some followups for the stuff commented, thanks!


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



[pve-devel] applied: [PATCH storage 1/1] PBSPlugin: use get_repository from PVE::PBSClient

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 12:43, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak 
> ---
>  PVE/Storage/PBSPlugin.pm | 25 +
>  1 file changed, 5 insertions(+), 20 deletions(-)
> 
>

applied, thanks!


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



[pve-devel] applied: [PATCH storage] pbs: fix token auth with PVE::APIClient

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 14:03, Wolfgang Bumiller wrote:
> Signed-off-by: Wolfgang Bumiller 
> ---
>  PVE/Storage/PBSPlugin.pm | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
>

applied, thanks!


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



Re: [pve-devel] [PATCH manager] api: metrics/server: test connection on add/update

2020-12-03 Thread Thomas Lamprecht
On 25.11.20 13:56, Dominik Csapak wrote:
> just a basic check, but better than not checking at all
> 

so, just had an issue with the network (some test IPv6 LAN here) and had a 
metric
server configured on that net, thus pvestatd spammed the log with "network
unreachable" messages, and all my resources got the good ol' question mark in 
the
gui, so far so good.
But, I then tried to disable that ext. metrics entry, but we then *also* do a
connection check which obv. fails ^^




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



[pve-devel] applied: [PATCH qemu-server 1/1] use get_repository from PVE::PBSClient

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 12:43, Dominik Csapak wrote:
> this fixes the issue that we did not generate the correct repository
> URL for pbs storages that contained an ipv6 address or a port
> 
> Signed-off-by: Dominik Csapak 
> ---
>  PVE/QemuServer.pm| 6 ++
>  PVE/VZDump/QemuServer.pm | 7 ++-
>  2 files changed, 4 insertions(+), 9 deletions(-)
> 
>

applied, thanks!

Did just a successful restore with
> connecting to repository 'root@pam!holerio@[fd0f:42::38:68]:zzz'


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



[pve-devel] [PATCH http-server 3/3] add debug log for problems during accept

2020-12-03 Thread Stoiko Ivanov
Co-Authored-by: Dominik Csapak 
Signed-off-by: Stoiko Ivanov 
---
 PVE/APIServer/AnyEvent.pm | 9 +
 1 file changed, 9 insertions(+)

diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
index 7038b07..d33f6b0 100644
--- a/PVE/APIServer/AnyEvent.pm
+++ b/PVE/APIServer/AnyEvent.pm
@@ -1520,6 +1520,11 @@ sub check_host_access {
 
 my $cip = Net::IP->new($clientip);
 
+if (!$cip) {
+   print "$$: check_host_access: clientip not parsable: $@\n" if 
$self->{debug};
+   return 0;
+}
+
 my $match_allow = 0;
 my $match_deny = 0;
 
@@ -1527,6 +1532,7 @@ sub check_host_access {
foreach my $t (@{$self->{allow_from}}) {
if ($t->overlaps($cip)) {
$match_allow = 1;
+   print "$$: check_host_access: clientip allowed: ". $t->prefix() 
. "\n" if $self->{debug};
last;
}
}
@@ -1535,6 +1541,7 @@ sub check_host_access {
 if ($self->{deny_from}) {
foreach my $t (@{$self->{deny_from}}) {
if ($t->overlaps($cip)) {
+   print "$$: check_host_access: clientip denied: ". $t->prefix() 
. "\n" if $self->{debug};
$match_deny = 1;
last;
}
@@ -1571,6 +1578,7 @@ sub accept_connections {
my ($pfamily, $pport, $phost) = 
PVE::Tools::unpack_sockaddr_in46($sin);
($reqstate->{peer_port}, $reqstate->{peer_host}) = ($pport,  
Socket::inet_ntop($pfamily, $phost));
} else {
+   print "$$: ACCEPT connection: getpeername failed: $!\n" if 
$self->{debug};
shutdown($clientfh, 1);
next;
}
@@ -1619,6 +1627,7 @@ sub accept_connections {
 
 if (my $err = $@) {
syslog('err', $err);
+   print "$$: ACCEPT connection error: $err\n" if $self->{debug};
shutdown($clientfh, 1) if $early_err;
$self->{end_loop} = 1;
 }
-- 
2.20.1



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



[pve-devel] [PATCH http-server 1/3] accept-phase: fix conn_count "leak"

2020-12-03 Thread Stoiko Ivanov
When handling new connections in 'accept_connections' the number of
active connections got increased before the AnyEvent::Handle
registered the callback which would decrement it on error.

Any error/die beforehand would skip the decrement, and leave the
process in an endless loop upon exiting in wait_end_loop.

This can happen e.g. when the call to getpeername fails, or if the
connection is denied by the ALLOW_FROM/DENY_FROM settings in
'/etc/default/pveproxy' (which is also the simplest reproducer for
that).

Additionally it can cause a denial of service, by attempting to
connect from a denied ip until the connection count exeeds the maximum
connections of all child-processes.

Reported via our community-forum:
https://forum.proxmox.com/threads/pveproxy-eats-available-ram.79617/

Co-Authored-by: Dominik Csapak 
Signed-off-by: Stoiko Ivanov 
---
 PVE/APIServer/AnyEvent.pm | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
index c55da7f..c5f5fdc 100644
--- a/PVE/APIServer/AnyEvent.pm
+++ b/PVE/APIServer/AnyEvent.pm
@@ -1479,8 +1479,6 @@ sub accept {
 
 fh_nonblocking $clientfh, 1;
 
-$self->{conn_count}++;
-
 return $clientfh;
 }
 
@@ -1561,7 +1559,7 @@ sub accept_connections {
my $reqstate = { keep_alive => $self->{keep_alive} };
 
# stop keep-alive when there are many open connections
-   if ($self->{conn_count} >= $self->{max_conn_soft_limit}) {
+   if ($self->{conn_count}+1 >= $self->{max_conn_soft_limit}) {
$reqstate->{keep_alive} = 0;
}
 
@@ -1600,6 +1598,9 @@ sub accept_connections {
},
($self->{tls_ctx} ? (tls => "accept", tls_ctx => 
$self->{tls_ctx}) : ()));
 
+   $self->{conn_count}++;
+
+
print "$$: ACCEPT FH" .  $clientfh->fileno() . " 
CONN$self->{conn_count}\n" if $self->{debug};
 
$self->push_request_header($reqstate);
-- 
2.20.1



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



[pve-devel] [PATCH http-server 2/3] accept-phase: shutdown socket on early error

2020-12-03 Thread Stoiko Ivanov
if an error happens before AnyEvent::Handle registers the cleanup
callback, we should shutdown the socket, when handling it.

Co-Authored-by: Dominik Csapak 
Signed-off-by: Stoiko Ivanov 
---
 PVE/APIServer/AnyEvent.pm | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
index c5f5fdc..7038b07 100644
--- a/PVE/APIServer/AnyEvent.pm
+++ b/PVE/APIServer/AnyEvent.pm
@@ -1552,9 +1552,13 @@ sub check_host_access {
 sub accept_connections {
 my ($self) = @_;
 
+my ($clientfh, $early_err);
 eval {
 
-   while (my $clientfh = $self->accept()) {
+   while (1) {
+   $early_err = 1;
+   $clientfh = $self->accept();
+   last if !$clientfh;
 
my $reqstate = { keep_alive => $self->{keep_alive} };
 
@@ -1566,15 +1570,21 @@ sub accept_connections {
if (my $sin = getpeername($clientfh)) {
my ($pfamily, $pport, $phost) = 
PVE::Tools::unpack_sockaddr_in46($sin);
($reqstate->{peer_port}, $reqstate->{peer_host}) = ($pport,  
Socket::inet_ntop($pfamily, $phost));
+   } else {
+   shutdown($clientfh, 1);
+   next;
}
 
if (!$self->{trusted_env} && 
!$self->check_host_access($reqstate->{peer_host})) {
print "$$: ABORT request from $reqstate->{peer_host} - access 
denied\n" if $self->{debug};
$reqstate->{log}->{code} = 403;
$self->log_request($reqstate);
+   shutdown($clientfh, 1);
next;
}
 
+   $early_err = 0;
+
$reqstate->{hdl} = AnyEvent::Handle->new(
fh => $clientfh,
rbuf_max => 64*1024,
@@ -1609,6 +1619,7 @@ sub accept_connections {
 
 if (my $err = $@) {
syslog('err', $err);
+   shutdown($clientfh, 1) if $early_err;
$self->{end_loop} = 1;
 }
 
-- 
2.20.1



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



[pve-devel] [PATCH http-server 0/3] improve error handling in accept_connections

2020-12-03 Thread Stoiko Ivanov
This patchset is the result of investigating a report in our community forum:
https://forum.proxmox.com/threads/pveproxy-eats-available-ram.79617/

The first patch fixes an issue where pveproxy worker processes would never
exit (and eat quite a bit of ram+cpu) when 'getpeername' returned an error.

The second seemed to me like a sensible further cleanup, and the third patch
will hopefully provide the needed information when debugging such things in
the future.

Huge thanks to Dominik, who analyzed this issue with me!

Stoiko Ivanov (3):
  accept-phase: fix conn_count "leak"
  accept-phase: shutdown socket on early error
  add debug log for problems during accept

 PVE/APIServer/AnyEvent.pm | 29 +
 1 file changed, 25 insertions(+), 4 deletions(-)

-- 
2.20.1



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



Re: [pve-devel] [PATCH http-server 3/3] add debug log for problems during accept

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 19:43, Stoiko Ivanov wrote:
> Co-Authored-by: Dominik Csapak 
> Signed-off-by: Stoiko Ivanov 
> ---
>  PVE/APIServer/AnyEvent.pm | 9 +
>  1 file changed, 9 insertions(+)
> 
> diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
> index 7038b07..d33f6b0 100644
> --- a/PVE/APIServer/AnyEvent.pm
> +++ b/PVE/APIServer/AnyEvent.pm
> @@ -1520,6 +1520,11 @@ sub check_host_access {
>  
>  my $cip = Net::IP->new($clientip);
>  
> +if (!$cip) {
> + print "$$: check_host_access: clientip not parsable: $@\n" if 
> $self->{debug};

I'd avoid using variable names 1:1 in log messages for such things, use "client 
IP"
(for not hard coding sub name see below)

> + return 0;
> +}
> +
>  my $match_allow = 0;
>  my $match_deny = 0;
>  
> @@ -1527,6 +1532,7 @@ sub check_host_access {
>   foreach my $t (@{$self->{allow_from}}) {
>   if ($t->overlaps($cip)) {
>   $match_allow = 1;
> + print "$$: check_host_access: clientip allowed: ". $t->prefix() 
> . "\n" if $self->{debug};
>   last;
>   }
>   }
> @@ -1535,6 +1541,7 @@ sub check_host_access {
>  if ($self->{deny_from}) {
>   foreach my $t (@{$self->{deny_from}}) {
>   if ($t->overlaps($cip)) {
> + print "$$: check_host_access: clientip denied: ". $t->prefix() 
> . "\n" if $self->{debug};
>   $match_deny = 1;
>   last;
>   }
> @@ -1571,6 +1578,7 @@ sub accept_connections {
>   my ($pfamily, $pport, $phost) = 
> PVE::Tools::unpack_sockaddr_in46($sin);
>   ($reqstate->{peer_port}, $reqstate->{peer_host}) = ($pport,  
> Socket::inet_ntop($pfamily, $phost));
>   } else {
> + print "$$: ACCEPT connection: getpeername failed: $!\n" if 
> $self->{debug};
>   shutdown($clientfh, 1);
>   next;
>   }
> @@ -1619,6 +1627,7 @@ sub accept_connections {
>  
>  if (my $err = $@) {
>   syslog('err', $err);
> + print "$$: ACCEPT connection error: $err\n" if $self->{debug};
>   shutdown($clientfh, 1) if $early_err;
>   $self->{end_loop} = 1;
>  }
> 

can we use a helper method for the printing? Something along:

my sub dprintln {
my ($line) = @_;
return if !$self->{debug};
print "worker[$$]: $line\n";
}

could maybe drop the worker prefix, but I'd say that all processes accepting 
connections
can be classified as workers..

If you want to get real fancy (I mean, for perl ;) you could use caller[0] to 
get some call
context to print.

my ($pkg, $pkgfile, $line, $sub) = caller(1);

print "worker[$$]: $sub: $line\n";

or even

print "worker[$$]: $pkg +$line: $sub: $line\n";

We could later put such a helper in PVE::Tools and add to EXPORT_OK, could be 
helpful,
may want to add some bells n' whistels (control flags?) then - but that's out 
of scope
for this series.

[0]: https://perldoc.perl.org/functions/caller



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



Re: [pve-devel] [PATCH http-server 1/3] accept-phase: fix conn_count "leak"

2020-12-03 Thread Thomas Lamprecht
On 03.12.20 19:43, Stoiko Ivanov wrote:
> When handling new connections in 'accept_connections' the number of
> active connections got increased before the AnyEvent::Handle
> registered the callback which would decrement it on error.
> 
> Any error/die beforehand would skip the decrement, and leave the
> process in an endless loop upon exiting in wait_end_loop.
> 
> This can happen e.g. when the call to getpeername fails, or if the
> connection is denied by the ALLOW_FROM/DENY_FROM settings in
> '/etc/default/pveproxy' (which is also the simplest reproducer for
> that).
> 
> Additionally it can cause a denial of service, by attempting to
> connect from a denied ip until the connection count exeeds the maximum
> connections of all child-processes.
> 
> Reported via our community-forum:
> https://forum.proxmox.com/threads/pveproxy-eats-available-ram.79617/
> 
> Co-Authored-by: Dominik Csapak 
> Signed-off-by: Stoiko Ivanov 
> ---
>  PVE/APIServer/AnyEvent.pm | 7 ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/APIServer/AnyEvent.pm b/PVE/APIServer/AnyEvent.pm
> index c55da7f..c5f5fdc 100644
> --- a/PVE/APIServer/AnyEvent.pm
> +++ b/PVE/APIServer/AnyEvent.pm
> @@ -1479,8 +1479,6 @@ sub accept {
>  
>  fh_nonblocking $clientfh, 1;
>  
> -$self->{conn_count}++;
> -
>  return $clientfh;
>  }
>  
> @@ -1561,7 +1559,7 @@ sub accept_connections {
>   my $reqstate = { keep_alive => $self->{keep_alive} };
>  
>   # stop keep-alive when there are many open connections
> - if ($self->{conn_count} >= $self->{max_conn_soft_limit}) {
> + if ($self->{conn_count}+1 >= $self->{max_conn_soft_limit}) {

style nit: don't glue operators together `self->{conn_count} + 1`

>   $reqstate->{keep_alive} = 0;
>   }
>  
> @@ -1600,6 +1598,9 @@ sub accept_connections {
>   },
>   ($self->{tls_ctx} ? (tls => "accept", tls_ctx => 
> $self->{tls_ctx}) : ()));
>  
> + $self->{conn_count}++;
> +

But isn't this wrong too? The FH could already get a EOF here, and thus get 
reduced
before increased - one could maybe argue "well it should get increased again 
after,
here, so brought in sync again", i.e.:

1. Get's registered
2. clientfh EOF
-> 
$self->client_do_disconnect($reqstate);
-> $self->{conn_count}--;

! Wrong counter here, could lead to possible wrong decisions now already (not 
checked
for sure) or when adding/changing something (as this is non-obvious, not even a 
comment
hinting it!)

3. resume here, brought in sync again, reminds me of a short comic strip I 
recently
   run into [0].

So between 2. and 3. we are in limbo, while short it still matters, every race 
triggers
sooner or later, computers are just to fast and scheduling to nondeterministic 
for that
to not happen.

Why not move the $self->{conn_count}++; before AnyEvent Handle instance is 
created,
i.e., where we do $early_err = 0; as this effectively is the barrier for the 
connection
being valid or not. We could also add handling for when the handle creation 
itself fails,
setting a flag afterwards and checking both, that flag and $early_err in the 
existing
error handling branch outside of the eval, and decrement in that case.


Or, do you have some documented behavior, not stated here in the commit, that 
this all
just cannot happen at all?

[0]: https://i.redd.it/m4zbw3u7rbk21.jpg

> +
>   print "$$: ACCEPT FH" .  $clientfh->fileno() . " 
> CONN$self->{conn_count}\n" if $self->{debug};
>  
>   $self->push_request_header($reqstate);
> 




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