コード例 #1
0
    def _add_classpath_libraries_to_archive(self, model_name, model_value, location):
        """
        This is a private method.

        Add the server files and directories listed in the server classpath attribute to the archive file.
        File locations in the oracle_home will be removed from the classpath and will not be added to the archive file.
        :param model_name: attribute for the server server start classpath attribute
        :param model_value: classpath value in domain
        :param location: context containing current location information
        :return model
        """
        _method_name = 'add_classpath_libraries_to_archive'
        server_name = self._get_server_name_from_location(location)
        _logger.entering(server_name, model_name, model_value, class_name=_class_name, method_name=_method_name)

        classpath_string = None
        if not StringUtils.isEmpty(model_value):
            # model values are comma-separated
            classpath_entries = model_value.split(MODEL_LIST_DELIMITER)

            if classpath_entries:
                classpath_list = []
                for classpath_entry in classpath_entries:
                    classpath_entry = self._model_context.replace_token_string(classpath_entry)
                    new_source_name = self._add_library(server_name, classpath_entry)
                    if new_source_name is not None:
                        classpath_list.append(new_source_name)

                classpath_string = StringUtils.getStringFromList(classpath_list, MODEL_LIST_DELIMITER)
                _logger.fine('WLSDPLY-06617', server_name, classpath_string, class_name=_class_name,
                             method_name=_method_name)

        _logger.exiting(class_name=_class_name, method_name=_method_name, result=classpath_string)
        return classpath_string
コード例 #2
0
def _fix_passwords_in_properties(dictionary):
    """
    Look for password properties in the mail session properties string, and replace the password with a fix me token.
    :param dictionary: containing the discovered mail session attributes
    """
    match_pattern = "mail\.\w*\.?password"
    replacement = '--FIX ME--'
    if model_constants.MAIL_SESSION_PROPERTIES in dictionary:
        new_properties = ''
        string_properties = dictionary[model_constants.MAIL_SESSION_PROPERTIES]
        if string_properties:
            properties = string_properties
            if isinstance(string_properties, str):
                properties = StringUtils.formatPropertiesFromString(
                    string_properties)
            new_properties = OrderedDict()
            iterator = properties.stringPropertyNames().iterator()
            while iterator.hasNext():
                key = iterator.next()
                new_key = str(key).strip()
                value = properties.getProperty(key)
                if StringUtils.matches(match_pattern, new_key):
                    value = replacement
                new_properties[new_key] = value
        dictionary[model_constants.MAIL_SESSION_PROPERTIES] = new_properties
コード例 #3
0
def convert_to_absolute_path(relative_to, file_name):
    """
    Transform the path by joining the relative_to before the file_name and converting the resulting path name to
    an absolute path name.
    :param relative_to: prefix of the path
    :param file_name: name of the file
    :return: absolute path of the relative_to and file_name
    """
    if not StringUtils.isEmpty(relative_to) and not StringUtils.isEmpty(file_name):
        file_name = os.path.join(relative_to, file_name)
    return file_name
コード例 #4
0
 def __get_log_directory(self, option_value):
     if StringUtils.isEmpty(option_value):
         log_dir = get_canonical_path(self.get_build_dir(),
                                      SystemTestSupport.LOG_DIR_DEFAULT)
     else:
         log_dir = get_canonical_file(option_value)
     return log_dir
コード例 #5
0
    def __get_and_validate_test_support_home(self, option_value):
        _method_name = '__get_and_validate_test_support_home'

        if StringUtils.isEmpty(option_value):
            test_support_home = get_canonical_path(
                self.get_build_dir(),
                SystemTestSupport.TEST_SUPPORT_HOME_DEFAULT)
        else:
            test_support_home = get_canonical_file(option_value)

        if not test_support_home.exists():
            ex = exception_helper.create_system_test_exception(
                'WLSDPLY-09869', 'TEST_SUPPORT_HOME',
                test_support_home.getPath())
            _logger.throwing(ex,
                             class_name=_class_name,
                             method_name=_method_name)
            raise ex
        elif not test_support_home.isDirectory():
            ex = exception_helper.create_system_test_exception(
                'WLSDPLY-09870', 'TEST_SUPPORT_HOME',
                test_support_home.getPath())
            _logger.throwing(ex,
                             class_name=_class_name,
                             method_name=_method_name)
            raise ex

        return test_support_home
