[openstack-dev] How to assign dynamic property to a Data Object via VMware SDK

Feng Xi Yan yfx_at_ibm at 163.com
Mon Jun 16 03:48:27 UTC 2014

Hi, Fellows,

Anyone familiar with VMWARE SDK?

I am now trying to cerate a network(or a dv port group) in vcenter via VMware SDK.

When I create a dvpg, I need to set vlan to config spec's defaultPortConfig(Type DO:DVPortSetting), but vlan is a dynamic property of DO:DVPortSetting.

I tried to directly assign a VmwareDistributedVirtualSwitchVlanIdSpec MOR to defaultPortConfig.vlan  property, but the task failed with error:
"oslo.vmware.exceptions.VimException: Exception in CreateDVPortgroup_Task.
Cause: Type not found: 'vlan'"

I thought this is not the right way.
Anybody has any clues?

Here is sample code I tried:
client_factory = self._session.vim.client.factory
config_spec = client_factory.create('ns0:DVPortgroupConfigSpec')
port_config_spec = client_factory.create('ns0:DVPortSetting')
vlan_spec = client_factory.create('ns0:VmwareDistributedVirtualSwitchVlanIdSpec')
vlan_spec.vlanId = 100
vlan_spec.inherited = 'True'
port_config_spec.vlan = vlan_spec
config_spec.name = 'test_21'
config_spec.description = 'test'
config_spec.numPorts = '100'
config_spec.autoExpand = 'True'
config_spec.type = 'earlyBinding'
config_spec.defaultPortConfig = port_config_spec
dvs = vmware_util.get_dvs(self._session, CONF.VMWARE.dvswitch)
pg_create_task = self._session.invoke_api(self._session.vim,
                                          dvs, spec=config_spec)
result = self._session.wait_for_task(pg_create_task)
dvpg = result.result
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20140616/5a6c0a61/attachment.html>

More information about the OpenStack-dev mailing list