def _add_named_elements(self, type_name, model_nodes, location):
        """
        Add each named element from the specified nodes in WLST and set its attributes.
        Sub-folders are processed in a generic manner if present.
        It is assumed that there are no attributes or sub-folders with special processing.
        :param type_name: the type name of the child nodes
        :param model_nodes: the child nodes of a model element
        :param location: the location where elements should be added
        """
        _method_name = '_add_named_elements'

        if len(model_nodes) == 0:
            return

        parent_type, parent_name = self.get_location_type_and_name(location)
        location = LocationContext(location).append_location(type_name)
        if not self._check_location(location):
            return

        deployer_utils.check_flattened_folder(location, self.alias_helper)
        existing_names = deployer_utils.get_existing_object_list(location, self.alias_helper)

        token = self.alias_helper.get_name_token(location)
        for name in model_nodes:
            is_add = name not in existing_names
            log_helper.log_updating_named_folder(type_name, name, parent_type, parent_name, is_add, self._class_name,
                                                 _method_name)

            if token is not None:
                location.add_name_token(token, name)
            deployer_utils.create_and_cd(location, existing_names, self.alias_helper)

            child_nodes = dictionary_utils.get_dictionary_element(model_nodes, name)
            self._set_attributes_and_add_subfolders(location, child_nodes)
        return
Example #2
0
    def _create_placeholder_coherence_cluster(self, cluster_name):
        """
        Create a placeholder Coherence cluster system resource to be referenced from a topology element.
        The new cluster will be created at the root domain level.
        :param cluster_name: the name of the Coherence cluster system resource to be added
        """
        _method_name = '_create_placeholder_coherence_cluster'
        original_location = self.wlst_helper.get_pwd()
        cluster_location = LocationContext().append_location(
            COHERENCE_CLUSTER_SYSTEM_RESOURCE)
        existing_names = deployer_utils.get_existing_object_list(
            cluster_location, self.alias_helper)

        if cluster_name not in existing_names:
            self.logger.info('WLSDPLY-12230',
                             cluster_name,
                             class_name=self.__class_name,
                             method_name=_method_name)

            cluster_token = self.alias_helper.get_name_token(cluster_location)
            cluster_location.add_name_token(cluster_token, cluster_name)
            deployer_utils.create_and_cd(cluster_location, existing_names,
                                         self.alias_helper)

        self.wlst_helper.cd(original_location)
    def _add_model_elements(self, type_name, model_nodes, location):
        """
        Add each model element from the specified nodes at the specified location and set its attributes.
        :param model_nodes: the child nodes of a model element
        :param location: the location where sub-folders should be added
        :param type_name: the name of the model folder to add
        """
        _method_name = '_add_model_elements'

        parent_type, parent_name = self.get_location_type_and_name(location)
        location = LocationContext(location).append_location(type_name)
        if not self._check_location(location):
            return

        deployer_utils.check_flattened_folder(location, self.alias_helper)
        existing_subfolder_names = deployer_utils.get_existing_object_list(location, self.alias_helper)

        mbean_name = deployer_utils.get_mbean_name(location, existing_subfolder_names, self.alias_helper)
        is_add = mbean_name not in existing_subfolder_names
        log_helper.log_updating_folder(type_name, parent_type, parent_name, is_add, self._class_name, _method_name)

        deployer_utils.create_and_cd(location, existing_subfolder_names, self.alias_helper)

        self._set_attributes_and_add_subfolders(location, model_nodes)
        return
    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
        :return: a list of names of created placeholders
        """
        _method_name = 'create_placeholder_named_elements'
        holder_names = []
        original_location = self.wlst_helper.get_pwd()
        resource_location = LocationContext(location).append_location(model_type)

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

            name_nodes = dictionary_utils.get_dictionary_element(model_nodes, model_type)
            for name in name_nodes.keys():
                if model_helper.is_delete_name(name):
                    # don't create placeholder for delete names
                    continue

                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.aliases.get_name_token(resource_location)
                    resource_location.add_name_token(token, name)
                    deployer_utils.create_and_cd(resource_location, existing_names, self.aliases)
                    self._update_placeholder(model_type, name, resource_location)
                    holder_names.append(name)

        self.wlst_helper.cd(original_location)
        return holder_names
    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)
    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)
Example #7
0
    def _create_placeholder_jms_template(self, template_name,
                                         resource_location):
        """
        :param template_name: the name of the template to be added
        :param resource_location: the location where the template should be added
        """
        _method_name = '_create_placeholder_jms_template'
        original_location = self.wlst_helper.get_pwd()
        template_location = LocationContext(resource_location).append_location(
            TEMPLATE)
        existing_names = deployer_utils.get_existing_object_list(
            template_location, self.aliases)

        if template_name not in existing_names:
            self.logger.info('WLSDPLY-09500',
                             template_name,
                             class_name=self._class_name,
                             method_name=_method_name)

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

        self.wlst_helper.cd(original_location)
        return result