def __resolve_paths(self):
        """
        Resolve any tokens in the template paths.
        :raises: CreateException: if an error occurs resolving the paths
        """
        _method_name = '__resolve_paths'

        if not self._paths_resolved:
            if self._model_context is None:
                ex = exception_helper.create_create_exception('WLSDPLY-12302')
                self._logger.throwing(ex,
                                      class_name=self.__class_name,
                                      method_name=_method_name)
                raise ex

            if 'baseTemplate' in self._domain_typedef:
                self._domain_typedef['baseTemplate'] = \
                    self._model_context.replace_token_string(self._domain_typedef['baseTemplate'])
            else:
                ex = exception_helper.create_create_exception(
                    'WLSDPLY-12303', self._domain_type,
                    self._domain_typedef_filename, self._version_typedef_name)
                self._logger.throwing(ex,
                                      class_name=self.__class_name,
                                      method_name=_method_name)
                raise ex

            if 'extensionTemplates' in self._domain_typedef:
                extension_templates = self._domain_typedef[
                    'extensionTemplates']
                resolved_templates = []
                for extension_template in extension_templates:
                    resolved_templates.append(
                        self._model_context.replace_token_string(
                            extension_template))
                self._domain_typedef['extensionTemplates'] = resolved_templates
            else:
                self._domain_typedef['extensionTemplates'] = []

            if 'customExtensionTemplates' in self._domain_typedef:
                extension_templates = self._domain_typedef[
                    'customExtensionTemplates']
                resolved_templates = []
                for extension_template in extension_templates:
                    resolved_templates.append(
                        self._model_context.replace_token_string(
                            extension_template))
                self._domain_typedef[
                    'customExtensionTemplates'] = resolved_templates
            else:
                self._domain_typedef['customExtensionTemplates'] = []

            if 'serverGroupsToTarget' not in self._domain_typedef:
                self._domain_typedef['serverGroupsToTarget'] = []

            if 'rcuSchemas' not in self._domain_typedef:
                self._domain_typedef['rcuSchemas'] = []

            self._paths_resolved = True
        return
Ejemplo n.º 2
0
    def __get_version_typedef(self):
        """
        Get the domain typedef that matches the current WLS version.
        :return: the version-specific domain typedef
        :raises: CreateException: if an error occurs resolving the paths
        """
        _method_name = '__get_version_typedef'

        if 'versions' not in self._domain_typedefs_dict:
            ex = exception_helper.create_create_exception('WLSDPLY-12304', self._domain_type,
                                                          self._domain_typedef_filename)
            self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex
        elif 'definitions' not in self._domain_typedefs_dict:
            ex = exception_helper.create_create_exception('WLSDPLY-12305', self._domain_type,
                                                          self._domain_typedef_filename)
            self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex

        self._version_typedef_name = self.__match_version_typedef(self._domain_typedefs_dict['versions'])

        if self._version_typedef_name in self._domain_typedefs_dict['definitions']:
            result = self._domain_typedefs_dict['definitions'][self._version_typedef_name]
        else:
            ex = exception_helper.create_create_exception('WLSDPLY-12306', self._domain_type,
                                                          self._domain_typedef_filename, self._version_typedef_name)
            self._logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex
        return result
    def __match_version_typedef(self, versions_dict):
        """
        Match the version typedef to the current WLS version
        :param versions_dict: the versions dictionary
        :return: the matching version typedef
        :raises: CreateException: if an error occurs resolving the paths
        """
        _method_name = '__match_version_typedef'

        self._logger.entering(versions_dict,
                              class_name=self.__class_name,
                              method_name=_method_name)
        if len(versions_dict) == 0:
            ex = exception_helper.create_create_exception(
                'WLSDPLY-12307', self._domain_type,
                self._domain_typedef_filename)
            self._logger.throwing(ex,
                                  class_name=self.__class_name,
                                  method_name=_method_name)
            raise ex

        wls_helper = WebLogicHelper(self._logger)
        wls_version = wls_helper.get_actual_weblogic_version()
        self._logger.fine('WLSDPLY-12310',
                          wls_version,
                          class_name=self.__class_name,
                          method_name=_method_name)

        result = None
        if wls_version in versions_dict:
            result = versions_dict[wls_version]
        else:
            new_version = wls_helper.get_next_higher_order_version_number(
                wls_version)
            while new_version is not None:
                if new_version in versions_dict:
                    result = versions_dict[new_version]
                    self._logger.finer('WLSDPLY-12308',
                                       self._domain_type,
                                       self._domain_typedef_filename,
                                       new_version,
                                       wls_version,
                                       class_name=self.__class_name,
                                       method_name=_method_name)
                    break
                else:
                    new_version = wls_helper.get_next_higher_order_version_number(
                        new_version)

            if result is None:
                ex = exception_helper.create_create_exception(
                    'WLSDPLY-12309', self._domain_type,
                    self._domain_typedef_filename, wls_version)
                self._logger.throwing(ex,
                                      class_name=self.__class_name,
                                      method_name=_method_name)
                raise ex
        self._logger.exiting(self.__class_name, _method_name, result)
        return result
