Esempio n. 1
0
 def upgrade_solr_client(self, env):
   pkg_provider = ManagerFactory.get()
   context = RepoCallContext()
   context.is_upgrade=True
   context.log_output = True
   context.use_repos = {}
   context.use_repos['ambari']=get_ambari_repo_file_full_name()
   pkg_provider.remove_package('ambari-infra-solr-client', context, ignore_dependencies=True)
   pkg_provider.upgrade_package('ambari-infra-solr-client', context)
Esempio n. 2
0
def get_json_url_from_repo_file():
    repo_file_path = get_ambari_repo_file_full_name()
    if os.path.exists(repo_file_path):
        with open(repo_file_path, 'r') as repo_file:
            for line in repo_file:
                line = line.rstrip()
                if "json.url" in line:
                    json_url_string = line.split("=", 1)[1].strip()
                    return json_url_string

    return None
Esempio n. 3
0
 def upgrade_logsearch_portal(self, env):
     pkg_provider = ManagerFactory.get()
     context = RepoCallContext()
     context.is_upgrade = True
     context.log_output = True
     context.use_repos = {}
     context.use_repos['ambari'] = get_ambari_repo_file_full_name()
     pkg_provider.remove_package('ambari-logsearch-portal',
                                 context,
                                 ignore_dependencies=True)
     pkg_provider.upgrade_package('ambari-logsearch-portal', context)
Esempio n. 4
0
    if(os.path.exists(jdk_file_path)):
      configDefaults.NR_ADJUST_OWNERSHIP_LIST.append((jdk_file_path, "644", "{0}", False))
  if jce_file_name:
    jce_file_path = os.path.abspath(os.path.join(resources_dir, jce_file_name))
    if(os.path.exists(jce_file_path)):
      configDefaults.NR_ADJUST_OWNERSHIP_LIST.append((jce_file_path, "644", "{0}", False))
  if java_home:
    jdk_security_dir = os.path.abspath(os.path.join(java_home, configDefaults.JDK_SECURITY_DIR))
    if(os.path.exists(jdk_security_dir)):
      configDefaults.NR_ADJUST_OWNERSHIP_LIST.append((jdk_security_dir, "644", "{0}", True))
      configDefaults.NR_ADJUST_OWNERSHIP_LIST.append((jdk_security_dir, "755", "{0}", False))

  # Grant read permissions to all users. This is required when a non-admin user is configured to setup ambari-server.
  # However, do not change ownership of the repo file to ambari user.

  ambari_repo_file = get_ambari_repo_file_full_name()

  if ambari_repo_file:
    if (os.path.exists(ambari_repo_file)):
        ambari_repo_file_owner = get_file_owner(ambari_repo_file)
        configDefaults.NR_ADJUST_OWNERSHIP_LIST.append((ambari_repo_file, "644", ambari_repo_file_owner, False))


  print "Adjusting ambari-server permissions and ownership..."

  for pack in configDefaults.NR_ADJUST_OWNERSHIP_LIST:
    file = pack[0]
    mod = pack[1]
    user = pack[2].format(ambari_user)
    recursive = pack[3]
    print_info_msg("Setting file permissions: {0} {1} {2} {3}".format(file, mod, user, recursive))
Esempio n. 5
0
def run_setup(argv=None):
    # Parse passed arguments
    retcode = parseArguments(argv)
    if (retcode["exitstatus"] != 0):
        return retcode

    (expected_hostname, passPhrase, hostname, user_run_as, projectVersion,
     server_port) = retcode["parsed_args"]

    retcode = checkServerReachability(hostname, server_port)
    if (retcode["exitstatus"] != 0):
        return retcode

    if projectVersion == "null" or projectVersion == "{ambariVersion}" or projectVersion == "":
        retcode = getOptimalVersion("")
    else:
        retcode = getOptimalVersion(projectVersion)

    if retcode["exitstatus"] == 0 and retcode["log"] != None and retcode[
            "log"] != "" and retcode["log"][0].strip() != "":
        availableProjectVersion = retcode["log"].strip()
        if not isAgentPackageAlreadyInstalled(availableProjectVersion):
            # Verify that the ambari repo file is available before trying to install ambari-agent
            ambari_repo_file = get_ambari_repo_file_full_name()
            if os.path.exists(ambari_repo_file):
                retcode = installAgent(availableProjectVersion)
                if (not retcode["exitstatus"] == 0):
                    return retcode
            else:
                return {
                    "exitstatus":
                    2,
                    "log":
                    "Ambari repo file not found: {0}".format(ambari_repo_file)
                }
                pass
    elif retcode["exitstatus"] == 1:
        if retcode["log"] != None and retcode["log"] != "" and retcode["log"][
                0].strip() != "":
            return {
                "exitstatus":
                1,
                "log":
                "Desired version (" + projectVersion +
                ") of ambari-agent package"
                " is not available."
                " Repository has following "
                "versions of ambari-agent:" + retcode["log"][0].strip()
            }
        else:
            # We are here because ambari-agent is not installed and version cannot be obtained from the repo file
            logmessage = "Desired version (" + projectVersion + ") of ambari-agent package is not available."
            ambari_repo_file = get_ambari_repo_file_full_name()
            if not os.path.exists(ambari_repo_file):
                logmessage = logmessage + " " + "Ambari repo file not found: {0}".format(
                    ambari_repo_file)
            return {"exitstatus": retcode["exitstatus"], "log": logmessage}
            pass
    else:
        return retcode

    retcode = configureAgent(hostname, user_run_as)
    if retcode['exitstatus'] != 0:
        return retcode
    return runAgent(passPhrase, expected_hostname, user_run_as, verbose)