def top(**kwargs):
 if ('id' not in kwargs['opts']):
  return {}
 cmd = '{0} {1}'.format(__opts__['master_tops']['ext_nodes'], kwargs['opts']['id'])
 ndata = yaml.safe_load(subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE).communicate()[0])
 if (not ndata):
  log.info('master_tops ext_nodes call did not return any data')
 ret = {}
 if ('environment' in ndata):
  env = ndata['environment']
 else:
  env = 'base'
 if ('classes' in ndata):
  if isinstance(ndata['classes'], dict):
   ret[env] = list(ndata['classes'])
  elif isinstance(ndata['classes'], list):
   ret[env] = ndata['classes']
  else:
   return ret
 else:
  log.info('master_tops ext_nodes call did not have a dictionary with a "classes" key.')
 return ret

def top ( ** kwargs ) : if ( 'id' not in kwargs [ 'opts' ] ) : return { } cmd = '{0} {1}' . format ( __opts__ [ 'master_tops' ] [ 'ext_nodes' ] , kwargs [ 'opts' ] [ 'id' ] ) ndata = yaml . safe_load ( subprocess . Popen ( cmd , shell = True , stdout = subprocess . PIPE ) . communicate ( ) [ 0 ] ) if ( not ndata ) : log . info ( 'master_tops ext_nodes call did not return any data' ) ret = { } if ( 'environment' in ndata ) : env = ndata [ 'environment' ] else : env = 'base' if ( 'classes' in ndata ) : if isinstance ( ndata [ 'classes' ] , dict ) : ret [ env ] = list ( ndata [ 'classes' ] ) elif isinstance ( ndata [ 'classes' ] , list ) : ret [ env ] = ndata [ 'classes' ] else : return ret else : log . info ( 'master_tops ext_nodes call did not have a dictionary with a "classes" key.' ) return ret
runs the docker top command on a specific container name container name or id cli example: **return data** a list of dictionaries containing information about each process .