コード例 #6
0
 def archive_file_store_directory(self, file_store_name,
                                  file_store_dictionary):
     _method_name = 'archive_file_store_directory'
     _logger.entering(file_store_name,
                      class_name=_class_name,
                      method_name=_method_name)
     if file_store_name is not None and model_constants.DIRECTORY in file_store_dictionary:
         directory = file_store_dictionary[model_constants.DIRECTORY]
         if not StringUtils.isEmpty(directory):
             archive_file = self._model_context.get_archive_file()
             try:
                 new_source_name = archive_file.addFileStoreDirectory(
                     file_store_name)
             except WLSDeployArchiveIOException, wioe:
                 de = exception_helper.create_discover_exception(
                     'WLSDPLY-06348', file_store_name, directory,
                     wioe.getLocalizedMessage())
                 _logger.throwing(class_name=_class_name,
                                  method_name=_method_name,
                                  error=de)
                 raise de
             if new_source_name is not None:
                 _logger.info('WLSDPLY-06349',
                              file_store_name,
                              new_source_name,
                              class_name=_class_name,
                              method_name=_method_name)
                 file_store_dictionary[
                     model_constants.DIRECTORY] = new_source_name
コード例 #7
0
def apply_jrf_global_updates(online,
                             jrf_targets,
                             admin_user=None,
                             admin_pass=None,
                             admin_url=None,
                             domain_home=None):
    """
    For installs that will control locally any updates from the apply_jrf
    :param online: True if the tool session is in online mode
    :param jrf_targets: the list target for the JRF resources
    :param admin_user: admin user if online session
    :param admin_pass: admin password if online session
    :param admin_url: admin url if online session
    :param domain_home: domain home if offline session
    :return:
    """
    _method_name = 'apply_jrf_global_updates'
    _logger.entering(StringUtils.stringForBoolean(online),
                     jrf_targets,
                     domain_home,
                     class_name=_class_name,
                     method_name=_method_name)

    session_start(online, jrf_targets, admin_user, admin_pass, admin_url,
                  domain_home)
    for jrf_target in jrf_targets:
        apply_jrf(jrf_target, domain_home, False)

    session_end(online, jrf_targets)

    _logger.exiting(class_name=_class_name, method_name=_method_name)
    return
コード例 #8
0
    def _resolve_deployment_plan_path(self, plan_dir, plan_path):
        """
        Find the deployment plan absolute file path.

        This is a private helper method.

        :param plan_dir: directory discovered from the domain, which is concatenated to the plan path
        :param plan_path: plan path discovered from the domain
        :return: absolute file path for the plan from the plan_dir and plan_paht
        """
        if not StringUtils.isEmpty(plan_path):
            if not StringUtils.isEmpty(plan_dir):
                relative_to = plan_dir
            else:
                relative_to = self._model_context.get_domain_home()
            return discoverer.convert_to_absolute_path(relative_to, plan_path)
        return plan_path
コード例 #9
0
    def __get_logging_properties_file(self, option_value):
        if StringUtils.isEmpty(option_value):
            logging_properties_file = get_canonical_path(
                self.get_build_dir(),
                SystemTestSupport.LOG_PROPERTIES_FILE_DEFAULT)
        else:
            logging_properties_file = get_canonical_file(option_value)

        return logging_properties_file
コード例 #10
0
    def __get_domain_parent_dir(self, option_value):
        if StringUtils.isEmpty(option_value):
            domain_parent_dir = get_canonical_path(
                self.get_build_dir(),
                SystemTestSupport.DOMAIN_PARENT_DIR_DEFAULT)
        else:
            domain_parent_dir = get_canonical_file(option_value)

        return domain_parent_dir
