Skip to content

vcsim: DistributedVirtualPortgroup does not have Portkeys #979

@Akasurde

Description

@Akasurde

As $title, DVPG created by vcsim does not have 'PortKeys' as mentioned in documentation.

Here is reproducer -

from pyVim.connect import SmartConnect, Disconnect
import ssl
import atexit
from pyVmomi import vim

def connect():
    context = ssl.SSLContext(ssl.PROTOCOL_SSLv23)
    context.verify_mode = ssl.CERT_NONE

    si = SmartConnect(host='0.0.0.0', user='user', pwd='pass', port=443, sslContext=context)
    atexit.register(Disconnect, si)
    content = si.RetrieveContent()
    return content

def get_obj(content, vimtype, name):
    """
    Return an object by name, if name is None the
    first found object is returned
    """
    obj = None
    container = content.viewManager.CreateContainerView(
        content.rootFolder, vimtype, True)
    for c in container.view:
        if name:
            if c.name == name:
                obj = c
                break
        else:
            obj = c
            break

    container.Destroy()
    return obj

content = connect()

dvpg = get_obj(content, [vim.dvs.DistributedVirtualPortgroup], 'DC0_DVPG0')
print dvpg.config
print dvpg.portKeys

Traceback -

python portgroup.py
(vim.dvs.DistributedVirtualPortgroup.ConfigInfo) {
   dynamicType = <unset>,
   dynamicProperty = (vmodl.DynamicProperty) [],
   key = 'dvportgroup-14',
   name = 'DC0_DVPG0',
   numPorts = 0,
   distributedVirtualSwitch = 'vim.DistributedVirtualSwitch:distributedvirtualswitch-10',
   defaultPortConfig = <unset>,
   description = <unset>,
   type = '',
   policy = <unset>,
   portNameFormat = <unset>,
   scope = (vim.ManagedEntity) [],
   vendorSpecificConfig = (vim.dvs.KeyedOpaqueBlob) [],
   configVersion = <unset>,
   autoExpand = <unset>,
   vmVnicNetworkResourcePoolKey = <unset>,
   uplink = <unset>
}
Traceback (most recent call last):
  File "portgroup.py", line 39, in <module>
    print dvpg.portKeys
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 574, in __call__
    return self.f(*args, **kwargs)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/VmomiSupport.py", line 394, in _InvokeAccessor
    return self._stub.InvokeAccessor(self, info)
  File "/Volumes/data/src/ansible/venv4/lib/python2.7/site-packages/pyVmomi/StubAdapterAccessorImpl.py", line 43, in InvokeAccessor
    objectContent = result.objects[0]
IndexError: list index out of range

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions