#NEWLINE# def stop( vm , force = False , key = 'uuid' ) : #NEWLINE# #INDENT# "\n    Stop a vm\n\n    vm : string\n        vm to be stopped\n    force : boolean\n        force stop of vm if true\n    key : string [uuid|alias|hostname]\n        value type of 'vm' parameter\n\n    CLI Example:\n\n    .. code-block:: bash\n\n        salt '*' vmadm.stop 186da9ab-7392-4f55-91a5-b8f1fe770543\n        salt '*' vmadm.stop 186da9ab-7392-4f55-91a5-b8f1fe770543 True\n        salt '*' vmadm.stop vm=nacl key=alias\n        salt '*' vmadm.stop vm=nina.example.org key=hostname\n    " #NEWLINE# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# vmadm = _check_vmadm ( ) #NEWLINE# if ( key not in [ 'uuid' , 'alias' , 'hostname' ] ) : #NEWLINE# #INDENT# ret [ 'Error' ] = 'Key must be either uuid, alias or hostname' #NEWLINE# return ret #NEWLINE# #UNINDENT# vm = lookup ( '{0}={1}' . format ( key , vmadm ) , one = True ) #NEWLINE# if ( 'Error' in vm ) : #NEWLINE# #INDENT# return vm #NEWLINE# #UNINDENT# cmd = '{vmadm} stop {force} {uuid}' . format ( vmadm = vmadm , force = ( '-F' if force else '' ) , uuid = vm ) #NEWLINE# res = __salt__ [ 'cmd.run_all' ] ( cmd ) #NEWLINE# retcode = res [ 'retcode' ] #NEWLINE# if ( retcode != 0 ) : #NEWLINE# #INDENT# ret [ 'Error' ] = _exit_status ( retcode ) #NEWLINE# return ret #NEWLINE# #UNINDENT# return True