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

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jan 12 09:16:31 CET 2011


Author: dietmar
Date: 2011-01-12 09:16:31 +0100 (Wed, 12 Jan 2011)
New Revision: 5362

Modified:
   pve-common/trunk/ChangeLog
   pve-common/trunk/INotify.pm
Log:
	(nodename): new method to read actual node name (hostname)



Modified: pve-common/trunk/ChangeLog
===================================================================
--- pve-common/trunk/ChangeLog	2011-01-12 08:03:59 UTC (rev 5361)
+++ pve-common/trunk/ChangeLog	2011-01-12 08:16:31 UTC (rev 5362)
@@ -2,6 +2,7 @@
 
 	* INotify.pm (read/write_etc_resolv_conf): functions to read/write
 	resolv.config
+	(nodename): new method to read actual node name (hostname)
 
 2010-11-09  Proxmox Support Team  <support at proxmox.com>
 

Modified: pve-common/trunk/INotify.pm
===================================================================
--- pve-common/trunk/INotify.pm	2011-01-12 08:03:59 UTC (rev 5361)
+++ pve-common/trunk/INotify.pm	2011-01-12 08:16:31 UTC (rev 5362)
@@ -3,6 +3,7 @@
 # fixme: maybe we do not need update_file() ?
 
 use strict;
+use POSIX;
 use IO::File;
 use IO::Dir;
 use File::stat;
@@ -491,6 +492,23 @@
     }
 }
 
+my $cached_nodename;
+
+sub nodename {
+
+    return $cached_nodename if $cached_nodename;
+
+    my ($sysname, $nodename) = POSIX::uname();
+
+    $nodename =~ s/\..*$//; # strip domain part, if any
+
+    die "unable to read node name\n" if !$nodename;
+
+    $cached_nodename = $nodename;
+
+    return $cached_nodename;
+}
+
 sub read_etc_hostname {
     my ($filename, $fd) = @_;
 




More information about the pve-devel mailing list