Exemplo n.º 1
0
    def _fix_default_links_for_current(self):
        """
    If a prior version of Ambari did not correctly reverse the conf symlinks, then they would
    be put into a bad state when distributing a new stack. For example:

    /etc/component/conf (directory)
    <stack-root>/v1/component/conf -> /etc/component/conf

    When distributing v2, we'd detect the /etc/component/conf problems and would try to adjust it:
    /etc/component/conf -> <stack-root>/current/component/conf
    <stack-root>/v2/component/conf -> /etc/component/v2/0

    The problem is that v1 never gets changed (since the stack being distributed is v2), and
    we end up with a circular link:
    /etc/component/conf -> <stack-root>/current/component/conf
    <stack-root>/v1/component/conf -> /etc/component/conf

    :return: None
    """
        Logger.info(
            "Attempting to fix any configuration symlinks which are not in the correct state"
        )
        from resource_management.libraries.functions import stack_select
        restricted_packages = conf_select.get_restricted_packages()

        if 0 == len(restricted_packages):
            Logger.info(
                "There are no restricted conf-select packages for this installation"
            )
        else:
            Logger.info("Restricting conf-select packages to {0}".format(
                restricted_packages))

        for package_name, directories in conf_select.get_package_dirs(
        ).iteritems():
            Logger.info(
                "Attempting to fix the default conf links for {0}".format(
                    package_name))
            Logger.info(
                "The following directories will be fixed for {0}: {1}".format(
                    package_name, str(directories)))

            component_name = None
            for directory_struct in directories:
                if "component" in directory_struct:
                    component_name = directory_struct["component"]
            if component_name:
                stack_version = stack_select.get_stack_version_before_install(
                    component_name)

            if 0 == len(restricted_packages
                        ) or package_name in restricted_packages:
                if stack_version:
                    conf_select.convert_conf_directories_to_symlinks(
                        package_name, stack_version, directories)
                else:
                    Logger.warning(
                        "Unable to fix {0} since there is no known installed version for this component"
                        .format(package_name))
Exemplo n.º 2
0
    def _relink_configurations_with_conf_select(self, stack_id, stack_version):
        """
    Sets up the required structure for /etc/<component>/conf symlinks and <stack-root>/current
    configuration symlinks IFF the current stack is < HDP 2.3+ and the new stack is >= HDP 2.3

    stack_id:  stack id, ie HDP-2.3
    stack_version:  version to set, ie 2.3.0.0-1234
    """
        if stack_id is None:
            Logger.info(
                "Cannot create config links when stack_id is not defined")
            return

        args = stack_id.upper().split('-')
        if len(args) != 2:
            Logger.info(
                "Unrecognized stack id {0}, cannot create config links".format(
                    stack_id))
            return

        target_stack_version = args[1]
        if not (target_stack_version and check_stack_feature(
                StackFeature.CONFIG_VERSIONING, target_stack_version)):
            Logger.info("Configuration symlinks are not needed for {0}".format(
                stack_version))
            return

        # After upgrading hdf-select package from HDF-2.X to HDF-3.Y, we need to create this symlink
        if self.stack_name.upper() == "HDF" \
                and not sudo.path_exists("/usr/bin/conf-select") and sudo.path_exists("/usr/bin/hdfconf-select"):
            Link("/usr/bin/conf-select", to="/usr/bin/hdfconf-select")

        restricted_packages = conf_select.get_restricted_packages()

        if 0 == len(restricted_packages):
            Logger.info(
                "There are no restricted conf-select packages for this installation"
            )
        else:
            Logger.info("Restricting conf-select packages to {0}".format(
                restricted_packages))

        for package_name, directories in conf_select.get_package_dirs(
        ).iteritems():
            if 0 == len(restricted_packages
                        ) or package_name in restricted_packages:
                conf_select.convert_conf_directories_to_symlinks(
                    package_name, stack_version, directories)
Exemplo n.º 3
0
    def test_restrictions(self):

        Script.config.update({
            'roleParameters': {
                'cluster_version_summary': {
                    'services': {
                        'HIVE': {
                            'upgrade': True
                        }
                    }
                }
            }
        })

        restricted = conf_select.get_restricted_packages()
        self.assertTrue("hive" in restricted)
        self.assertTrue("hive-hcatalog" in restricted)
        self.assertTrue("hive2" in restricted)
        self.assertTrue("tez_hive2" in restricted)
        self.assertTrue("hadoop" not in restricted)