#NEWLINE# def info( vm , info_type = 'all' , key = 'uuid' ) : #NEWLINE# #INDENT# "\n    Lookup info on running kvm\n\n    vm : string\n        vm to be targetted\n    info_type : string [all|block|blockstats|chardev|cpus|kvm|pci|spice|version|vnc]\n        info type to return\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.info 186da9ab-7392-4f55-91a5-b8f1fe770543\n        salt '*' vmadm.info 186da9ab-7392-4f55-91a5-b8f1fe770543 vnc\n        salt '*' vmadm.info nacl key=alias\n        salt '*' vmadm.info nacl vnc key=alias\n    " #NEWLINE# ret = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# vmadm = _check_vmadm ( ) #NEWLINE# if ( info_type not in [ 'all' , 'block' , 'blockstats' , 'chardev' , 'cpus' , 'kvm' , 'pci' , 'spice' , 'version' , 'vnc' ] ) : #NEWLINE# #INDENT# ret [ 'Error' ] = 'Requested info_type is not available' #NEWLINE# return ret #NEWLINE# #UNINDENT# 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 , vm ) , one = True ) #NEWLINE# if ( 'Error' in vm ) : #NEWLINE# #INDENT# return vm #NEWLINE# #UNINDENT# cmd = '{vmadm} info {uuid} {type}' . format ( vmadm = vmadm , uuid = vm , type = info_type ) #NEWLINE# res = __salt__ [ 'cmd.run_all' ] ( cmd ) #NEWLINE# retcode = res [ 'retcode' ] #NEWLINE# if ( retcode != 0 ) : #NEWLINE# #INDENT# ret [ 'Error' ] = ( res [ 'stderr' ] if ( 'stderr' in res ) else _exit_status ( retcode ) ) #NEWLINE# return ret #NEWLINE# #UNINDENT# return json . loads ( res [ 'stdout' ] )