Hi,
I am having trouble getting FindByInventoryPath to find my DVS
I have a ver simple inventory (please see the attached pic)
Datacenter "dc1" and inside it I have "dvSwitch1"
I tried the following paths. None of them worked
dc1/dvSwitch1
dc1/network/dvSwitch1 (I added network because DVS was inside the networkFolder)
dc1/networkFolder/dvSwitch1
Can anyone help me with this. I am not sure what I am missing.
I am able to find the DVS through MOB. Also, it is inside the networkFolder of the datacenter "dc1"
Documentation of the FindByInventoryPath says that it can get us any ManagedEntity, and DistributedVirtualSwitch is an extension of ManagedEntity
Thanks a lot
I haven't used FindByInventoryPath but you can just get a Datacenter view and do the following:
foreach(@$hosts) { print "Datacenter Name: ", $_->name,"\n"; if(defined $_->networkFolder) { my $networkFolder = Vim::get_view(mo_ref => $_->networkFolder); my $childEntArr = Vim::get_views(mo_ref_array => $networkFolder->childEntity,view_type => 'VmwareDistributedVirtualSwitch'); foreach(@$childEntArr) { print "\t",$_->name,"\n"; } } }
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
If you find this information useful, please award points for "correct" or "helpful".
also, I noticed you have a dvs1 folder under your Datacenter, you might want to see if adding that helps. What type of an error/faulse were you getting with the snippet of code? Can you also post that
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
If you find this information useful, please award points for "correct" or "helpful".
Thanks for quick response.
I was really interested in using MOB to get this information.
I know that we can get the Datacenter reference and go from there.
However, I really wanted to directly access the DVS I am interested in.
Further, if we are able to get from Datacenter, there should be a equivalent path as well.
Somehow it doesn't seem to work
It doesn't give any error message. It gives an empty result (void)
I copied this from my browser. Observe the void result at the end.
Managed Object Browser
Managed Object Type: ManagedObjectReference:SearchIndex Managed Object ID: SearchIndex Method: FindByInventoryPath |
Parameters
Name | Type | Value |
---|---|---|
inventoryPath (required) | string | |
dc1/dvSwitch1 | ||
[Invoke Method\ | javascript:invokeMethod()] |
Method Invocation Result: void
Okay, so I gave it a try and here's what I found from my simple testing.
Try just providing the name of your Datacenter, so for my development it's called primp-industries-DEV you should get a return value of a MoRef of Datacenter, for mines it was datacenter-2 if you click on that, you'll get information regarding the datacenter and you should see networkFolder and for mines it was group-n6, click on that and you'll find MoRef to networkFolder and you should find your DVS under childEntity.
I'm not sure what the exact syntax is to get to the dvs using the inventory tree, but at least you can get to your DVS via the MOB.
=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at:
If you find this information useful, please award points for "correct" or "helpful".
Thanks Lam for the detailed instructions.
Yes, I am trying the same approach to get to the DVS. It works, but I feel it is roundabout.
I am also thinking from the programming perspective.
When I use the FindByInventoryPath API, I want to directly reach to the DVS using the inventory path. We will have the data to comput the inventory path, so the most preferable option for us it to directly get to the DVS, based on the computed path.
Lets see if we have any alternatives.
I am wondering if there is any glitch in the code
Try using <datacenter name>/network/<dvSwtichname> as inventorypath in your call. I am assuming you created the DVS directly under your datacenter object, there were no folders in between. Here network is the name of the NetworkFolder which contains Network objects. If your inventory does not further conatin folder seggregation for objects, then this this is right path for your DirtsributedVirtualSwitch.
Thanks for the response. Yes, I did use this path dc1/network/dvSwitch1
It did not work. Yes, I did create the dvs directly under the datacenter dc1
In fact I could see the DVS dvSwitch1 in the networkFolder property of the Datacenter.
I am running the VSphere Beta code.
I will give it a try with some other Datacenter and DVS combinations.