[pve-devel] Pool View
Dietmar Maurer
dietmar at proxmox.com
Mon Jul 21 07:40:10 CEST 2014
here are a few comments and question (inline):
> diff -Nuarp usr/share/perl5/PVE/AccessControl.pm
> usr/share/perl5/PVE/AccessControl.pm
> --- usr/share/perl5/PVE/AccessControl.pm 2014-06-27 16:23:34.305587119
> +1200
> +++ usr/share/perl5/PVE/AccessControl.pm 2014-06-27 16:23:44.077692909
> +1200
> @@ -492,7 +492,7 @@ my $privgroups = {
> },
> };
>
> -my $valid_privs = {};
> +our $valid_privs = {};
using global vars is bad design!
> my $special_roles = {
> 'NoAccess' => {}, # no priviledges
> diff -Nuarp usr/share/perl5/PVE/API2/Cluster.pm
> usr/share/perl5/PVE/API2/Cluster.pm
> --- usr/share/perl5/PVE/API2/Cluster.pm 2014-06-27 16:22:37.302970017
> +1200
> +++ usr/share/perl5/PVE/API2/Cluster.pm 2014-06-27 16:26:30.939493106
> +1200
> @@ -19,6 +19,8 @@ use PVE::RESTHandler;
> use PVE::RPCEnvironment;
> use PVE::JSONSchema qw(get_standard_option);
>
> +use PVE::AccessControl qw(valid_privs);
> +
> use base qw(PVE::RESTHandler);
>
> __PACKAGE__->register_method ({
> @@ -160,12 +162,20 @@ __PACKAGE__->register_method({
> my $vmlist = PVE::Cluster::get_vmlist() || {};
> my $idlist = $vmlist->{ids} || {};
>
> + my $storage_pool = {};
> +
> + foreach my $pool (keys(%{$usercfg->{pools}})) {
> + foreach my $storage (keys(%{$usercfg->{pools}->{$pool}-
> >{storage}})) {
> + $storage_pool->{$storage}=$pool;
> + }
> + }
> +
> my $pooldata = {};
> if (!$param->{type} || $param->{type} eq 'pool') {
> foreach my $pool (keys %{$usercfg->{pools}}) {
> my $d = $usercfg->{pools}->{$pool};
>
> - next if !$rpcenv->check($authuser, "/pool/$pool", [
> 'Pool.Allocate' ], 1);
> + next if !$rpcenv->check_any($authuser, "/pool/$pool", [keys
> $PVE::AccessControl::valid_privs], 1);
Please can you explain that change?
>
> my $entry = {
> id => "/pool/$pool",
> @@ -185,9 +195,9 @@ __PACKAGE__->register_method({
>
> my $data = $idlist->{$vmid};
> my $entry = PVE::API2Tools::extract_vm_stats($vmid, $data,
> $rrd);
> - if ($entry->{uptime}) {
> - if (my $pool = $usercfg->{vms}->{$vmid}) {
> - if (my $pe = $pooldata->{$pool}) {
> + if (my $pool = $usercfg->{vms}->{$vmid}) {
> + if (my $pe = $pooldata->{$pool}) {
> + if ($entry->{uptime}) {
> $pe->{uptime} = $entry->{uptime} if !$pe-
> >{uptime} || $entry->{uptime} > $pe->{uptime};
> $pe->{mem} = 0 if !$pe->{mem};
> $pe->{mem} += $entry->{mem};
> @@ -198,6 +208,7 @@ __PACKAGE__->register_method({
> $pe->{maxcpu} = 0 if !$pe->{maxcpu};
> $pe->{maxcpu} += $entry->{maxcpu};
> }
> + $entry->{pool} = $pe->{pool};
> }
> }
>
> @@ -228,6 +239,9 @@ __PACKAGE__->register_method({
> next if !PVE::Storage::storage_check_enabled($cfg,
> $storeid, $node, 1);
>
> my $entry =
> PVE::API2Tools::extract_storage_stats($storeid, $scfg, $node, $rrd);
> + if (exists $storage_pool->{$entry->{storage}}) {
> + $entry->{"pool"}=$storage_pool->{$entry-
> >{storage}};
> + }
> push @$res, $entry;
> }
> }
> diff -Nuarp usr/share/pve-manager/css/ext-pve.css usr/share/pve-
> manager/css/ext-pve.css
> --- usr/share/pve-manager/css/ext-pve.css 2014-06-27 16:33:46.291799762
> +1200
> +++ usr/share/pve-manager/css/ext-pve.css 2014-06-27 16:34:56.083492567
> +1200
> @@ -108,7 +108,7 @@
> .x-tree-node-pool,
> .x-grid-tree-pool-expanded .x-tree-node-pool
> {
> - background-image:url(../images/connect_established.png);
> + background-image:url(../images/connect_established.png) !important;
why is this required?
More information about the pve-devel
mailing list