reubenur-rahman / vmware-pyvmomi-examples

The example codes are written using the VMware official python library pyvmomi
Apache License 2.0
89 stars 60 forks source link

Set VLAN id on dvp to a specific integer #15

Closed jonathanmier closed 7 years ago

jonathanmier commented 7 years ago

Is there a way to set the VLAN id in s portgroup to a specific value instead of a range of values?

reubenur-rahman commented 7 years ago

That's easy. Tomorrow I will reply you

On 29-Jun-2017 2:21 AM, "jonnymier" notifications@github.com wrote:

Is there a way to set the VLAN id in s portgroup to a specific value instead of a range of values?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/rreubenur/vmware-pyvmomi-examples/issues/15, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWBy8GLTzqS8CkD_qidqUWo_ptVcAgvks5sIrzBgaJpZM4OIg4S .

jonathanmier commented 7 years ago

I figured this out already but I would like to know how to change specs on a DVPortgroup once it is created. Say I want to change the VLAN id to something different. @rreubenur

jonathanmier commented 7 years ago

@rreubenur nvm got it. Thanks.

reubenur-rahman commented 7 years ago

dv_pg_spec = vim.dvs.DistributedVirtualPortgroup.ConfigSpec() dv_pg_spec.defaultPortConfig = vim.dvs.VmwareDistributedVirtualSwitch.VmwarePortConfigPolicy()

dv_pg_spec.defaultPortConfig.vlan = vim.dvs.VmwareDistributedVirtualSwitch.VlanIdSpec() dv_pg_spec.defaultPortConfig.vlan.vlanId =

dv_pg_spec.defaultPortConfig.vlan = vim.dvs.VmwareDistributedVirtualSwitch.TrunkVlanSpec() dv_pg_spec.defaultPortConfig.vlan.vlanId = [vim.NumericRange(start=1, end=4094)]

reconfig_task = pg_obj.ReconfigureDVPortgroup_Task(spec=dv_pg_spec)

task.waitForTask(reconfig_task, si)

On 29-Jun-2017 11:53 PM, "jonnymier" notifications@github.com wrote:

I figured this out already but I would like to know how to change specs on a DVPortgroup once it is created. Say I want to change the VLAN id to something different.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/rreubenur/vmware-pyvmomi-examples/issues/15#issuecomment-312053617, or mute the thread https://github.com/notifications/unsubscribe-auth/AGWByw13UZMRZd_NX3n3phjNTCt5xAzHks5sI-u1gaJpZM4OIg4S .