Hello,
if I try to use vcenter's MOB portal (ie: http://x.x.x.x/mob ) I can browse under "host -> configManager -> datastoreSystem-3271” and utilize “CreateNasDatastore” method to add new NFS datastore, ie:
<spec>
<remoteHost>192.168.x.x</remoteHost>
<remotePath>/NFS/vcenter-nfs</remotePath>
<localPath>vcenter-nfs</localPath>
<accessMode>readWrite</accessMode>
<!-- optional -->
<type>nfs</type>
<!-- optional -->
<userName></userName>
<!-- optional -->
<password></password>
<!-- optional -->
<!-- array start -->
<!-- optional -->
<remoteHostNames>string</remoteHostNames>
<!-- array end -->
<!-- optional -->
<securityType></securityType>
</spec>
If I try the same using pyvmomi:
spec=vim.host.NasVolume.Specification
spec.remoteHost="192.168.x.x"
spec.remotePath="/NFS/vcenter-nfs"
spec.localPath="vcenter-nfs"
spec.accessMode="readWrite"
host.configManager.datastoreSystem.CreateNasDatastore(spec)
I got following error:
Traceback (most recent call last):
File "./add_nfs_datastore.py", line 159, in <module>
main(sys.argv)
File "./add_nfs_datastore.py", line 154, in main
host.configManager.datastoreSystem.CreateNasDatastore(spec)
File "/Library/Python/2.7/site-packages/pyvmomi-5.5.0.2014.1.1-py2.7.egg/pyVmomi/VmomiSupport.py", line 566, in <lambda>
File "/Library/Python/2.7/site-packages/pyvmomi-5.5.0.2014.1.1-py2.7.egg/pyVmomi/VmomiSupport.py", line 374, in _InvokeMethod
File "/Library/Python/2.7/site-packages/pyvmomi-5.5.0.2014.1.1-py2.7.egg/pyVmomi/VmomiSupport.py", line 949, in CheckField
TypeError: For "spec" expected type vim.host.NasVolume.Specification, but got LazyType
If I stop the script execution before the error then I'm able to inspect host and host.configManager.datastoreSystem variables obtaining:
>>> host
'vim.HostSystem:host-311'
>>> host.configManager.datastoreSystem
'vim.host.DatastoreSystem:datastoreSystem-311'
>>>
So path with that is equivalent to what I get through /MOB...
But why I end up getting LazyType error ??
Thx,
Andrea