vmware / pyvmomi

VMware vSphere API Python Bindings
Apache License 2.0
2.22k stars 766 forks source link

Configure lag on existing DVS #1059

Open sarojabkhpe opened 11 months ago

sarojabkhpe commented 11 months ago

Describe the bug

While configuring lag in passive mode on a existing DVS switch, method not found exception was caught, even though the method has been defined in the class. Exception details: (vmodl.fault.MethodNotFound) { dynamicType = , dynamicProperty = (vmodl.DynamicProperty) [], msg = , faultCause = , faultMessage = (vmodl.LocalizableMessage) [], receiver = 'vim.dvs.VmwareDistributedVirtualSwitch:dvs-73', method = 'UpdateLacpGroupConfig' }

Reproduction steps

def create_lag(si, dvsName, lagName, numberOfUplinks): try: dvs_vim_type = [vim.DistributedVirtualSwitch] vds = get_obj(si,dvs_vim_type,dvsName) except Exception as e: print(e) return None

#create lacp in passive mode
try:     

    lacpGroupSpec_0 = vim.dvs.VmwareDistributedVirtualSwitch.LacpGroupSpec()
    lacpGroupSpec_0.lacpGroupConfig = vim.dvs.VmwareDistributedVirtualSwitch.LacpGroupConfig()
    lacpGroupSpec_0.lacpGroupConfig.mode = 'passive'
    lacpGroupSpec_0.lacpGroupConfig.ipfix = vim.dvs.VmwareDistributedVirtualSwitch.LagIpfixConfig()
    lacpGroupSpec_0.lacpGroupConfig.loadbalanceAlgorithm = 'srcDestIpTcpUdpPortVlan'
    lacpGroupSpec_0.lacpGroupConfig.vlan = vim.dvs.VmwareDistributedVirtualSwitch.LagVlanConfig()
    lacpGroupSpec_0.lacpGroupConfig.name = 'vsan_lag'
    #lacpGroupSpec_0.lacpGroupConfig.timeoutMode = 'slow'
    lacpGroupSpec_0.lacpGroupConfig.uplinkNum = 2
    lacpGroupSpec_0.operation = 'add'
    lacpGroupSpec = [lacpGroupSpec_0]
    task = vds.UpdateDVSLacpGroupConfig_Task(lacpGroupSpec)
    # The attributes of lacpGroupConfig includes: 'dynamicProperty', 'dynamicType', 'ipfix', 'key', 'loadbalanceAlgorithm', 'mode', 'name', 'uplinkName', 'uplinkNum', 'uplinkPortKey', 'vlan'
    # this list does not contain timeoutMode. As default value for timeout mode is slow, ignoring this for now
    # TO DO : how to set the timeoutMode should be explored

    state, result = wait_for_task(task)
    if not state:
        print(result)
        exit()       
    return result
except Exception as e:
    print(e)
    return None

Obtained similar result when task = vds.UpdateLacpGroupConfig(lacpGroupSpec) was used.

Expected behavior

  1. Exception should have fault cause and fault message set to an appropriate value that describes the nature of the fault.
  2. Clear instructions of what pre-requisites needs to be set should be documented.

Additional context

Please note that the main logic of the code was generated using the developer center's code capture feature