Ejemplo n.º 1
0
 def upgrade_logsearch_portal(self, env):
     pkg_provider = ManagerFactory.get()
     context = RepoCallContext()
     context.log_output = True
     pkg_provider.remove_package(
         'ambari-logsearch-portal', context, ignore_dependencies=True)
     pkg_provider.upgrade_package('ambari-logsearch-portal', context)
Ejemplo n.º 2
0
 def upgrade_solr_instance(self, env):
     pkg_provider = ManagerFactory.get()
     context = RepoCallContext()
     context.log_output = True
     pkg_provider.remove_package('ambari-infra-solr',
                                 context,
                                 ignore_dependencies=True)
     pkg_provider.upgrade_package('ambari-infra-solr', context)
Ejemplo n.º 3
0
 def __create_context(self):
   """
   Build RepoCallContext from Resource properties
   """
   return RepoCallContext(
     ignore_errors=self.resource.ignore_failures,
     use_repos=self.resource.use_repos,
     skip_repos=self.resource.skip_repos,
     log_output=True if self.resource.logoutput is None or self.resource.logoutput is True else False,
     retry_count=self.resource.retry_count,
     retry_sleep=self.resource.retry_sleep,
     retry_on_repo_unavailability=self.resource.retry_on_repo_unavailability,
     retry_on_locked=self.resource.retry_on_locked
   )
Ejemplo n.º 4
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)
Ejemplo n.º 5
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)
Ejemplo n.º 6
0
    def install_packages(self, package_list):
        """
    Actually install the packages using the package manager.
    :param package_list: List of package names to install
    :return: Returns 0 if no errors were found, and 1 otherwise.
    """
        ret_code = 0

        config = self.get_config()
        agent_stack_retry_on_unavailability = cbool(
            config['ambariLevelParams']['agent_stack_retry_on_unavailability'])
        agent_stack_retry_count = cint(
            config['ambariLevelParams']['agent_stack_retry_count'])

        # Install packages
        packages_were_checked = False
        packages_installed_before = []
        stack_selector_package = stack_tools.get_stack_tool_package(
            stack_tools.STACK_SELECTOR_NAME)

        try:
            # install the stack-selector; we need to supply the action as "upgrade" here since the normal
            # install command will skip if the package is already installed in the system.
            # This is required for non-versioned components, like stack-select, since each version of
            # the stack comes with one. Also, scope the install by repository since we need to pick a
            # specific repo that the stack-select tools are coming out of in case there are multiple
            # patches installed
            repositories = config['repositoryFile']['repositories']
            command_repos = CommandRepository(config['repositoryFile'])
            repository_ids = [
                repository['repoId'] for repository in repositories
            ]
            repos_to_use = {}
            for repo_id in repository_ids:
                if repo_id in self.repo_files:
                    repos_to_use[repo_id] = self.repo_files[repo_id]

            self.repo_mgr.upgrade_package(
                stack_selector_package,
                RepoCallContext(ignore_errors=False,
                                use_repos=repos_to_use,
                                retry_on_repo_unavailability=
                                agent_stack_retry_on_unavailability,
                                retry_count=agent_stack_retry_count))

            packages_installed_before = self.repo_mgr.installed_packages()
            packages_installed_before = [
                package[0] for package in packages_installed_before
            ]
            packages_were_checked = True
            filtered_package_list = self.filter_package_list(package_list)
            try:
                available_packages_in_repos = self.repo_mgr.get_available_packages_in_repos(
                    command_repos)
            except Exception:
                available_packages_in_repos = []

            installation_context = RepoCallContext(
                ignore_errors=False,
                retry_on_repo_unavailability=
                agent_stack_retry_on_unavailability,
                retry_count=agent_stack_retry_count)

            for package in filtered_package_list:
                name = self.get_package_from_available(
                    package['name'], available_packages_in_repos)

                # This enables upgrading non-versioned packages, despite the fact they exist.
                # Needed by 'mahout' which is non-version but have to be updated
                self.repo_mgr.upgrade_package(name, installation_context)
        except Exception as err:
            ret_code = 1
            Logger.logger.error(
                "Package Manager failed to install packages: {0}".format(
                    str(err)))

            # Remove already installed packages in case of fail
            if packages_were_checked and packages_installed_before:
                packages_installed_after = self.repo_mgr.installed_packages()
                packages_installed_after = [
                    package[0] for package in packages_installed_after
                ]
                packages_installed_before = set(packages_installed_before)
                new_packages_installed = [
                    package for package in packages_installed_after
                    if package not in packages_installed_before
                ]

                if OSCheck.is_ubuntu_family():
                    package_version_string = self.repository_version.replace(
                        '.', '-')
                else:
                    package_version_string = self.repository_version.replace(
                        '-', '_')
                    package_version_string = package_version_string.replace(
                        '.', '_')

                for package in new_packages_installed:
                    if package_version_string and (package_version_string
                                                   in package):
                        self.repo_mgr.remove_package(package,
                                                     RepoCallContext())

        if not self.repo_mgr.verify_dependencies():
            ret_code = 1
            Logger.logger.error("Failure while verifying dependencies")
            Logger.logger.error(
                "*******************************************************************************"
            )
            Logger.logger.error(
                "Manually verify and fix package dependencies and then re-run install_packages"
            )
            Logger.logger.error(
                "*******************************************************************************"
            )

        # Compute the actual version in order to save it in structured out
        try:
            if ret_code == 0:
                self.compute_actual_version()
            else:
                self.check_partial_install()
        except Fail as err:
            ret_code = 1
            Logger.logger.exception(
                "Failure while computing actual version. Error: {0}".format(
                    str(err)))
        return ret_code