def IxVmAddHypervisor(ixNet, vChassisIp, vLoadModuleLogin, vLoadModulePassword, vLoadModuleType): availableHardwareObj = ixNet.getList(ixNet.getRoot(), 'availableHardware')[0] vChassisObj = ixNet.getList(availableHardwareObj, 'virtualChassis')[0] try: hypervisor = ixNet.add(vChassisObj, 'hypervisor') ixNet.setAttribute(hypervisor, '-enable', '%s' % 'true') ixNet.setAttribute(hypervisor, '-serverIp', '%s' % vChassisIp) ixNet.setAttribute(hypervisor, '-user', '%s' % vLoadModuleLogin) ixNet.setAttribute(hypervisor, '-password', '%s' % vLoadModulePassword) ixNet.setAttribute(hypervisor, '-type', '%s' % vLoadModuleType) ixNet.commit() except: #hypervisor = '::ixNet::OBJ-/availableHardware/virtualChassis/hypervisor:"192.168.70.10"' hypervisor = ixNet.getList(vChassisObj, 'hypervisor')[0] if len(hypervisor) != 0: print 'Hypervisor:', hypervisor return hypervisor else: return 0