コード例 #11
0
def get_filename_from_path(file_path):
    """
    Return the filename from the existing file path.
    :param file_path: path containing a file name
    :return: file name or None if a file name is not present or the file or file path does not exist
    """
    file_name = None
    if not JStringUtils.isEmpty(file_path) and (os.path.exists(file_path) is False or os.path.isfile(file_path)):
        __, file_name = os.path.split(file_path)
    return file_name
コード例 #12
0
def check_against_server_list(server_name, dynamic_size, prefix, starting):
    if dynamic_size > 0 and prefix is not None and server_name.startswith(
            prefix):
        split_it = server_name.split(prefix)
        if len(split_it) == 2:
            number = StringUtils.stringToInteger(split_it[1].strip())
            if number is not None and starting <= number < (dynamic_size +
                                                            starting):
                return True
    return False
コード例 #13
0
    def __get_supported_versions(self, option_value):
        """
        Converts a string of comma-separated WLS versions into a Python list
        :param option_value: A comma-separated string of WLS versions (without the dots)
        :return: A Python list containing the supported WLS versions without the dots in them
        """
        if StringUtils.isEmpty(
                option_value
        ) or option_value == SystemTestSupport.SUPPORTED_VERSIONS_ALL:
            supported_versions = SystemTestSupport.SUPPORTED_VERSIONS_DEFAULT
        else:
            supported_versions = [
                x.strip() for x in option_value.split(',') if x
            ]

        return supported_versions
コード例 #14
0
    def __validate_locations_for_java_versions_required(self, env, version):
        _method_name = '__validate_locations_for_java_versions_required'

        _logger.entering(env,
                         version,
                         class_name=_class_name,
                         method_name=_method_name)

        if version[-1] == '.':
            version = _get_dot_delimited_version(version)

        requires_java9 = self.does_wls_version_require_java9(version)
        requires_java8 = self.does_wls_version_require_java8(version)
        requires_java7 = self.does_wls_version_require_java7(version)

        java_home_name = None
        java_home_key = None
        validated = False

        if requires_java9:
            if self._java_homes.__contains__(SystemTestSupport._JAVA9):
                validated = True
            else:
                java_home_name = os.environ[
                    SystemTestSupport.JAVA9_HOME_ENVVAR]
                java_home_key = SystemTestSupport._JAVA9
        elif requires_java8:
            if self._java_homes.__contains__(SystemTestSupport._JAVA8):
                validated = True
            else:
                java_home_name = os.environ[
                    SystemTestSupport.JAVA8_HOME_ENVVAR]
                java_home_key = SystemTestSupport._JAVA8
        elif requires_java7:
            if self._java_homes.__contains__(SystemTestSupport._JAVA7):
                validated = True
            else:
                java_home_name = os.environ[
                    SystemTestSupport.JAVA7_HOME_ENVVAR]
                java_home_key = SystemTestSupport._JAVA7
        else:
            ex = exception_helper.create_system_test_exception(
                'WLSDPLY-09867', version)
            _logger.throwing(ex,
                             class_name=_class_name,
                             method_name=_method_name)
            raise ex

        if not validated:
            if StringUtils.isEmpty(java_home_name):
                ex = exception_helper.create_system_test_exception(
                    'WLSDPLY-09868', version)
                _logger.throwing(ex,
                                 class_name=_class_name,
                                 method_name=_method_name)
                raise ex

        java_home = get_canonical_file(java_home_name)
        if not java_home.exists():
            _logger.finer('WLSDPLY-09886',
                          java_home_name,
                          class_name=_class_name,
                          method_name=_method_name)
        elif not java_home.isDirectory():
            _logger.finer('WLSDPLY-09887',
                          java_home_name,
                          class_name=_class_name,
                          method_name=_method_name)

        self._java_homes[java_home_key] = java_home
コード例 #15
0
    _method_name = 'is_editor'
    _logger.entering(class_name=_class_name, method_name=_method_name)

    try:
        result = cmgr.isEditor()
    except WLSTException, e:
        pwe = exception_helper.create_pywlst_exception('WLSDPLY-00094',
                                                       _format_exception(e),
                                                       error=e)
        _logger.throwing(class_name=_class_name,
                         method_name=_method_name,
                         error=pwe)
        raise pwe
    _logger.exiting(class_name=_class_name,
                    method_name=_method_name,
                    result=StringUtils.stringForBoolean(result))
    return result


def have_unactivated_changes(cmgr):
    """
    Return True if there is any unactivated changes in the domain
    :param cmgr: configuration manager
    :return: True if there is any unactivated changes in the domain
    :raises: PyWLSTException: if a WLST error occurs
    """
    _method_name = 'have_unactivated_changes'
    _logger.entering(cmgr, class_name=_class_name, method_name=_method_name)

    try:
        result = cmgr.haveUnactivatedChanges()
コード例 #16
0
    if present == ValidationCodes.VALID:
        attr_name = aliases.get_wlst_attribute_name(location, DYNAMIC_CLUSTER_SIZE)
    else:
        attr_name = aliases.get_wlst_attribute_name(location, MAX_DYNAMIC_SERVER_COUNT)
    dynamic_size = _wlst_helper.get(attr_name)
    attr_name = aliases.get_wlst_attribute_name(location, SERVER_NAME_PREFIX)
    prefix = _wlst_helper.get(attr_name)
    starting = 1
    present, __ = aliases.is_valid_model_attribute_name(location, SERVER_NAME_START_IDX)
    if present == ValidationCodes.VALID:
        attr_name = aliases.get_model_attribute_name(location, SERVER_NAME_START_IDX)
        starting = _wlst_helper.get(attr_name)
    if dynamic_size > 0 and prefix is not None and server_name.startswith(prefix):
        split_it = server_name.split(prefix)
        if len(split_it) == 2:
            number = StringUtils.stringToInteger(split_it[1].strip())
            if number is not None and starting <= number < (dynamic_size + starting):
                return True
    return False


def delete_online_deployment_targets(model, aliases, wlst_mode):
    """
    For online deploy and update, remove any deleted targets from existing apps and libraries.
    This step needs to occur during the WLST edit session, before regular app/library deployment.
    :param model: the model to be examined
    :param aliases: to resolve WLST paths
    :param wlst_mode: to check for online mode
    """
    if wlst_mode == WlstModes.ONLINE:
        app_deployments = dictionary_utils.get_dictionary_element(model.get_model(), APP_DEPLOYMENTS)
コード例 #17
0
def is_editor(cmgr):
    """
    Determine if an edit is in progress and if this context is the current editor.
    :param cmgr: current configuration manager
    :return: True if context is current editor
    """
    _method_name = 'is_editor'
    _logger.entering(class_name=_class_name, method_name=_method_name)

    try:
        result = cmgr.isEditor()
    except WLSTException, e:
        pwe = exception_helper.create_pywlst_exception('WLSDPLY-00094', _format_exception(e), error=e)
        _logger.throwing(class_name=_class_name, method_name=_method_name, error=pwe)
        raise pwe
    _logger.exiting(class_name=_class_name, method_name=_method_name, result=StringUtils.stringForBoolean(result))
    return result


def have_unactivated_changes(cmgr):
    """
    Return True if there is any unactivated changes in the domain
    :param cmgr: configuration manager
    :return: True if there is any unactivated changes in the domain
    :raises: PyWLSTException: if a WLST error occurs
    """
    _method_name = 'have_unactivated_changes'
    _logger.entering(cmgr, class_name=_class_name, method_name=_method_name)

    try:
        result = cmgr.haveUnactivatedChanges()