[pve-devel] r5303 - pve-common/trunk

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Nov 9 08:20:55 CET 2010


Author: dietmar
Date: 2010-11-09 07:20:55 +0000 (Tue, 09 Nov 2010)
New Revision: 5303

Modified:
   pve-common/trunk/ChangeLog
   pve-common/trunk/INotify.pm
Log:


Modified: pve-common/trunk/ChangeLog
===================================================================
--- pve-common/trunk/ChangeLog	2010-11-09 06:24:35 UTC (rev 5302)
+++ pve-common/trunk/ChangeLog	2010-11-09 07:20:55 UTC (rev 5303)
@@ -1,3 +1,7 @@
+2010-11-09  Proxmox Support Team  <support at proxmox.com>
+
+	* INotify.pm (read_vmlist): add parser for vmlist file.
+
 2010-11-08  Proxmox Support Team  <support at proxmox.com>
 
 	* INotify.pm (read_etc_hostname): impl. read/write /etc/hostname

Modified: pve-common/trunk/INotify.pm
===================================================================
--- pve-common/trunk/INotify.pm	2010-11-09 06:24:35 UTC (rev 5302)
+++ pve-common/trunk/INotify.pm	2010-11-09 07:20:55 UTC (rev 5303)
@@ -12,6 +12,7 @@
 use Storable qw(dclone);            
 use Linux::Inotify2;
 use base 'Exporter';
+use JSON; 
 
 our @EXPORT_OK = qw(read_file write_file register_file);
 
@@ -490,6 +491,21 @@
     }
 }
 
+sub read_vmlist {
+    my ($filename, $fd) = @_;
+
+    my $res = {};
+    
+    return $res if !$fd;
+
+    local $/; # enable localized slurp mode
+    my $json_text = <$fd>;
+
+    $res = from_json($json_text);
+
+    return $res;
+}
+
 sub read_etc_hostname {
     my ($filename, $fd) = @_;
 
@@ -510,8 +526,13 @@
     return $hostname;
 }
 
-register_file ('hostname', "/etc/hostname",  
-	       \&read_etc_hostname, 
-	       \&write_etc_hostname);
+register_file('hostname', "/etc/hostname",  
+	      \&read_etc_hostname, 
+	      \&write_etc_hostname);
 
+register_file('vmlist', "/var/lib/pve-cluster/status/vmlist",  
+	      \&read_vmlist, undef, undef, 
+	      always_call_parser => 1);
+
+
 1;




More information about the pve-devel mailing list