def main():
    try:
        si = None
        try:
            print "Trying to connect to VCENTER SERVER . . ."
            si = connect.Connect(inputs['vcenter_ip'], 443, inputs['vcenter_user'], inputs['vcenter_password'])
        except __HOLE__, e:
            pass
            atexit.register(Disconnect, si)

        print "Connected to VCENTER SERVER !"
        
        content = si.RetrieveContent()

        if inputs['operation'] == 'stop' or inputs['operation'] == 'suspend':
            force = inputs['force']
   
        vm = get_obj(content, [vim.VirtualMachine], inputs['vm_name'])

        #current_state = vm.runtime.powerState
        
        if inputs['operation'] == 'start':
            invoke_and_track(vm.PowerOn, None)

        elif inputs['operation'] == 'stop':
            if not force:
                invoke_and_track(vm.ShutdownGuest)
            else:
                invoke_and_track(vm. PowerOff)
        
        elif inputs['operation'] == 'suspend':
            if not force:
                invoke_and_track(vm.StandbyGuest)
            else:
                invoke_and_track(vm. Suspend)
                
        #wait_for_task(task, si)        
        
    except vmodl.MethodFault, e:
        print "Caught vmodl fault: %s" % e.msg
        return 1
    except Exception, e:
        if str(e) == 'Query':
            return 1
        print "Caught exception: %s" % str(e)
        return 1
    
# Start program
dataset/ETHPy150Open rreubenur/vmware-pyvmomi-examples/vm_power_ops.py/main