Exemplo n.º 1
0
class Creator(object):
    """
    The base class used by the DomainCreator.
    """
    __class_name = 'Creator'

    def __init__(self,
                 model,
                 model_context,
                 aliases,
                 exception_type=ExceptionType.CREATE,
                 logger=PlatformLogger('wlsdeploy.create')):

        self.logger = logger
        self.aliases = aliases
        self._exception_type = exception_type
        self.alias_helper = AliasHelper(self.aliases, self.logger,
                                        exception_type)
        self.wlst_helper = WlstHelper(self.logger, exception_type)
        self.model = Model(model)
        self.model_context = model_context
        self.wls_helper = WebLogicHelper(self.logger)
        self.attribute_setter = AttributeSetter(self.aliases, self.logger,
                                                exception_type)
        self.custom_folder_helper = CustomFolderHelper(self.aliases,
                                                       self.logger,
                                                       self.model_context,
                                                       exception_type)

        # Must be initialized by the subclass since only it has
        # the knowledge required to compute the domain name.
        self.archive_helper = None
        self.files_to_extract_from_archive = list()
        return

    def _create_named_mbeans(self,
                             type_name,
                             model_nodes,
                             base_location,
                             log_created=False):
        """
        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.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)
        for model_name in model_nodes:
            name = self.wlst_helper.get_quoted_name_for_wlst(model_name)

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

            wlst_type, wlst_name = self.alias_helper.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.alias_helper, 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.alias_helper.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

    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.alias_helper.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.alias_helper.get_wlst_create_path(location)
        existing_folder_names = self._get_existing_folders(create_path)

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

        token_name = self.alias_helper.get_name_token(location)
        if token_name is not None:
            if self.alias_helper.requires_unpredictable_single_name_handling(
                    location):
                existing_subfolder_names = deployer_utils.get_existing_object_list(
                    location, self.alias_helper)
                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.alias_helper, 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.alias_helper.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

    def _create_named_subtype_mbeans(self,
                                     type_name,
                                     model_nodes,
                                     base_location,
                                     log_created=False):
        """
        Create the specified type of MBeans that support multiple instances, and require an artificial subtype
        layer after each name.
        There is no default behavior for this method. Sub-classes (currently only SecurityProviderCreator) will
        implement specialized behavior.
        :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
        """
        return

    def _create_subfolders(self, location, model_nodes):
        """
        Create the child MBean folders at the specified location.
        :param location: the location
        :param model_nodes: the model dictionary
        :raises: CreateException: if an error occurs
        """
        _method_name = '_create_subfolders'

        self.logger.entering(location.get_folder_path(),
                             class_name=self.__class_name,
                             method_name=_method_name)
        model_subfolder_names = self.alias_helper.get_model_subfolder_names(
            location)
        for key in model_nodes:
            if key in model_subfolder_names:
                subfolder_nodes = model_nodes[key]
                # don't check for empty subfolder nodes here, some create methods allow them

                sub_location = LocationContext(location).append_location(key)

                if self.alias_helper.requires_artificial_type_subfolder_handling(
                        sub_location):
                    self.logger.finest('WLSDPLY-12116',
                                       key,
                                       str(sub_location),
                                       subfolder_nodes,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._create_named_subtype_mbeans(key, subfolder_nodes,
                                                      location, True)
                elif self.alias_helper.supports_multiple_mbean_instances(
                        sub_location):
                    self.logger.finest('WLSDPLY-12109',
                                       key,
                                       str(sub_location),
                                       subfolder_nodes,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._create_named_mbeans(key, subfolder_nodes, location)
                elif self.alias_helper.is_artificial_type_folder(sub_location):
                    # these should have been handled inside create_named_subtype_mbeans
                    ex = exception_helper.create_create_exception(
                        'WLSDPLY-12120', str(sub_location), key, str(location))
                    self.logger.throwing(ex,
                                         class_name=self.__class_name,
                                         method_name=_method_name)
                    raise ex
                else:
                    self.logger.finest('WLSDPLY-12110',
                                       key,
                                       str(sub_location),
                                       subfolder_nodes,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._create_mbean(key, subfolder_nodes, location)

        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return

    def _process_child_nodes(self, location, model_nodes):
        """
        Process the model nodes at the specified location.
        The default behavior is to process attributes, then sub-folders.
        Sub-classes may override to reverse this order, or for other special processing.
        :param location: the location where the nodes should be applied
        :param model_nodes: the model dictionary of the nodes to be applied
        :raises: CreateException: if an error occurs
        """
        _method_name = '_process_child_nodes'

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

    def _set_attributes(self, location, model_nodes):
        """
        Set the attributes for the MBean at the specified location.
        :param location: the location
        :param model_nodes: the model dictionary
        :raises: CreateException: if an error occurs
        """
        _method_name = '_set_attributes'

        model_attribute_names = self.alias_helper.get_model_attribute_names_and_types(
            location)
        password_attribute_names = self.alias_helper.get_model_password_type_attribute_names(
            location)
        set_method_map = self.alias_helper.get_model_mbean_set_method_attribute_names_and_types(
            location)
        uses_path_tokens_attribute_names = self.alias_helper.get_model_uses_path_tokens_attribute_names(
            location)
        model_folder_path = self.alias_helper.get_model_folder_path(location)
        pwd = self.wlst_helper.get_pwd()

        for key, value in model_nodes.iteritems():
            if key in model_attribute_names:
                if key in set_method_map:
                    self.logger.finest('WLSDPLY-12112',
                                       key,
                                       pwd,
                                       model_folder_path,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._set_mbean_attribute(location, key, value,
                                              set_method_map)
                elif key in password_attribute_names:
                    self.logger.finest('WLSDPLY-12113',
                                       key,
                                       pwd,
                                       model_folder_path,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._set_attribute(location,
                                        key,
                                        value,
                                        uses_path_tokens_attribute_names,
                                        masked=True)
                else:
                    self.logger.finest('WLSDPLY-12113',
                                       key,
                                       pwd,
                                       model_folder_path,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._set_attribute(location, key, value,
                                        uses_path_tokens_attribute_names)
        return

    def _set_mbean_attribute(self, location, model_key, model_value,
                             set_method_map):
        """
        Set the attributes for the MBean that require an MBean value to set at the specified location.
        :param location: the location
        :param model_key: the model attribute name
        :param model_value: the model attribute value
        :param set_method_map: the set method map that maps the attribute names requiring MBean
                               values to the attribute setter method name
        :raises: CreateException: if an error occurs
        """
        _method_name = '_set_mbean_attribute'

        set_method_info = dictionary_utils.get_dictionary_element(
            set_method_map, model_key)
        set_method_name = dictionary_utils.get_element(set_method_info,
                                                       'set_method')

        if set_method_name is not None:
            try:
                self.logger.finest('WLSDPLY-12114',
                                   model_key,
                                   model_value,
                                   set_method_name,
                                   class_name=self.__class_name,
                                   method_name=_method_name)
                set_method = getattr(self.attribute_setter, set_method_name)
                set_method(location, model_key, model_value, None)
            except AttributeError, ae:
                ex = exception_helper.create_create_exception(
                    'WLSDPLY-12104',
                    set_method_name,
                    model_key,
                    self.alias_helper.get_model_folder_path(location),
                    error=ae)
                self.logger.throwing(ex,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                raise ex
        else:
Exemplo n.º 2
0
class Deployer(object):
    """
    The base class for deployers.
    Maintains model, model context, WLST mode, etc.
    Has common methods for deployers.
    """
    _class_name = "Deployer"

    _mbean_interface = Class.forName('weblogic.management.configuration.ConfigurationMBean')
    _object_name_class = Class.forName('javax.management.ObjectName')
    _list_interface = Class.forName('java.util.List')

    def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
        self.name = self._class_name
        self.model = model
        self.wlst_mode = wlst_mode
        self.model_context = model_context
        self.aliases = aliases
        self.logger = PlatformLogger('wlsdeploy.deploy')
        self.alias_helper = AliasHelper(aliases, self.logger, ExceptionType.DEPLOY)
        self.wls_helper = WebLogicHelper(self.logger)
        self.wlst_helper = WlstHelper(self.logger, ExceptionType.DEPLOY)
        self.attribute_setter = AttributeSetter(self.aliases, self.logger, ExceptionType.DEPLOY, wlst_mode=wlst_mode)

        self.archive_helper = None
        archive_file_name = self.model_context.get_archive_file_name()
        if archive_file_name is not None:
            self.archive_helper = ArchiveHelper(archive_file_name, self.model_context.get_domain_home(), self.logger,
                                                exception_helper.ExceptionType.DEPLOY)
        return

    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

    def _add_subfolders(self, model_nodes, location, excludes=None):
        """
        Add each model sub-folder from the specified nodes 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 excludes: optional list of sub-folder names to be excluded from processing
        """
        location = LocationContext(location)
        model_subfolder_names = self.alias_helper.get_model_subfolder_names(location)

        for subfolder in model_nodes:
            key_excluded = (excludes is not None) and (subfolder in excludes)
            if subfolder in model_subfolder_names and not key_excluded:
                subfolder_nodes = model_nodes[subfolder]
                if len(subfolder_nodes) != 0:
                    sub_location = LocationContext(location).append_location(subfolder)
                    if self.alias_helper.supports_multiple_mbean_instances(sub_location):
                        self._add_named_elements(subfolder, subfolder_nodes, location)
                    else:
                        self._add_model_elements(subfolder, subfolder_nodes, location)
        return

    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 _set_attributes_and_add_subfolders(self, location, model_nodes):
        """
        Set the attributes and add sub-folders for the specified location.
        This method can be overridden for finer control of the ordering
        :param location: the location of the attributes and sub-folders
        :param model_nodes: a map of model nodes including attributes and sub-folders
        :raise: DeployException: if an error condition is encountered
        """
        self.set_attributes(location, model_nodes)
        self._add_subfolders(model_nodes, location)
        return

    def set_attributes(self, location, model_nodes, excludes=None):
        """
        Set all the attributes in the model_nodes list. Exclude items that are sub-folders.
        :param location: the location of the attributes to be set
        :param model_nodes: a map of model nodes with attributes to be set
        :param excludes: a list of items that should not be set
        :raise: DeployException: if an error condition is encountered
        """
        _method_name = 'set_attributes'
        attribute_names = self.alias_helper.get_model_attribute_names(location)
        uses_path_tokens_attribute_names = self.alias_helper.get_model_uses_path_tokens_attribute_names(location)
        restart_attribute_names = self.alias_helper.get_model_restart_required_attribute_names(location)
        merge_attribute_names = self.alias_helper.get_model_merge_required_attribute_names(location)
        lsa_required_attribute_names = self.aliases.get_model_lsa_required_attribute_names(location)
        set_method_map = self.alias_helper.get_model_mbean_set_method_attribute_names_and_types(location)

        for key in model_nodes:
            key_excluded = (excludes is not None) and (key in excludes)
            if key in attribute_names and not key_excluded:
                value = model_nodes[key]
                if key in uses_path_tokens_attribute_names:
                    self._extract_from_archive_if_needed(location, key, value)

                wlst_merge_value = None
                if key in merge_attribute_names:
                    wlst_merge_value = self._get_existing_wlst_value(location, key, lsa_required_attribute_names)

                if not self._skip_setting_attribute(key, value, wlst_merge_value, restart_attribute_names) and \
                        (not self.set_special_attribute(location, key, value, wlst_merge_value, set_method_map)):
                    try:
                        self.attribute_setter.set_attribute(location, key, value, wlst_merge_value)
                    except PyWLSTException, pwe:
                        loc_type, loc_name = self.get_location_type_and_name(location)
                        ex = exception_helper.create_deploy_exception('WLSDPLY-09200', key, loc_type, loc_name,
                                                                      pwe.getLocalizedMessage(), error=pwe)
                        self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
                        raise ex
        return
Exemplo n.º 3
0
class Creator(object):
    """
    The base class used by the DomainCreator.
    """
    __class_name = 'Creator'

    def __init__(self,
                 model,
                 model_context,
                 aliases,
                 exception_type=ExceptionType.CREATE,
                 logger=PlatformLogger('wlsdeploy.create')):

        self.logger = logger
        self.aliases = aliases
        self.alias_helper = AliasHelper(self.aliases, self.logger,
                                        exception_type)
        self.wlst_helper = WlstHelper(self.logger, exception_type)
        self.model = Model(model)
        self.model_context = model_context
        self.wls_helper = WebLogicHelper(self.logger)
        self.attribute_setter = AttributeSetter(self.aliases, self.logger,
                                                exception_type)
        # Must be initialized by the subclass since only it has
        # the knowledge required to compute the domain name.
        self.archive_helper = None
        self.files_to_extract_from_archive = list()
        return

    def _create_named_mbeans(self,
                             type_name,
                             model_nodes,
                             base_location,
                             log_created=False):
        """
        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.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)
        for model_name in model_nodes:
            name = self.wlst_helper.get_quoted_name_for_wlst(model_name)

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

            wlst_type, wlst_name = self.alias_helper.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.alias_helper, 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.alias_helper.get_wlst_attributes_path(
                    location)
                self.wlst_helper.cd(attribute_path)

            child_nodes = dictionary_utils.get_dictionary_element(
                model_nodes, name)
            self.logger.finest(
                'WLSDPLY-12111',
                self.alias_helper.get_model_folder_path(location),
                self.wlst_helper.get_pwd(),
                class_name=self.__class_name,
                method_name=_method_name)
            self._set_attributes(location, child_nodes)
            self._create_subfolders(location, child_nodes)

        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return

    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.alias_helper.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.alias_helper.get_wlst_create_path(location)
        existing_folder_names = self._get_existing_folders(create_path)

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

        token_name = self.alias_helper.get_name_token(location)
        if token_name is not None:
            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.alias_helper, 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.alias_helper.get_wlst_attributes_path(
                location)
            self.wlst_helper.cd(attribute_path)

        self.logger.finest('WLSDPLY-12111',
                           self.alias_helper.get_model_folder_path(location),
                           self.wlst_helper.get_pwd(),
                           class_name=self.__class_name,
                           method_name=_method_name)
        self._set_attributes(location, model_nodes)
        self._create_subfolders(location, model_nodes)
        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return

    def _create_security_provider_mbeans(self,
                                         type_name,
                                         model_nodes,
                                         base_location,
                                         log_created=False):
        """
        Create the specified security provider MBean types that support multiple instances but use an
        artificial type subfolder 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_security_provider_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.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)
        for model_name in model_nodes:
            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)
            model_node = model_nodes[model_name]
            if model_node is not None:
                if len(model_node) == 1:
                    model_type_subfolder_name = list(model_node.keys())[0]
                    prov_location.append_location(model_type_subfolder_name)
                    wlst_type = self.alias_helper.get_wlst_mbean_type(
                        prov_location)
                else:
                    ex = exception_helper.create_create_exception(
                        'WLSDPLY-12117', type_name, model_name,
                        len(model_node))
                    self.logger.throwing(ex,
                                         class_name=self.__class_name,
                                         method_name=_method_name)
                    raise ex
            else:
                # The node is empty so nothing to do...move to the next named node.
                continue

            if wlst_name not in existing_folder_names:
                if log_created:
                    self.logger.info('WLSDPLY-12118',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                else:
                    self.logger.fine('WLSDPLY-12118',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     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,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                else:
                    self.logger.fine('WLSDPLY-12119',
                                     type_name,
                                     model_type_subfolder_name,
                                     name,
                                     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)

            child_nodes = dictionary_utils.get_dictionary_element(
                model_node, model_type_subfolder_name)
            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

    def _set_attributes(self, location, model_nodes):
        """
        Set the attributes for the MBean at the specified location.
        :param location: the location
        :param model_nodes: the model dictionary
        :raises: CreateException: if an error occurs
        """
        _method_name = '_set_attributes'

        model_attribute_names = self.alias_helper.get_model_attribute_names_and_types(
            location)
        password_attribute_names = self.alias_helper.get_model_password_type_attribute_names(
            location)
        set_method_map = self.alias_helper.get_model_mbean_set_method_attribute_names_and_types(
            location)
        uses_path_tokens_attribute_names = self.alias_helper.get_model_uses_path_tokens_attribute_names(
            location)
        model_folder_path = self.alias_helper.get_model_folder_path(location)
        pwd = self.wlst_helper.get_pwd()

        for key, value in model_nodes.iteritems():
            if key in model_attribute_names:
                if key in set_method_map:
                    self.logger.finest('WLSDPLY-12112',
                                       key,
                                       pwd,
                                       model_folder_path,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._set_mbean_attribute(location, key, value,
                                              set_method_map)
                elif key in password_attribute_names:
                    self.logger.finest('WLSDPLY-12113',
                                       key,
                                       pwd,
                                       model_folder_path,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._set_attribute(location,
                                        key,
                                        value,
                                        uses_path_tokens_attribute_names,
                                        masked=True)
                else:
                    self.logger.finest('WLSDPLY-12113',
                                       key,
                                       pwd,
                                       model_folder_path,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    self._set_attribute(location, key, value,
                                        uses_path_tokens_attribute_names)
        return

    def _set_mbean_attribute(self, location, model_key, model_value,
                             set_method_map):
        """
        Set the attributes for the MBean that require an MBean value to set at the specified location.
        :param location: the location
        :param model_key: the model attribute name
        :param model_value: the model attribute value
        :param set_method_map: the set method map that maps the attribute names requiring MBean
                               values to the attribute setter method name
        :raises: CreateException: if an error occurs
        """
        _method_name = '_set_mbean_attribute'

        set_method_info = dictionary_utils.get_dictionary_element(
            set_method_map, model_key)
        set_method_name = dictionary_utils.get_element(set_method_info,
                                                       'set_method')

        if set_method_name is not None:
            try:
                self.logger.finest('WLSDPLY-12114',
                                   model_key,
                                   model_value,
                                   set_method_name,
                                   class_name=self.__class_name,
                                   method_name=_method_name)
                set_method = getattr(self.attribute_setter, set_method_name)
                set_method(location, model_key, model_value, None)
            except AttributeError, ae:
                ex = exception_helper.create_create_exception(
                    'WLSDPLY-12104',
                    set_method_name,
                    model_key,
                    self.alias_helper.get_model_folder_path(location),
                    error=ae)
                self.logger.throwing(ex,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                raise ex
        else: