vmware / open-vm-tools

Official repository of VMware open-vm-tools project
http://sourceforge.net/projects/open-vm-tools/
2.21k stars 422 forks source link

OpenVMTools does not configure Primary IP with hostname in /etc/hosts #546

Open davidwadddell opened 2 years ago

davidwadddell commented 2 years ago

Given this VM in VCD :


ExtensionData   : VMware.VimAutomation.Cloud.Views.Vm
Status          : PoweredOn
Deleted         : False
GuestOsFullName : Other Linux (64-bit)
CpuCount        : 4
MemoryMB        : 16384
MemoryGB        : 16
VMVersion       : v11
Org             : dw-lab
OrgVdc          : dw-vdc
VApp            : StratumSDF
Description     :
Href            : https://10.20.179.7/api/vApp/vm-e8f54e62-576c-4391-9232-117682983f24
Id              : urn:vcloud:vm:e8f54e62-576c-4391-9232-117682983f24
Name            : sdf01
Uid             : /CIServer=dw-lab-user:dw-lab@10.20.179.7:443/CIVM=urn:vcloud:vm:e8f54e62-576c-4391-9232-117682983f24/

With network adapters as such (note primary nic)

PS /var/buildsnew/cloud/vnf/sdmce/vcloud_ovfs/powercli> Get-CIVapp StratumSDF | Get-CIVM | Get-CINetworkAdapter

Index Primary Connected  IPAddressAllocation IPAddress       ExternalIPAddress VM
----- ------- ---------  ------------------- ---------       ----------------- --
1     False   True       Pool                192.168.211.15                    sdf01
0     True    True       Manual              10.20.180.165                     sdf01

open-vm-tools populates /etc/hosts with the IP of the secondary nic

[root@sdf01 ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.211.15  sdf01.mydomain sdf01

Would expect the IP of the primary NIC to be placed here.

Debug logging (full IMC log attached)

<snip> 
DEBUG: Processing line: '[NIC1]'
DEBUG: FOUND CATEGORY = NIC1
DEBUG: Processing line: 'MACADDR = 00:50:56:01:2e:08'
DEBUG: ADDED KEY-VAL :: 'NIC1|MACADDR' = '00:50:56:01:2e:08'
DEBUG: Processing line: 'ONBOOT = yes'
DEBUG: ADDED KEY-VAL :: 'NIC1|ONBOOT' = 'yes'
DEBUG: Processing line: 'IPv4_MODE = BACKWARDS_COMPATIBLE'
DEBUG: ADDED KEY-VAL :: 'NIC1|IPv4_MODE' = 'BACKWARDS_COMPATIBLE'
DEBUG: Processing line: 'BOOTPROTO = static'
DEBUG: ADDED KEY-VAL :: 'NIC1|BOOTPROTO' = 'static'
DEBUG: Processing line: 'IPADDR = 192.168.211.15'
DEBUG: ADDED KEY-VAL :: 'NIC1|IPADDR' = '192.168.211.15'
DEBUG: Processing line: 'NETMASK = 255.255.255.0'
DEBUG: ADDED KEY-VAL :: 'NIC1|NETMASK' = '255.255.255.0'
DEBUG: Processing line: 'GATEWAY = 192.168.211.1'
DEBUG: ADDED KEY-VAL :: 'NIC1|GATEWAY' = '192.168.211.1'
DEBUG: Processing line: ''
DEBUG: Empty line. Ignored.
DEBUG: Processing line: '[NIC2]'
DEBUG: FOUND CATEGORY = NIC2
DEBUG: Processing line: 'MACADDR = 00:50:56:01:2e:09'
DEBUG: ADDED KEY-VAL :: 'NIC2|MACADDR' = '00:50:56:01:2e:09'
DEBUG: Processing line: 'PRIMARY = yes'
DEBUG: ADDED KEY-VAL :: 'NIC2|PRIMARY' = 'yes'
DEBUG: Processing line: 'ONBOOT = yes'
DEBUG: ADDED KEY-VAL :: 'NIC2|ONBOOT' = 'yes'
DEBUG: Processing line: 'IPv4_MODE = BACKWARDS_COMPATIBLE'
DEBUG: ADDED KEY-VAL :: 'NIC2|IPv4_MODE' = 'BACKWARDS_COMPATIBLE'
DEBUG: Processing line: 'BOOTPROTO = static'
DEBUG: ADDED KEY-VAL :: 'NIC2|BOOTPROTO' = 'static'
DEBUG: Processing line: 'IPADDR = 10.20.180.165'
DEBUG: ADDED KEY-VAL :: 'NIC2|IPADDR' = '10.20.180.165'
DEBUG: Processing line: 'NETMASK = 255.255.255.0'
DEBUG: ADDED KEY-VAL :: 'NIC2|NETMASK' = '255.255.255.0'
DEBUG: Processing line: 'GATEWAY = 10.20.180.1'
DEBUG: ADDED KEY-VAL :: 'NIC2|GATEWAY' = '10.20.180.1'

<snip>
DEBUG: Line (out):
192.168.211.15  sdf01.mydomain sdf01

DEBUG: opening file for writing (/etc/hosts).
DEBUG: Command: 'chmod 644 /etc/hosts'
DEBUG: Result:
DEBUG: Exit Code: 0
davidwadddell commented 2 years ago

toolsDeployPkg.log

VinodKumarGoku commented 2 years ago

Hello david,

Thank you for time and raising an issue with open-vm-tools. I would like to collect more info. Could please confirm the vmtools version and provide us with vmware.logs

VinodKumarGoku commented 2 years ago

Hello david,

Could you also please provide us more information. Please run and provide us information by execution following commands. "netsh interface ip show config" Kindly share /var/log/messages file as well.