def __init__(self, options, properties, storage_type):
    self.dbPropKeys = DbPropKeys(
      JDBC_DATABASE_PROPERTY,
      JDBC_DRIVER_PROPERTY,
      JDBC_HOSTNAME_PROPERTY,
      JDBC_PORT_PROPERTY,
      JDBC_DATABASE_NAME_PROPERTY,
      JDBC_URL_PROPERTY)
    self.dbAuthKeys = MSSQLAuthenticationKeys(
      JDBC_USE_INTEGRATED_AUTH_PROPERTY,
      JDBC_USER_NAME_PROPERTY,
      JDBC_PASSWORD_PROPERTY,
      JDBC_RCA_PASSWORD_ALIAS,
      JDBC_PASSWORD_FILENAME
    )

    super(MSSQLAmbariDBConfig, self).__init__(options, properties, storage_type)

    if self.database_name is None or self.database_name is "":
      self.database_name = AMBARI_DATABASE_NAME

    self.persistence_property = PERSISTENCE_TYPE_PROPERTY

    self.env_var_db_name ='AMBARIDBNAME'
    self.env_var_db_log_name = 'AMBARIDBLOGNAME'

    # The values from options supersede the values from properties
    self.init_script_file = compress_backslashes(DBMSConfig._init_member_with_default(options, "init_db_script_file",
        "resources" + os.path.sep + "Ambari-DDL-SQLServer-CREATE.sql"))
    self.drop_tables_script_file = compress_backslashes(DBMSConfig._init_member_with_default(options, "cleanup_db_script_file",
        "resources" + os.path.sep + "Ambari-DDL-SQLServer-DROP.sql"))
  def __init__(self, options, properties, storage_type):
    self.dbPropKeys = DbPropKeys(
      JDBC_DATABASE_PROPERTY,
      JDBC_DRIVER_PROPERTY,
      JDBC_HOSTNAME_PROPERTY,
      JDBC_PORT_PROPERTY,
      JDBC_DATABASE_NAME_PROPERTY,
      JDBC_URL_PROPERTY)
    self.dbAuthKeys = SqlServerAuthenticationKeys(
      JDBC_USE_INTEGRATED_AUTH_PROPERTY,
      JDBC_USER_NAME_PROPERTY,
      JDBC_PASSWORD_PROPERTY,
      JDBC_RCA_PASSWORD_ALIAS,
      JDBC_PASSWORD_FILENAME
    )

    super(SQLServerAmbariDBConfig, self).__init__(options, properties, storage_type)

    if self.database_name is None or self.database_name is "":
      self.database_name = AMBARI_DATABASE_NAME

    self.persistence_property = PERSISTENCE_TYPE_PROPERTY

    self.env_var_db_name ='AMBARIDBNAME'
    self.env_var_db_log_name = 'AMBARIDBLOGNAME'
    self.env_var_db_owner = 'AMBARIDBOWNER'

    # The values from options supersede the values from properties
    self.init_script_file = compress_backslashes(DBMSConfig._init_member_with_default(options, "init_db_script_file",
        "resources" + os.path.sep + "Ambari-DDL-SQLServer-CREATE.sql"))
    self.drop_tables_script_file = compress_backslashes(DBMSConfig._init_member_with_default(options, "cleanup_db_script_file",
        "resources" + os.path.sep + "Ambari-DDL-SQLServer-DROP.sql"))
Пример #3
0
  def _ensure_java_home_env_var_is_set(self, java_home_dir):
    if not os.environ.has_key(JAVA_HOME) or os.environ[JAVA_HOME] != java_home_dir:
      java_home_dir_unesc = compress_backslashes(java_home_dir)
      retcode, out, err = run_os_command("SETX {0} {1} /M".format(JAVA_HOME, java_home_dir_unesc))
      if retcode != 0:
        print_warning_msg("SETX output: " + out)
        print_warning_msg("SETX error output: " + err)
        err = "Setting JAVA_HOME failed. Exit code={0}".format(retcode)
        raise FatalException(1, err)

      os.environ[JAVA_HOME] = java_home_dir
