6

There has to be a way to do this that I'm missing. I'm trying to modify attributes on a whole bunch of VMs at the same time from the CLI:

Look! 24 VMs:

$ vmware-cmd --server 10.91.1.1 --username root --password vmware -h 10.91.1.3 -l
/vmfs/volumes/volumes/V-RHEL-01/V-RHEL-01.vmx
/vmfs/volumes/volumes/V-RHEL-02/V-RHEL-02.vmx
/vmfs/volumes/volumes/V-RHEL-03/V-RHEL-03.vmx
…
/vmfs/volumes/volumes/V-RHEL-24/V-RHEL-24.vmx

Let's try and modify them:

$ for i in `seq -w 1 24`; do
  CFG="/vmfs/volumes/volumes/V-RHEL-$i/V-RHEL-$i.vmx"
  echo $CFG
  vmware-cmd --server 10.91.1.1 --username root --password vmware -h 10.91.1.3 "$CFG" setguestinfo memsize 8192
  vmware-cmd --server 10.91.1.1 --username root --password vmware -h 10.91.1.3 "$CFG" setguestinfo sched.mem.min 2048
done

results in:

/vmfs/volumes/volumes/V-RHEL-01/V-RHEL-01.vmx
No virtual machine found.
No virtual machine found.
/vmfs/volumes/volumes/V-RHEL-02/V-RHEL-02.vmx
No virtual machine found.
No virtual machine found.
/vmfs/volumes/volumes/V-RHEL-03/V-RHEL-03.vmx
No virtual machine found.
No virtual machine found.
…

I'm running VMware-vSphere-CLI-5.1.0-780721 and ESXi 5.1.

2
  • I may be well off here, but could there be an extra line break in there? The no vm found error is repeated for each line. does for i in {01..24}; make any difference?
    – Rqomey
    Nov 21, 2012 at 12:05
  • Oh, I see what you mean. It's repeated since I run two commands in each loop.
    – MikeyB
    Nov 21, 2012 at 14:21

1 Answer 1

4

Apparently when the tool DISPLAYS configs, it uses the old path-style format. But when it accepts them it uses the datastore reference:

$ for i in `seq -w 1 24`; do
    CFG="[nfshost1-data] V-RHEL-$i/V-RHEL-$i.vmx"
    echo $CFG
    vmware-cmd --server 10.91.1.1 --username root --password vmware -h 10.91.1.3 "$CFG" setguestinfo memsize 8192
    vmware-cmd --server 10.91.1.1 --username root --password vmware -h 10.91.1.3 "$CFG" setguestinfo sched.mem.min 2048
  done

[nfshost1-data] V-RHEL-01/V-RHEL-01.vmx
setguestinfo(memsize 8192) = 1
setguestinfo(sched.mem.min 2048) = 1
…

Not that this actually works! It appears to make the change, but doesn't actually change anything!

2
  • To be honest, I would have run it directly on the host. But good for pointing out the datastore notation.
    – ewwhite
    Nov 21, 2012 at 14:44
  • vmware-cmd isn't available on the host as a command ;(
    – MikeyB
    Nov 21, 2012 at 14:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .