Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python2.7
- import ssl
- import requests
- import pprint
- from pyVim.connect import SmartConnect, Disconnect
- from pyVmomi import vim, vmodl
- # Disabling urllib3 ssl warnings
- requests.packages.urllib3.disable_warnings()
- # Disabling SSL certificate verification
- context = ssl.SSLContext(ssl.PROTOCOL_TLSv1)
- context.verify_mode = ssl.CERT_NONE
- vc = None
- #vCenter settings
- vcenter_host = "10.10.0.7"
- vcenter_port = 443
- vcenter_username = "administrator@kippie.lab"
- vcenter_password = "Q!w2e3r4"
- # Connecting to vCenter
- try:
- vc = SmartConnect(host=vcenter_host, user=vcenter_username, pwd=vcenter_password, port=vcenter_port, sslContext=context)
- content= vc.RetrieveContent()
- List = content.customizationSpecManager
- viewMgr = content.viewManager
- objView = viewMgr.CreateContainerView(content.rootFolder,[vim.VirtualMachine],True)
- collector = vc.content.propertyCollector
- obj_spec = vmodl.query.PropertyCollector.ObjectSpec()
- obj_spec.obj=objView
- obj_spec.skip=True
- traversal_spec = vmodl.query.PropertyCollector.TraversalSpec()
- traversal_spec.name = 'traverseEntities'
- traversal_spec.path = 'view'
- traversal_spec.skip = False
- traversal_spec.type = vim.ContainerView
- obj_spec.selectSet.append(traversal_spec)
- property_spec = vmodl.query.PropertyCollector.PropertySpec()
- property_spec.type = vim.HbrManager.ReplicationVmInfo
- property_spec.pathSet.extend(['state'])
- filter_spec = vmodl.query.PropertyCollector.FilterSpec()
- filter_spec.objectSet.append(obj_spec)
- filter_spec.propSet.append(property_spec)
- props = collector.RetrieveContents([filter_spec])
- pprint(props)
- except IOError as e:
- print "I/O error({0}): {1}".format(e.errno, e.strerror)
- Traceback (most recent call last):
- File "./vcConnect2.py", line 65, in <module>
- File "/usr/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 570, in <lambda>
- self.f(*(self.args + (obj,) + args), **kwargs)
- File "/usr/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 376, in _InvokeMethod
- return self._stub.InvokeMethod(self, info, args)
- File "/usr/lib/python2.7/site-packages/pyVmomi/SoapAdapter.py", line 1335, in InvokeMethod
- raise obj # pylint: disable-msg=E0702
- pyVmomi.VmomiSupport.InvalidType: (vmodl.fault.InvalidType) {
- dynamicType = <unset>,
- dynamicProperty = (vmodl.DynamicProperty) [],
- msg = 'The request refers to an unexpected or unknown type.',
- faultCause = <unset>,
- faultMessage = (vmodl.LocalizableMessage) [],
- argument = u'vim.HbrManager.ReplicationVmInfo'
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement