parameters: (self,data,module_name,module_args=None)
docstring: 处理ANSIBLE 模块输出内容
docstring_summary: 处理ANSIBLE 模块输出内容
docstring_tokens: 处理ANSIBLE 模块输出内容
function: def handle_model_data(self,data,module_name,module_args=None):
          '''处理ANSIBLE 模块输出内容'''
          module_data = json.loads(data)
          failed = module_data.get('failed')
          success = module_data.get('success')
          unreachable = module_data.get('unreachable')
          data_list = []
          if module_name == "raw":
              if failed:
                  for x,y in failed.items():   
                      data = {}                  
                      data['ip'] = x
                      try:
                          data['msg'] = y.get('stdout').replace('\t\t','<br>').replace('\r\n','<br>').replace('\t','<br>')
                      except:
                          data['msg'] = None
                      if y.get('rc') == 0:
                          data['status'] = 'succeed' 
                      else:
                          data['status'] = 'failed'
                      data_list.append(data)
              if success:
                  for x,y in success.items(): 
                      data = {}                    
                      data['ip'] = x
                      try:
                          data['msg'] = y.get('stdout').replace('\t\t','<br>').replace('\r\n','<br>').replace('\t','<br>')
                      except:
                          data['msg'] = None
                      if y.get('rc') == 0:
                          data['status'] = 'succeed' 
                      else:
                          data['status'] = 'failed'  
                      data_list.append(data)
                      
          elif module_name == "ping":
              if success:
                  for x,y in success.items():
                      data = {}
                      data['ip'] = x
                      if y.get('ping'):
                          data['msg'] = y.get('ping')
                          data['status'] = 'succeed'
                      data_list.append(data)                    
          else:
              if success:
                  for x,y in success.items():
                      data = {}
                      data['ip'] = x
                      if y.get('invocation'):
                          data['msg'] = "Ansible %s with %s execute success." % (module_name,module_args)
                          data['status'] = 'succeed'
                      data_list.append(data) 
                      
              if failed:
                  for x,y in failed.items():   
                      data = {}                  
                      data['ip'] = x
                      data['msg'] = y.get('msg')
                      data['status'] = 'failed'
                      data_list.append(data)  
                                                    
          if unreachable:
              for x,y in unreachable.items(): 
                  data = {}                    
                  data['ip'] = x
                  data['msg'] = y.get('msg')
                  data['status'] = 'failed'  
                  data_list.append(data)            
          if data_list:
              return  data_list
          else:
              return False
function_tokens: def handle_model_data ( self , data , module_name , module_args = None ) : module_data = json . loads ( data ) failed = module_data . get ( 'failed' ) success = module_data . get ( 'success' ) unreachable = module_data . get ( 'unreachable' ) data_list = [ ] if module_name == "raw" : if failed : for x , y in failed . items ( ) : data = { } data [ 'ip' ] = x try : data [ 'msg' ] = y . get ( 'stdout' ) . replace ( '\t\t' , '<br>' ) . replace ( '\r\n' , '<br>' ) . replace ( '\t' , '<br>' ) except : data [ 'msg' ] = None if y . get ( 'rc' ) == 0 : data [ 'status' ] = 'succeed' else : data [ 'status' ] = 'failed' data_list . append ( data ) if success : for x , y in success . items ( ) : data = { } data [ 'ip' ] = x try : data [ 'msg' ] = y . get ( 'stdout' ) . replace ( '\t\t' , '<br>' ) . replace ( '\r\n' , '<br>' ) . replace ( '\t' , '<br>' ) except : data [ 'msg' ] = None if y . get ( 'rc' ) == 0 : data [ 'status' ] = 'succeed' else : data [ 'status' ] = 'failed' data_list . append ( data ) elif module_name == "ping" : if success : for x , y in success . items ( ) : data = { } data [ 'ip' ] = x if y . get ( 'ping' ) : data [ 'msg' ] = y . get ( 'ping' ) data [ 'status' ] = 'succeed' data_list . append ( data ) else : if success : for x , y in success . items ( ) : data = { } data [ 'ip' ] = x if y . get ( 'invocation' ) : data [ 'msg' ] = "Ansible %s with %s execute success." % ( module_name , module_args ) data [ 'status' ] = 'succeed' data_list . append ( data ) if failed : for x , y in failed . items ( ) : data = { } data [ 'ip' ] = x data [ 'msg' ] = y . get ( 'msg' ) data [ 'status' ] = 'failed' data_list . append ( data ) if unreachable : for x , y in unreachable . items ( ) : data = { } data [ 'ip' ] = x data [ 'msg' ] = y . get ( 'msg' ) data [ 'status' ] = 'failed' data_list . append ( data ) if data_list : return data_list else : return False