Browse code

Adding support for v6 address in /etc/hosts

Change-Id: Ie1ad57cb9488df06c5a9c7c13c162beef9ca23e9
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1483
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: suezzelur <anishs@vmware.com>

Kumar Kaushik authored on 2016/10/06 03:29:12
Showing 2 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,93 @@
0
+diff -ru gosc-scripts/imc-shell/imgcust-scripts/CustomizationUtils.sh gosc-scripts-modified/imc-shell/imgcust-scripts/CustomizationUtils.sh
1
+--- gosc-scripts/imc-shell/imgcust-scripts/CustomizationUtils.sh	2016-04-29 15:41:27.000000000 -0700
2
+@@ -182,7 +182,7 @@
3
+   echo "$newDomainname"
4
+ }
5
+ 
6
+-# Finds the first IPv4 out of all NICs.
7
++# Finds the first static IPv4 out of all NICs.
8
+ #
9
+ # Args:
10
+ #   None
11
+@@ -210,6 +210,40 @@
12
+   echo "$ipv4Addr"
13
+ }
14
+ 
15
++# Finds the first static IPv6 out of all NICs.
16
++#
17
++# Args:
18
++#   None
19
++# Results:
20
++#   string: the first IPv6 or empty string in case there are no NICs or all are DHCP.
21
++# Throws:
22
++#   Dies in case NICs setting is empty or IPv6 address setting is empty.
23
++FindFirstStaticIpV6()
24
++{
25
++  local ipv6Addr=''
26
++  local nicsCnt='' # needs to be declared before assigned
27
++
28
++  nicsCnt=$(ConfigFile_GetNicsCnt) || exit 1
29
++
30
++  local i=
31
++  for i in $(seq 1 $nicsCnt);  do
32
++    local nic=$(ConfigFile_GetNicByIndex $i)
33
++    local ipv6Cnt=$(ConfigFile_GetIpV6Cnt $nic) || exit 1
34
++    local j=
35
++    for j in $(seq 1 $ipv6Cnt);  do
36
++       ipv6Addr=$(ConfigFile_GetIpV6AddrByInd $nic $j) || exit 1
37
++       if [[ -n "$ipv6Addr" ]]; then
38
++          break
39
++       fi
40
++    done
41
++    if [[ -n "$ipv6Addr" ]]; then
42
++      break
43
++    fi
44
++  done
45
++
46
++  echo "$ipv6Addr"
47
++}
48
++
49
+ # Processes content of the existing /etc/hosts file.
50
+ #
51
+ # Args:
52
+@@ -341,7 +375,7 @@
53
+ 
54
+   local hostNameWasSet=0 #$(ProcessEtcHosts "$hostsFile" "$oldHostname" "$oldFQDN" "$newHostname" configFileVar output)
55
+ 
56
+-  # Add mapping to the customized static ip
57
++  # Add mapping to the customized static V4 ip
58
+   local ipaddr=$(FindFirstStaticIpV4) || exit 1
59
+   if [[ -n "$ipaddr" ]]; then
60
+     local newStaticIPEntry="$ipaddr"$'\t'"$newFQDN"
61
+@@ -354,6 +388,21 @@
62
+     Debug "Static ip entry '$newStaticIPEntry' added"
63
+   fi
64
+ 
65
++  # Add mapping to the customized static V6 ip
66
++  local ipv6addr=$(FindFirstStaticIpV6) || exit 1
67
++  if [[ -n "$ipv6addr" ]]; then
68
++    local newStaticIPV6Entry="$ipv6addr"$'\t'"$newFQDN"
69
++    if [[ '$newFQDN' != '$newHostname' ]]; then
70
++      newStaticIPV6Entry="$newStaticIPV6Entry $newHostname";
71
++    fi
72
++
73
++    hostNameWasSet=1
74
++    output="$output""::1 localhost ip6-localhost ip6-loopback"$'\n'
75
++    output="$output""$newStaticIPV6Entry"$'\n'
76
++    Debug "Static ip v6 entry '$newStaticIPV6Entry' added"
77
++  fi
78
++
79
++
80
+   # Add mapping to loopback 127.0.1.1 if new hostname is still not set
81
+   if [[ $hostNameWasSet -eq 0 ]]; then
82
+     # Hostname still not added - use a loopback entry to
83
+@@ -744,7 +793,7 @@
84
+     Exec "$execute"    
85
+     Debug "Light wave domain join procedure completed"
86
+   else
87
+-    Debug "ERROR :: Either Domain Name or Password Missing: Cannot Join Lighwave domain"
88
++    Debug "Lightwave config not provided: Nothing to customize"
89
+   fi
90
+   
91
+ }
... ...
@@ -1,7 +1,7 @@
1 1
 Summary:        Usermode tools for VmWare virts
2 2
 Name:           open-vm-tools
3 3
 Version:        10.0.5
4
-Release:        13%{?dist}
4
+Release:        14%{?dist}
5 5
 License:        LGPLv2+
6 6
 URL:            https://github.com/vmware/open-vm-tools
7 7
 Group:          Applications/System
... ...
@@ -17,6 +17,7 @@ Patch0:         open-vm-tools-service-link.patch
17 17
 Patch1:         GOSC-libDeploy.patch
18 18
 Patch2:         IPv6Support.patch
19 19
 Patch3:         hostnameReCustomizationFix.patch
20
+Patch4:         PureIPv6-hosts.patch
20 21
 BuildRequires:  glib-devel
21 22
 BuildRequires:  xerces-c-devel
22 23
 BuildRequires:  xml-security-c-devel
... ...
@@ -44,6 +45,7 @@ VmWare virtualization user mode tools
44 44
 %patch1 -p1
45 45
 %patch2 -p0
46 46
 %patch3 -p0
47
+%patch4 -p0
47 48
 %build
48 49
 touch ChangeLog
49 50
 autoreconf -i
... ...
@@ -104,6 +106,8 @@ fi
104 104
 
105 105
 
106 106
 %changelog
107
+*       Wed Oct 05 2016 Kumar Kaushik <kaushikk@vmware.com> 10.0.5-14
108
+-       Adding proper entry to /etc/hosts for IPv6.
107 109
 *       Mon Oct 04 2016 ChangLee <changLee@vmware.com> 10.0.5-13
108 110
 -       Modified %check
109 111
 *       Thu Jun 23 2016 Kumar Kaushik <kaushikk@vmware.com> 10.0.5-12