mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-08-17 22:43:20 +00:00
render resource pools
This commit is contained in:
parent
b9938a0bcb
commit
84916eb2d9
@ -143,7 +143,8 @@ __PACKAGE__->register_method({
|
|||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
my $rpcenv = PVE::RPCEnvironment::get();
|
my $rpcenv = PVE::RPCEnvironment::get();
|
||||||
my $user = $rpcenv->get_user();
|
my $authuser = $rpcenv->get_user();
|
||||||
|
my $usercfg = $rpcenv->{user_cfg};
|
||||||
|
|
||||||
my $res = [];
|
my $res = [];
|
||||||
|
|
||||||
@ -155,6 +156,24 @@ __PACKAGE__->register_method({
|
|||||||
my $vmlist = PVE::Cluster::get_vmlist() || {};
|
my $vmlist = PVE::Cluster::get_vmlist() || {};
|
||||||
my $idlist = $vmlist->{ids} || {};
|
my $idlist = $vmlist->{ids} || {};
|
||||||
|
|
||||||
|
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", [ 'VM.Audit' ], 1);
|
||||||
|
|
||||||
|
my $entry = {
|
||||||
|
id => "/pool/$pool",
|
||||||
|
pool => $pool,
|
||||||
|
type => 'pool',
|
||||||
|
};
|
||||||
|
|
||||||
|
$pooldata->{$pool} = $entry;
|
||||||
|
|
||||||
|
push @$res, $entry;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# we try to generate 'numbers' by using "$X + 0"
|
# we try to generate 'numbers' by using "$X + 0"
|
||||||
if (!$param->{type} || $param->{type} eq 'vm') {
|
if (!$param->{type} || $param->{type} eq 'vm') {
|
||||||
@ -162,7 +181,7 @@ __PACKAGE__->register_method({
|
|||||||
my $data = $idlist->{$vmid};
|
my $data = $idlist->{$vmid};
|
||||||
|
|
||||||
|
|
||||||
next if !$rpcenv->check($user, "/vms/$vmid", [ 'VM.Audit' ], 1);
|
next if !$rpcenv->check($authuser, "/vms/$vmid", [ 'VM.Audit' ], 1);
|
||||||
|
|
||||||
my $entry = {
|
my $entry = {
|
||||||
id => "$data->{type}/$vmid",
|
id => "$data->{type}/$vmid",
|
||||||
@ -182,8 +201,23 @@ __PACKAGE__->register_method({
|
|||||||
$entry->{mem} = ($d->[6] || 0) + 0;
|
$entry->{mem} = ($d->[6] || 0) + 0;
|
||||||
$entry->{maxdisk} = ($d->[7] || 0) + 0;
|
$entry->{maxdisk} = ($d->[7] || 0) + 0;
|
||||||
$entry->{disk} = ($d->[8] || 0) + 0;
|
$entry->{disk} = ($d->[8] || 0) + 0;
|
||||||
|
|
||||||
|
if (my $pool = $usercfg->{vms}->{$vmid}) {
|
||||||
|
if (my $pe = $pooldata->{$pool}) {
|
||||||
|
$pe->{uptime} = $entry->{uptime} if !$pe->{uptime} || $entry->{uptime} > $pe->{uptime};
|
||||||
|
$pe->{mem} = 0 if !$pe->{mem};
|
||||||
|
$pe->{mem} += $entry->{mem};
|
||||||
|
$pe->{maxmem} = 0 if !$pe->{maxmem};
|
||||||
|
$pe->{maxmem} += $entry->{maxmem};
|
||||||
|
$pe->{cpu} = 0 if !$pe->{cpu};
|
||||||
|
$pe->{cpu} += $entry->{cpu};
|
||||||
|
$pe->{maxcpu} = 0 if !$pe->{maxcpu};
|
||||||
|
$pe->{maxcpu} += $entry->{maxcpu};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
push @$res, $entry;
|
push @$res, $entry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -221,7 +255,7 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
foreach my $storeid (@sids) {
|
foreach my $storeid (@sids) {
|
||||||
my $scfg = PVE::Storage::storage_config($cfg, $storeid);
|
my $scfg = PVE::Storage::storage_config($cfg, $storeid);
|
||||||
next if !$rpcenv->check($user, "/storage/$storeid", [ 'Datastore.Audit' ], 1);
|
next if !$rpcenv->check($authuser, "/storage/$storeid", [ 'Datastore.Audit' ], 1);
|
||||||
# we create a entry for each node
|
# we create a entry for each node
|
||||||
foreach my $node (@$nodelist) {
|
foreach my $node (@$nodelist) {
|
||||||
next if !PVE::Storage::storage_check_enabled($cfg, $storeid, $node, 1);
|
next if !PVE::Storage::storage_check_enabled($cfg, $storeid, $node, 1);
|
||||||
@ -268,7 +302,7 @@ __PACKAGE__->register_method({
|
|||||||
my ($param) = @_;
|
my ($param) = @_;
|
||||||
|
|
||||||
my $rpcenv = PVE::RPCEnvironment::get();
|
my $rpcenv = PVE::RPCEnvironment::get();
|
||||||
my $user = $rpcenv->get_user();
|
my $authuser = $rpcenv->get_user();
|
||||||
|
|
||||||
my $tlist = PVE::Cluster::get_tasklist();
|
my $tlist = PVE::Cluster::get_tasklist();
|
||||||
|
|
||||||
@ -276,10 +310,10 @@ __PACKAGE__->register_method({
|
|||||||
|
|
||||||
return $res if !$tlist;
|
return $res if !$tlist;
|
||||||
|
|
||||||
my $all = $rpcenv->check($user, "/", [ 'Sys.Audit' ], 1);
|
my $all = $rpcenv->check($authuser, "/", [ 'Sys.Audit' ], 1);
|
||||||
|
|
||||||
foreach my $task (@$tlist) {
|
foreach my $task (@$tlist) {
|
||||||
push @$res, $task if $all || ($task->{user} eq $user);
|
push @$res, $task if $all || ($task->{user} eq $authuser);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $res;
|
return $res;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
.pve-itype-icon-node,
|
.pve-itype-icon-node,
|
||||||
.pve-itype-icon-node-running,
|
.pve-itype-icon-node-running,
|
||||||
.pve-itype-icon-storage,
|
.pve-itype-icon-storage,
|
||||||
|
.pve-itype-icon-pool,
|
||||||
.pve-itype-icon-itype
|
.pve-itype-icon-itype
|
||||||
{
|
{
|
||||||
background-repeat: no-repeat;
|
background-repeat: no-repeat;
|
||||||
@ -83,6 +84,13 @@
|
|||||||
background-image:url(../images/drive-harddisk.png);
|
background-image:url(../images/drive-harddisk.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pve-itype-icon-pool,
|
||||||
|
.x-tree-node-pool,
|
||||||
|
.x-grid-tree-pool-expanded .x-tree-node-pool
|
||||||
|
{
|
||||||
|
background-image:url(../images/connect_established.png);
|
||||||
|
}
|
||||||
|
|
||||||
.pve-itype-icon-itype
|
.pve-itype-icon-itype
|
||||||
{
|
{
|
||||||
background-image:url(../ext4/resources/themes/images/default/tree/folder.gif);
|
background-image:url(../ext4/resources/themes/images/default/tree/folder.gif);
|
||||||
|
@ -13,6 +13,7 @@ GNOME_IMAGES = \
|
|||||||
network.png \
|
network.png \
|
||||||
drive-harddisk.png \
|
drive-harddisk.png \
|
||||||
network-server.png \
|
network-server.png \
|
||||||
|
connect_established.png \
|
||||||
computer.png
|
computer.png
|
||||||
|
|
||||||
IMAGES = ${GNOME_IMAGES} \
|
IMAGES = ${GNOME_IMAGES} \
|
||||||
|
BIN
www/images/connect_established.png
Normal file
BIN
www/images/connect_established.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 704 B |
@ -72,6 +72,8 @@ Ext.define('PVE.data.ResourceStore', {
|
|||||||
|
|
||||||
if (info.type === 'node') {
|
if (info.type === 'node') {
|
||||||
text = info.node;
|
text = info.node;
|
||||||
|
} else if (info.type === 'pool') {
|
||||||
|
text = info.pool;
|
||||||
} else if (info.type === 'storage') {
|
} else if (info.type === 'storage') {
|
||||||
text = info.storage + ' (' + info.node + ')';
|
text = info.storage + ' (' + info.node + ')';
|
||||||
} else if (info.type === 'qemu' || info.type === 'openvz') {
|
} else if (info.type === 'qemu' || info.type === 'openvz') {
|
||||||
@ -162,6 +164,13 @@ Ext.define('PVE.data.ResourceStore', {
|
|||||||
hidden: true,
|
hidden: true,
|
||||||
sortable: true,
|
sortable: true,
|
||||||
width: 110
|
width: 110
|
||||||
|
},
|
||||||
|
pool: {
|
||||||
|
header: gettext('Pool'),
|
||||||
|
type: 'text',
|
||||||
|
hidden: true,
|
||||||
|
sortable: true,
|
||||||
|
width: 110
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -12,6 +12,10 @@ Ext.define('PVE.tree.ResourceTree', {
|
|||||||
iconCls: 'x-tree-node-server',
|
iconCls: 'x-tree-node-server',
|
||||||
text: gettext('Node list')
|
text: gettext('Node list')
|
||||||
},
|
},
|
||||||
|
pool: {
|
||||||
|
iconCls: 'x-tree-node-pool',
|
||||||
|
text: gettext('Resource Pool')
|
||||||
|
},
|
||||||
storage: {
|
storage: {
|
||||||
iconCls: 'x-tree-node-harddisk',
|
iconCls: 'x-tree-node-harddisk',
|
||||||
text: gettext('Storage list')
|
text: gettext('Storage list')
|
||||||
|
Loading…
Reference in New Issue
Block a user