Hello,
as we are using the new vSphere 4.1 feature "DRS Host Affinity" I'd like to automate some tasks like putting VMs into predefined affinity groups. Unforunately I couldn't find the appropriate API methods and properties to accomplish this so far.
This is what I want to do:
Enumerate the existing Virtual Machine DRS Groups
Enumerate the existing Host DRS Groups
Add/remove VM to/from an existing Virtual Machine DRS Group
Enumerate the members of a given (existing) Virtual Machine and/or Host DRS Group
Add/Remove a Virtual Machines DRS Group
Does anybody here already have some experience in using this new features with the Web Services SDK 4.1?
Thanks in advance...
If you're new to VMware's API/SDKs, please take some time and go over this document before starting, it will answer most of your questions and help get you started -
Next, you should familiarized yourself with the vSphere API documentation - http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/index.html Learn to love and use the search functionality that is built int when looking for certain properties or methods, 4 out of 5 times, you will find the correct parameter by just doing a search.
1. To view both VM/Host groups take a look at http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.cluster.ConfigInfoEx.htm...
2. To make changes to a cluster take a look at http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.ComputeResource.html#rec...
These are really the two areas you need to focus on in terms of querying information out of a Cluster and making changes to it.
=========================================================================
William Lam
VMware vExpert 2009,2010
VMware scripts and resources at:
Getting Started with the vMA (tips/tricks)
Getting Started with the vSphere SDK for Perl
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Hello William,
I'm not sure why you answer this way and without any really helpful hint. This was, in my opinion, a fairly decent question without any obvious or easy to find answer. Of course I did a forum search first to possibly find some threads which may cover this topic, without any result. Of course I also tried to find the information within the vSphere Web Services API Reference Documentation - but no luck there, too.
Because DRS Host Affinity is a new feature in 4.1, I hoped to find some clue in the "What’s New in vSphere API 4.1?" section - but there aren't any methods and properties concerning the management of the new DRS groups mentioned there.
If you really have some experience on the topic to share (e.g. some sample code), you're highly welcome - otherwise, please don't keep others from sharing their knowledge.
Thank you.
Not sure what you meant by "I'm not sure why you answer this way and without any really helpful hint."
I've not only provided you with documents to start off if you're new to vSphere API/SDKs, I also provided exactly areas in the API to look for the operations and properties you've requested. Many times, new users will have a request to perform operation X or look for property Y and without looking at any of the documentation, understanding the vSphere API object model is very important and the search within API reference is invaluable.
So again, here are the two areas you'll want to focus on:
1) Querying for both host and VM rules - http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.cluster.ConfigInfoEx.htm...
2) Making changes to cluster, you'll want to use this method - http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.ComputeResource.html#rec...
I did not mean to offend you, if you took it as that, sorry. I just want to make sure you spent the time looking at what I referenced as that is answering your question directly.
If you want examples, again it depends on what language you're trying to implement this code in. There are lots of snippets of code in Code Central that you can reference - http://communities.vmware.com/community/developer/codecentral
If you're looking for specific examples that uses the above properties and methods, check out the following:
<- Hint: Do a search in the script for AFFINITY and you'll see how the rules are being queried
<- This scripts uses the ReconfigureComputeResource_Task method which you can get a working example from
I've created and manage more than 100+ scripts to share with the community, you can check for those here:
So you see that, it's not that I don't want to give you the answer but I would hope that users want to figure out how to retrieve this information and you've posted 0 lines of code to start with.
Hopefully this gets you to start in the right direction
=========================================================================
William Lam
VMware vExpert 2009,2010
VMware scripts and resources at:
Getting Started with the vMA (tips/tricks)
Getting Started with the vSphere SDK for Perl
VMware Code Central - Scripts/Sample code for Developers and Administrators
If you find this information useful, please award points for "correct" or "helpful".
Hello William,
of course I didn't mean any offence myself - I'm just desperately searching for some help. This time, your hints were indeed very helpful - especially the health check pearl script which clearly shows some of the needed objects and properties. Thank you very much for that... :smileylaugh: