[pve-devel] r5524 - in pve-cluster/trunk/data: . perl

svn-commits at proxmox.com svn-commits at proxmox.com
Tue Feb 15 11:20:29 CET 2011


Author: dietmar
Date: 2011-02-15 11:20:29 +0100 (Tue, 15 Feb 2011)
New Revision: 5524

Modified:
   pve-cluster/trunk/data/ChangeLog
   pve-cluster/trunk/data/perl/Cluster.pm
   pve-cluster/trunk/data/perl/test1.pl
Log:


Modified: pve-cluster/trunk/data/ChangeLog
===================================================================
--- pve-cluster/trunk/data/ChangeLog	2011-02-15 10:05:05 UTC (rev 5523)
+++ pve-cluster/trunk/data/ChangeLog	2011-02-15 10:20:29 UTC (rev 5524)
@@ -1,3 +1,8 @@
+2011-02-15  Proxmox Support Team  <support at proxmox.com>
+
+	* perl/Cluster.pm (cfs_file_version): A way to get the actual
+	version of a file. Can be used to detect file modifications.
+
 2011-02-02  Proxmox Support Team  <support at proxmox.com>
 
 	* perl/Cluster.pm (remote_node_ip): implement stub

Modified: pve-cluster/trunk/data/perl/Cluster.pm
===================================================================
--- pve-cluster/trunk/data/perl/Cluster.pm	2011-02-15 10:05:05 UTC (rev 5523)
+++ pve-cluster/trunk/data/perl/Cluster.pm	2011-02-15 10:20:29 UTC (rev 5524)
@@ -450,7 +450,7 @@
     return $res;
 };
 
-sub cfs_read_file {
+sub cfs_file_version {
     my ($filename) = @_;
 
     my $version;
@@ -467,8 +467,15 @@
     }
 
     my $info = $file_info->{$infotag} ||
-	die "unknown file type '$filename' (no parser registered)\n";
+	die "unknown file type '$filename'\n";
 
+    return wantarray ? ($version, $info) : $version;
+}
+
+sub cfs_read_file {
+    my ($filename) = @_;
+
+    my ($version, $info) = cfs_file_version($filename); 
     my $parser = $info->{parser};
 
     return &$ccache_read($filename, $parser, $version);

Modified: pve-cluster/trunk/data/perl/test1.pl
===================================================================
--- pve-cluster/trunk/data/perl/test1.pl	2011-02-15 10:05:05 UTC (rev 5523)
+++ pve-cluster/trunk/data/perl/test1.pl	2011-02-15 10:20:29 UTC (rev 5524)
@@ -4,49 +4,33 @@
 
 use PVE::Cluster;
 use PVE::INotify;
+use PVE::AccessControl;
 use Data::Dumper;
 
+
 my $nodename = PVE::INotify::nodename();
-PVE::Cluster::log_msg(1, "ident2", "msg1 öäü");
-print PVE::Cluster::get_system_log(undef, 0);
-exit 0;
+#PVE::Cluster::log_msg(1, "ident2", "msg1 öäü");
+#print PVE::Cluster::get_system_log(undef, 0);
+#exit 0;
 
 #print PVE::Cluster::get_system_log(undef, 0);
 
 PVE::Cluster::cfs_update();
 
-my $res = PVE::Cluster::get_vmlist();
-print "TEST1: " . Dumper($res->{ids});
+#my $res = PVE::Cluster::get_vmlist();
+#print "TEST1: " . Dumper($res->{ids});
 
-exit 0;
+#exit 0;
 
-sub parse_user_config {
-    my ($filename, $data) = @_;
-
-
-    return {} if !defined($data);
-
-    print "PARSE: $data\n";
-
-    while ($data =~ s/^(.*)\n//) {
-	my $line = $1;
-	print "LINE: $line\n";
-    }
-
-    return $data;
-}
-
-PVE::Cluster::cfs_register_file('user.cfg', \&parse_user_config);
-
-
 while (1) {
 
     PVE::Cluster::cfs_update();
 
-    my $res = PVE::Cluster::cfs_read_file('user.cfg');
+    my $res = PVE::Cluster::cfs_file_version('user.cfg');
 
+    print "VER $res\n";
 
-    sleep(2);
+    sleep(1);
 }
 exit 0;
 



More information about the pve-devel mailing list