Exemple #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

    # 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 = get_provider("Package")

      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
Exemple #2
0
    def save_component_version_to_structured_out(self, command_name):
        """
    Saves the version of the component for this command to the structured out file. If the
    command is an install command and the repository is trusted, then it will use the version of
    the repository. Otherwise, it will consult the stack-select tool to read the symlink version.
    :param command_name: command name
    :return: None
    """
        from resource_management.libraries.functions.default import default
        from resource_management.libraries.functions import stack_select

        repository_resolved = default("repositoryFile/resolved", False)
        repository_version = default("repositoryFile/repoVersion", None)
        is_install_command = command_name is not None and command_name.lower(
        ) == "install"

        # start out with no version
        component_version = None

        # install command + trusted repo means use the repo version and don't consult stack-select
        # this is needed in cases where an existing symlink is on the system and stack-select can't
        # change it on installation (because it's scared to in order to support parallel installs)
        if is_install_command and repository_resolved and repository_version is not None:
            Logger.info("The repository with version {0} for this command has been marked as resolved."\
              " It will be used to report the version of the component which was installed".format(repository_version))

            component_version = repository_version

        stack_name = Script.get_stack_name()
        stack_select_package_name = stack_select.get_package_name()

        if stack_select_package_name and stack_name:
            # only query for the component version from stack-select if we can't trust the repository yet
            if component_version is None:
                component_version = get_component_version_from_symlink(
                    stack_name, stack_select_package_name)

            if component_version:
                self.put_structured_out({"version": component_version})

                # if repository_version_id is passed, pass it back with the version
                from resource_management.libraries.functions.default import default
                repo_version_id = default(
                    "/hostLevelParams/repository_version_id", None)
                if repo_version_id:
                    self.put_structured_out(
                        {"repository_version_id": repo_version_id})
            else:
                if not self.is_hook():
                    Logger.error(
                        "Component '{0}' did not advertise a version. This may indicate a problem with the component packaging."
                        .format(stack_select_package_name))
Exemple #3
0
  def pre_upgrade_restart(self, env, upgrade_type=None):
    import params
    env.set_params(params)

    # this function should not execute if the version can't be determined or
    # the stack does not support rolling upgrade
    if not (params.stack_version_formatted and check_stack_feature(StackFeature.ROLLING_UPGRADE, params.stack_version_formatted)):
      return

    stack_component = stack_select.get_package_name()

    Logger.info("Executing Accumulo Upgrade pre-restart for {0}".format(stack_component))
    stack_select.select_packages(params.version)
Exemple #4
0
  def save_component_version_to_structured_out(self):
    """
    :param stack_name: One of HDP, HDPWIN, PHD, BIGTOP.
    :return: Append the version number to the structured out.
    """
    from resource_management.libraries.functions import stack_select

    stack_name = Script.get_stack_name()
    stack_select_package_name = stack_select.get_package_name()

    if stack_select_package_name and stack_name:
      component_version = get_component_version(stack_name, stack_select_package_name)

      if component_version:
        self.put_structured_out({"version": component_version})

        # if repository_version_id is passed, pass it back with the version
        from resource_management.libraries.functions.default import default
        repo_version_id = default("/hostLevelParams/repository_version_id", None)
        if repo_version_id:
          self.put_structured_out({"repository_version_id": repo_version_id})
Exemple #5
0
  def save_component_version_to_structured_out(self):
    """
    :param stack_name: One of HDP, HDPWIN, PHD, BIGTOP.
    :return: Append the version number to the structured out.
    """
    from resource_management.libraries.functions import stack_select

    stack_name = Script.get_stack_name()
    stack_select_package_name = stack_select.get_package_name()

    if stack_select_package_name and stack_name:
      component_version = get_component_version(stack_name, stack_select_package_name)

      if component_version:
        self.put_structured_out({"version": component_version})

        # if repository_version_id is passed, pass it back with the version
        from resource_management.libraries.functions.default import default
        repo_version_id = default("/hostLevelParams/repository_version_id", None)
        if repo_version_id:
          self.put_structured_out({"repository_version_id": repo_version_id})
      else:
        if not self.is_hook():
          Logger.error("Component '{0}' did not advertise a version. This may indicate a problem with the component packaging.".format(stack_select_package_name))
Exemple #6
0
  def save_component_version_to_structured_out(self, command_name):
    """
    Saves the version of the component for this command to the structured out file. If the
    command is an install command and the repository is trusted, then it will use the version of
    the repository. Otherwise, it will consult the stack-select tool to read the symlink version.

    Under rare circumstances, a component may have a bug which prevents it from reporting a
    version back after being installed. This is most likely due to the stack-select tool not being
    invoked by the package's installer. In these rare cases, we try to see if the component
    should have reported a version and we try to fallback to the "<stack-select> versions" command.

    :param command_name: command name
    :return: None
    """
    from resource_management.libraries.functions.default import default
    from resource_management.libraries.functions import stack_select

    repository_resolved = default("repositoryFile/resolved", False)
    repository_version = default("repositoryFile/repoVersion", None)
    is_install_command = command_name is not None and command_name.lower() == "install"

    # start out with no version
    component_version = None

    # install command + trusted repo means use the repo version and don't consult stack-select
    # this is needed in cases where an existing symlink is on the system and stack-select can't
    # change it on installation (because it's scared to in order to support parallel installs)
    if is_install_command and repository_resolved and repository_version is not None:
      Logger.info("The repository with version {0} for this command has been marked as resolved."\
        " It will be used to report the version of the component which was installed".format(repository_version))

      component_version = repository_version

    stack_name = Script.get_stack_name()
    stack_select_package_name = stack_select.get_package_name()

    if stack_select_package_name and stack_name:
      # only query for the component version from stack-select if we can't trust the repository yet
      if component_version is None:
        component_version = version_select_util.get_component_version_from_symlink(stack_name, stack_select_package_name)

      # last ditch effort - should cover the edge case where the package failed to setup its
      # link and we have to try to see if <stack-select> can help
      if component_version is None:
        output, code, versions = stack_select.unsafe_get_stack_versions()
        if len(versions) == 1:
          component_version = versions[0]
          Logger.error("The '{0}' component did not advertise a version. This may indicate a problem with the component packaging. " \
                         "However, the stack-select tool was able to report a single version installed ({1}). " \
                         "This is the version that will be reported.".format(stack_select_package_name, component_version))

      if component_version:
        self.put_structured_out({"version": component_version})

        # if repository_version_id is passed, pass it back with the version
        from resource_management.libraries.functions.default import default
        repo_version_id = default("/repositoryFile/repoVersionId", None)
        if repo_version_id:
          self.put_structured_out({"repository_version_id": repo_version_id})
      else:
        if not self.is_hook():
          Logger.error("The '{0}' component did not advertise a version. This may indicate a problem with the component packaging.".format(stack_select_package_name))