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,
"CreateDVPortgroup_Task",
dvs, spec=config_spec)
result = self._session.wait_for_task(pg_create_task)
dvpg = result.result
print(dvpg)
_______________________________________________
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev