Beispiel #1
0
    def get_datasources(self):
        """
        Discover JDBC datasource information from the domain.
        :return: model name for the dictionary and the dictionary containing the datasources information
        """
        _method_name = 'get_datasources'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        result = OrderedDict()
        model_top_folder_name = model_constants.JDBC_SYSTEM_RESOURCE
        model_second_folder = model_constants.JDBC_RESOURCE
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        datasources = self._find_names_in_folder(location)
        if datasources is not None:
            _logger.info('WLSDPLY-06340', len(datasources), class_name=_class_name, method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for datasource in datasources:
                _logger.info('WLSDPLY-06341', datasource, class_name=_class_name, method_name=_method_name)
                result[datasource] = OrderedDict()
                location.add_name_token(name_token, datasource)
                self._populate_model_parameters(result[datasource], location)

                location.append_location(model_second_folder)
                if self.wlst_cd(self._alias_helper.get_wlst_attributes_path(location), location):
                    result[datasource][model_second_folder] = OrderedDict()
                    resource_result = result[datasource][model_second_folder]
                    self._populate_model_parameters(resource_result, location)
                    self._discover_subfolders(resource_result, location)
                    location.remove_name_token(name_token)
                    location.pop_location()
        _logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
        return model_top_folder_name, result
Beispiel #2
0
    def get_clusters(self):
        """
        Discover the Clusters in the domain.
        :return:  model name for the dictionary and the dictionary containing the cluster information
        """
        _method_name = 'get_clusters'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        result = OrderedDict()
        model_top_folder_name = model_constants.CLUSTER
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        clusters = self._find_names_in_folder(location)
        if clusters is not None:
            _logger.info('WLSDPLY-06601',
                         len(clusters),
                         class_name=_class_name,
                         method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for cluster in clusters:
                _logger.info('WLSDPLY-06602',
                             cluster,
                             class_name=_class_name,
                             method_name=_method_name)
                location.add_name_token(name_token, cluster)
                result[cluster] = OrderedDict()
                self._populate_model_parameters(result[cluster], location)
                self._discover_subfolders(result[cluster], location)
                location.remove_name_token(name_token)
            location.pop_location()

        _logger.exiting(class_name=_class_name,
                        method_name=_method_name,
                        result=model_top_folder_name)
        return model_top_folder_name, result
 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
    def __get_domain_location(self, location):
        """
        Returns a copy of the specified location with all folders removed, but tokens intact.
        :param location: the location to be examined
        :return: the domain location
        """
        _method_name = '__get_domain_location'
        self.__logger.entering(str(location), class_name=self._class_name, method_name=_method_name)

        location = LocationContext(location)
        while len(location.get_model_folders()) > 0:
            location.pop_location()
        return location
    def __get_parent_location(self, location, folder_name):
        """
        Searches the specified location for the specified folder name, and returns the corresponding location.
        :param location: the location to be examined
        :param folder_name: the folder name to find
        :return: the parent location
        :raises BundleAwareException of the specified type: if the folder is not found in the location folders list
        """
        method_name = '__get_parent_location'

        try:
            location = LocationContext(location)
            resource_index = location.get_model_folders().index(folder_name)
            while len(location.get_model_folders()) > resource_index + 1:
                location.pop_location()
        except:
            # index throws a ValueError if the item is not in the list...
            ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-19205', folder_name, str(location))
            self.__logger.throwing(class_name=self._class_name, method_name=method_name, error=ex)
            raise ex
        return location
    def set_attributes(self, location, model_nodes, excludes=None):
        """
        Override this method to set the Name attribute in JDBCResource folder for online deployment.
        Bug 27091687 requires this value to be explicitly set.
        :param location: the location to set attributes
        :param model_nodes: model nodes containing attributes to be set
        :param excludes: names of attributes to avoid setting
        """
        type_name = self.get_location_type(location)
        if type_name == JDBC_RESOURCE and self.wlst_mode == WlstModes.ONLINE:
            existing_name = self.wlst_helper.get('Name')
            if existing_name is None:
                parent_location = LocationContext(location)
                parent_location.pop_location()
                data_source_token = self.aliases.get_name_token(
                    parent_location)
                data_source_name = location.get_name_for_token(
                    data_source_token)
                self.wlst_helper.set('Name', data_source_name)
            # continue

        Deployer.set_attributes(self, location, model_nodes, excludes)
        return
Beispiel #7
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