Hi All,
Does anyone know if it's possible, when you register a guest VM from CLI (Script) to automaticaly assign it to a resource pool ?
Cheers
Pieter
glad you actually figured it out, that must have been a pain, I would have believed the data would have been found within "vimsh" interface ....who would have known.
You could do something like the following if you know the resource pool name:
vmware-vim-cmd /solo/registervm /vmfs/volumes/......XXX.vmx MACHINE_NAME `cat /etc/vmware/hostd/pools.xml | grep "YOUR-RESOURCE-POOL-NAME" -A1 | grep "<objID>" | sed 's/<objID>//;s/<\/objID>//g' | sed -e 's/^[[:blank:]]*//;s/[[:blank:]]*$//'`
You can just substitute your "resource pool name" and this should grep it out of /etc/vwmare/hostd/pools.xml and return you the "ObjectID" without having you to search for it
If you're referring to the Service Console CLI on either ESX 3.5 or limited busybox console on ESXi, then yes
This allows you to register a Virtual Machine passing in the path of the .vmx file as you would with traditional "vmware-cmd -s register" but also gives you option of specifying a different displayName and resource pool to add. I have not personally used the resourcepool option but I assume it would just be the name of your resource pool
[root@himalaya scripts]# vmware-vim-cmd solo/registervm Insufficient arguments. Usage: registervm vm path [name] [resourcepool] registervm [cfg path] [name(optional)] [resourcepool(optional)] Register the vm
You could also use the VMware internal vimsh to create/manage resources pools on a given ESX Server, again this is something I've not used before but you can play around with the different options:
[root@himalaya scripts]# vmware-vim-cmd hostsvc/rsrc Commands available under hostsvc/rsrc/: create pool_config_get pools_get vm_config_set destroy pool_config_set rename vms_get destroy_children pool_runtime_get vm_config_get
good luck
Hi Peezee
As far as I know "vwmare-cmd" can register a VM for you via COS but it does not have many options
/usr/bin/vmware-cmd -s register <config_file_path>
rgds,
J.
If you find this or any other answer useful please consider awarding points by marking the answer helpful or correct.
-
El Blog de Virtualizacion en Español
-
Hi,
Thanks for your posts, Unfortunatley "vmware-vim-cmd" doesn't seem to be suported under 3.5, i get the following error;
(vim.fault.NotFound) {
dynamicType = <unset>,
msg = "The object or item referred to could not be found."
}
with regards to vmware-cmd -s register, unfortunatley it doesn't appear to have the ability to put the guest into a resource pool :-s
Rgds
Pieter
What version of ESX are you running, you posted on ESX 3.5 so I assume you're running at least 3.5u1?
You can always try vimsh, but you'll need to pass in special flags to make it non-interactive (-n -e), else it'll take you into the vimsh itself. Also if you're running post ESX 3.5, not all commands are available, I know as of 3.5 they released new feature set with vimsh.
As was stated you can do it with vmware-vim-cmd.
Xtravirt has a good whitepaper on vmware-vim-cmd, one of the examples is how to register a VM and assign resource pool
http://knowledge.xtravirt.com/white-papers/scripting.html
sorry, i posted the wrong error
(vmodl.fault.ManagedObjectNotFound) {
dynamicType = <unset>,
obj = 'vim.ResourcePool:DMZ',
msg = "The request refers to an object that no longer exists or has never existed."
rgds
Pieter
If you're running 3.5, that command should be there. What version of ESX are you running? (vmware -v)
You can either use "vmware-vim-cmd" or "vimsh" or "vmware-vimsh", the command has augmented over time to make it easier to use. Post 3.5, you needed to pass in extra flags on the console (-n -e). Try passing in the full path to the binary
#recommended one to use
/usr/bin/vmware-vim-cmd solo/registervm
#legacy
/usr/bin/vmware-vimsh -n -e "/solo/registervm"
#legacy
/usr/bin/vimsh -n -e "/solo/registervm"
duplicated, due to forum issues.
Hi LAMW,
Thanks for your help on this but it's still not working, i have created a new resource pool called "test" and entered the following, error at the end ?
any further sugestions would be most welcome.
Pieter
File not found.
Current working directory: /usr/lib/vmware/hostd
HOSTINFO: Seeing Intel CPU, numCoresPerCPU 4 numThreadsPerCore 1.
HOSTINFO: hyperthreading disabled, setting number of threads per core to 1.
HOSTINFO: This machine has 2 physical CPUS, 8 total cores, and 8 logical CPUs.
System libcrypto.so.0.9.7 library is older than our library (90701F < 90709F)
Vmacore::InitSSL: doVersionCheck = true, handshakeTimeoutUs = 120000000
Unsetting unknown path: /vmomi/
$ solo/registervm /vmfs/volumes/bips-rec01:storage1/scriptedVM/scriptedVM.vmx test DMZ* * ============BEGIN FAILED METHOD CALL DUMP============
"[]/vmfs/volumes/bips-rec01:storage1/scriptedVM/scriptedVM.vmx"
"test"
false
'vim.ResourcePool:DMZ'
Fault Msg: "The request refers to an object that no longer exists or has never existed."
============END FAILED METHOD CALL DUMP============
(vmodl.fault.ManagedObjectNotFound) {
dynamicType = <unset>,
obj = 'vim.ResourcePool:DMZ',
msg = "The request refers to an object that no longer exists or has never existed."
}
Sorry, i am running 3.5 update 2
VMware ESX Server 3.5.0 build-110268
Rgds
Pieter
Yea I tried something similar and it errors out. Seems like the other commands don't work as expected, they all reference the poolID, but there's no where to query that information. Guess it may not work as expected.
Hi Lamw,
I have found the solution after many hours of investigation, the problem lies with the pool name you specify, this can be found here; /etc/vmware/hostd/pools.xml, find the pool name that you need to register against and the coresponding <objID> is the field you need to use in conjustion with the following command;
vmware-vim-cmd /solo/registervm /vmfs/volumes/......XXX.vmx
All working now, and thanks for your help
Rgds
Pieter
glad you actually figured it out, that must have been a pain, I would have believed the data would have been found within "vimsh" interface ....who would have known.
You could do something like the following if you know the resource pool name:
vmware-vim-cmd /solo/registervm /vmfs/volumes/......XXX.vmx MACHINE_NAME `cat /etc/vmware/hostd/pools.xml | grep "YOUR-RESOURCE-POOL-NAME" -A1 | grep "<objID>" | sed 's/<objID>//;s/<\/objID>//g' | sed -e 's/^[[:blank:]]*//;s/[[:blank:]]*$//'`
You can just substitute your "resource pool name" and this should grep it out of /etc/vwmare/hostd/pools.xml and return you the "ObjectID" without having you to search for it
thanks again for your help, i will try the grep'ing another time when i am less busy :smileygrin:
Rgds
Pieter