Пример #4
0
    def __init__(self, options, properties, storage_type):
        super(SQLServerConfig, self).__init__(options, properties,
                                              storage_type)
        """
    #Just load the defaults. The derived classes will be able to modify them later
    """
        self.dbms = DATABASE_DBMS_SQLSERVER
        self.driver_class_name = DATABASE_DRIVER_NAME_SQLSERVER

        self.JDBC_DRIVER_INSTALL_MSG = 'Before starting Ambari Server, you must install the SQL Server JDBC driver.'

        # The values from options supersede the values from properties
        self.database_host = DBMSConfig._init_member_with_prop_default(
            options, "database_host", properties, self.dbPropKeys.server_key,
            "")
        try:
            if not self.database_host:
                self.database_host = options.default_database_host
            else:
                self.database_host = compress_backslashes(self.database_host)
        except:
            self.database_host = DATABASE_SERVER_SQLSERVER_DEFAULT
            pass
        self.database_port = DBMSConfig._init_member_with_prop_default(
            options, "database_port", properties, self.dbPropKeys.port_key,
            "1433")
        self.database_name = DBMSConfig._init_member_with_prop_default(
            options, "database_name", properties, self.dbPropKeys.db_name_key,
            configDefaults.DEFAULT_DB_NAME)

        self.use_windows_authentication = cbool(
            DBMSConfig._init_member_with_prop_default(
                options, "database_windows_auth", properties,
                self.dbAuthKeys.integrated_auth_key, False))
        self.database_username = DBMSConfig._init_member_with_prop_default(
            options, "database_username", properties,
            self.dbAuthKeys.user_name_key, DEFAULT_USERNAME)
        self.database_password = DBMSConfig._init_member_with_default(
            options, "database_password", "")
        if not self.database_password:
            self.database_password = DBMSConfig._read_password_from_properties(
                properties)

        self.database_url = self._build_sql_server_connection_string()

        self.persistence_property = None

        self.env_var_db_name = ""
        self.env_var_db_log_name = ""
        self.env_var_db_owner = ""

        self.init_script_file = ""
        self.drop_tables_script_file = ""
  def __init__(self, options, properties, storage_type):
    super(SQLServerConfig, self).__init__(options, properties, storage_type)

    """
    #Just load the defaults. The derived classes will be able to modify them later
    """
    self.dbms = DATABASE_DBMS_SQLSERVER
    self.driver_class_name = DATABASE_DRIVER_NAME_SQLSERVER

    self.JDBC_DRIVER_INSTALL_MSG = 'Before starting Ambari Server, you must install the SQL Server JDBC driver.'

    # The values from options supersede the values from properties
    self.database_host = DBMSConfig._init_member_with_prop_default(options, "database_host", properties, self.dbPropKeys.server_key, "")
    try:
      if not self.database_host:
        self.database_host = options.default_database_host
      else:
        self.database_host = compress_backslashes(self.database_host)
    except:
      self.database_host = DATABASE_SERVER_SQLSERVER_DEFAULT
      pass
    self.database_port = DBMSConfig._init_member_with_prop_default(options, "database_port",
                                                                   properties, self.dbPropKeys.port_key, "1433")
    self.database_name = DBMSConfig._init_member_with_prop_default(options, "database_name",
                                                                   properties, self.dbPropKeys.db_name_key, configDefaults.DEFAULT_DB_NAME)

    self.use_windows_authentication = cbool(DBMSConfig._init_member_with_prop_default(options, "database_windows_auth",
        properties, self.dbAuthKeys.integrated_auth_key, False))
    self.database_username = DBMSConfig._init_member_with_prop_default(options, "database_username",
                                                                       properties, self.dbAuthKeys.user_name_key, DEFAULT_USERNAME)
    self.database_password = DBMSConfig._init_member_with_default(options, "database_password", "")
    if not self.database_password:
      self.database_password = DBMSConfig._read_password_from_properties(properties)

    self.database_url = self._build_sql_server_connection_string()

    self.persistence_property = None

    self.env_var_db_name = ""
    self.env_var_db_log_name = ""
    self.env_var_db_owner = ""

    self.init_script_file = ""
    self.drop_tables_script_file = ""
