Beispiel #1
0
  def check_nifi_process_status(self, pid_file):
    """
    Function checks whether process is running.
    Process is considered running, if pid file exists, and process with
    a pid, mentioned in pid file is running
    If process is not running, will throw ComponentIsNotRunning exception

    @param pid_file: path to service pid file
    """
    if not pid_file or not os.path.isfile(pid_file):
        raise ComponentIsNotRunning()

    try:
        lines = [line.rstrip('\n') for line in open(pid_file)]
        pid = int(lines[2].split('=')[1]);
    except:
        Logger.warn("Pid file {0} does not exist".format(pid_file))
        raise ComponentIsNotRunning()

    code, out = shell.call(["ps","-p", str(pid)])

    if code:
        Logger.debug("Process with pid {0} is not running. Stale pid file"
                     " at {1}".format(pid, pid_file))
        raise ComponentIsNotRunning()
    pass
def resolve_ambari_config():
  config_path = os.path.abspath(AmbariConfig.getConfigFile())
  try:
    if os.path.exists(config_path):
      agent_config.read(config_path)
    else:
      raise Exception("No config found at %s" % str(config_path))
  except Exception, err:
    Logger.warn(err)
Beispiel #3
0
def resolve_ambari_config():
  config_path = os.path.abspath(AmbariConfig.getConfigFile())
  try:
    if os.path.exists(config_path):
      agent_config.read(config_path)
    else:
      raise Exception("No config found at %s" % str(config_path))
  except Exception, err:
    Logger.warn(err)
Beispiel #4
0
  def start(self, env):
    import params
    env.set_params(params)
    self.configure(env, action = 'start')

    start_cmd = format("{ams_grafana_script} start")
    Execute(start_cmd,
            user=params.ams_user,
            not_if = params.grafana_process_exists_cmd,
            )
    pidfile = format("{ams_grafana_pid_dir}/grafana-server.pid")
    if not sudo.path_exists(pidfile):
      Logger.warn("Pid file doesn't exist after starting of the component.")
    else:
      Logger.info("Grafana Server has started with pid: {0}".format(sudo.read_file(pidfile).strip()))

    # Create datasource
    create_ams_datasource()
    # Create pre-built dashboards
    create_ams_dashboards()
Beispiel #5
0
 def __dump_db(self, command, type, is_db_here):
     dump_dir = "/etc/hive/dbdump"
     dump_file = format(
         "{dump_dir}/hive-{stack_version_formatted}-{type}-dump.sql")
     if is_db_here:
         if not os.path.exists(dump_dir):
             Directory(dump_dir)
         Execute(format(command), user="******")
         Logger.info(
             format(
                 "Hive Metastore database backup created at {dump_file}"))
     else:
         Logger.warn(
             format(
                 "Hive Metastore is using an external {hive_metastore_db_type} database, the connection url is {hive_jdbc_connection_url}."
             ))
         Logger.warn(
             format(
                 "Please log in to that host, and create a db backup manually by executing the following command: \"{command}\", then click on 'IGNORE AND PROCEED'"
             ))
         raise Fail()