vmware / open-vm-tools

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

Need documentation about getting configuration parameters #375

Open dkacar-oradian opened 5 years ago

dkacar-oradian commented 5 years ago

I've searched the web, but couldn't find documentation or examples about getting configuration parameters via open-vm-tools command line utilities.

Virtual machines are running on ESXi 6.5. I've tried to get the parameters on two virtual machines: a) CentOS 7.7 with 4.4.162 kernel from elrepo b) CentOS 7.7 with 5.3.0 kernel from elrepo

open-vm-tools version 10.3.0 from the distribution. VmWare kernel modules are from the kernel package and there are no additional modules, as far as I can see.

# lsmod | grep \^vmw
vmw_vsock_vmci_transport    32768  1 
vmw_balloon            24576  0 
vmw_vmci               69632  2 vmw_balloon,vmw_vsock_vmci_transport
vmwgfx                303104  1 
vmw_pvscsi             28672  7 

I've tried the following on both VMs and I'm getting the same result on both:

# vmware-toolbox-cmd config get guestinfo toolsVersion
[guestinfo] toolsVersion UNSET
# vmware-namespace-cmd get-value guestInfo -k toolsVersion
failure: There is no namespace database associated with this virtual machine.

I've tried different combinations of section and key name, but I always get the same result. I'm not sure if case is significant, so I've been trying various combinations, but the result was always the same. I don't understand what "There is no namespace database associated with this virtual machine." means. That is, I don't understand what should I do about that.

I also don't know where I could find the section names list. Is that a managed object name (eg. https://pubs.vmware.com/vi3/sdk/ReferenceGuide/vim.vm.GuestInfo.html) or something else?

I'm actually trying to map hard disk names as visible in vSphere (eg. Hard disk 1, Hard disk 2, etc.) to WWN ids (which exist in Managed Objects). I have VMs configured with disk.enableUUID: TRUE, so WWNs are created by VmWare and appropriate symlinks are created in the OS directories by udev.

I don't know if that info can be obtained with the above tools, but I'm currently unable to get anything with them. If there's a documentation about this somewhere on the Internet I'd really appreciate a pointer to it.

johnwvmw commented 5 years ago

As far as tools version goes, the most simple an direct means is either: vmware-toolbox-cmd -v vmtoolsd -v

Neither the vmware-toolbox-cmd or vmware-namespace-cmd cannot be used to access the VM's Managed Object content/settings. Vmware-toolbox-cmd has a limited set of functions covered in https://www.vmware.com/pdf/vmware-tools-cli.pdf. Exact features available will vary depending on host (esxi, WS or Fusion) and filesystem type.

The vmware-namespace-cmd may be used to create and maintain a limited number (6, I believe) key/value namespace DBs per VM. A VM does not come with a preset namespace DB.

Interestingly VMware is laying the ground work to also map the guest OS mounted files systems back to the corresponding .vmdk of the VM. Open-vm-tools 11.0.0 and later can provide a additional information for each files system including filesystem type, and device name - scsi0:0, ide0:0, sata0:5, etc. We may expose this information through the vSphere API in the future. If you are interested, please take a look at services/plugins/guestInfo/diskInfo.c source on the stable-11..0.x branch (https://github.com/vmware/open-vm-tools/blob/stable-11.0.x/open-vm-tools/services/plugins/guestInfo/diskInfo.c)

dkacar-oradian commented 5 years ago

Thanks, but as far as I can see, that code is getting information from the guest system only. Correct me if I'm wrong.

I need mapping between VmWare's disk labels and WWNs on the OS (On Linux symlinks in /dev/disk/by-id) to be able to auto-provision servers. I'm using salt-cloud and it's config file currently looks like this:

...
  devices:
    disk:
      Hard disk 2:
        size: 512
      Hard disk 3:
        size: 512
      Hard disk 4:
        size: 512
      Hard disk 5:
        size: 512
      Hard disk 6:
        size: 512
...
    grains:
      diskconfig:
        os:
          - /dev/sda
        pgextra:
          - /dev/sdb
        pgmirror:
          - /dev/sdc
          - /dev/sdd
          - /dev/sde
          - /dev/sdf

The problem with this is that /dev/sd* names aren't stable (ie. they can change when the guest VM is rebooted). Therefore I'd like to have Hard disk 2, Hard disk 3, etc. instead of /dev/sdb, /dev/sdc, etc. (There is no Hard disk 1 above because that disk is created by cloning a template VM and /dev/sda is under diskconfig configuration for documentation purposes only).

After the VM is created by salt-cloud a set of salt "scripts" will be run and they need to create file systems, but first they need to know which disk is which. In this particular example ext4 on LVM would be created on Hard disk 2 and BTRFS file system in raid0 would be created on disks 3-6. But in reality Hard disk 2 doesn't have to be /dev/sdb.

For my purposes it would be ideal if VmWare tools (or open-vm-tools or anything else) could get me a mapping between disk's name in VmWare (eg. Hard disk 2) and it's WWN in /dev/disk/by-id). WWNs are created when the VM has disk.enableUUID: TRUE setting, so that part works. But they are in the managed object describing the disk and I don't know how to get that data from the guest VM.

In theory I could enable each VM to contact vSphere, but that creates a huge security nightmare in case of a security breach, so I won't do that. Another option is to get the data from vSphere when the VM is created, but that doesn't work reliably currently and bug fixing is completely outside of my control because that part of infrastructure is managed by another company and I'm just a not-too-overjoyed customer.

It would be great if a program running on the guest VM could get the data from managed objects describing that VM. Read-only, I have no need for modification.