Пример #6
0
def ams(name=None):
  import params
  if name == 'collector':
    if not check_windows_service_exists(params.ams_collector_win_service_name):
      Execute(format("cmd /C cd {ams_collector_home_dir} & ambari-metrics-collector.cmd setup"))

    Directory(params.ams_collector_conf_dir,
              owner=params.ams_user,
              create_parents = True
    )

    Directory(params.ams_checkpoint_dir,
              owner=params.ams_user,
              create_parents = True
    )

    XmlConfig("ams-site.xml",
              conf_dir=params.ams_collector_conf_dir,
              configurations=params.config['configurations']['ams-site'],
              configuration_attributes=params.config['configuration_attributes']['ams-site'],
              owner=params.ams_user,
    )

    merged_ams_hbase_site = {}
    merged_ams_hbase_site.update(params.config['configurations']['ams-hbase-site'])
    if params.security_enabled:
      merged_ams_hbase_site.update(params.config['configurations']['ams-hbase-security-site'])

    XmlConfig( "hbase-site.xml",
               conf_dir = params.ams_collector_conf_dir,
               configurations = merged_ams_hbase_site,
               configuration_attributes=params.config['configuration_attributes']['ams-hbase-site'],
               owner = params.ams_user,
    )

    if (params.log4j_props != None):
      File(os.path.join(params.ams_collector_conf_dir, "log4j.properties"),
           owner=params.ams_user,
           content=params.log4j_props
      )

    File(os.path.join(params.ams_collector_conf_dir, "ams-env.cmd"),
         owner=params.ams_user,
         content=InlineTemplate(params.ams_env_sh_template)
    )

    ServiceConfig(params.ams_collector_win_service_name,
                  action="change_user",
                  username = params.ams_user,
                  password = Script.get_password(params.ams_user))

    if not params.is_local_fs_rootdir:
      # Configuration needed to support NN HA
      XmlConfig("hdfs-site.xml",
            conf_dir=params.ams_collector_conf_dir,
            configurations=params.config['configurations']['hdfs-site'],
            configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
            owner=params.ams_user,
            group=params.user_group,
            mode=0644
      )

      XmlConfig("hdfs-site.xml",
            conf_dir=params.hbase_conf_dir,
            configurations=params.config['configurations']['hdfs-site'],
            configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
            owner=params.ams_user,
            group=params.user_group,
            mode=0644
      )

      XmlConfig("core-site.xml",
                conf_dir=params.ams_collector_conf_dir,
                configurations=params.config['configurations']['core-site'],
                configuration_attributes=params.config['configuration_attributes']['core-site'],
                owner=params.ams_user,
                group=params.user_group,
                mode=0644
      )

      XmlConfig("core-site.xml",
                conf_dir=params.hbase_conf_dir,
                configurations=params.config['configurations']['core-site'],
                configuration_attributes=params.config['configuration_attributes']['core-site'],
                owner=params.ams_user,
                group=params.user_group,
                mode=0644
      )

    else:
      ServiceConfig(params.ams_embedded_hbase_win_service_name,
                    action="change_user",
                    username = params.ams_user,
                    password = Script.get_password(params.ams_user))
      # creating symbolic links on ams jars to make them available to services
      links_pairs = [
        ("%COLLECTOR_HOME%\\hbase\\lib\\ambari-metrics-hadoop-sink-with-common.jar",
         "%SINK_HOME%\\hadoop-sink\\ambari-metrics-hadoop-sink-with-common-*.jar"),
        ]
      for link_pair in links_pairs:
        link, target = link_pair
        real_link = os.path.expandvars(link)
        target = compress_backslashes(glob.glob(os.path.expandvars(target))[0])
        if not os.path.exists(real_link):
          #TODO check the symlink destination too. Broken in Python 2.x on Windows.
          Execute('cmd /c mklink "{0}" "{1}"'.format(real_link, target))
    pass

  elif name == 'monitor':
    if not check_windows_service_exists(params.ams_monitor_win_service_name):
      Execute(format("cmd /C cd {ams_monitor_home_dir} & ambari-metrics-monitor.cmd setup"))

    # creating symbolic links on ams jars to make them available to services
    links_pairs = [
      ("%HADOOP_HOME%\\share\\hadoop\\common\\lib\\ambari-metrics-hadoop-sink-with-common.jar",
       "%SINK_HOME%\\hadoop-sink\\ambari-metrics-hadoop-sink-with-common-*.jar"),
      ("%HBASE_HOME%\\lib\\ambari-metrics-hadoop-sink-with-common.jar",
       "%SINK_HOME%\\hadoop-sink\\ambari-metrics-hadoop-sink-with-common-*.jar"),
    ]
    for link_pair in links_pairs:
      link, target = link_pair
      real_link = os.path.expandvars(link)
      target = compress_backslashes(glob.glob(os.path.expandvars(target))[0])
      if not os.path.exists(real_link):
        #TODO check the symlink destination too. Broken in Python 2.x on Windows.
        Execute('cmd /c mklink "{0}" "{1}"'.format(real_link, target))

    Directory(params.ams_monitor_conf_dir,
              owner=params.ams_user,
              create_parents = True
    )

    TemplateConfig(
      os.path.join(params.ams_monitor_conf_dir, "metric_monitor.ini"),
      owner=params.ams_user,
      template_tag=None
    )

    TemplateConfig(
      os.path.join(params.ams_monitor_conf_dir, "metric_groups.conf"),
      owner=params.ams_user,
      template_tag=None
    )

    ServiceConfig(params.ams_monitor_win_service_name,
                  action="change_user",
                  username = params.ams_user,
                  password = Script.get_password(params.ams_user))
