EXPERT RESPONSE
Here are the answers to your questions:
When the following line from the code executes it takes about 30 seconds to complete: vim_svc = new VimService(); Any thoughts why it takes so long or how to improve it?
VMware solved the issue of the class taking a frustratingly long time to instantiate (it was a problem with how the XML serialization was generated). There is a KB article on the subject at VMware's Website.
Can you provide any examples how to query for a single VM object given its name?
For this you would use the FindByDnsName method (you can look it up in the SDK reference guide). In a recent article I demonstrate how to use the FindByIP method, the use is almost the same. Here is an example:
ManagedObjectReference moref_vm =
vim_svc.FindByDnsName( vim_svc_content.searchIndex, null,
"foo.lostcreations.local", true );
That will get you a managed object reference to the VM you are looking for.
Can you also point me where to learn how to create a "registered" assembly/class (not sure what the proper terminology would be) that could be called from other .net apps, scripts, etc.?
Simply create a library assembly (DLL) and you can reference it from other .NET applications. For scripts you would need to do a type library export to make the .NET classes available as COM objects. The tlbexport command should do the trick. In order for a .NET assembly to be globally visible you must install it into the Global Assembly Cache. To do this the assembly must be signed by a strong name key. The tool "snk" will help you with that, but so can Visual Studio.
Hope this helps!
|