Ejemplo n.º 4
0
    def _set_attribute(self, location, model_name, model_value, uses_path_tokens_names, masked=False):
        """
        Set the specified attribute at the specified location to the specified value.
        :param location: the location
        :param model_name: the model attribute name
        :param model_value: the model attribute value
        :param: uses_path_token_names: the list of model attribute names that use file system path tokens
        :param masked: whether or not to mask the attribute value in the log
        :raises: CreateException: if an error occurs
        """
        _method_name = '_set_attribute'

        if model_name in uses_path_tokens_names and WLSDeployArchive.isPathIntoArchive(model_value):
            if self.archive_helper is not None:
                if self.archive_helper.contains_file(model_value):
                    #
                    # We cannot extract the files until the domain directory exists
                    # so add them to the list so that they can be extracted after
                    # domain creation completes.
                    #
                    self.files_to_extract_from_archive.append(model_value)
                else:
                    path = self.alias_helper.get_model_folder_path(location)
                    archive_file_name = self.model_context.get_archive_file_name
                    ex = exception_helper.create_create_exception('WLSDPLY-12121', model_name, path,
                                                                  model_value, archive_file_name)
                    self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
                    raise ex
            else:
                path = self.alias_helper.get_model_folder_path(location)
                ex = exception_helper.create_create_exception('WLSDPLY-12122', model_name, path, model_value)
                self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
                raise ex

        wlst_name, wlst_value = self.alias_helper.get_wlst_attribute_name_and_value(location, model_name, model_value)

        if wlst_name is None:
            self.logger.info('WLSDPLY-12106', model_name, self.alias_helper.get_model_folder_path(location),
                             class_name=self.__class_name, method_name=_method_name)
        elif wlst_value is None:
            logged_value = model_value
            if masked:
                logged_value = '<masked>'
            self.logger.info('WLSDPLY-12107', model_name, logged_value,
                             self.alias_helper.get_model_folder_path(location),
                             class_name=self.__class_name, method_name=_method_name)
        else:
            logged_value = wlst_value
            if masked:
                logged_value = '<masked>'
            self.logger.finest('WLSDPLY-12115', wlst_name, logged_value,
                               class_name=self.__class_name, method_name=_method_name)
            self.wlst_helper.set(wlst_name, wlst_value, masked=masked)
        return
Ejemplo n.º 5
0
    def _extract_archive_files(self, location, model_name, model_value):
        """
        Extract any archive files associated with the specified model attribute value.
        The attribute has already been determined to use path tokens.
        :param location: the location of the attribute
        :param model_name: the model attribute name
        :param model_value: the model attribute value
        :raises: CreateException: if an error occurs
        """
        _method_name = '_extract_archive_files'

        # model value should be a list, comma-delimited string, or string
        model_paths = model_value
        if isinstance(model_value, str):
            model_paths = model_value.split(',')

        for model_path in model_paths:
            model_path = model_path.strip()

            # check for path starting with "wlsdeploy/".
            # skip classpath libraries, they are extracted elsewhere.
            if WLSDeployArchive.isPathIntoArchive(
                    model_path
            ) and not WLSDeployArchive.isClasspathEntry(model_path):
                if self.archive_helper is not None:
                    if self.archive_helper.contains_file(model_path):
                        #
                        # We cannot extract the files until the domain directory exists
                        # so add them to the list so that they can be extracted after
                        # domain creation completes.
                        #
                        self.files_to_extract_from_archive.append(model_path)
                    else:
                        path = self.alias_helper.get_model_folder_path(
                            location)
                        archive_file_name = self.model_context.get_archive_file_name(
                        )
                        ex = exception_helper.create_create_exception(
                            'WLSDPLY-12121', model_name, path, model_path,
                            archive_file_name)
                        self.logger.throwing(ex,
                                             class_name=self.__class_name,
                                             method_name=_method_name)
                        raise ex
                else:
                    path = self.alias_helper.get_model_folder_path(location)
                    ex = exception_helper.create_create_exception(
                        'WLSDPLY-12122', model_name, path, model_path)
                    self.logger.throwing(ex,
                                         class_name=self.__class_name,
                                         method_name=_method_name)
                    raise ex
Ejemplo n.º 6
0
    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.aliases.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.aliases.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.aliases.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.aliases.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 install_domain_libraries(self):
        """
        Extract the domain libraries listed in the model, if any, to the <DOMAIN_HOME>/lib directory.
        :raises: BundleAwareException of the specified type: if an error occurs
        """
        _method_name = 'install_domain_libraries'

        self.logger.entering(self.domain_home, class_name=self.__class_name, method_name=_method_name)
        domain_info_dict = self.model.get_model_domain_info()
        if DOMAIN_LIBRARIES not in domain_info_dict or len(domain_info_dict[DOMAIN_LIBRARIES]) == 0:
            self.logger.info('WLSDPLY-12213', class_name=self.__class_name, method_name=_method_name)
        elif DOMAIN_LIBRARIES in domain_info_dict:
            domain_libs = dictionary_utils.get_dictionary_element(domain_info_dict, DOMAIN_LIBRARIES)
            if self.archive_helper is None:
                ex = exception_helper.create_create_exception('WLSDPLY-12214', domain_libs)
                self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
                raise ex

            for domain_lib in domain_libs:
                if WLSDeployArchive.isPathIntoArchive(domain_lib):
                    self.logger.info('WLSDPLY-12215', domain_lib, self.domain_home,
                                     class_name=self.__class_name, method_name=_method_name)
                    self.archive_helper.extract_domain_library(domain_lib)
                else:
                    self.logger.info('WLSDPLY-12235', domain_lib, self.domain_home,
                                     class_name=self.__class_name, method_name=_method_name)
                    self._copy_domain_library(domain_lib)

        self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
        return
Ejemplo n.º 8
0
    def __run_rcu(self):
        """
        The method that runs RCU to drop and then create the schemas.
        :raises CreateException: if running rcu fails
        """
        _method_name = '__run_rcu'

        self.logger.entering(class_name=self.__class_name, method_name=_method_name)
        if not self.model_context.is_run_rcu():
            self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
            return
        elif not self.wls_helper.is_weblogic_version_or_above('12.1.2'):
            ex = exception_helper.create_create_exception('WLSDPLY-12201', self.__program_name,
                                                          self.wls_helper.get_actual_weblogic_version())
            self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex

        rcu_schemas = self._domain_typedef.get_rcu_schemas()
        if len(rcu_schemas) == 0:
            self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
            return

        domain_type = self.model_context.get_domain_type()
        oracle_home = self.model_context.get_oracle_home()
        java_home = self.model_context.get_java_home()
        rcu_db = self.model_context.get_rcu_database()
        rcu_prefix = self.model_context.get_rcu_prefix()
        rcu_sys_pass = self.model_context.get_rcu_sys_pass()
        rcu_schema_pass = self.model_context.get_rcu_schema_pass()

        runner = RCURunner(domain_type, oracle_home, java_home, rcu_db, rcu_prefix, rcu_schemas)
        runner.runRcu(rcu_sys_pass, rcu_schema_pass)

        self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
        return