Пример #7
0
def ams(name=None):
  import params
  if name == 'collector':
    if not check_windows_service_exists(params.ams_collector_win_service_name):
      Execute(format("cmd /C cd {ams_collector_home_dir} & ambari-metrics-collector.cmd setup"))

    Directory(params.ams_collector_conf_dir,
              owner=params.ams_user,
              recursive=True
    )

    Directory(params.ams_checkpoint_dir,
              owner=params.ams_user,
              recursive=True
    )

    XmlConfig("ams-site.xml",
              conf_dir=params.ams_collector_conf_dir,
              configurations=params.config['configurations']['ams-site'],
              configuration_attributes=params.config['configuration_attributes']['ams-site'],
              owner=params.ams_user,
    )

    merged_ams_hbase_site = {}
    merged_ams_hbase_site.update(params.config['configurations']['ams-hbase-site'])
    if params.security_enabled:
      merged_ams_hbase_site.update(params.config['configurations']['ams-hbase-security-site'])

    XmlConfig( "hbase-site.xml",
               conf_dir = params.ams_collector_conf_dir,
               configurations = merged_ams_hbase_site,
               configuration_attributes=params.config['configuration_attributes']['ams-hbase-site'],
               owner = params.ams_user,
    )

    if (params.log4j_props != None):
      File(os.path.join(params.ams_collector_conf_dir, "log4j.properties"),
           owner=params.ams_user,
           content=params.log4j_props
      )

    File(os.path.join(params.ams_collector_conf_dir, "ams-env.cmd"),
         owner=params.ams_user,
         content=InlineTemplate(params.ams_env_sh_template)
    )

    ServiceConfig(params.ams_collector_win_service_name,
                  action="change_user",
                  username = params.ams_user,
                  password = Script.get_password(params.ams_user))

    if params.is_hbase_distributed:
      # Configuration needed to support NN HA
      XmlConfig("hdfs-site.xml",
            conf_dir=params.ams_collector_conf_dir,
            configurations=params.config['configurations']['hdfs-site'],
            configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
            owner=params.ams_user,
            group=params.user_group,
            mode=0644
      )

      XmlConfig("hdfs-site.xml",
            conf_dir=params.hbase_conf_dir,
            configurations=params.config['configurations']['hdfs-site'],
            configuration_attributes=params.config['configuration_attributes']['hdfs-site'],
            owner=params.ams_user,
            group=params.user_group,
            mode=0644
      )

      XmlConfig("core-site.xml",
                conf_dir=params.ams_collector_conf_dir,
                configurations=params.config['configurations']['core-site'],
                configuration_attributes=params.config['configuration_attributes']['core-site'],
                owner=params.ams_user,
                group=params.user_group,
                mode=0644
      )

      XmlConfig("core-site.xml",
                conf_dir=params.hbase_conf_dir,
                configurations=params.config['configurations']['core-site'],
                configuration_attributes=params.config['configuration_attributes']['core-site'],
                owner=params.ams_user,
                group=params.user_group,
                mode=0644
      )

    else:
      ServiceConfig(params.ams_embedded_hbase_win_service_name,
                    action="change_user",
                    username = params.ams_user,
                    password = Script.get_password(params.ams_user))
      # creating symbolic links on ams jars to make them available to services
      links_pairs = [
        ("%COLLECTOR_HOME%\\hbase\\lib\\ambari-metrics-hadoop-sink-with-common.jar",
         "%SINK_HOME%\\hadoop-sink\\ambari-metrics-hadoop-sink-with-common-*.jar"),
        ]
      for link_pair in links_pairs:
        link, target = link_pair
        real_link = os.path.expandvars(link)
        target = compress_backslashes(glob.glob(os.path.expandvars(target))[0])
        if not os.path.exists(real_link):
          #TODO check the symlink destination too. Broken in Python 2.x on Windows.
          Execute('cmd /c mklink "{0}" "{1}"'.format(real_link, target))
    pass

  elif name == 'monitor':
    if not check_windows_service_exists(params.ams_monitor_win_service_name):
      Execute(format("cmd /C cd {ams_monitor_home_dir} & ambari-metrics-monitor.cmd setup"))

    # creating symbolic links on ams jars to make them available to services
    links_pairs = [
      ("%HADOOP_HOME%\\share\\hadoop\\common\\lib\\ambari-metrics-hadoop-sink-with-common.jar",
       "%SINK_HOME%\\hadoop-sink\\ambari-metrics-hadoop-sink-with-common-*.jar"),
      ("%HBASE_HOME%\\lib\\ambari-metrics-hadoop-sink-with-common.jar",
       "%SINK_HOME%\\hadoop-sink\\ambari-metrics-hadoop-sink-with-common-*.jar"),
    ]
    for link_pair in links_pairs:
      link, target = link_pair
      real_link = os.path.expandvars(link)
      target = compress_backslashes(glob.glob(os.path.expandvars(target))[0])
      if not os.path.exists(real_link):
        #TODO check the symlink destination too. Broken in Python 2.x on Windows.
        Execute('cmd /c mklink "{0}" "{1}"'.format(real_link, target))

    Directory(params.ams_monitor_conf_dir,
              owner=params.ams_user,
              recursive=True
    )

    TemplateConfig(
      os.path.join(params.ams_monitor_conf_dir, "metric_monitor.ini"),
      owner=params.ams_user,
      template_tag=None
    )

    TemplateConfig(
      os.path.join(params.ams_monitor_conf_dir, "metric_groups.conf"),
      owner=params.ams_user,
      template_tag=None
    )

    ServiceConfig(params.ams_monitor_win_service_name,
                  action="change_user",
                  username = params.ams_user,
                  password = Script.get_password(params.ams_user))