def service_cgconfig_control(action):
 actions = ['start', 'stop', 'restart', 'condrestart']
 if (action in actions):
  try:
   utils.run(('service cgconfig %s' % action))
   logging.debug('%s cgconfig successfully', action)
   return True
  except error.CmdError as detail:
   logging.error('Failed to %s cgconfig:\n%s', action, detail)
   return False
 elif ((action == 'status') or (action == 'exists')):
  cmd_result = utils.run('service cgconfig status', ignore_status=True)
  if (action == 'exists'):
   if cmd_result.exit_status:
    return False
   else:
    return True
  if (((not cmd_result.exit_status) and cmd_result.stdout.strip()) == 'Running'):
   logging.info('Cgconfig service is running')
   return True
  else:
   return False
 else:
  raise error.TestError(('Unknown action: %s' % action))

def service_cgconfig_control ( action ) : actions = [ 'start' , 'stop' , 'restart' , 'condrestart' ] if ( action in actions ) : try : utils . run ( ( 'service cgconfig %s' % action ) ) logging . debug ( '%s cgconfig successfully' , action ) return True except error . CmdError as detail : logging . error ( 'Failed to %s cgconfig:\n%s' , action , detail ) return False elif ( ( action == 'status' ) or ( action == 'exists' ) ) : cmd_result = utils . run ( 'service cgconfig status' , ignore_status = True ) if ( action == 'exists' ) : if cmd_result . exit_status : return False else : return True if ( ( ( not cmd_result . exit_status ) and cmd_result . stdout . strip ( ) ) == 'Running' ) : logging . info ( 'Cgconfig service is running' ) return True else : return False else : raise error . TestError ( ( 'Unknown action: %s' % action ) )
cgconfig control by action .