def get_folder_map(self, model_folder_list, base_location):
     location = LocationContext(base_location)
     folder_map = dict()
     for name in model_folder_list:
         if name is None:
             self.__logger.warning('have a problem with the list at location {0} : {1}', location.get_folder_path(),
                             model_folder_list)
         else:
             location.append_location(name)
             self.__logger.finer('Checking the folder {0} for flattened and type', location.get_folder_path())
             flattened_info = None
             print '******* ', location.get_folder_path()
             if not location.get_folder_path().startswith('/NMProperties') and not location.get_folder_path() == '/':
                 flattened_info = self.__aliases.get_wlst_flattened_folder_info(location)
             if flattened_info is not None:
                 # make a message
                 self.__logger.fine('The mbean type {0} at location {1} is a flattened folder ', name,
                              location.get_folder_path())
                 wlst_mbean = flattened_info.get_mbean_type()
             else:
                 wlst_mbean = self.__aliases.get_wlst_mbean_type(location)
             if wlst_mbean is None:
                 # create a message for this
                 self.__logger.finer('Mbean folder {0} at location {1} is not implemented in aliases for version {2}}',
                               name, location.get_folder_path(), self.__model_context.get_target_wls_version())
             else:
                 folder_map[wlst_mbean] = name
             location.pop_location()
     return folder_map
Пример #2
0
    def __print_top_level_usage(self, top_level_key, valid_section_folder_keys,
                                control_option):
        """
        Prints out the usage for a section of a model, when just the section_name[:[/}} is provided

        :param top_level_key: The name of one of the model sections
        :param valid_section_folder_keys: Python list of the valid model section names
        :param control_option: A command-line switch that controls what is output to STDOUT
        :return:
        """

        _method_name = '__print_top_level_usage'

        self._logger.finest('1 top_level_key={0}',
                            top_level_key,
                            class_name=_class_name,
                            method_name=_method_name)

        location_path = '%s:' % top_level_key
        self._logger.finest('1 location_path={0}',
                            location_path,
                            class_name=_class_name,
                            method_name=_method_name)

        model_section = validation_utils.format_message(
            'WLSDPLY-05104', location_path)

        # Print 'Section: <model_section>' label and field
        validation_utils.print_indent(model_section, 0)

        if control_option == self.ControlOptions.ATTRIBUTES_ONLY:
            # Doing an ATTRIBUTES_ONLY on a top level key is a no-op
            return

        validation_location = LocationContext()

        if control_option == self.ControlOptions.FOLDERS_ONLY:
            validation_utils.print_blank_lines()
            validation_utils.print_indent(
                validation_utils.format_message('WLSDPLY-05105'), 1)
            valid_section_folder_keys.sort()

        for section_folder_key in valid_section_folder_keys:
            if control_option == self.ControlOptions.FOLDERS_ONLY:
                validation_utils.print_indent(section_folder_key, 2)

            elif control_option == self.ControlOptions.RECURSIVE:
                validation_location.append_location(section_folder_key)

                name_token = self._alias_helper.get_name_token(
                    validation_location)
                if name_token is not None:
                    validation_location.add_name_token(
                        name_token, '%s-0' % section_folder_key)

                self._logger.finest('1 validation_location={0}',
                                    validation_location,
                                    class_name=_class_name,
                                    method_name=_method_name)

                location_path = '%s:%s' % (
                    top_level_key, validation_location.get_folder_path())
                model_path = validation_utils.format_message(
                    'WLSDPLY-05103', location_path)

                validation_utils.print_blank_lines()
                validation_utils.print_indent(model_path, 0)
                validation_utils.print_blank_lines()

                self.__print_folders_usage(validation_location, control_option,
                                           1)
                validation_location.pop_location()
        return
    def __print_top_level_usage(self, top_level_key, valid_section_folder_keys, control_option):
        """
        Prints out the usage for a section of a model, when just the section_name[:[/}} is provided

        :param top_level_key: The name of one of the model sections
        :param valid_section_folder_keys: Python list of the valid model section names
        :param control_option: A command-line switch that controls what is output to STDOUT
        :return:
        """

        _method_name = '__print_top_level_usage'

        self._logger.finest('1 top_level_key={0}', top_level_key,
                            class_name=_class_name, method_name=_method_name)

        location_path = '%s:' % top_level_key
        self._logger.finest('1 location_path={0}', location_path,
                            class_name=_class_name, method_name=_method_name)

        model_section = validation_utils.format_message('WLSDPLY-05104', location_path)

        # Print 'Section: <model_section>' label and field
        validation_utils.print_indent(model_section, 0)
        validation_utils.print_blank_lines()

        validation_location = LocationContext()

        # topology level has attributes, use empty location
        if top_level_key == model_constants.TOPOLOGY:
            self.__print_attributes_usage(validation_location, 1)

        # domainInfo level has attributes, use special location
        if top_level_key == model_constants.DOMAIN_INFO:
            info_location = LocationContext().append_location("DomainInfo")
            self.__print_attributes_usage(info_location, 1)

        if control_option == self.ControlOptions.FOLDERS_ONLY:
            validation_utils.print_indent(validation_utils.format_message('WLSDPLY-05105'), 1)
            valid_section_folder_keys.sort()

        for section_folder_key in valid_section_folder_keys:
            if control_option == self.ControlOptions.FOLDERS_ONLY:
                validation_utils.print_indent(section_folder_key, 2)

            elif control_option == self.ControlOptions.RECURSIVE:
                validation_location.append_location(section_folder_key)

                name_token = self._alias_helper.get_name_token(validation_location)
                if name_token is not None:
                    validation_location.add_name_token(name_token, '%s-0' % section_folder_key)

                self._logger.finest('1 validation_location={0}', validation_location,
                                    class_name=_class_name, method_name=_method_name)

                location_path = '%s:%s' % (top_level_key, validation_location.get_folder_path())
                model_path = validation_utils.format_message('WLSDPLY-05103', location_path)

                validation_utils.print_blank_lines()
                validation_utils.print_indent(model_path, 0)
                validation_utils.print_blank_lines()

                self.__print_folders_usage(validation_location, control_option, 1)
                validation_location.pop_location()
        return