[pve-devel] r6062 - pve-storage/pve2/PVE/API2/Storage

svn-commits at proxmox.com svn-commits at proxmox.com
Tue May 31 11:00:54 CEST 2011


Author: dietmar
Date: 2011-05-31 11:00:54 +0200 (Tue, 31 May 2011)
New Revision: 6062

Modified:
   pve-storage/pve2/PVE/API2/Storage/Status.pm
Log:
impl. rrd


Modified: pve-storage/pve2/PVE/API2/Storage/Status.pm
===================================================================
--- pve-storage/pve2/PVE/API2/Storage/Status.pm	2011-05-31 08:04:23 UTC (rev 6061)
+++ pve-storage/pve2/PVE/API2/Storage/Status.pm	2011-05-31 09:00:54 UTC (rev 6062)
@@ -13,12 +13,13 @@
 
 use base qw(PVE::RESTHandler);
 
+
 __PACKAGE__->register_method ({
     subclass => "PVE::API2::Storage::Content", 
     # set fragment delimiter (no subdirs) - we need that, because volume
     # IDs may contain a slash '/' 
     fragmentDelimiter => '', 
-    path => '{storage}',
+    path => '{storage}/content',
 });
 
 __PACKAGE__->register_method ({
@@ -72,4 +73,156 @@
 	return PVE::RESTHandler::hash_to_array($info, 'storage');
     }});
 
+__PACKAGE__->register_method ({
+    name => 'diridx',
+    path => '{storage}', 
+    method => 'GET',
+    description => "",
+    parameters => {
+    	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    storage => get_standard_option('pve-storage-id'),
+	},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => {
+		subdir => { type => 'string' },
+	    },
+	},
+	links => [ { rel => 'child', href => "{subdir}" } ],
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $res = [
+	    { subdir => 'status' },
+	    { subdir => 'content' },
+	    { subdir => 'rrd' },
+	    { subdir => 'rrddata' },
+	    ];
+	
+	return $res;
+    }});
+
+__PACKAGE__->register_method ({
+    name => 'read_status',
+    path => '{storage}/status', 
+    method => 'GET',
+    description => "Read storage status.",
+    protected => 1,
+    proxyto => 'node',
+    parameters => {
+    	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    storage => get_standard_option('pve-storage-id'),
+	},
+    },
+    returns => {
+	type => "object",
+	properties => {},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $cfg = cfs_read_file("storage.cfg");
+
+	my $info = PVE::Storage::storage_info($cfg, $param->{content});
+
+	my $data = $info->{$param->{storage}};
+
+	raise_param_exc({ storage => "No such storage." })
+	    if !defined($data);
+    
+	return $data;
+    }});
+
+__PACKAGE__->register_method ({
+    name => 'rrd',
+    path => '{storage}/rrd', 
+    method => 'GET',
+    description => "Read storage RRD statistics (returns PNG).",
+    protected => 1,
+    proxyto => 'node',
+    parameters => {
+    	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    storage => get_standard_option('pve-storage-id'),
+	    timeframe => {
+		description => "Specify the time frame you are interested in.",
+		type => 'string',
+		enum => [ 'hour', 'day', 'week', 'month', 'year' ],
+	    },
+	    ds => {
+		description => "The list of datasources you want to display.",
+ 		type => 'string', format => 'pve-configid-list',
+	    },
+	    cf => {
+		description => "The RRD consolidation function",
+ 		type => 'string',
+		enum => [ 'AVERAGE', 'MAX' ],
+		optional => 1,
+	    },
+	},
+    },
+    returns => {
+	type => "object",
+	properties => {
+	    filename => { type => 'string' },
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::Cluster::create_rrd_graph(
+	    "pve2-storage/$param->{node}/$param->{storage}", 
+	    $param->{timeframe}, $param->{ds}, $param->{cf});
+					      
+    }});
+
+__PACKAGE__->register_method ({
+    name => 'rrddata',
+    path => '{storage}/rrddata', 
+    method => 'GET',
+    description => "Read storage RRD statistics.",
+    protected => 1,
+    proxyto => 'node',
+    parameters => {
+    	additionalProperties => 0,
+	properties => {
+	    node => get_standard_option('pve-node'),
+	    storage => get_standard_option('pve-storage-id'),
+	    timeframe => {
+		description => "Specify the time frame you are interested in.",
+		type => 'string',
+		enum => [ 'hour', 'day', 'week', 'month', 'year' ],
+	    },
+	    cf => {
+		description => "The RRD consolidation function",
+ 		type => 'string',
+		enum => [ 'AVERAGE', 'MAX' ],
+		optional => 1,
+	    },
+	},
+    },
+    returns => {
+	type => "array",
+	items => {
+	    type => "object",
+	    properties => {},
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::Cluster::create_rrd_data(
+	    "pve2-storage/$param->{node}/$param->{storage}", 
+	    $param->{timeframe}, $param->{cf});	      
+    }});
+    
 1;




More information about the pve-devel mailing list