Ejemplo n.º 9
0
    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
    def __set_admin_password(self):
        """
        Set the administrative user's password.
        :raises: CreateException: if an error occurs
        """
        _method_name = '__set_admin_password'

        if ADMIN_PASSWORD in self._domain_info:
            admin_password = self._domain_info[ADMIN_PASSWORD]
            admin_username = self.wls_helper.get_default_admin_username()
            if ADMIN_USERNAME in self._domain_info:
                admin_username = self._domain_info[ADMIN_USERNAME]

            location = LocationContext().append_location(SECURITY)
            token_name = self.alias_helper.get_name_token(location)
            if token_name is not None:
                location.add_name_token(token_name, self._domain_name)

            location.append_location(USER)
            token_name = self.alias_helper.get_name_token(location)
            if token_name is not None:
                location.add_name_token(
                    token_name, self.wls_helper.get_default_admin_username())

            admin_user_path = self.alias_helper.get_wlst_attributes_path(
                location)
            self.wlst_helper.cd(admin_user_path)
            wlst_name, wlst_value = \
                self.alias_helper.get_wlst_attribute_name_and_value(location, NAME, admin_username)
            self.wlst_helper.set_if_needed(wlst_name, wlst_value, NAME,
                                           admin_username)
            wlst_name, wlst_value = \
                self.alias_helper.get_wlst_attribute_name_and_value(location, PASSWORD, admin_password, masked=True)
            self.wlst_helper.set_if_needed(wlst_name,
                                           wlst_value,
                                           PASSWORD,
                                           '<masked>',
                                           masked=True)

        else:
            ex = exception_helper.create_create_exception(
                'WLSDPLY-12228', 'AdminPassword',
                model_helper.get_model_domain_info_key())
            self.logger.throwing(ex,
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            raise ex
        return
    def _copy_domain_library(self, domain_lib):
        """
        Copy the specified domain library to the domain's lib directory.
        :raises: BundleAwareException of the specified type: if an error occurs
        """
        _method_name = '_copy_domain_library'

        source_path = File(domain_lib).getAbsolutePath()
        target_dir = File(self.domain_home, 'lib').getPath()

        try:
            copy(str(source_path), str(target_dir))
        except IOError:
            ex = exception_helper.create_create_exception('WLSDPLY-12234', source_path, target_dir)
            self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex
Ejemplo n.º 12
0
    def install_domain_scripts(self):
        """
        Extract the scripts from domain bin listed in the model, if any, to the <DOMAIN_HOME>/bin directory.
        :raises: BundleAwareException of the specified type: if an error occurs
        """
        _method_name = 'install_domain_scripts'

        self.logger.entering(self.domain_home,
                             class_name=self.__class_name,
                             method_name=_method_name)
        domain_info_dict = self.model.get_model_domain_info()
        if DOMAIN_SCRIPTS not in domain_info_dict or len(
                domain_info_dict[DOMAIN_SCRIPTS]) == 0:
            self.logger.info('WLSDPLY-12241',
                             class_name=self.__class_name,
                             method_name=_method_name)
        elif DOMAIN_SCRIPTS in domain_info_dict:
            domain_scripts = dictionary_utils.get_dictionary_element(
                domain_info_dict, DOMAIN_SCRIPTS)
            if self.archive_helper is None:
                ex = exception_helper.create_create_exception(
                    'WLSDPLY-12250', domain_scripts)
                self.logger.throwing(ex,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                raise ex

            for domain_script in domain_scripts:
                if WLSDeployArchive.isPathIntoArchive(domain_script):
                    self.logger.info('WLSDPLY-12251',
                                     domain_script,
                                     self.domain_home,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                    self.archive_helper.extract_domain_bin_script(
                        domain_script)
                else:
                    self.logger.info('WLSDPLY-12252',
                                     domain_script,
                                     self.domain_home,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                    self._copy_domain_bin(domain_script)

        self.logger.exiting(class_name=self.__class_name,
                            method_name=_method_name)
        return
Ejemplo n.º 13
0
    def __fail_mt_1221_domain_creation(self):
        """
        Abort create if domain contains MT artifacts that cannot be created in the version of WLST offline being used.
        :raises: CreateException: if the MT domain cannot be provision on the specified version of WLST offline
        """
        _method_name = '__fail_mt_1221_domain_creation'

        if self.wls_helper.is_mt_offline_provisioning_supported():
            return

        resources_dict = self.model.get_model_resources()
        if (not dictionary_utils.is_empty_dictionary_element(self._topology, VIRTUAL_TARGET)) or \
                (not dictionary_utils.is_empty_dictionary_element(resources_dict, RESOURCE_GROUP_TEMPLATE)) or \
                (not dictionary_utils.is_empty_dictionary_element(resources_dict, RESOURCE_GROUP)) or \
                (not dictionary_utils.is_empty_dictionary_element(resources_dict, PARTITION)):

            ex = exception_helper.create_create_exception('WLSDPLY-12202', self.wls_helper.wl_version)
            self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex
        return
Ejemplo n.º 14
0
    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]
                sub_location = LocationContext(location).append_location(key)
                # both create and update are merge to model so will process a subfolder with an empty node
                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_security_provider_mbeans(key, subfolder_nodes, location, True)
                elif len(subfolder_nodes) != 0:
                    if 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):
                        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
Ejemplo n.º 15
0
                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.aliases.get_model_folder_path(location),
                    error=ae)
                self.logger.throwing(ex,
                                     class_name=self.__class_name,
                                     method_name=_method_name)
                raise ex
        else:
            ex = exception_helper.create_create_exception(
                'WLSDPLY-12105', model_key,
                self.aliases.get_model_folder_path(location))
            self.logger.throwing(ex,
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            raise ex
        return

    def _set_attribute(self,
                       location,
                       model_name,
                       model_value,
                       uses_path_tokens_names,
                       masked=False):
        """
        Set the specified attribute at the specified location to the specified value.
    def __init__(self, model_dictionary, model_context, aliases):
        _method_name = '__init__'
        Creator.__init__(self, model_dictionary, model_context, aliases)

        # domainInfo section is required to get the admin password, everything else
        # is optional and will use the template defaults
        if model_helper.get_model_domain_info_key() not in model_dictionary:
            ex = exception_helper.create_create_exception(
                'WLSDPLY-12200', self.__program_name,
                model_helper.get_model_domain_info_key(),
                self.model_context.get_model_file())
            self.logger.throwing(ex,
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            raise ex

        self.topology_helper = TopologyHelper(self.aliases,
                                              ExceptionType.CREATE,
                                              self.logger)
        self.security_provider_creator = SecurityProviderCreator(
            model_dictionary, model_context, aliases, ExceptionType.CREATE,
            self.logger)

        self._domain_typedef = self.model_context.get_domain_typedef()
        self._topology = self.model.get_model_topology()
        self._domain_info = self.model.get_model_domain_info()

        if DOMAIN_NAME in self._topology:
            self._domain_name = self._topology[DOMAIN_NAME]
        else:
            self._domain_name = DEFAULT_WLS_DOMAIN_NAME

        # if domain home specified on command line, set it here, otherwise append domain name to domain parent
        model_domain_home = self.model_context.get_domain_home()
        if model_domain_home:
            self._domain_home = model_domain_home
        else:
            self._domain_home = os.path.join(
                self.model_context.get_domain_parent_dir(), self._domain_name)

        if ADMIN_SERVER_NAME in self._topology:
            self._admin_server_name = self._topology[ADMIN_SERVER_NAME]
        else:
            self._admin_server_name = DEFAULT_ADMIN_SERVER_NAME

        self.__default_domain_name = None
        self.__default_admin_server_name = None
        self.__default_security_realm_name = 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._domain_home, self.logger,
                exception_helper.ExceptionType.CREATE)

        self.library_helper = LibraryHelper(self.model, self.model_context,
                                            self.aliases, self._domain_home,
                                            ExceptionType.CREATE, self.logger)

        self.target_helper = TargetHelper(self.model, self.model_context,
                                          self.aliases, ExceptionType.CREATE,
                                          self.logger)

        #
        # This list gets modified as the domain is being created so do use this list for anything else...
        #
        self.__topology_folder_list = self.alias_helper.get_model_topology_top_level_folder_names(
        )
        return
Ejemplo n.º 17
0
    def __init__(self, model_dictionary, model_context, aliases):
        _method_name = '__init__'
        Creator.__init__(self, model_dictionary, model_context, aliases)

        # domainInfo section is required to get the admin password, everything else
        # is optional and will use the template defaults
        if model_helper.get_model_domain_info_key() not in model_dictionary:
            ex = exception_helper.create_create_exception('WLSDPLY-12200', self.__program_name,
                                                          model_helper.get_model_domain_info_key(),
                                                          self.model_context.get_model_file())
            self.logger.throwing(ex, class_name=self.__class_name, method_name=_method_name)
            raise ex

        self.topology_helper = TopologyHelper(self.aliases, ExceptionType.CREATE, self.logger)
        self.security_provider_creator = SecurityProviderCreator(model_dictionary, model_context, aliases,
                                                                 ExceptionType.CREATE, self.logger)

        self._domain_typedef = self.model_context.get_domain_typedef()
        self._topology = self.model.get_model_topology()
        self._domain_info = self.model.get_model_domain_info()

        if DOMAIN_NAME in self._topology:
            self._domain_name = self._topology[DOMAIN_NAME]
        else:
            self._domain_name = DEFAULT_WLS_DOMAIN_NAME
        self._domain_home = os.path.join(self.model_context.get_domain_parent_dir(), self._domain_name)

        if ADMIN_SERVER_NAME in self._topology:
            self._admin_server_name = self._topology[ADMIN_SERVER_NAME]
        else:
            self._admin_server_name = DEFAULT_ADMIN_SERVER_NAME

        self.__default_domain_name = None
        self.__default_admin_server_name = None
        self.__default_security_realm_name = 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._domain_home, self.logger,
                                                exception_helper.ExceptionType.CREATE)

        self.library_helper = LibraryHelper(self.model, self.model_context, self.aliases, self._domain_home,
                                            ExceptionType.CREATE, self.logger)

        self.target_helper = TargetHelper(self.model, self.model_context, self.aliases, ExceptionType.CREATE,
                                          self.logger)

        #
        # Creating domains with the wls.jar template is busted for pre-12.1.2 domains with regards to the
        # names of the default authentication providers (both the DefaultAuthenticator and the
        # DefaultIdentityAsserter names are 'Provider', making it impossible to work with in WLST.  If
        # the WLS version is earlier than fix this as part of domain creation...
        #
        self.__fix_default_authentication_provider_names = \
            self.wls_helper.do_default_authentication_provider_names_need_fixing()

        #
        # This list gets modified as the domain is being created so do use this list for anything else...
        #
        self.__topology_folder_list = self.alias_helper.get_model_topology_top_level_folder_names()
        return
Ejemplo n.º 18
0
    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