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
def load_available_packages(self): if self.available_packages_in_repos: return self.available_packages_in_repos pkg_provider = get_provider("Package") try: self.available_packages_in_repos = pkg_provider.get_available_packages_in_repos(CommandRepository(self.get_config()['repositoryFile'])) except Exception as err: Logger.exception("Unable to load available packages") self.available_packages_in_repos = []
def install_packages(self, env): """ List of packages that are required< by service is received from the server as a command parameter. The method installs all packages from this list exclude_packages - list of regexes (possibly raw strings as well), the packages which match the regex won't be installed. NOTE: regexes don't have Python syntax, but simple package regexes which support only * and .* and ? """ config = self.get_config() if 'host_sys_prepped' in config['hostLevelParams']: # do not install anything on sys-prepped host if config['hostLevelParams']['host_sys_prepped'] is True: Logger.info("Node has all packages pre-installed. Skipping.") return pass try: package_list_str = config['hostLevelParams']['package_list'] agent_stack_retry_on_unavailability = bool(config['hostLevelParams']['agent_stack_retry_on_unavailability']) agent_stack_retry_count = int(config['hostLevelParams']['agent_stack_retry_count']) pkg_provider = get_provider("Package") try: available_packages_in_repos = pkg_provider.get_available_packages_in_repos(config['repositoryFile']['repositories']) except Exception as err: Logger.exception("Unable to load available packages") available_packages_in_repos = [] if isinstance(package_list_str, basestring) and len(package_list_str) > 0: package_list = json.loads(package_list_str) for package in package_list: if self.check_package_condition(package): name = self.get_package_from_available(package['name'], available_packages_in_repos) # HACK: On Windows, only install ambari-metrics packages using Choco Package Installer # TODO: Update this once choco packages for hadoop are created. This is because, service metainfo.xml support # <osFamily>any<osFamily> which would cause installation failure on Windows. if OSCheck.is_windows_family(): if "ambari-metrics" in name: Package(name) else: Package(name, retry_on_repo_unavailability=agent_stack_retry_on_unavailability, retry_count=agent_stack_retry_count) except KeyError: pass # No reason to worry if OSCheck.is_windows_family(): #TODO hacky install of windows msi, remove it or move to old(2.1) stack definition when component based install will be implemented hadoop_user = config["configurations"]["cluster-env"]["hadoop.user.name"] install_windows_msi(config['hostLevelParams']['jdk_location'], config["hostLevelParams"]["agentCacheDir"], ["hdp-2.3.0.0.winpkg.msi", "hdp-2.3.0.0.cab", "hdp-2.3.0.0-01.cab"], hadoop_user, self.get_password(hadoop_user), str(config['hostLevelParams']['stack_version'])) reload_windows_env()
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 = get_provider("Package") for low_version in versions_to_remove: self.remove_stack_version(structured_output, low_version)
def __init__(self): self.reportFileHandler = HostCheckReportFileHandler() self.pkg_provider = get_provider("Package")
def __init__(self): super(InstallPackages, self).__init__() self.pkg_provider = get_provider("Package") self.repo_files = {}