VMware Cloud Community
peezee
Contributor
Contributor
Jump to solution

Resource Pools from CLI

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

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

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

View solution in original post

0 Kudos
14 Replies
lamw
Community Manager
Community Manager
Jump to solution

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

0 Kudos
jose_maria_gonz
Virtuoso
Virtuoso
Jump to solution

Hi Peezee

As far as I know "vwmare-cmd" can register a VM for you via COS but it does not have many options Smiley Sad

/usr/bin/vmware-cmd -s register &lt;config_file_path&gt;

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

http://josemariagonzalez.es

-


0 Kudos
peezee
Contributor
Contributor
Jump to solution

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 = &lt;unset&gt;,

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

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

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.

0 Kudos
petedr
Virtuoso
Virtuoso
Jump to solution

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

www.thevirtualheadline.com www.liquidwarelabs.com
0 Kudos
peezee
Contributor
Contributor
Jump to solution

sorry, i posted the wrong error

(vmodl.fault.ManagedObjectNotFound) {

dynamicType = &lt;unset&gt;,

obj = 'vim.ResourcePool:DMZ',

msg = "The request refers to an object that no longer exists or has never existed."

rgds

Pieter

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

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"

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

duplicated, due to forum issues.

peezee
Contributor
Contributor
Jump to solution

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

# vmware-vimsh

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 &lt; 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============

Invoking on

Arg path:

"[]/vmfs/volumes/bips-rec01:storage1/scriptedVM/scriptedVM.vmx"

Arg name:

"test"

Arg asTemplate:

false

Arg pool:

'vim.ResourcePool:DMZ'

Arg host:

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 = &lt;unset&gt;,

obj = 'vim.ResourcePool:DMZ',

msg = "The request refers to an object that no longer exists or has never existed."

}

$

0 Kudos
peezee
Contributor
Contributor
Jump to solution

Sorry, i am running 3.5 update 2

VMware ESX Server 3.5.0 build-110268

Rgds

Pieter

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

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.

0 Kudos
peezee
Contributor
Contributor
Jump to solution

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 &lt;objID&gt; 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

0 Kudos
lamw
Community Manager
Community Manager
Jump to solution

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

0 Kudos
peezee
Contributor
Contributor
Jump to solution

thanks again for your help, i will try the grep'ing another time when i am less busy :smileygrin:

Rgds

Pieter

0 Kudos