[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH OSSTEST] ts-xen-install: Rewrite /etc/hosts to comment out 127.0.1.1 entry



On Wed, 2015-09-09 at 18:31 +0100, Ian Jackson wrote:
> Ian Campbell writes ("[PATCH OSSTEST] ts-xen-install: Rewrite
> /etc/hosts to comment out 127.0.1.1 entry"):
> > +       s|^127.0.1.1|#$&|;
> 
> I think you mean
> 
>     s|^\Q127.0.1.1\E\b|#$&|;
> 
> or
> 
>     s|^127\.0\.1\.1\b|#$&|;
> 
> (I have tested both of these ad-hoc.)

Yes, I went with the former.
    
> Also
> 
> > +        my $hn = $ho->{Name};
> 
> This seems unused ?

Right, it was a remnant of a previous attempt.

> With those two this corrected.
> 
> Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

Thanks, I've added the following to pretest.

Ian.

commit e1adb8b552dda5c653958083c9c7457f0398ad09
Author: Ian Campbell <ian.campbell@xxxxxxxxxx>
Date:   Mon Sep 7 13:58:29 2015 +0100

    ts-xen-install: Rewrite /etc/hosts to comment out 127.0.1.1 entry
    
    Debian creates an entry such as:
    127.0.1.1             lace-bug.xs.citrite.net         lace-bug
    
    This causes local lookups of the FQDN to get 127.0.1.1, which is
    unhelpful if you are looking for an address to bind to and were hoping
    to get the public IP address, as libvirt does on the target host for
    migration.
    
    Here we remove (actually, comment) any 127.0.1.1 line in /etc/hosts.
    This means that lookups of a hosts own name (fqdn or just dn) now rely
    on DNS, which may not be ideal. However for a host which uses DHCP I'm
    not aware of a way to keep /etc/hosts up to date with the actual IP
    address the machine has.  In our infra the test host IP addresses are
    all static, but I don't think we want to rely on at any more that we
    already do.
    
    Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
    Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>

diff --git a/ts-xen-install b/ts-xen-install
index 070e74d..b511e2b 100755
--- a/ts-xen-install
+++ b/ts-xen-install
@@ -230,6 +230,23 @@ END
     target_cmd_root($ho, $cmd);
 }
 
+sub hosts () {
+    # Debian installer generates a line like:
+    #
+    # 127.0.1.1             lace-bug.xs.citrite.net         lace-bug
+    #
+    # Where xs.citrite.net is $c{TestHostDomain} and lace-bug is the
+    # hostname, this causes lookups of the hosts FQDN to result in
+    # 127.0.1.1 which is not useful if the reason for the lookup was
+    # to be able to bind to the externally accessible IP address.
+    target_editfile_root($ho, "/etc/hosts", "etc-hosts", sub {
+        while (<EI>) {
+           s|^\Q127.0.1.1\E\b|#$&|;
+           print EO;
+        }
+    });
+}
+
 sub nodhcp () {
     target_editfile_root($ho, "/etc/network/interfaces",
                          "etc-network-interfaces", sub {
@@ -351,4 +368,5 @@ if ($checkmode) {
     setupboot();
     setupinitd();
     nodhcp();
+    hosts();
 }

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.