Commit d100ceaa authored by Dietmar Maurer's avatar Dietmar Maurer

add subscription status to datacenter summary

parent 670b1cb9
......@@ -206,26 +206,7 @@ __PACKAGE__->register_method({
if (!$param->{type} || $param->{type} eq 'node') {
foreach my $node (@$nodelist) {
my $entry = {
id => "node/$node",
node => $node,
type => "node",
};
if (my $d = $rrd->{"pve2-node/$node"}) {
if (!$members || # no cluster
($members->{$node} && $members->{$node}->{online})) {
$entry->{uptime} = ($d->[0] || 0) + 0;
$entry->{cpu} = ($d->[4] || 0) + 0;
$entry->{mem} = ($d->[7] || 0) + 0;
$entry->{disk} = ($d->[11] || 0) + 0;
}
$entry->{maxcpu} = ($d->[3] || 0) + 0;
$entry->{maxmem} = ($d->[6] || 0) + 0;
$entry->{maxdisk} = ($d->[10] || 0) + 0;
}
my $entry = PVE::API2Tools::extract_node_stats($node, $members, $rrd);
push @$res, $entry;
}
}
......@@ -357,7 +338,7 @@ __PACKAGE__->register_method({
}});
my $parse_clustat = sub {
my ($clinfo, $members, $nodename, $raw) = @_;
my ($clinfo, $members, $rrd, $nodename, $raw) = @_;
my $createNode = sub {
my ($expat, $tag, %attrib) = @_;
......@@ -390,6 +371,11 @@ my $parse_clustat = sub {
$node->{ip} = $ip;
}
}
if (my $entry = PVE::API2Tools::extract_node_stats($name, $members, $rrd)) {
$node->{level} = $entry->{level} || '';
}
} elsif ($tag eq 'group') {
my $name = $node->{name};
return if !$name; # just to be sure
......@@ -467,15 +453,20 @@ __PACKAGE__->register_method({
my $clinfo = PVE::Cluster::get_clinfo();
my $members = PVE::Cluster::get_members();
my $nodename = PVE::INotify::nodename();
my $rrd = PVE::Cluster::rrd_dump();
if ($members) {
my $cmd = ['clustat', '-x'];
my $out = '';
PVE::Tools::run_command($cmd, outfunc => sub { $out .= shift; });
return &$parse_clustat($clinfo, $members, $nodename, $out);
return &$parse_clustat($clinfo, $members, $rrd, $nodename, $out);
} else {
# fake entry for local node if no cluster defined
my $pmxcfs = ($clinfo && $clinfo->{version}) ? 1 : 0; # pmxcfs online ?
my $subinfo = PVE::INotify::read_file('subscription');
my $sublevel = $subinfo->{level} || '';
return [{
type => 'node',
id => "node/$nodename",
......@@ -483,7 +474,8 @@ __PACKAGE__->register_method({
'local' => 1,
nodeid => 0,
pmxcfs => $pmxcfs,
state => 1
state => 1,
level => $sublevel,
}];
}
}});
......
......@@ -57,7 +57,7 @@ sub parse_key {
my ($key) = @_;
if ($key =~ m/^pve([124])([cbsp])-[0-9a-f]{10}$/) {
return wantarray ? ($1, $2) : $1; # number of sockets, type
return wantarray ? ($1, $2) : $1; # number of sockets, level
}
return undef;
}
......@@ -110,7 +110,8 @@ sub read_etc_pve_subscription {
my $key = <$fh>; # first line is the key
chomp $key;
die "Wrong subscription key format\n" if !parse_key($key);
my ($sockets, $level) = parse_key($key);
die "Wrong subscription key format\n" if !$sockets;
my $csum = <$fh>; # second line is a checksum
......@@ -153,6 +154,10 @@ sub read_etc_pve_subscription {
}
}
if ($info->{status} eq 'Active') {
$info->{level} = $level;
}
return $info;
}
......
......@@ -3,6 +3,32 @@ package PVE::API2Tools;
use strict;
use warnings;
sub extract_node_stats {
my ($node, $members, $rrd) = @_;
my $entry = {
id => "node/$node",
node => $node,
type => "node",
};
if (my $d = $rrd->{"pve2-node/$node"}) {
if (!$members || # no cluster
($members->{$node} && $members->{$node}->{online})) {
$entry->{uptime} = ($d->[0] || 0) + 0;
$entry->{cpu} = ($d->[5] || 0) + 0;
$entry->{mem} = ($d->[8] || 0) + 0;
$entry->{disk} = ($d->[12] || 0) + 0;
}
$entry->{level} = $d->[1];
$entry->{maxcpu} = ($d->[4] || 0) + 0;
$entry->{maxmem} = ($d->[7] || 0) + 0;
$entry->{maxdisk} = ($d->[11] || 0) + 0;
}
return $entry;
}
sub extract_vm_stats {
my ($vmid, $data, $rrd) = @_;
......
......@@ -15,6 +15,7 @@ use PVE::Storage;
use PVE::QemuServer;
use PVE::OpenVZ;
use PVE::RPCEnvironment;
use PVE::API2::Subscription;
$SIG{'__WARN__'} = sub {
my $err = $@;
......@@ -144,6 +145,9 @@ sub update_node_status {
my $maxcpu = $cpuinfo->{cpus};
my $subinfo = PVE::INotify::read_file('subscription');
my $sublevel = $subinfo->{level} || '';
# traffic from/to physical interface cards
my $netin = 0;
my $netout = 0;
......@@ -162,7 +166,7 @@ sub update_node_status {
# everything not free is considered to be used
my $dused = $dinfo->{blocks} - $dinfo->{bfree};
my $data = "$uptime:$ctime:$avg1:$maxcpu:$stat->{cpu}:$stat->{wait}:" .
my $data = "$uptime:$sublevel:$ctime:$avg1:$maxcpu:$stat->{cpu}:$stat->{wait}:" .
"$meminfo->{memtotal}:$meminfo->{memused}:" .
"$meminfo->{swaptotal}:$meminfo->{swapused}:" .
"$dinfo->{blocks}:$dused:$netin:$netout";
......
pve-manager (2.0-46) unstable; urgency=low
* code cleanups
-- Proxmox Support Team <support@proxmox.com> Mon, 26 Mar 2012 10:38:33 +0200
pve-manager (2.0-45) unstable; urgency=low
* fix bug 124: correctly return maxfiles flag
......
......@@ -2,7 +2,7 @@ RELEASE=2.0
VERSION=2.0
PACKAGE=pve-manager
PACKAGERELEASE=45
PACKAGERELEASE=46
BINDIR=${DESTDIR}/usr/bin
PERLLIBDIR=${DESTDIR}/usr/share/perl5
......
......@@ -100,6 +100,13 @@ Ext.define('PVE.Utils', { statics: {
7: "debug"
},
support_level_hash: {
'c': gettext('Community'),
'b': gettext('Basic'),
's': gettext('Standard'),
'p': gettext('Premium')
},
kvm_ostypes: {
other: gettext('Other OS types'),
wxp: 'Microsoft Windows XP/2003',
......@@ -723,6 +730,10 @@ Ext.define('PVE.Utils', { statics: {
return PVE.Utils.format_duration_long(uptime);
},
render_support_level: function(value, metaData, record) {
return PVE.Utils.support_level_hash[value] || '-';
},
render_upid: function(value, metaData, record) {
var type = record.data.type;
var id = record.data.id;
......
......@@ -45,6 +45,13 @@ Ext.define('PVE.dc.NodeView', {
dataIndex: 'state',
renderer: PVE.Utils.format_boolean
},
{
header: gettext('Support'),
width: 100,
sortable: true,
dataIndex: 'level',
renderer: PVE.Utils.render_support_level
},
{
header: gettext('Estranged'),
width: 100,
......@@ -94,7 +101,7 @@ Ext.define('PVE.dc.NodeView', {
Ext.define('pve-dc-nodes', {
extend: 'Ext.data.Model',
fields: [ 'id', 'type', 'name', 'state', 'nodeid', 'ip',
'pmxcfs', 'rgmanager', 'estranged' ],
'pmxcfs', 'rgmanager', 'estranged', 'level' ],
idProperty: 'id'
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment