summaryrefslogtreecommitdiffstats
path: root/sysprep
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-30 12:32:30 +0000
committerRichard W.M. Jones <rjones@redhat.com>2012-11-30 12:37:48 +0000
commitf5ae46dca79511cf2d4762ca4ef07b59bd647309 (patch)
tree7fe5861a5a8519a1623d18737a556986d1faaea0 /sysprep
parentfe4cdb2a477e88cd65d418aa3c3f12cb029f3dde (diff)
downloadlibguestfs-f5ae46dca79511cf2d4762ca4ef07b59bd647309.tar.gz
libguestfs-f5ae46dca79511cf2d4762ca4ef07b59bd647309.tar.xz
libguestfs-f5ae46dca79511cf2d4762ca4ef07b59bd647309.zip
inspection, virt-sysprep: Use /etc/hostname on F18+, RHEL7+ (RHBZ#881953, RHBZ#858696).
Diffstat (limited to 'sysprep')
-rw-r--r--sysprep/sysprep_operation_hostname.ml26
1 files changed, 16 insertions, 10 deletions
diff --git a/sysprep/sysprep_operation_hostname.ml b/sysprep/sysprep_operation_hostname.ml
index a1dd15a8..33e3b0ae 100644
--- a/sysprep/sysprep_operation_hostname.ml
+++ b/sysprep/sysprep_operation_hostname.ml
@@ -29,12 +29,22 @@ let hostname = ref "localhost.localdomain"
let hostname_perform g root =
let typ = g#inspect_get_type root in
let distro = g#inspect_get_distro root in
- match typ, distro with
- | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based") ->
- (* Fedora 18 anaconda can create guests without
- * /etc/sysconfig/network file. If this happens then we may need
- * to create this file (RHBZ#858696).
+ let major_version = g#inspect_get_major_version root in
+
+ let update_etc_hostname () =
+ g#write "/etc/hostname" !hostname;
+ [ `Created_files ]
+ in
+
+ match typ, distro, major_version with
+ (* Fedora 18 (hence RHEL 7+) changed to using /etc/hostname
+ * (RHBZ#881953, RHBZ#858696).
*)
+ | "linux", "fedora", v when v >= 18 -> update_etc_hostname ()
+ | "linux", "rhel", v when v >= 7 -> update_etc_hostname ()
+ | "linux", ("debian"|"ubuntu"), _ -> update_etc_hostname ()
+
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"redhat-based"), _ ->
let filename = "/etc/sysconfig/network" in
if g#is_file filename then (
(* Replace HOSTNAME=... entry. The code assumes it's a small,
@@ -54,14 +64,10 @@ let hostname_perform g root =
);
[ `Created_files ]
- | "linux", ("opensuse"|"sles"|"suse-based") ->
+ | "linux", ("opensuse"|"sles"|"suse-based"), _ ->
g#write "/etc/HOSTNAME" !hostname;
[ `Created_files ]
- | "linux", ("debian"|"ubuntu") ->
- g#write "/etc/hostname" !hostname;
- [ `Created_files ]
-
| _ -> []
let hostname_op = {