def _get_log_filters(self):
        """
        Discover the log filters that are used in the different types of Logs in the domain.
        :return: model name for the folder: dictionary containing the discovered log filters
        """
        _method_name = '_get_log_filters'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        model_top_folder_name = model_constants.LOG_FILTER
        result = OrderedDict()
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        filters = self._find_names_in_folder(location)
        if filters is not None:
            _logger.info('WLSDPLY-06628', len(filters), class_name=_class_name, method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for logfilter in filters:
                _logger.info('WLSDPLY-06629', logfilter, class_name=_class_name, method_name=_method_name)
                location.add_name_token(name_token, logfilter)
                result[logfilter] = OrderedDict()
                self._populate_model_parameters(result[logfilter], location)
                location.remove_name_token(name_token)

        _logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
        return model_top_folder_name, result
    def _get_reliable_delivery_policies(self):
        """
        Discover the reliable delivery policies that are used for soap message delivery in the servers.
        :return: model name for the folder: dictionary containing the discovered ws reliable delivery policies
        """
        _method_name = '_get_reliable_delivery_policies'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        model_top_folder_name = model_constants.WS_RELIABLE_DELIVERY_POLICY
        result = OrderedDict()
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        policies = self._find_names_in_folder(location)
        if policies is not None:
            _logger.info('WLSDPLY-06630', len(policies), class_name=_class_name, method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for policy in policies:
                _logger.info('WLSDPLY-06631', policy, class_name=_class_name, method_name=_method_name)
                location.add_name_token(name_token, policy)
                result[policy] = OrderedDict()
                self._populate_model_parameters(result[policy], location)
                location.remove_name_token(name_token)

        _logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
        return model_top_folder_name, result
Пример #3
0
 def get_wldf_system_resources(self):
     """
     Discover each WLDF system resource in the domain.
     :return: model name for the WLDF system resource:dictionary containing the discovered WLDF system resources
     """
     _method_name = 'get_wldf_system_resources'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.WLDF_SYSTEM_RESOURCE
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     wldf_resources = self._find_names_in_folder(location)
     if wldf_resources is not None:
         _logger.info('WLSDPLY-06357', len(wldf_resources), class_name=_class_name, method_name=_method_name)
         name_token = self._alias_helper.get_name_token(location)
         for wldf_resource in wldf_resources:
             _logger.info('WLSDPLY-06358', wldf_resource, class_name=_class_name, method_name=_method_name)
             location.add_name_token(name_token, wldf_resource)
             result[wldf_resource] = OrderedDict()
             self._populate_model_parameters(result[wldf_resource], location)
             self._discover_subfolders(result[wldf_resource], location)
             location.remove_name_token(name_token)
     _logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
     return model_top_folder_name, result
 def get_server_templates(self):
     """
     Discover Server Templates in the domain.
     :return: model name for the dictionary and the dictionary containing the server template information
     """
     _method_name = 'get_server_templates'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.SERVER_TEMPLATE
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     templates = self._find_names_in_folder(location)
     if templates is not None:
         _logger.info('WLSDPLY-06605', len(templates), class_name=_class_name, method_name=_method_name)
         name_token = self._alias_helper.get_name_token(location)
         for template in templates:
             _logger.info('WLSDPLY-06606', template, class_name=_class_name, method_name=_method_name)
             location.add_name_token(name_token, template)
             result[template] = OrderedDict()
             self._populate_model_parameters(result[template], location)
             self._discover_subfolders(result[template], location)
             location.remove_name_token(name_token)
     _logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
     return model_top_folder_name, result
Пример #5
0
 def get_file_stores(self):
     """
     Discover the file stores used for weblogic persistence
     :return: model folder name: dictionary with the discovered file stores
     """
     _method_name = 'get_file_stores'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.FILE_STORE
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     file_stores = self._find_names_in_folder(location)
     if file_stores is not None:
         _logger.info('WLSDPLY-06346', len(file_stores), class_name=_class_name, method_name=_method_name)
         name_token = self._alias_helper.get_name_token(location)
         for file_store in file_stores:
             _logger.info('WLSDPLY-06347', file_store, class_name=_class_name, method_name=_method_name)
             result[file_store] = OrderedDict()
             location.add_name_token(name_token, file_store)
             self._populate_model_parameters(result[file_store], location)
             self.archive_file_store_directory(file_store, result[file_store])
             location.remove_name_token(name_token)
     _logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
     return model_top_folder_name, result
Пример #6
0
 def get_jdbc_stores(self):
     """
     Discover the JDBC stores used for weblogic persistence
     :return: model file name: dictionary containing discovered JDBC stores
     """
     _method_name = 'get_jdbc_stores'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.JDBC_STORE
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     jdbc_stores = self._find_names_in_folder(location)
     if jdbc_stores is not None:
         _logger.info('WLSDPLY-06350', len(jdbc_stores), class_name=_class_name, method_name=_method_name)
         name_token = self._alias_helper.get_name_token(location)
         for jdbc_store in jdbc_stores:
             _logger.info('WLSDPLY-06351', jdbc_store, class_name=_class_name, method_name=_method_name)
             result[jdbc_store] = OrderedDict()
             location.add_name_token(name_token, jdbc_store)
             self._populate_model_parameters(result[jdbc_store], location)
             self.archive_jdbc_create_script(jdbc_store, result[jdbc_store])
             location.remove_name_token(name_token)
     _logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
     return model_top_folder_name, result
Пример #7
0
 def get_resource_management(self):
     """
     Discover the global resource management and the domain resource managers.
     :return: model name for resource management:dictionary containing discovered resource management
     """
     _method_name = 'get_resource_management'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.RESOURCE_MANAGEMENT
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     resource = self._find_singleton_name_in_folder(location)
     if resource is not None:
         _logger.info('WLSDPLY-06708',
                      class_name=_class_name,
                      method_name=_method_name)
         location.add_name_token(
             self._alias_helper.get_name_token(location), resource)
         self._populate_model_parameters(result, location)
         self._discover_subfolders(result, location)
     _logger.exiting(class_name=_class_name,
                     method_name=_method_name,
                     result=result)
     return model_top_folder_name, result
Пример #8
0
 def get_saf_agents(self):
     """
     Discover the SAF agents from the domain.
     :return: model folder name: dictionary containing the discovered SAF agents
     """
     _method_name = 'get_saf_agents'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.SAF_AGENT
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     agents = self._find_names_in_folder(location)
     if agents is not None:
         _logger.info('WLSDPLY-06472', len(agents), class_name=_class_name, method_name=_method_name)
         name_token = self._alias_helper.get_name_token(location)
         for agent in agents:
             _logger.info('WLSDPLY-06473', agent, class_name=_class_name, method_name=_method_name)
             location.add_name_token(name_token, agent)
             result[agent] = OrderedDict()
             self._populate_model_parameters(result[agent], location)
             self._discover_subfolders(result[agent], location)
             location.remove_name_token(name_token)
     _logger.exiting(class_name=_class_name, method_name=_method_name, result=result)
     return model_top_folder_name, result
Пример #9
0
 def testWithSegmentInDictionary(self):
     expected = dict()
     short_name = self._helper.get_folder_short_name(
         LocationContext().append_location('MailSession'))
     expected[
         short_name +
         '.MailSession-0.Properties--SmtpHost'] = 'stbeehive.oracle.com'
     expected[
         short_name +
         '.MyMailSession.Properties--SmtpHost'] = 'stbeehive.oracle.com'
     expected[
         short_name +
         '.MailSession-0.Properties--ImapHost'] = 'stbeehive.oracle.com'
     expected[
         short_name +
         '.MyMailSession.Properties--ImapHost'] = 'stbeehive.oracle.com'
     replacement_dict = dict()
     replacement_dict['MailSession.Properties'] = dict()
     list_entry1 = dict()
     list_entry1[variable_injector.REGEXP_PATTERN] = 'mail.smtp.host'
     list_entry1[variable_injector.REGEXP_SUFFIX] = 'SmtpHost'
     list_entry2 = dict()
     list_entry2[variable_injector.REGEXP_PATTERN] = 'mail.imap.host'
     list_entry2[variable_injector.REGEXP_SUFFIX] = 'ImapHost'
     replacement_dict['MailSession.Properties'][
         variable_injector.REGEXP] = [list_entry1, list_entry2]
     actual = self._helper.inject_variables(replacement_dict)
     self._compare_to_expected_dictionary(expected, actual)
     self.assertEqual(
         '@@PROP:' + short_name + '.MyMailSession.Properties--SmtpHost@@',
         self._model['resources']['MailSession']['MyMailSession']
         ['Properties']['mail.smtp.host'])
     self.assertEqual(
         '@@PROP:' + short_name + '.MyMailSession.Properties--ImapHost@@',
         self._model['resources']['MailSession']['MyMailSession']
         ['Properties']['mail.imap.host'])
Пример #10
0
    def clear_jdbc_placeholder_targeting(self, jdbc_names):
        """
        Remove any targets for the JDBC resources in the specified list of names.
        Targets may have been inadvertently assigned when clusters were added after JDBC placeholders.
        :param jdbc_names: names of placeholders to clear
        """
        _method_name = 'clear_jdbc_placeholder_targeting'
        resource_location = LocationContext().append_location(
            JDBC_SYSTEM_RESOURCE)
        token = self.alias_helper.get_name_token(resource_location)

        for name in jdbc_names:
            self.logger.info('WLSDPLY-19404',
                             JDBC_SYSTEM_RESOURCE,
                             name,
                             class_name=self.__class_name,
                             method_name=_method_name)

            resource_location.add_name_token(token, name)
            wlst_path = self.alias_helper.get_wlst_attributes_path(
                resource_location)
            if self.wlst_helper.path_exists(wlst_path):
                mbean = self.wlst_helper.get_mbean_for_wlst_path(wlst_path)
                mbean.setTargets(None)
    def create_placeholder_named_elements(self, location, model_type,
                                          model_nodes):
        """
        Create a placeholder entry for each element in the specified named element nodes.
        This is necessary when there can be circular references with other elements.
        :param location: the location for the nodes to be added
        :param model_type: the type of the specified model nodes
        :param model_nodes: the model nodes
        """
        _method_name = 'create_placeholder_named_elements'
        original_location = self.wlst_helper.get_pwd()
        resource_location = LocationContext(location).append_location(
            model_type)

        if self.alias_helper.get_wlst_mbean_type(
                resource_location) is not None:
            existing_names = deployer_utils.get_existing_object_list(
                resource_location, self.alias_helper)

            name_nodes = dictionary_utils.get_dictionary_element(
                model_nodes, model_type)
            for name in name_nodes:
                if name not in existing_names:
                    self.logger.info('WLSDPLY-19403',
                                     model_type,
                                     name,
                                     class_name=self.__class_name,
                                     method_name=_method_name)

                    token = self.alias_helper.get_name_token(resource_location)
                    resource_location.add_name_token(token, name)
                    deployer_utils.create_and_cd(resource_location,
                                                 existing_names,
                                                 self.alias_helper)

        self.wlst_helper.cd(original_location)
    def create_placeholder_jdbc_resources(self, resources):
        """
        Create a placeholder JDBC resource for each name in the resources section.
        This is necessary because cluster attributes may reference JDBC resources.
        :param resources: the resource model nodes
        """
        _method_name = 'create_placeholder_jdbc_resources'
        original_location = self.wlst_helper.get_pwd()
        resource_location = LocationContext().append_location(JDBC_SYSTEM_RESOURCE)

        if self.alias_helper.get_wlst_mbean_type(resource_location) is not None:
            existing_names = deployer_utils.get_existing_object_list(resource_location, self.alias_helper)

            jdbc_nodes = dictionary_utils.get_dictionary_element(resources, JDBC_SYSTEM_RESOURCE)
            for jdbc_name in jdbc_nodes:
                if jdbc_name not in existing_names:
                    self.logger.info('WLSDPLY-19401', jdbc_name, class_name=self.__class_name,
                                     method_name=_method_name)

                    jdbc_token = self.alias_helper.get_name_token(resource_location)
                    resource_location.add_name_token(jdbc_token, jdbc_name)
                    deployer_utils.create_and_cd(resource_location, existing_names, self.alias_helper)

        self.wlst_helper.cd(original_location)
    def create_placeholder_server_templates(self, topology):
        """
        Create a placeholder server template for each name in the topology.
        This is necessary because there is a circular dependency between clusters and server templates.
        :param topology: the topology model nodes
        """
        _method_name = 'create_placeholder_server_templates'
        original_location = self.wlst_helper.get_pwd()
        template_location = LocationContext().append_location(SERVER_TEMPLATE)

        if self.alias_helper.get_wlst_mbean_type(template_location) is not None:
            existing_names = deployer_utils.get_existing_object_list(template_location, self.alias_helper)

            template_nodes = dictionary_utils.get_dictionary_element(topology, SERVER_TEMPLATE)
            for template_name in template_nodes:
                if template_name not in existing_names:
                    self.logger.info('WLSDPLY-19400', template_name, class_name=self.__class_name,
                                     method_name=_method_name)

                    template_token = self.alias_helper.get_name_token(template_location)
                    template_location.add_name_token(template_token, template_name)
                    deployer_utils.create_and_cd(template_location, existing_names, self.alias_helper)

        self.wlst_helper.cd(original_location)
Пример #14
0
    def get_shared_libraries(self):
        """
        Discover the shared library deployment information from the domain. Collect any shared library binaries into
        the discovered archive file. If the shared library cannot be collected into the archive, the shared library
        source path will be removed from the model and the shared library un-targeted.
        :return: model name for the dictionary and the dictionary containing the shared library information
        """
        _method_name = 'get_shared_libraries'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        result = OrderedDict()
        model_top_folder_name = model_constants.LIBRARY
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        libraries = self._find_names_in_folder(location)
        if libraries:
            _logger.info('WLSDPLY-06381',
                         len(libraries),
                         class_name=_class_name,
                         method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for library in libraries:
                _logger.info('WLSDPLY-06382',
                             library,
                             class_name=_class_name,
                             method_name=_method_name)
                location.add_name_token(name_token, library)
                result[library] = OrderedDict()
                self._populate_model_parameters(result[library], location)
                self._add_shared_libraries_to_archive(library, result[library])
                self._discover_subfolders(result[library], location)
                location.remove_name_token(name_token)

        _logger.exiting(class_name=_class_name,
                        method_name=_method_name,
                        result=model_top_folder_name)
        return model_top_folder_name, result
Пример #15
0
 def get_foreign_jndi_providers(self):
     """
     Discover Foreign JNDI providers from the domain.
     :return: model name for the dictionary and the dictionary containing the foreign JNDI provider information
     """
     _method_name = 'get_foreign_jndi_providers'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.FOREIGN_JNDI_PROVIDER
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     providers = self._find_names_in_folder(location)
     if providers is not None:
         _logger.info('WLSDPLY-06342', len(providers), class_name=_class_name, method_name=_method_name)
         name_token = self._alias_helper.get_name_token(location)
         for provider in providers:
             _logger.info('WLSDPLY-06343', provider, class_name=_class_name, method_name=_method_name)
             location.add_name_token(name_token, provider)
             result[provider] = OrderedDict()
             self._populate_model_parameters(result[provider], location)
             self._discover_subfolders(result[provider], location)
             location.remove_name_token(name_token)
     _logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
     return model_top_folder_name, result
    def _get_xml_registries(self):
        """
        Discover the XML registries that are used by the servers.
        :return: model name for the folder: dictionary containing the discovered log xml registries
        """
        _method_name = '_get_xml_registries'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        model_top_folder_name = model_constants.XML_REGISTRY
        result = OrderedDict()
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        registries = self._find_names_in_folder(location)
        if registries is not None:
            _logger.info('WLSDPLY-06634', len(registries), class_name=_class_name, method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for registry in registries:
                _logger.info('WLSDPLY-06635', registry, class_name=_class_name, method_name=_method_name)
                location.add_name_token(name_token, registry)
                result[registry] = OrderedDict()
                self._populate_model_parameters(result[registry], location)
                location.remove_name_token(name_token)

        _logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
        return model_top_folder_name, result
    def _get_xml_entity_caches(self):
        """
        Discover the XML entity caches that are used by the servers in the domain.
        :return: model name for the folder: dictionary containing the discovered xml entity caches
        """
        _method_name = '_get_xml_entity_caches'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        model_top_folder_name = model_constants.XML_ENTITY_CACHE
        result = OrderedDict()
        location = LocationContext(self._base_location)
        location.append_location(model_top_folder_name)
        caches = self._find_names_in_folder(location)
        if caches is not None:
            _logger.info('WLSDPLY-06632', len(caches), class_name=_class_name, method_name=_method_name)
            name_token = self._alias_helper.get_name_token(location)
            for cache in caches:
                _logger.info('WLSDPLY-06633', cache, class_name=_class_name, method_name=_method_name)
                location.add_name_token(name_token, cache)
                result[cache] = OrderedDict()
                self._populate_model_parameters(result[cache], location)
                location.remove_name_token(name_token)

        _logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
        return model_top_folder_name, result
Пример #18
0
 def get_embedded_ldap_configuration(self):
     """
     Get the Embedded LDAP server configuration for the domain and only return the configuration
     when there are non-default settings other than the credential value.
     :return: name for the model:dictionary containing the discovered Embedded LDAP configuration
     """
     _method_name = 'get_embedded_ldap_configuration'
     _logger.entering(class_name=_class_name, method_name=_method_name)
     result = OrderedDict()
     model_top_folder_name = model_constants.EMBEDDED_LDAP
     location = LocationContext(self._base_location)
     location.append_location(model_top_folder_name)
     embedded_ldap_configuration = self._find_singleton_name_in_folder(
         location)
     if embedded_ldap_configuration is not None:
         location.add_name_token(
             self._alias_helper.get_name_token(location),
             embedded_ldap_configuration)
         self._populate_model_parameters(result, location)
         # IFF credential is the only attribute, skip adding the Embedded LDAP server configuration
         if len(result
                ) == 1 and model_constants.CREDENTIAL_ENCRYPTED in result:
             injector = self._get_variable_injector()
             if injector is not None:
                 injector.remove_from_cache(
                     location, model_constants.CREDENTIAL_ENCRYPTED)
             result = OrderedDict()
             _logger.info('WLSDPLY-06639',
                          class_name=_class_name,
                          method_name=_method_name)
         else:
             _logger.info('WLSDPLY-06640',
                          class_name=_class_name,
                          method_name=_method_name)
     _logger.exiting(class_name=_class_name, method_name=_method_name)
     return model_top_folder_name, result
Пример #19
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
Пример #20
0
    def _create_named_subtype_mbeans(self,
                                     type_name,
                                     model_nodes,
                                     base_location,
                                     log_created=False):
        """
        Create the MBeans for a single security provider type, such as "AuthenticationProvider".
        These are the only named subtype MBeans within security configuration, so no further checks are required.
        :param type_name: the model folder type
        :param model_nodes: the model dictionary of the specified model folder type
        :param base_location: the base location object to use to create the MBeans
        :param log_created: whether or not to log created at INFO level, by default it is logged at the FINE level
        :raises: CreateException: if an error occurs
        """
        _method_name = '_create_named_subtype_mbeans'

        self.logger.entering(type_name,
                             str(base_location),
                             log_created,
                             class_name=self.__class_name,
                             method_name=_method_name)

        if not self._is_type_valid(base_location, type_name):
            return

        # some providers may be skipped
        if not self._check_provider_type(type_name, model_nodes):
            return

        location = LocationContext(base_location).append_location(type_name)
        self._process_flattened_folder(location)

        # For create, delete the existing nodes, and re-add in order found in model in iterative code below
        self._delete_existing_providers(location)

        if model_nodes is None or len(model_nodes) == 0:
            return

        token_name = self.alias_helper.get_name_token(location)
        create_path = self.alias_helper.get_wlst_create_path(location)
        list_path = self.alias_helper.get_wlst_list_path(location)
        existing_folder_names = self._get_existing_folders(list_path)
        known_providers = self.alias_helper.get_model_subfolder_names(location)
        allow_custom = str(
            self.alias_helper.is_custom_folder_allowed(location))

        for model_name in model_nodes:
            model_node = model_nodes[model_name]

            if model_node is None:
                # The node is empty so nothing to do... move to the next named node.
                continue

            if len(model_node) != 1:
                # there should be exactly one type folder under the name folder
                ex = exception_helper.create_exception(self._exception_type,
                                                       'WLSDPLY-12117',
                                                       type_name, model_name,
                                                       len(model_node))
                self.logger.throwing(ex,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                raise ex

            model_type_subfolder_name = list(model_node.keys())[0]
            child_nodes = dictionary_utils.get_dictionary_element(
                model_node, model_type_subfolder_name)

            # custom providers require special processing, they are not described in alias framework
            if allow_custom and (model_type_subfolder_name
                                 not in known_providers):
                self.custom_folder_helper.update_security_folder(
                    base_location, type_name, model_type_subfolder_name,
                    model_name, child_nodes)
                continue

            # for a known provider, process using aliases
            prov_location = LocationContext(location)
            name = self.wlst_helper.get_quoted_name_for_wlst(model_name)
            if token_name is not None:
                prov_location.add_name_token(token_name, name)

            wlst_base_provider_type, wlst_name = self.alias_helper.get_wlst_mbean_type_and_name(
                prov_location)

            prov_location.append_location(model_type_subfolder_name)
            wlst_type = self.alias_helper.get_wlst_mbean_type(prov_location)

            if wlst_name not in existing_folder_names:
                if log_created:
                    self.logger.info('WLSDPLY-12118',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     create_path,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                else:
                    self.logger.fine('WLSDPLY-12118',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     create_path,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                self.wlst_helper.cd(create_path)
                self.wlst_helper.create(wlst_name, wlst_type,
                                        wlst_base_provider_type)
            else:
                if log_created:
                    self.logger.info('WLSDPLY-12119',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     create_path,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                else:
                    self.logger.fine('WLSDPLY-12119',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     create_path,
                                     class_name=self.__class_name,
                                     method_name=_method_name)

            attribute_path = self.alias_helper.get_wlst_attributes_path(
                prov_location)
            self.wlst_helper.cd(attribute_path)

            self.logger.finest(
                'WLSDPLY-12111',
                self.alias_helper.get_model_folder_path(prov_location),
                self.wlst_helper.get_pwd(),
                class_name=self.__class_name,
                method_name=_method_name)
            self._set_attributes(prov_location, child_nodes)
            self._create_subfolders(prov_location, child_nodes)

        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return
Пример #21
0
    def target_server_groups_to_servers(self, server_groups_to_target):
        """
        Target the server groups to the servers.
        :param server_groups_to_target: the list of server groups to target
        :raises: BundleAwareException of the specified type: if an error occurs
        """
        _method_name = 'target_server_groups_to_servers'

        self.logger.entering(server_groups_to_target, class_name=self.__class_name, method_name=_method_name)
        if len(server_groups_to_target) == 0:
            return list(), list()

        location = LocationContext()
        root_path = self.alias_helper.get_wlst_attributes_path(location)
        self.wlst_helper.cd(root_path)

        # We need to get the effective list of servers for the domain.  Since any servers
        # referenced in the model have already been created but the templates may have
        # defined new servers not listed in the model, get the list from WLST.
        server_names = self._get_existing_server_names()

        # Get the clusters and and their members
        cluster_map = self._get_clusters_and_members_map()
        dynamic_cluster_names = list()
        for cluster_name in cluster_map:
            if DYNAMIC_SERVERS in cluster_map[cluster_name]:
                dynamic_cluster_names.append(cluster_name)

        # Get any limits that may have been defined in the model
        domain_info = self.model.get_model_domain_info()
        server_group_targeting_limits = \
            dictionary_utils.get_dictionary_element(domain_info, SERVER_GROUP_TARGETING_LIMITS)
        if len(server_group_targeting_limits) > 0:
            server_group_targeting_limits = \
                self._get_server_group_targeting_limits(server_group_targeting_limits, cluster_map)

        self.logger.finer('WLSDPLY-12240', str(server_group_targeting_limits),
                          class_name=self.__class_name, method_name=_method_name)

        # Get the map of server names to server groups to target
        server_to_server_groups_map =\
            self._get_server_to_server_groups_map(self._admin_server_name,
                                                  server_names,
                                                  dynamic_cluster_names,
                                                  server_groups_to_target,
                                                  server_group_targeting_limits)  # type: dict
        self.logger.finer('WLSDPLY-12242', str(server_to_server_groups_map), class_name=self.__class_name,
                          method_name=_method_name)

        final_assignment_map = dict()
        dynamic_cluster_assigns = dict()
        # Target servers and dynamic clusters to the server group resources
        if len(server_names) > 0 or len(dynamic_cluster_names) > 0:
            for server, server_groups in server_to_server_groups_map.iteritems():
                if len(server_groups) > 0:
                    if server in server_names:
                        final_assignment_map[server] = server_groups
                    elif server in dynamic_cluster_names:
                        dynamic_cluster_assigns[server] = server_groups

        #
        # Domain has not targeted the server groups to managed servers (configured), or the
        # domain has no managed servers (configured) but has user server groups. The resources for the
        # user server groups must be targeted before the write/update domain or the write/update will fail.
        # Thus assign the user server groups to the admin server.
        #
        # Because of the interaction of the working context in the different wlst helpers, the dynamic
        # clusters will be applied to the resources separately and after the write/update domain.
        #
        # (From original blurb)
        #  This is really a best effort attempt.  It works for JRF domains but it is certainly possible
        # that it may cause problems with other custom domain types.  Of course, creating a domain with
        # no managed servers is not a primary use case of this tool so do it and hope for the best...
        #
        # (New comment)
        # As we have added the intricacies of the dynamic clusters, if the targeting is to dynamic
        # clusters only, the set server groups with the admin server will get through the write/update domain
        # and the applyJRF with the dynamic cluster should theoretically unset the AdminServer on the user server
        # groups. It works with JRF type domains.

        if len(server_groups_to_target) > 0:
            if len(final_assignment_map) == 0:
                # This is a quickie to fix the issue where server groups are not targeted because no configured
                #  managed servers exist in the domain
                final_assignment_map[server_names[0]] = server_groups_to_target
            else:
                # If a server group or groups is not targeted in the assignments, log it to stdout
                no_targets = [server_target for server_target in server_groups_to_target if server_target not in
                              [server_target for row in final_assignment_map.itervalues() for
                               server_target in server_groups_to_target if server_target in row]]
                if len(no_targets) > 0:
                    self.logger.info('WLSDPLY-12248', no_targets,
                                     class_name=self.__class_name, method_name=_method_name)

        self.logger.exiting(result=str(dynamic_cluster_assigns),
                            class_name=self.__class_name, method_name=_method_name)
        return final_assignment_map, dynamic_cluster_assigns
Пример #22
0
    def _create_mbean(self,
                      type_name,
                      model_nodes,
                      base_location,
                      log_created=False):
        """
        Create the specified type of MBean that support a single instance in the specified location.
        :param type_name: the model folder type
        :param model_nodes: the model dictionary of the specified model folder type
        :param base_location: the base location object to use to create the MBean
        :param log_created: whether or not to log created at INFO level, by default it is logged at the FINE level
        :raises: CreateException: if an error occurs
        """
        _method_name = '_create_mbean'

        self.logger.entering(type_name,
                             str(base_location),
                             log_created,
                             class_name=self.__class_name,
                             method_name=_method_name)
        if model_nodes is None or len(
                model_nodes) == 0 or not self._is_type_valid(
                    base_location, type_name):
            return

        location = LocationContext(base_location).append_location(type_name)
        result, message = self.aliases.is_version_valid_location(location)
        if result == ValidationCodes.VERSION_INVALID:
            self.logger.warning('WLSDPLY-12123',
                                message,
                                class_name=self.__class_name,
                                method_name=_method_name)
            return

        create_path = self.aliases.get_wlst_create_path(location)
        existing_folder_names = self._get_existing_folders(create_path)

        mbean_type, mbean_name = self.aliases.get_wlst_mbean_type_and_name(
            location)

        token_name = self.aliases.get_name_token(location)
        if token_name is not None:
            if self.aliases.requires_unpredictable_single_name_handling(
                    location):
                existing_subfolder_names = deployer_utils.get_existing_object_list(
                    location, self.aliases)
                if len(existing_subfolder_names) > 0:
                    mbean_name = existing_subfolder_names[0]

            location.add_name_token(token_name, mbean_name)

        self._process_flattened_folder(location)
        if mbean_type not in existing_folder_names:
            if log_created:
                self.logger.info('WLSDPLY-12102',
                                 type_name,
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            else:
                self.logger.fine('WLSDPLY-12102',
                                 type_name,
                                 class_name=self.__class_name,
                                 method_name=_method_name)

            self.wlst_helper.create_and_cd(self.aliases, mbean_type,
                                           mbean_name, location, create_path)
        else:
            if log_created:
                self.logger.info('WLSDPLY-20013',
                                 type_name,
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            else:
                self.logger.fine('WLSDPLY-12102',
                                 type_name,
                                 class_name=self.__class_name,
                                 method_name=_method_name)

            attribute_path = self.aliases.get_wlst_attributes_path(location)
            self.wlst_helper.cd(attribute_path)

        self._process_child_nodes(location, model_nodes)
        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return
Пример #23
0
    def _create_named_mbeans(self,
                             type_name,
                             model_nodes,
                             base_location,
                             log_created=False,
                             delete_now=True):
        """
        Create the specified type of MBeans that support multiple instances in the specified location.
        :param type_name: the model folder type
        :param model_nodes: the model dictionary of the specified model folder type
        :param base_location: the base location object to use to create the MBeans
        :param log_created: whether or not to log created at INFO level, by default it is logged at the FINE level
        :raises: CreateException: if an error occurs
        """
        _method_name = '_create_named_mbeans'

        self.logger.entering(type_name,
                             str(base_location),
                             log_created,
                             class_name=self.__class_name,
                             method_name=_method_name)
        if model_nodes is None or len(
                model_nodes) == 0 or not self._is_type_valid(
                    base_location, type_name):
            return

        location = LocationContext(base_location).append_location(type_name)
        self._process_flattened_folder(location)

        token_name = self.aliases.get_name_token(location)
        create_path = self.aliases.get_wlst_create_path(location)
        list_path = self.aliases.get_wlst_list_path(location)
        existing_folder_names = self._get_existing_folders(list_path)
        for model_name in model_nodes.keys():
            name = self.wlst_helper.get_quoted_name_for_wlst(model_name)
            if model_helper.is_delete_name(name):
                if delete_now:
                    deployer_utils.delete_named_element(
                        location, name, existing_folder_names, self.aliases)
                continue

            if token_name is not None:
                location.add_name_token(token_name, name)

            wlst_type, wlst_name = self.aliases.get_wlst_mbean_type_and_name(
                location)
            if wlst_name not in existing_folder_names:
                if log_created:
                    self.logger.info('WLSDPLY-12100',
                                     type_name,
                                     name,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                else:
                    self.logger.fine('WLSDPLY-12100',
                                     type_name,
                                     name,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                self.wlst_helper.create_and_cd(self.aliases, wlst_type,
                                               wlst_name, location,
                                               create_path)
            else:
                if log_created:
                    self.logger.info('WLSDPLY-12101',
                                     type_name,
                                     name,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                else:
                    self.logger.fine('WLSDPLY-12101',
                                     type_name,
                                     name,
                                     class_name=self.__class_name,
                                     method_name=_method_name)

                attribute_path = self.aliases.get_wlst_attributes_path(
                    location)
                self.wlst_helper.cd(attribute_path)

            child_nodes = dictionary_utils.get_dictionary_element(
                model_nodes, name)
            self._process_child_nodes(location, child_nodes)

        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return
Пример #24
0
    def target_server_groups_to_servers(self, server_groups_to_target):
        """
        Target the server groups to the servers.
        :param server_groups_to_target: the list of server groups to target
        :raises: BundleAwareException of the specified type: if an error occurs
        """
        _method_name = 'target_server_groups_to_servers'

        self.logger.entering(server_groups_to_target,
                             class_name=self.__class_name,
                             method_name=_method_name)
        if len(server_groups_to_target) == 0:
            return None, None

        location = LocationContext()
        root_path = self.alias_helper.get_wlst_attributes_path(location)
        self.wlst_helper.cd(root_path)

        # We need to get the effective list of servers for the domain.  Since any servers
        # referenced in the model have already been created but the templates may have
        # defined new servers not listed in the model, get the list from WLST.
        server_names = self._get_existing_server_names()

        # Get the clusters and and their members
        cluster_map = self._get_clusters_and_members_map()
        dynamic_cluster_names = list()
        for cluster_name in cluster_map:
            if DYNAMIC_SERVERS in cluster_map[cluster_name]:
                dynamic_cluster_names.append(cluster_name)

        # Get any limits that may have been defined in the model
        domain_info = self.model.get_model_domain_info()
        server_group_targeting_limits = \
            dictionary_utils.get_dictionary_element(domain_info, SERVER_GROUP_TARGETING_LIMITS)
        if len(server_group_targeting_limits) > 0:
            server_group_targeting_limits = \
                self._get_server_group_targeting_limits(server_group_targeting_limits, cluster_map)

        self.logger.finer('WLSDPLY-12240',
                          str(server_group_targeting_limits),
                          class_name=self.__class_name,
                          method_name=_method_name)

        # Get the map of server names to server groups to target
        server_to_server_groups_map =\
            self._get_server_to_server_groups_map(self._admin_server_name,
                                                  server_names,
                                                  dynamic_cluster_names,
                                                  server_groups_to_target,
                                                  server_group_targeting_limits)  # type: dict
        self.logger.finer('WLSDPLY-12242',
                          str(server_to_server_groups_map),
                          class_name=self.__class_name,
                          method_name=_method_name)

        final_assignment_map = dict()
        if len(server_names) > 0:
            for server, server_groups in server_to_server_groups_map.iteritems(
            ):
                if server in server_names and len(server_groups) > 0:
                    final_assignment_map[server] = server_groups

        elif len(server_names) == 0 and len(dynamic_cluster_names) == 0:
            #
            # Domain has no managed servers and there were not targeting limits specified to target
            # server groups to the admin server so make sure that the server groups are targeted to
            # the admin server.
            #
            # This is really a best effort attempt.  It works for JRF domains but it is certainly possible
            # that it may cause problems with other custom domain types.  Of course, creating a domain with
            # no managed servers is not a primary use case of this tool so do it and hope for the best...
            #
            final_assignment_map[server_names[0]] = server_groups_to_target

        # Target any dynamic clusters to the server group resources
        dynamic_cluster_assigns = None
        if len(dynamic_cluster_names) > 0:
            dynamic_cluster_assigns = dict()
            for name in dynamic_cluster_names:
                if name in server_to_server_groups_map:
                    dynamic_cluster_assigns[
                        name] = server_to_server_groups_map[name]

        self.logger.exiting(result=str(dynamic_cluster_assigns),
                            class_name=self.__class_name,
                            method_name=_method_name)
        return final_assignment_map, dynamic_cluster_assigns
Пример #25
0
    def _get_clusters_and_members_map(self):
        """
        Get a map keyed by cluster name with values that are a list of member server names
        :return: the cluster name to member server names map
        :raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST
        """
        _method_name = '_get_clusters_and_members_map'

        self.logger.entering(class_name=self.__class_name,
                             method_name=_method_name)
        server_location = LocationContext().append_location(SERVER)
        server_list_path = self.alias_helper.get_wlst_list_path(
            server_location)
        server_names = self.wlst_helper.get_existing_object_list(
            server_list_path)
        server_token = self.alias_helper.get_name_token(server_location)
        cluster_map = OrderedDict()
        for server_name in server_names:
            server_location.add_name_token(server_token, server_name)
            server_attributes_path = self.alias_helper.get_wlst_attributes_path(
                server_location)
            self.wlst_helper.cd(server_attributes_path)

            server_attributes_map = self.wlst_helper.lsa()
            cluster_name = dictionary_utils.get_element(
                server_attributes_map, CLUSTER)
            if string_utils.is_empty(cluster_name):
                # if server is not part of a cluster, continue with the next server
                continue

            if cluster_name not in cluster_map:
                cluster_map[cluster_name] = list()
            cluster_map[cluster_name].append(server_name)

        clusters_location = LocationContext().append_location(CLUSTER)
        cluster_list_path = self.alias_helper.get_wlst_list_path(
            clusters_location)
        cluster_names = self.wlst_helper.get_existing_object_list(
            cluster_list_path)
        cluster_token = self.alias_helper.get_name_token(clusters_location)
        # Add the cluster with dynamic servers, if not already in the cluster member list.
        # A cluster may contain both dynamic and configured servers (referred to as mixed cluster).
        # Add a token marking DYNAMIC SERVERS in the member list.
        for cluster_name in cluster_names:
            cluster_location = LocationContext(clusters_location)
            cluster_location.add_name_token(cluster_token, cluster_name)
            cluster_attributes_path = self.alias_helper.get_wlst_attributes_path(
                cluster_location)
            self.wlst_helper.cd(cluster_attributes_path)
            cluster_location.append_location(DYNAMIC_SERVERS)
            wlst_subfolder_name = self.alias_helper.get_wlst_mbean_type(
                cluster_location)
            if self.wlst_helper.subfolder_exists(wlst_subfolder_name):
                if cluster_name not in cluster_map:
                    cluster_map[cluster_name] = list()
                cluster_map[cluster_name].append(DYNAMIC_SERVERS)

        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name,
                            result=cluster_map)
        return cluster_map
Пример #26
0
    def update(self):
        """
        Deploy resource model elements at the domain level, including multi-tenant elements.
        """
        # For issue in setServerGroups in online mode (new configured clusters and stand-alone managed servers
        # will not have extension template resources targeted)
        existing_managed_servers, existing_configured_clusters = self._create_list_of_setservergroups_targets(
        )
        domain_token = deployer_utils.get_domain_token(self.alias_helper)

        location = LocationContext()
        location.add_name_token(domain_token,
                                self.model_context.get_domain_name())

        # create a list, then remove each element as it is processed
        folder_list = self.alias_helper.get_model_topology_top_level_folder_names(
        )

        # /Security cannot be updated on existing domain
        folder_list.remove(SECURITY)

        self._security_provider_creator.create_security_configuration(location)
        folder_list.remove(SECURITY_CONFIGURATION)

        # set the domain attributes
        self._set_domain_attributes()

        self._process_section(self._topology, folder_list, ADMIN_CONSOLE,
                              location)
        self._process_section(self._topology, folder_list, MACHINE, location)
        self._process_section(self._topology, folder_list, UNIX_MACHINE,
                              location)

        # avoid circular references between clusters and server templates
        self._topology_helper.create_placeholder_server_templates(
            self._topology)

        # create placeholders for JDBC resources that may be referenced in cluster definition.
        self._topology_helper.create_placeholder_jdbc_resources(
            self._resources)

        self._process_section(self._topology, folder_list, CLUSTER, location)
        self._process_section(self._topology, folder_list, SERVER_TEMPLATE,
                              location)

        # create placeholders for Servers that are in a cluster as /Server/JTAMigratableTarget
        # can reference "other" servers
        self._topology_helper.create_placeholder_servers_in_cluster(
            self._topology)

        self._process_section(self._topology, folder_list, SERVER, location)

        self._process_section(self._topology, folder_list, MIGRATABLE_TARGET,
                              location)

        new_managed_server_list, new_configured_cluster_list = self._create_list_of_setservergroups_targets(
        )

        self._check_for_online_setservergroups_issue(existing_managed_servers,
                                                     new_managed_server_list)
        self._check_for_online_setservergroups_issue(
            existing_configured_clusters, new_configured_cluster_list)

        # process remaining top-level folders. copy list to avoid concurrent update in loop
        remaining = list(folder_list)
        for folder_name in remaining:
            self._process_section(self._topology, folder_list, folder_name,
                                  location)

        if self.wls_helper.is_set_server_groups_supported():
            server_groups_to_target = self._domain_typedef.get_server_groups_to_target(
            )
            server_assigns, dynamic_assigns = \
                self.target_helper.target_server_groups_to_servers(server_groups_to_target)
            if len(dynamic_assigns) > 0:
                self.wlst_helper.save_and_close(self.model_context)
                self.target_helper.target_server_groups_to_dynamic_clusters(
                    dynamic_assigns)
                self.wlst_helper.reopen(self.model_context)
            if len(server_assigns) > 0:
                self.target_helper.target_server_groups(server_assigns)
        elif self._domain_typedef.is_jrf_domain_type():
            self.target_helper.target_jrf_groups_to_clusters_servers()

        self.library_helper.install_domain_libraries()
        self.library_helper.extract_classpath_libraries()
Пример #27
0
    def _create_list_of_setservergroups_targets(self):
        """
        If an update is executed in online WLST mode, return a list of all existing configured / mixed clusters and
        stand-alone managed servers. This method will be invoked to create a list of existing, and a list of new
        as added by the update tool. These lists will be compared to determine if they will encounter
        the online WLST problem with setServerGroups. The setServerGroups will target template resources to the
        new entities, but this targeting is not persisted to the config.xml.
        """
        _method_name = '_create_list_of_setservergroups_targets'
        self.logger.entering(class_name=self._class_name,
                             method_name=_method_name)

        if not self.is_online_with_ext_templates():
            self.logger.exiting(class_name=self._class_name,
                                method_name=_method_name)
            return list(), list()

        location = LocationContext().append_location(SERVER)
        server_path = self.alias_helper.get_wlst_list_path(location)
        existing_managed_servers = list()
        existing_servers = self.wlst_helper.get_existing_object_list(
            server_path)
        if existing_servers is not None:
            name_token = self.alias_helper.get_name_token(location)
            for server_name in existing_servers:
                location.add_name_token(name_token, server_name)
                wlst_path = self.alias_helper.get_wlst_attributes_path(
                    location)
                self.wlst_helper.cd(wlst_path)
                cluster_attribute = self.alias_helper.get_wlst_attribute_name(
                    location, CLUSTER)
                cluster_value = self.wlst_helper.get(cluster_attribute)
                if cluster_value is None:
                    existing_managed_servers.append(server_name)
                location.remove_name_token(name_token)

        existing_configured_clusters = list()
        location = LocationContext().append_location(CLUSTER)
        cluster_path = self.alias_helper.get_wlst_list_path(location)
        existing_clusters = self.wlst_helper.get_existing_object_list(
            cluster_path)
        if existing_clusters is not None:
            name_token = self.alias_helper.get_name_token(location)
            for cluster_name in existing_clusters:
                location.add_name_token(name_token, cluster_name)
                wlst_path = self.alias_helper.get_wlst_attributes_path(
                    location)
                self.wlst_helper.cd(wlst_path)
                ds_mbean = self.alias_helper.get_wlst_mbean_type(location)
                if not self.wlst_helper.subfolder_exists(
                        ds_mbean,
                        self.alias_helper.get_wlst_subfolders_path(location)):
                    existing_configured_clusters.append(cluster_name)
                location.remove_name_token(name_token)

        self.logger.exiting(
            class_name=self._class_name,
            method_name=_method_name,
            result='configured_clusters=' + str(existing_configured_clusters) +
            ' managed servers=' + str(existing_managed_servers))
        return existing_configured_clusters, existing_managed_servers
Пример #28
0
 def _add_cache_config(self, model_name, model_value, location):
     """
     Add the cache configuration file to the archive file. The file name stored in the cache configuration file
     attribute may be either a URL where the configuration is hosted or a physical location on the current machine.
     The file will be collected from either location and stored in the archive file. The attribute value will be
     updated to point to the location where the file will exist after the archive file is deployed.
     :param model_name: name of the coherence cluster cache config file attribute
     :param model_value: containing the cache configuration file URL or location
     :return: update cache configuration file value
     """
     _method_name = '_add_cache_config'
     temp = LocationContext()
     temp.append_location(model_constants.COHERENCE_CLUSTER_SYSTEM_RESOURCE)
     cluster_name = location.get_name_for_token(
         self._alias_helper.get_name_token(temp))
     _logger.entering(cluster_name,
                      model_name,
                      model_value,
                      class_name=_class_name,
                      method_name=_method_name)
     new_name = model_value
     if model_value is not None:
         archive_file = self._model_context.get_archive_file()
         success, url = _get_from_url(cluster_name, model_value)
         if success:
             if url is not None:
                 try:
                     new_name = archive_file.addCoherenceConfigFileFromUrl(
                         cluster_name, url)
                     _logger.info('WLSDPLY-06317',
                                  cluster_name,
                                  url,
                                  new_name,
                                  class_name=_class_name,
                                  method_name=_method_name)
                 except (IllegalArgumentException,
                         WLSDeployArchiveIOException), wioe:
                     _logger.warning('WLSDPLY-06318',
                                     cluster_name,
                                     model_value,
                                     'url',
                                     wioe.getLocalizedMessage(),
                                     class_name=_class_name,
                                     method_name=_method_name)
                     new_name = None
             else:
                 try:
                     new_name = archive_file.addCoherenceConfigFile(
                         cluster_name, File(model_value))
                     _logger.info('WLSDPLY-06319',
                                  cluster_name,
                                  model_value,
                                  new_name,
                                  class_name=_class_name,
                                  method_name=_method_name)
                 except (IllegalArgumentException,
                         WLSDeployArchiveIOException), wioe:
                     _logger.warning('WLSDPLY-06318', cluster_name,
                                     model_value, 'file',
                                     wioe.getLocalizedMessage())
                     new_name = None
Пример #29
0
    def _add_group_params(self, group_name_nodes, location):
        """
        Add each group param entry from group name nodes and set its attributes.
        A two-pass approach is required since the new folder's name does not always match the group name.
        Special processing for error destination attributes (build mbean)
        :param group_name_nodes: the nodes containing group parameter names
        :param location: the WLST location where the parameters should be added
        """
        _method_name = '_add_group_params'
        if len(group_name_nodes) == 0:
            return

        # use a copy of the dictionary to remove items as they are deleted
        remaining_name_nodes = group_name_nodes.copy()

        parent_type, parent_name = self.get_location_type_and_name(location)
        template_path = self.aliases.get_wlst_subfolders_path(location)
        groups_location = LocationContext(location)
        groups_location.append_location(GROUP_PARAMS)
        groups_token = self.aliases.get_name_token(groups_location)
        name_attribute = self.aliases.get_wlst_attribute_name(
            groups_location, SUB_DEPLOYMENT_NAME)
        mbean_type = self.aliases.get_wlst_mbean_type(groups_location)

        for group_name in group_name_nodes:
            if model_helper.is_delete_name(group_name):
                group_nodes = group_name_nodes[group_name]
                name = model_helper.get_delete_item_name(group_name)
                sub_name = self._get_subdeployment_name(group_nodes, name)
                self._delete_mapped_mbean(groups_location, groups_token,
                                          mbean_type, name_attribute, sub_name)
                del remaining_name_nodes[group_name]

        # loop once to create and name any missing folders.
        folder_map = self._build_folder_map(groups_location, groups_token,
                                            name_attribute)

        for group_name in remaining_name_nodes:
            group_nodes = remaining_name_nodes[group_name]
            sub_deployment_name = self._get_subdeployment_name(
                group_nodes, group_name)
            folder_name = dictionary_utils.get_element(folder_map,
                                                       sub_deployment_name)
            if folder_name is None:
                self.wlst_helper.cd(template_path)
                group = self.wlst_helper.create(sub_deployment_name,
                                                mbean_type)
                group.setSubDeploymentName(sub_deployment_name)

        # loop a second time to set attributes
        new_folder_map = self._build_folder_map(groups_location, groups_token,
                                                name_attribute)

        for group_name in remaining_name_nodes:
            group_nodes = remaining_name_nodes[group_name]
            sub_deployment_name = self._get_subdeployment_name(
                group_nodes, group_name)
            is_add = sub_deployment_name not in folder_map
            log_helper.log_updating_named_folder(GROUP_PARAMS, group_name,
                                                 parent_type, parent_name,
                                                 is_add, self._class_name,
                                                 _method_name)

            folder_name = dictionary_utils.get_element(new_folder_map,
                                                       sub_deployment_name)
            groups_location.add_name_token(groups_token, folder_name)
            self.wlst_helper.cd(
                self.aliases.get_wlst_attributes_path(groups_location))
            self.set_attributes(groups_location, group_nodes)
Пример #30
0
    def _add_jndi_properties(self, property_name_nodes, location):
        """
        Add each property entry from property nodes and set its attributes.
        A two-pass approach is required since the new folder's name does not always match the property name.
        :param property_name_nodes: the nodes containing property names
        :param location: the WLST location where the properties should be added
        """
        _method_name = '_add_jndi_properties'
        if len(property_name_nodes) == 0:
            return

        # use a copy of the dictionary to remove items as they are deleted
        remaining_name_nodes = property_name_nodes.copy()

        parent_type, parent_name = self.get_location_type_and_name(location)
        is_online = self.wlst_mode == WlstModes.ONLINE
        if is_online and deployer_utils.is_in_resource_group_or_template(
                location):
            self.logger.info('WLSDPLY-09501',
                             JNDI_PROPERTY,
                             parent_type,
                             parent_name,
                             class_name=self._class_name,
                             method_name=_method_name)
            return

        foreign_server_path = self.aliases.get_wlst_subfolders_path(location)
        properties_location = LocationContext(location).append_location(
            JNDI_PROPERTY)
        properties_token = self.aliases.get_name_token(properties_location)
        name_attribute = self.aliases.get_wlst_attribute_name(
            properties_location, KEY)
        mbean_type = self.aliases.get_wlst_mbean_type(properties_location)

        for property_name in property_name_nodes:
            if model_helper.is_delete_name(property_name):
                name = model_helper.get_delete_item_name(property_name)
                self._delete_mapped_mbean(properties_location,
                                          properties_token, mbean_type,
                                          name_attribute, name)
                del remaining_name_nodes[property_name]

        # loop once to create and name any missing folders.
        folder_map = self._build_folder_map(properties_location,
                                            properties_token, name_attribute)

        for property_name in remaining_name_nodes:
            folder_name = dictionary_utils.get_element(folder_map,
                                                       property_name)
            if folder_name is None:
                self.wlst_helper.cd(foreign_server_path)
                new_property = self.wlst_helper.create(property_name,
                                                       mbean_type)
                new_property.setKey(property_name)

        # loop a second time to set attributes
        new_folder_map = self._build_folder_map(properties_location,
                                                properties_token,
                                                name_attribute)

        for property_name in remaining_name_nodes:
            is_add = property_name not in folder_map
            log_helper.log_updating_named_folder(JNDI_PROPERTY, property_name,
                                                 parent_type, parent_name,
                                                 is_add, self._class_name,
                                                 _method_name)

            folder_name = dictionary_utils.get_element(new_folder_map,
                                                       property_name)
            properties_location.add_name_token(properties_token, folder_name)
            self.wlst_helper.cd(
                self.aliases.get_wlst_attributes_path(properties_location))

            property_nodes = remaining_name_nodes[property_name]
            self.set_attributes(properties_location, property_nodes)