]> xenbits.xensource.com Git - osstest.git/commitdiff
ts-xen-install: Rewrite /etc/hosts to comment out 127.0.1.1 entry flight-61791 flight-61973 flight-61992 flight-61995 flight-61996 flight-61997 flight-61998 flight-61999 flight-62000 flight-62002 flight-62003 flight-62004 flight-62006 flight-62007 flight-62009 flight-62010 flight-62011 flight-62012 flight-62013 flight-62015 flight-62016 flight-62017 flight-62018 flight-62019 flight-62020 flight-62021 flight-62022 flight-62023 flight-62024 flight-62025 flight-62026 flight-62027 flight-62028 flight-62029 flight-62030 flight-62035 flight-62036 flight-62037 flight-62038 flight-62039 flight-62040 flight-62041 flight-62042 flight-62043 flight-62044 flight-62045 flight-62046 flight-62047 flight-62048 flight-62049 flight-62051 flight-62052 flight-62053 flight-62054 flight-62055 flight-62056 flight-62057 flight-62058 flight-62059 flight-62060 flight-62061 flight-62062 flight-62064 flight-62065 flight-62066 flight-62067 flight-62068 flight-62069 flight-62070 flight-62071 flight-62073 flight-62074 flight-62075 flight-62076 flight-62077 flight-62078 flight-62079 flight-62080 flight-62081 flight-62082 flight-62083 flight-62084 flight-62085 flight-62087 flight-62088 flight-62089 flight-62090 flight-62091 flight-62092 flight-62093 flight-62094 flight-62095 flight-62096 flight-62097 flight-62098 flight-62099 flight-62100 flight-62101 flight-62102 flight-62103 flight-62104 flight-62105 flight-62106 flight-62107 flight-62108 flight-62109 flight-62110 flight-62111 flight-62112 flight-62113 flight-62114 flight-62115 flight-62116 flight-62117 flight-62118
authorIan Campbell <ian.campbell@citrix.com>
Mon, 7 Sep 2015 12:58:29 +0000 (13:58 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 9 Sep 2015 18:04:19 +0000 (19:04 +0100)
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@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
ts-xen-install

index 070e74ded120185f8cbe699889afbe994a4c308e..b511e2b03cfa42b28825e702ab49177b36549a84 100755 (executable)
@@ -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();
 }