[pve-devel] r6041 - in pve-manager/pve2: lib/PVE/API2 www/new www/new/data www/new/node www/new/window
svn-commits at proxmox.com
svn-commits at proxmox.com
Mon May 30 10:56:24 CEST 2011
Author: dietmar
Date: 2011-05-30 10:56:24 +0200 (Mon, 30 May 2011)
New Revision: 6041
Added:
pve-manager/pve2/www/new/node/Syslog.js
Modified:
pve-manager/pve2/lib/PVE/API2/Nodes.pm
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/data/PVEProxy.js
pve-manager/pve2/www/new/node/Config.js
pve-manager/pve2/www/new/node/Tasks.js
pve-manager/pve2/www/new/window/TaskViewer.js
Log:
impl. simplified syslog
Modified: pve-manager/pve2/lib/PVE/API2/Nodes.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Nodes.pm 2011-05-30 06:52:14 UTC (rev 6040)
+++ pve-manager/pve2/lib/PVE/API2/Nodes.pm 2011-05-30 08:56:24 UTC (rev 6041)
@@ -354,42 +354,75 @@
path => '/nodes/{node}',
privs => [ 'Sys.Syslog' ],
},
+ protected => 1,
parameters => {
additionalProperties => 0,
properties => {
node => get_standard_option('pve-node'),
- max => {
+ start => {
type => 'integer',
- description => "Maximum number of entries.",
+ minimum => 0,
optional => 1,
- minimum => 1,
- }
+ },
+ limit => {
+ type => 'integer',
+ minimum => 0,
+ optional => 1,
+ },
},
},
returns => {
type => 'array',
- items => {
+ items => {
type => "object",
- properties => {},
- },
+ properties => {
+ n => {
+ description=> "Line number",
+ type=> 'integer',
+ },
+ t => {
+ description=> "Line text",
+ type => 'string',
+ }
+ }
+ }
},
code => sub {
my ($param) = @_;
+ my $lines = [];
+
my $rpcenv = PVE::RPCEnvironment::get();
-
- my $max = $param->{max} || 0;
my $user = $rpcenv->get_user();
+ my $node = $param->{node};
- my $loguser = $user eq 'root at pam' ? "" : $user;
+ my $fh = IO::File->new("/var/log/syslog", "r");
+ die "unable to open file - $!" if !$fh;
- # fixme: read local file instead? use start/limit parameter?
- my $res = decode_json(PVE::Cluster::get_system_log($loguser, $max));
+ my $start = $param->{start} || 0;
+ my $limit = $param->{limit} || 50;
+ my $count = 0;
+ my $line;
+ while (defined ($line = <$fh>)) {
+ next if $count++ < $start;
+ next if $limit <= 0;
+ chomp $line;
+ push @$lines, { n => $count, t => $line};
+ $limit--;
+ }
- # fixme: can we avoid that?
- my $list = [ reverse @{$res->{data}} ];
+ close($fh);
- return $list;
+ # HACK: ExtJS store.guaranteeRange() does not like empty array
+ # so we add a line
+ if (!$count) {
+ $count++;
+ push @$lines, { n => $count, t => "no content"};
+ }
+
+ $rpcenv->set_result_count($count);
+
+ return $lines;
}});
my $sslcert;
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-05-30 06:52:14 UTC (rev 6040)
+++ pve-manager/pve2/www/new/Makefile.am 2011-05-30 08:56:24 UTC (rev 6041)
@@ -45,6 +45,7 @@
node/ServiceView.js \
node/NetworkEdit.js \
node/NetworkView.js \
+ node/Syslog.js \
node/Tasks.js \
node/Config.js \
qemu/StatusView.js \
Modified: pve-manager/pve2/www/new/data/PVEProxy.js
===================================================================
--- pve-manager/pve2/www/new/data/PVEProxy.js 2011-05-30 06:52:14 UTC (rev 6040)
+++ pve-manager/pve2/www/new/data/PVEProxy.js 2011-05-30 08:56:24 UTC (rev 6041)
@@ -41,6 +41,12 @@
idProperty: 'key'
});
+ Ext.define('pve-string-list', {
+ extend: 'Ext.data.Model',
+ fields: [ 'n', 't' ],
+ idProperty: 'n'
+ });
+
Ext.define('pve-tasks', {
extend: 'Ext.data.Model',
fields: [
Modified: pve-manager/pve2/www/new/node/Config.js
===================================================================
--- pve-manager/pve2/www/new/node/Config.js 2011-05-30 06:52:14 UTC (rev 6040)
+++ pve-manager/pve2/www/new/node/Config.js 2011-05-30 08:56:24 UTC (rev 6041)
@@ -39,6 +39,11 @@
xtype: 'pveNodeTimeView'
},
{
+ title: 'Syslog',
+ itemId: 'syslog',
+ xtype: 'pveNodeSyslog'
+ },
+ {
title: 'Tasks',
itemId: 'tasks',
xtype: 'pveNodeTasks'
Added: pve-manager/pve2/www/new/node/Syslog.js
===================================================================
--- pve-manager/pve2/www/new/node/Syslog.js (rev 0)
+++ pve-manager/pve2/www/new/node/Syslog.js 2011-05-30 08:56:24 UTC (rev 6041)
@@ -0,0 +1,47 @@
+Ext.define('PVE.node.Syslog', {
+ extend: 'Ext.grid.GridPanel',
+
+ alias: ['widget.pveNodeSyslog'],
+
+ initComponent : function() {
+ var me = this;
+
+ var nodename = me.pveSelNode.data.node;
+ if (!nodename)
+ throw "no node name specified";
+
+ var store = Ext.create('Ext.data.Store', {
+ pageSize: 500,
+ buffered: true,
+ model: 'pve-string-list',
+ proxy: {
+ type: 'pve',
+ startParam: 'start',
+ limitParam: 'limit',
+ url: "/api2/json/nodes/" + nodename + "/syslog"
+ }
+ });
+
+ Ext.apply(me, {
+ store: store,
+ features: [ {ftype: 'selectable'}],
+ stateful: false,
+ verticalScrollerType: 'paginggridscroller',
+ loadMask: true,
+ invalidateScrollerOnRefresh: false,
+ viewConfig: {
+ trackOver: false,
+ stripeRows: false
+ },
+ hideHeaders: true,
+ columns: [
+ { header: "Text", dataIndex: 't', flex: 1 }
+ ]
+ });
+
+ me.callParent();
+
+ store.guaranteeRange(0, store.pageSize - 1);
+ }
+});
+
Modified: pve-manager/pve2/www/new/node/Tasks.js
===================================================================
--- pve-manager/pve2/www/new/node/Tasks.js 2011-05-30 06:52:14 UTC (rev 6040)
+++ pve-manager/pve2/www/new/node/Tasks.js 2011-05-30 08:56:24 UTC (rev 6041)
@@ -152,6 +152,8 @@
});
me.callParent();
+
+ store.guaranteeRange(0, store.pageSize - 1);
}
});
Modified: pve-manager/pve2/www/new/window/TaskViewer.js
===================================================================
--- pve-manager/pve2/www/new/window/TaskViewer.js 2011-05-30 06:52:14 UTC (rev 6040)
+++ pve-manager/pve2/www/new/window/TaskViewer.js 2011-05-30 08:56:24 UTC (rev 6041)
@@ -45,11 +45,7 @@
};
var store = Ext.create('Ext.data.Store', {
- model: Ext.define('pve-string-list', {
- extend: 'Ext.data.Model',
- fields: [ 'n', 't' ],
- idProperty: 'n'
- }),
+ model: 'pve-string-list',
pageSize: 200,
buffered: true,
proxy: {
@@ -57,7 +53,7 @@
startParam: 'start',
limitParam: 'limit',
url: "/api2/json/nodes/" + task.node + "/tasks/" + me.upid + "/log"
- },
+ }
});
var statstore = Ext.create('PVE.data.ObjectStore', {
More information about the pve-devel
mailing list