Пример #1
0
  def get_stack_version_before_packages_installed(self):
    """
    This works in a lazy way (calculates the version first time and stores it). 
    If you need to recalculate the version explicitly set:
    
    Script.stack_version_from_distro_select = None
    
    before the call. However takes a bit of time, so better to avoid.

    :return: stack version including the build number. e.g.: 2.3.4.0-1234.
    """
    from resource_management.libraries.functions import stack_select
    from ambari_commons.repo_manager import ManagerFactory

    # preferred way is to get the actual selected version of current component
    stack_select_package_name = stack_select.get_package_name()
    if not Script.stack_version_from_distro_select and stack_select_package_name:
      Script.stack_version_from_distro_select = stack_select.get_stack_version_before_install(stack_select_package_name)

    # If <stack-selector-tool> has not yet been done (situations like first install),
    # we can use <stack-selector-tool> version itself.
    # Wildcards cause a lot of troubles with installing packages, if the version contains wildcards we should try to specify it.
    if not Script.stack_version_from_distro_select or '*' in Script.stack_version_from_distro_select:
      # FIXME: this method is not reliable to get stack-selector-version
      # as if there are multiple versions installed with different <stack-selector-tool>, we won't detect the older one (if needed).
      pkg_provider = ManagerFactory.get()

      Script.stack_version_from_distro_select = pkg_provider.get_installed_package_version(
              stack_tools.get_stack_tool_package(stack_tools.STACK_SELECTOR_NAME))


    return Script.stack_version_from_distro_select
Пример #2
0
  def load_available_packages(self):
    from ambari_commons.repo_manager import ManagerFactory

    if self.available_packages_in_repos:
      return self.available_packages_in_repos

    config = self.get_config()

    service_name = config['serviceName'] if 'serviceName' in config else None
    repos = CommandRepository(config['repositoryFile'])
    repo_ids = [repo.repo_id for repo in repos.items]
    Logger.info("Command repositories: {0}".format(", ".join(repo_ids)))
    repos.items = [x for x in repos.items if (not x.applicable_services or service_name in x.applicable_services) ]
    applicable_repo_ids = [repo.repo_id for repo in repos.items]
    Logger.info("Applicable repositories: {0}".format(", ".join(applicable_repo_ids)))


    pkg_provider = ManagerFactory.get()
    try:
      self.available_packages_in_repos = pkg_provider.get_available_packages_in_repos(repos)
    except Exception as err:
      Logger.exception("Unable to load available packages")
      self.available_packages_in_repos = []

    return self.available_packages_in_repos
Пример #3
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)
Пример #4
0
  def load_available_packages(self):
    from ambari_commons.repo_manager import ManagerFactory

    if self.available_packages_in_repos:
      return self.available_packages_in_repos

    config = self.get_config()

    service_name = config['serviceName'] if 'serviceName' in config else None
    repos = CommandRepository(config['repositoryFile'])

    from resource_management.libraries.functions import lzo_utils

    # remove repos with 'GPL' tag when GPL license is not approved
    repo_tags_to_skip = set()
    if not lzo_utils.is_gpl_license_accepted():
      repo_tags_to_skip.add("GPL")
    repos.items = [r for r in repos.items if not (repo_tags_to_skip & r.tags)]

    repo_ids = [repo.repo_id for repo in repos.items]
    Logger.info("Command repositories: {0}".format(", ".join(repo_ids)))
    repos.items = [x for x in repos.items if (not x.applicable_services or service_name in x.applicable_services) ]
    applicable_repo_ids = [repo.repo_id for repo in repos.items]
    Logger.info("Applicable repositories: {0}".format(", ".join(applicable_repo_ids)))


    pkg_provider = ManagerFactory.get()
    try:
      self.available_packages_in_repos = pkg_provider.get_available_packages_in_repos(repos)
    except Exception as err:
      Logger.exception("Unable to load available packages")
      self.available_packages_in_repos = []

    return self.available_packages_in_repos
Пример #5
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)
Пример #6
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)
Пример #7
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)
Пример #8
0
    def actionexecute(self, env):
        config = Script.get_config()
        structured_output = {}
        version = config['commandParams']['version']
        self.stack_tool_package = stack_tools.get_stack_tool_package(
            stack_tools.STACK_SELECTOR_NAME)

        versions_to_remove = self.get_lower_versions(version)
        self.pkg_provider = ManagerFactory.get()

        for low_version in versions_to_remove:
            self.remove_stack_version(structured_output, low_version)
Пример #9
0
    def __init__(self):
        super(InstallPackages, self).__init__()

        self.repo_mgr = ManagerFactory.get()
        self.repo_files = {}
Пример #10
0
 def __init__(self):
   self.reportFileHandler = HostCheckReportFileHandler()
   self.pkg_provider = ManagerFactory.get()
Пример #11
0
 def __init__(self, *args, **kwargs):
   super(PackageProvider, self).__init__(*args, **kwargs)
   self._pkg_manager = ManagerFactory.get()