Hello,
I have been trying to understand this and spent few hours to find out the answer which could help but did not get much information.
Basically we use get-view to use the API and same is available in MOB. but when i try to explore MOB .I see 4 different views for viewManager
Also when i create container view and try to invoke the method of managed object it says it does not exist.
I am trying to do using pyVmomi to replicate how we do in powercli
vc=connect.Connect("vCenterName","443","UserName","Password")
cm=vc.content.certificateManager
recursive=True
rootdirectory=vc.content.rootFlder
certmgr=vc.content.viewManager.CreateContainerView(rootdirectory,cm,recursive)
certmgr.CertMgrRefreshCertificates_Task(host'sMORef)
But I am getting error method is not found .
That is because you are working with a MoRef (Managed Object Reference), not an object.
All methods and properties are available through the object, not the MoRef.
View the MoRef as a kind of pointer to the actual object.
To go from a MoRef to the corresponding object you use the Get-View cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I try to stay far away from Python, but I guess that code is trying to do something like this.
Refresh the certificate on all ESXi nodes.
$si = Get-View ServiceInstance
$viewMgr = Get-View -Id ViewManager
$recurse = $true
$cViewMoRef = $viewMgr.CreateContainerView($si.Content.RootFolder,'HostSystem',$recurse)
$cView = Get-View -Id $cViewMoRef
$certMgr = Get-View -Id $si.Content.CertificateManager
$certMgr.CertMgrRefreshCertificates_Task($cView.View)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hello Luc,
thank for your quick response .
yes you are correct i was trying to use same way as we use in powercli.
Can you please suggest
why we Do not do see method related to managed object until we pass their ID again to get-view
example
Cm=get-view serviceinstance.content.certificatemanager
cm|gm It usually provide no method to refresh
cmgr=get-view -id cm. # passing id of certificate manager
I will get all methods
any technical logic behind this ?
i was in assumption line 1 provide ID to me
then another view for corresponding object
but i have seen some managedObject directly provide method in first command only
Example Sessionmanager
get-view sessionmanager will give all method and we do not need 2 nd line where we pass ID
That is the only roadblock in python i am facing
i created the view but no method is coming
That is because you are working with a MoRef (Managed Object Reference), not an object.
All methods and properties are available through the object, not the MoRef.
View the MoRef as a kind of pointer to the actual object.
To go from a MoRef to the corresponding object you use the Get-View cmdlet.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference