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

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

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

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


[pve-devel] [PATCH pve-manager] api : cluster resources: add sdn audit permission

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

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index 76560fa4..062ca849 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -411,7 +411,7 @@ __PACKAGE__->register_method({
 
foreach my $id (keys %{$sdns}) {
my $sdn = $sdns->{$id};
-   #next if !$rpcenv->check($authuser, "/sdn/$id", [ 
'SDN.Audit' ], 1);
+   next if !$rpcenv->check($authuser, "/sdn/zones/$id", [ 
'SDN.Audit' ], 1);
my $entry = {
id => "sdn/$node/$id",
sdn => $id,
-- 
2.20.1

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


[pve-devel] [PATCH widget-toolkit 2/4] show Task warnings differently

2020-06-12 Thread Dominik Csapak
tasks can now show also 'WARNINGS: '
filter it out and provide a 'parse_task_status' function for easy reuse

Signed-off-by: Dominik Csapak 
---
 src/Utils.js | 17 +
 src/css/ext6-pmx.css |  4 
 src/node/Tasks.js| 22 --
 3 files changed, 37 insertions(+), 6 deletions(-)

diff --git a/src/Utils.js b/src/Utils.js
index c3b13f4..2163794 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -711,6 +711,23 @@ utilities: {
return task;
 },
 
+parse_task_status: function(status) {
+   if (status === 'OK') {
+   return 'ok';
+   }
+
+   if (status === 'unknown') {
+   return 'unknown';
+   }
+
+   let match = status.match(/^WARNINGS: (.*)$/);
+   if (match) {
+   return 'warning';
+   }
+
+   return 'error';
+},
+
 render_duration: function(value) {
if (value === undefined) {
return '-';
diff --git a/src/css/ext6-pmx.css b/src/css/ext6-pmx.css
index a7d446b..df5c73d 100644
--- a/src/css/ext6-pmx.css
+++ b/src/css/ext6-pmx.css
@@ -14,6 +14,10 @@
 background-color: #f3d6d7;
 }
 
+.proxmox-warning-row {
+background-color: #f5e5d8;
+}
+
 /* some icons have to be color manually */
 .black {
 color: #000;
diff --git a/src/node/Tasks.js b/src/node/Tasks.js
index 3d9267e..5aff06d 100644
--- a/src/node/Tasks.js
+++ b/src/node/Tasks.js
@@ -81,8 +81,13 @@ Ext.define('Proxmox.node.Tasks', {
getRowClass: function(record, index) {
let status = record.get('status');
 
-   if (status && status !== 'OK') {
-   return "proxmox-invalid-row";
+   if (status) {
+   let parsed = Proxmox.Utils.parse_task_status(status);
+   if (parsed === 'error') {
+   return "proxmox-invalid-row";
+   } else if (parsed === 'warning') {
+   return "proxmox-warning-row";
+   }
}
return '';
},
@@ -162,14 +167,19 @@ Ext.define('Proxmox.node.Tasks', {
dataIndex: 'status',
width: 200,
renderer: function(value, metaData, record) {
-   if (value === 'OK') {
-   return 'OK';
-   }
if (value === undefined && !record.data.endtime) {
metaData.tdCls = "x-grid-row-loading";
return '';
}
-   return "ERROR: " + value;
+
+   let parsed = Proxmox.Utils.parse_task_status(value);
+   switch (parsed) {
+   case 'unknown': return Proxmox.Utils.unknownText;
+   case 'error': return Proxmox.Utils.errorText + ': ' 
+ value;
+   case 'ok': // fall-through
+   case 'warning': // fall-through
+   default: return value;
+   }
},
},
],
-- 
2.20.1


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


[pve-devel] [PATCH widget-toolkit 4/4] format_duration_human: say <1s instead of 0s

2020-06-12 Thread Dominik Csapak
if we get a duration of <=0s it should actually be somewhere
betweeen 0 and 1s so return <1s

Signed-off-by: Dominik Csapak 
---
 src/Utils.js | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Utils.js b/src/Utils.js
index 2163794..a914795 100644
--- a/src/Utils.js
+++ b/src/Utils.js
@@ -158,7 +158,7 @@ utilities: {
let seconds = 0, minutes = 0, hours = 0, days = 0;
 
if (ut <= 0) {
-   return '0s';
+   return '<1s';
}
 
let remaining = ut;
-- 
2.20.1


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


[pve-devel] [PATCH widget-toolkit 3/4] TaskViewer: show endtime and duration in status

2020-06-12 Thread Dominik Csapak
but only when the caller gives us the endtime, since the status
api call does not give us the endtime

Signed-off-by: Dominik Csapak 
---
 src/node/Tasks.js|  1 +
 src/window/TaskViewer.js | 23 +++
 2 files changed, 24 insertions(+)

diff --git a/src/node/Tasks.js b/src/node/Tasks.js
index 5aff06d..c41f0b5 100644
--- a/src/node/Tasks.js
+++ b/src/node/Tasks.js
@@ -60,6 +60,7 @@ Ext.define('Proxmox.node.Tasks', {
 
let win = Ext.create('Proxmox.window.TaskViewer', {
upid: rec.data.upid,
+   endtime: rec.data.endtime,
});
win.show();
};
diff --git a/src/window/TaskViewer.js b/src/window/TaskViewer.js
index 2f31023..fedf693 100644
--- a/src/window/TaskViewer.js
+++ b/src/window/TaskViewer.js
@@ -152,6 +152,29 @@ Ext.define('Proxmox.window.TaskViewer', {
},
};
 
+   if (me.endtime) {
+   if (typeof me.endtime === 'object') {
+   // convert to epoch
+   me.endtime = parseInt(me.endtime.getTime()/1000, 10);
+   }
+   rows.endtime = {
+   header: gettext('End Time'),
+   required: true,
+   renderer: function() {
+   return Proxmox.Utils.render_timestamp(me.endtime);
+   },
+   };
+   rows.duration = {
+   header: gettext('Duration'),
+   required: true,
+   renderer: function() {
+   let starttime = statgrid.getObjectValue('starttime');
+   let duration = me.endtime - starttime;
+   return Proxmox.Utils.format_duration_human(duration);
+   },
+   };
+   }
+
let statstore = Ext.create('Proxmox.data.ObjectStore', {
 url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + 
"/status",
interval: 1000,
-- 
2.20.1


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


[pve-devel] [PATCH widget-toolkit 1/4] ProxmoxProxy: add duration fields for proxmox-tasks

2020-06-12 Thread Dominik Csapak
Signed-off-by: Dominik Csapak 
---
 src/data/ProxmoxProxy.js | 12 
 1 file changed, 12 insertions(+)

diff --git a/src/data/ProxmoxProxy.js b/src/data/ProxmoxProxy.js
index 53e92f3..40fdc08 100644
--- a/src/data/ProxmoxProxy.js
+++ b/src/data/ProxmoxProxy.js
@@ -43,6 +43,18 @@ Ext.define('Proxmox.RestProxy', {
{ name: 'starttime', type: 'date', dateFormat: 'timestamp' },
{ name: 'endtime', type: 'date', dateFormat: 'timestamp' },
{ name: 'pid', type: 'int' },
+   {
+   name: 'duration',
+   sortType: 'asInt',
+   calculate: function(data) {
+   let endtime = data.endtime;
+   let starttime = data.starttime;
+   if (endtime !== undefined) {
+   return ((endtime - starttime)/1000).toFixed(0);
+   }
+   return 0;
+   },
+   },
'node', 'upid', 'user', 'status', 'type', 'id',
],
idProperty: 'upid',
-- 
2.20.1


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


[pve-devel] [PATCH pve-manager] sdn: browser: fix Permissions.Modify

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

diff --git a/www/manager6/sdn/Browser.js b/www/manager6/sdn/Browser.js
index 20944bd5..1415f966 100644
--- a/www/manager6/sdn/Browser.js
+++ b/www/manager6/sdn/Browser.js
@@ -34,7 +34,7 @@ Ext.define('PVE.sdn.Browser', {
});
}
 
-// if (caps.sdn['Permissions.Modify']) {
+   if (caps.sdn['Permissions.Modify']) {
me.items.push({
xtype: 'pveACLView',
title: gettext('Permissions'),
@@ -42,7 +42,7 @@ Ext.define('PVE.sdn.Browser', {
itemId: 'permissions',
path: '/sdn/zones/' + sdnid
});
-// }
+   }
 
me.callParent();
}
-- 
2.20.1

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


[pve-devel] [PATCH pve-access-control] api2: AccessControl: add sdn permissions.modify

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

diff --git a/PVE/API2/AccessControl.pm b/PVE/API2/AccessControl.pm
index 8b053dc..fd27786 100644
--- a/PVE/API2/AccessControl.pm
+++ b/PVE/API2/AccessControl.pm
@@ -176,7 +176,7 @@ my $compute_api_permission = sub {
access => qr/(User|Group)\.|Permissions\.Modify/,
storage => qr/Datastore\.|Permissions\.Modify/,
nodes => qr/Sys\.|Permissions\.Modify/,
-   sdn => qr/SDN\./,
+   sdn => qr/SDN\.|Permissions\.Modify/,
dc => qr/Sys\.Audit|SDN\./,
 };
 map { $res->{$_} = {} } keys %$priv_re_map;
-- 
2.20.1

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


Re: [pve-devel] [PATCH common] debian/postinst: check for existing /etc/aliases

2020-06-12 Thread Stoiko Ivanov
sorry - forgot (again :/ ) to add the bugreference:
fix #2796

On Fri, 12 Jun 2020 11:14:38 +0200
Stoiko Ivanov  wrote:

> Signed-off-by: Stoiko Ivanov 
> ---
> Tested by installing libpve-common-perl=6.0-4 on a buster system w/o
> /etc/aliases and then installing one with this patch applied (and the
> libproxmox-acme-perl dependency removed).
> debian/postinst | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/debian/postinst b/debian/postinst
> index 5a19c69..7bd635a 100644
> --- a/debian/postinst
> +++ b/debian/postinst
> @@ -9,7 +9,7 @@ case "$1" in
>  if test -n "$2"; then
>  
>  # TODO: remove once PVE 7.0 is released
> -if dpkg --compare-versions "$2" 'lt' '6.0-5'; then
> +if dpkg --compare-versions "$2" 'lt' '6.0-5' && [ -e /etc/aliases ]; 
> then
>  sed -E -i -e 's/^www:(\w)/www: \1/' /etc/aliases
> fi
>  fi


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


[pve-devel] [PATCH common] debian/postinst: check for existing /etc/aliases

2020-06-12 Thread Stoiko Ivanov
Signed-off-by: Stoiko Ivanov 
---
Tested by installing libpve-common-perl=6.0-4 on a buster system w/o
/etc/aliases and then installing one with this patch applied (and the
libproxmox-acme-perl dependency removed).
debian/postinst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/debian/postinst b/debian/postinst
index 5a19c69..7bd635a 100644
--- a/debian/postinst
+++ b/debian/postinst
@@ -9,7 +9,7 @@ case "$1" in
 if test -n "$2"; then
 
 # TODO: remove once PVE 7.0 is released
-if dpkg --compare-versions "$2" 'lt' '6.0-5'; then
+if dpkg --compare-versions "$2" 'lt' '6.0-5' && [ -e /etc/aliases ]; 
then
 sed -E -i -e 's/^www:(\w)/www: \1/' /etc/aliases
fi
 fi
-- 
2.20.1


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