class ApplicationsVersionHelper(object):
    _EXTENSION_INDEX = 0
    _SPEC_INDEX = 1
    _IMPL_INDEX = 2

    _APP_VERSION_MANIFEST_KEY = 'Weblogic-Application-Version'

    def __init__(self, model_context, archive_helper):
        self._class_name = 'ApplicationsVersionHelper'
        self.model_context = model_context
        self.archive_helper = archive_helper
        self.logger = PlatformLogger('wlsdeploy.deploy')

    def get_library_versioned_name(self, source_path, model_name, from_archive=False):
        """
        Get the proper name of the deployable library that WLST requires in the target domain.  This method is
        primarily needed for shared libraries in the Oracle Home where the implementation version may have
        changed.  Rather than requiring the modeller to have to know/adjust the shared library name, we extract
        the information from the target domain's archive file (e.g., war file) and compute the correct name.
        :param source_path: the SourcePath value of the shared library
        :param model_name: the model name of the library
        :param from_archive: if True, use the manifest from the archive, otherwise from the file system
        :return: the updated shared library name for the target environment
        :raises: DeployException: if an error occurs
        """
        _method_name = 'get_library_versioned_name'

        self.logger.entering(source_path, model_name, class_name=self._class_name, method_name=_method_name)

        old_name_tuple = deployer_utils.get_library_name_components(model_name)
        try:
            versioned_name = old_name_tuple[self._EXTENSION_INDEX]
            manifest = self.__get_manifest(source_path, from_archive)
            if manifest is not None:
                attributes = manifest.getMainAttributes()

                extension_name = attributes.getValue(EXTENSION_NAME)
                if not string_utils.is_empty(extension_name):
                    versioned_name = extension_name

                specification_version = attributes.getValue(SPECIFICATION_VERSION)
                if not string_utils.is_empty(specification_version):
                    versioned_name += '#' + specification_version

                    # Cannot specify an impl version without a spec version
                    implementation_version = attributes.getValue(IMPLEMENTATION_VERSION)
                    if not string_utils.is_empty(implementation_version):
                        versioned_name += '@' + implementation_version

                self.logger.info('WLSDPLY-09324', model_name, versioned_name,
                                 class_name=self._class_name, method_name=_method_name)

        except (IOException, FileNotFoundException, ZipException, IllegalStateException), e:
            ex = exception_helper.create_deploy_exception('WLSDPLY-09325', model_name, source_path, str(e), error=e)
            self.logger.throwing(ex, class_name=self._class_name, method_name=_method_name)
            raise ex

        self.logger.exiting(class_name=self._class_name, method_name=_method_name, result=versioned_name)
        return versioned_name
Esempio n. 2
0
class ValidationTestCase(unittest.TestCase):
    _program_name = 'validation_test'
    _class_name = 'ValidationTestCase'
    _resources_dir = '../../test-classes'
    # _variable_file = _resources_dir + "/test_sub_variable_file.properties"
    # _model_file = _resources_dir + '/test_empty.json'
    # _variable_file = _resources_dir + "/test_invalid_variable_file.properties"
    # _archive_file = _resources_dir + "/test_jms_archive.zip"

    def setUp(self):
        self.name = 'ValidationTestCase'
        self._logger = PlatformLogger('wlsdeploy.validate')
        self.wls_helper = WebLogicHelper(self._logger)

        # add summary handler to validate logger to check results
        self._summary_handler = SummaryHandler()
        self._logger.logger.addHandler(self._summary_handler)

    def tearDown(self):
        # remove summary handler for next test suite
        self._logger.logger.removeHandler(self._summary_handler)

    def testModelValidation(self):
        _method_name = 'testModelValidation'

        _model_file = self._resources_dir + '/variablestest.yaml'
        _variable_file = self._resources_dir + '/variablestest.properties'
        _archive_file = self._resources_dir + '/variablestest.zip'

        mw_home = os.environ['MW_HOME']
        args_map = {
            '-oracle_home': mw_home,
            '-model_file': _model_file,
            '-variable_file': _variable_file,
            '-archive_file': _archive_file
        }

        model_context = ModelContext('ValidationTestCase', args_map)

        try:
            model_dictionary = FileToPython(model_context.get_model_file()).parse()
            model_validator = Validator(model_context,
                                        wlst_mode=WlstModes.ONLINE)
            return_code = model_validator.validate_in_tool_mode(model_dictionary,
                                                                model_context.get_variable_file(),
                                                                model_context.get_archive_file_name())
            self._logger.info('The Validator.validate_in_tool_mode() call returned {0}',
                              Validator.ReturnCode.from_value(return_code),
                              class_name=self._class_name, method_name=_method_name)
        except TranslateException, te:
            return_code = Validator.ReturnCode.STOP
            self._logger.severe('WLSDPLY-20009',
                                self._program_name,
                                model_context.get_model_file(),
                                te.getLocalizedMessage(), error=te,
                                class_name=self._class_name, method_name=_method_name)

        self.assertNotEqual(return_code, Validator.ReturnCode.STOP)
Esempio n. 3
0
    __logger.info("WLSDPLY-09005",
                  admin_url,
                  method_name=_method_name,
                  class_name=_class_name)

    try:
        __wlst_helper.connect(admin_user, admin_pwd, admin_url)
        deployer_utils.ensure_no_uncommitted_changes_or_edit_sessions()
        __wlst_helper.edit()
        __wlst_helper.start_edit()
    except BundleAwareException, ex:
        raise ex

    __logger.info("WLSDPLY-09007",
                  admin_url,
                  method_name=_method_name,
                  class_name=_class_name)

    try:
        model_deployer.deploy_resources(model,
                                        model_context,
                                        aliases,
                                        wlst_mode=__wlst_mode)
    except DeployException, de:
        __release_edit_session_and_disconnect()
        raise de

    exit_code = 0

    try:
        # First we enable the stdout again and then redirect the stdoout to a string output stream
    except EncryptionException, ee:
        __logger.severe('WLSDPLY-04208',
                        _program_name,
                        ee.getLocalizedMessage(),
                        error=ee,
                        class_name=_class_name,
                        method_name=_method_name)
        return CommandLineArgUtil.PROG_ERROR_EXIT_CODE

    if variable_change_count > 0:
        try:
            variable_helper.write_variables(_program_name, variables,
                                            variable_file)
            __logger.info('WLSDPLY-04209',
                          _program_name,
                          variable_change_count,
                          variable_file,
                          class_name=_class_name,
                          method_name=_method_name)
        except VariableException, ve:
            __logger.severe('WLSDPLY-20007',
                            _program_name,
                            variable_file,
                            ve.getLocalizedMessage(),
                            error=ve,
                            class_name=_class_name,
                            method_name=_method_name)
            return CommandLineArgUtil.PROG_ERROR_EXIT_CODE

    if model_change_count > 0:
        try:
            model_writer = PythonToFile(model)
def _add_domain_name(location, aliases):
    _method_name = '_get_domain_name'
    try:
        wlst_helper.cd('/')
        domain_name = wlst_helper.get(model_constants.DOMAIN_NAME)
    except PyWLSTException, pe:
        de = exception_helper.create_discover_exception(
            'WLSDPLY-06020', pe.getLocalizedMessage())
        __logger.throwing(class_name=_class_name,
                          method_name=_method_name,
                          error=de)
        raise de
    if domain_name is not None:
        location.add_name_token(aliases.get_name_token(location), domain_name)
        __logger.info('WLSDPLY-06022',
                      domain_name,
                      class_name=_class_name,
                      method_name=_method_name)
    else:
        de = exception_helper.create_discover_exception(
            'WLSDPLY-WLSDPLY-06023')
        __logger.throwing(class_name=_class_name,
                          method_name=_method_name,
                          error=de)
        raise de


def __discover_multi_tenant(model, model_context, base_location, aliases):
    """
    Discover the multi-tenant-related parts of the domain, if they exist.
    :param model: the model object to populate
    :param model_context: the model context object
        if exit_code != CommandLineArgUtil.HELP_EXIT_CODE:
            __logger.severe('WLSDPLY-20008', _program_name, ex.getLocalizedMessage(), error=ex,
                            class_name=_class_name, method_name=_method_name)
        __log_and_exit(exit_code, _class_name, _method_name)

    model_file = model_context.get_model_file()
    try:
        model = FileToPython(model_file, True).parse()
    except TranslateException, te:
        __logger.severe('WLSDPLY-20009', _program_name, model_file, te.getLocalizedMessage(), error=te,
                        class_name=_class_name, method_name=_method_name)
        sys.exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE)

    inserted, model = __inject(model, model_context)
    if inserted:
        __logger.info('WLSDPLY-19604', class_name=_class_name, method_name=_method_name)
        try:
            __persist_model(model, model_context)

        except TranslateException, ex:
            __logger.severe('WLSDPLY-20024', _program_name, model_context.get_archive_file_name(),
                            ex.getLocalizedMessage(), error=ex, class_name=_class_name, method_name=_method_name)
            __log_and_exit(CommandLineArgUtil.PROG_ERROR_EXIT_CODE, _class_name, _method_name)

    __close_archive(model_context)

    __logger.exiting(result=exit_code, class_name=_class_name, method_name=_method_name)
    sys.exit(exit_code)


if __name__ == '__main__' or __name__ == 'main':
class OdlDeployer(object):
    """
    Handle the ODL validation and configuration.
    """
    __class_name = 'OdlHelper'

    def __init__(self, model, model_context, aliases, wlst_mode):
        self.model = model
        self.model_context = model_context
        self.aliases = aliases

        self.logger = PlatformLogger('wlsdeploy.deploy')
        self.wlst_mode = wlst_mode

    def configure_odl(self, parent_dict, parent_location):
        """
        Apply the ODL configuration section of the model, if present.
        :param parent_dict: the model dictionary that may contains ODL configuration
        :param parent_location: the alias location of the parent dictionary (used for logging paths)
        """
        _method_name = 'configure_odl'
        self.logger.entering(class_name=self.__class_name,
                             method_name=_method_name)

        odl_info = dictionary_utils.get_dictionary_element(
            parent_dict, ODL_CONFIGURATION)
        if len(odl_info):
            typedef = self.model_context.get_domain_typedef()
            if not (typedef.is_jrf_domain_type()
                    or typedef.is_restricted_jrf_domain_type()):
                self.logger.info('WLSDPLY-19709',
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            elif self.wlst_mode == WlstModes.ONLINE:
                self.logger.info('WLSDPLY-19700',
                                 class_name=self.__class_name,
                                 method_name=_method_name)
            else:
                for config in odl_info:
                    self._update_config(config, odl_info[config],
                                        parent_location)

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

    def _update_config(self, config_name, config_dictionary, parent_location):
        _method_name = '_update_config'

        config_location = LocationContext(parent_location).append_location(
            ODL_CONFIGURATION)
        token = self.aliases.get_name_token(config_location)
        config_location.add_name_token(token, config_name)

        servers = dictionary_utils.get_element(config_dictionary, _SERVERS)
        if servers is not None:
            servers_list = alias_utils.convert_to_type(
                'list', servers, delimiter=MODEL_LIST_DELIMITER)
            for server in servers_list:
                self.logger.info('WLSDPLY-19708',
                                 ODL_CONFIGURATION,
                                 config_name,
                                 server,
                                 class_name=self.__class_name,
                                 method_name=_method_name)
                self._update_server(server, config_dictionary, config_location)

    def _update_server(self, name, dictionary, config_location):
        _method_name = '_update_server'

        # these imports are local, since they are only present in JRF environments.
        # this method is only called after that check has been made.
        from oracle.core.ojdl.weblogic.ODLConfiguration import CONFIG_DIR
        from oracle.core.ojdl.weblogic.ODLConfiguration import CONFIG_FILE
        from oracle.core.ojdl.logging.config import LoggingConfigurationDocument

        config_dir = File(self.model_context.get_domain_home(), CONFIG_DIR)
        server_dir = File(config_dir, name)
        config_file = File(server_dir, CONFIG_FILE)
        log_template_dir = config_dir.getParentFile()

        try:
            if config_file.exists():
                source_file = config_file
                FileUtils.validateWritableFile(config_file.getPath())
            else:
                # for dynamic servers, the logging config does not exist until the server is started.
                # read the from template file, verify that the server directory is present and writable.
                source_file = File(log_template_dir, LOGGING_TEMPLATE_FILE)
                FileUtils.validateExistingFile(source_file)
                if not server_dir.exists() and not server_dir.mkdirs():
                    ex = exception_helper.create_deploy_exception(
                        'WLSDPLY-19710', server_dir)
                    self.logger.throwing(ex,
                                         class_name=self.__class_name,
                                         method_name=_method_name)
                    raise ex
                FileUtils.validateWritableDirectory(server_dir.getPath())

            document = LoggingConfigurationDocument(
                FileInputStream(source_file))

            # configure AddJvmNumber
            add_jvm_number = dictionary_utils.get_element(
                dictionary, _ADD_JVM_NUMBER)
            if add_jvm_number is not None:
                document.setAddJvmNumber(
                    alias_utils.convert_boolean(add_jvm_number))

            # configure HandlerDefaults
            handler_defaults = dictionary_utils.get_dictionary_element(
                dictionary, _HANDLER_DEFAULTS)
            if handler_defaults is not None:
                for key in handler_defaults:
                    value = handler_defaults[key]
                    document.setHandlerDefault(key, _get_property_text(value))

            # configure Handlers
            # do these before loggers, in case new handlers are assigned to loggers
            existing_handler_names = document.getHandlerNames()
            handlers = dictionary_utils.get_dictionary_element(
                dictionary, _HANDLER)
            if handlers is not None:
                for handler_name in handlers:
                    handler = handlers[handler_name]
                    self._configure_handler(handler_name, handler, document,
                                            existing_handler_names,
                                            config_location)

            # configure Loggers
            existing_logger_names = document.getLoggerNames()
            loggers = dictionary_utils.get_dictionary_element(
                dictionary, _LOGGER)
            if loggers is not None:
                for logger_name in loggers:
                    logger = loggers[logger_name]
                    self._configure_logger(logger_name, logger, document,
                                           existing_logger_names,
                                           config_location)

            document.writeDocument(FileOutputStream(config_file))

        except (ParserConfigurationException, SAXException, IOException,
                IllegalArgumentException), ex:
            self.logger.severe('WLSDPLY-19707',
                               name,
                               ex.getLocalizedMessage(),
                               class_name=self.__class_name,
                               method_name=_method_name)
        return
Esempio n. 8
0
        model_dictionary = cla_helper.merge_model_files(model_file_name)
        model_validator = Validator(model_context, logger=__logger)
        validation_results = model_validator.validate_in_standalone_mode(model_dictionary,
                                                                         model_context.get_variable_file(),
                                                                         model_context.get_archive_file_name())
    except TranslateException, te:
        __logger.severe('WLSDPLY-20009', _program_name, model_file_name, te.getLocalizedMessage(),
                        error=te, class_name=_class_name, method_name=_method_name)
        ex = exception_helper.create_validate_exception(te.getLocalizedMessage(), error=te)
        __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
        raise ex

    if print_usage is None:
        __logger.info('WLSDPLY-05403',
                      model_file_name,
                      validation_results.get_errors_count(),
                      validation_results.get_warnings_count(),
                      validation_results.get_infos_count(),
                      class_name=_class_name, method_name=_method_name)

    validation_results.print_details()

    __logger.exiting(class_name=_class_name, method_name=_method_name)


def main(args):
    """
    The main entry point for the validateModel tool.

    :param args:
    :return:
    """
class CredentialMapHelper(object):
    """
    Creates .ldift initialization file for user/password credential mappings
    """
    _class_name = 'CredentialMapHelper'

    def __init__(self, model_context, exception_type):
        """
        Initialize an instance of CredentialMapHelper.
        :param model_context: used to find domain home
        :param exception_type: the type of exception to be thrown
        """
        self._model_context = model_context
        self._exception_type = exception_type
        self._logger = PlatformLogger('wlsdeploy.tool.util')
        self._weblogic_helper = WebLogicHelper(self._logger)
        self._resource_escaper = ResourcePolicyIdUtil.getEscaper()
        self._b64_encoder = BASE64Encoder()

    def create_default_init_file(self, default_mapping_nodes):
        """
        Create a .ldift file to initialize default credential mappers.
        Build a hash map for use with a template file resource.
        Write the file to a known location in the domain.
        :param default_mapping_nodes: the credential mapping elements from the model
        """
        _method_name = 'create_default_init_file'

        template_hash = self._build_default_template_hash(
            default_mapping_nodes)
        template_path = TEMPLATE_PATH + '/' + DEFAULT_MAPPER_INIT_FILE

        output_dir = File(self._model_context.get_domain_home(),
                          SECURITY_SUBDIR)
        output_file = File(output_dir, DEFAULT_MAPPER_INIT_FILE)

        self._logger.info('WLSDPLY-01790',
                          output_file,
                          class_name=self._class_name,
                          method_name=_method_name)

        file_template_helper.create_file(template_path, template_hash,
                                         output_file, self._exception_type)

    def _build_default_template_hash(self, mapping_section_nodes):
        """
        Create a dictionary of substitution values to apply to the default credential mappers template.
        :param mapping_section_nodes: the credential mapping elements from the model
        :return: the template hash dictionary
        """
        template_hash = dict()

        credential_mappings = []
        resource_mappings = []

        for mapping_type in mapping_section_nodes.keys():
            mapping_name_nodes = mapping_section_nodes[mapping_type]
            for mapping_name in mapping_name_nodes.keys():
                mapping = mapping_name_nodes[mapping_name]
                mapping_hash = self._build_mapping_hash(
                    mapping_type, mapping_name, mapping)

                # add a hash with remote target details to create a single passwordCredentialMap element
                credential_mappings.append(mapping_hash)

                # add a modified hash for each local user to create resourceMap elements
                resource_name = mapping_hash[HASH_RESOURCE_NAME]
                local_users = self._get_local_users(mapping_type, mapping_name,
                                                    mapping)
                for local_user in local_users:
                    resource_hash = dict(mapping_hash)
                    resource_hash[HASH_LOCAL_USER] = local_user
                    resource_hash[HASH_RESOURCE_CN] = self._create_cn(
                        resource_name, local_user)
                    resource_mappings.append(resource_hash)

        template_hash[CREDENTIAL_MAPPINGS] = credential_mappings
        template_hash[RESOURCE_MAPPINGS] = resource_mappings
        return template_hash

    def _build_mapping_hash(self, mapping_type, mapping_name, mapping):
        """
        Build a template hash for the specified mapping element from the model.
        :param mapping_type: the type of the mapping, such as 'CrossDomain'
        :param mapping_name: the mapping name from the model, such as 'map1'
        :param mapping: the mapping element from the model
        :return: the template hash
        """
        resource_name = self._build_resource_name(mapping_type, mapping_name,
                                                  mapping)

        remote_user = self._get_required_attribute(mapping, REMOTE_USER,
                                                   mapping_type, mapping_name)
        credential_cn = self._create_cn(resource_name, remote_user)

        # the password needs to be encrypted, then base64 encoded
        password = self._get_required_attribute(mapping, REMOTE_PASSWORD,
                                                mapping_type, mapping_name)
        encrypted = self._weblogic_helper.encrypt(
            password, self._model_context.get_domain_home())
        password_encoded = self._b64_encoder.encodeBuffer(
            String(encrypted).getBytes("UTF-8"))

        # the local user and resource CN will be updated later for each user
        return {
            HASH_CREDENTIAL_CN: credential_cn,
            HASH_LOCAL_USER: NULL,
            HASH_PASSWORD_ENCODED: password_encoded,
            HASH_REMOTE_USER: remote_user,
            HASH_RESOURCE_CN: NULL,
            HASH_RESOURCE_NAME: resource_name
        }

    def _build_resource_name(self, mapping_type, mapping_name, mapping):
        """
        Build the resource name based on elements in the mapping element from the model.
        Example: type=<remote>, protocol=http, remoteHost=my.host, remotePort=7020, path=/myapp, method=POST
        :param mapping_type: the type of the mapping, such as 'CrossDomain'
        :param mapping_name: the mapping name from the model, such as 'map1'
        :param mapping: the mapping element from the model
        :return: the resource name
        """

        # for cross-domain mapping, use domain for remote host, and set cross-domain protocol
        if mapping_type == CROSS_DOMAIN:
            remote_host = self._get_required_attribute(mapping, REMOTE_DOMAIN,
                                                       mapping_type,
                                                       mapping_name)
            protocol = CROSS_DOMAIN_PROTOCOL
        else:
            remote_host = self._get_required_attribute(mapping, REMOTE_HOST,
                                                       mapping_type,
                                                       mapping_name)
            protocol = dictionary_utils.get_element(mapping, PROTOCOL)

        # build a map of available values, some may be None
        resource_name_values = {
            ID_METHOD: dictionary_utils.get_element(mapping, METHOD),
            ID_PATH: dictionary_utils.get_element(mapping, PATH),
            ID_PROTOCOL: protocol,
            ID_REMOTE_HOST: remote_host,
            ID_REMOTE_PORT: dictionary_utils.get_element(mapping, REMOTE_PORT)
        }

        # build the resource name string
        resource_name = 'type=<remote>'
        for field in RESOURCE_FIELDS:
            value = dictionary_utils.get_element(resource_name_values, field)
            if value is not None:
                resource_name += ', %s=%s' % (field, value)

        return resource_name

    def _get_local_users(self, mapping_type, mapping_name, mapping):
        """
        Get the local users list, based on the mapping element from the model.
        :param mapping_type: the type of the mapping, such as 'CrossDomain'
        :param mapping_name: the mapping name from the model, such as 'map1'
        :param mapping: the mapping element from the model
        :return: a list of local users
        """
        if mapping_type == CROSS_DOMAIN:
            return [CROSS_DOMAIN_USER]

        local_user_value = self._get_required_attribute(
            mapping, USER, mapping_type, mapping_name)
        return TypeUtils.convertToType(list, local_user_value)

    def _get_required_attribute(self, dictionary, name, mapping_type,
                                mapping_name):
        """
        Return the value of the specified attribute from the specified dictionary.
        Log and throw an exception if the attribute is not found.
        :param dictionary: the dictionary to be checked
        :param name: the name of the attribute to find
        :param mapping_type: the type of the mapping, such as 'CrossDomain'
        :param mapping_name: the mapping name from the model, such as 'map1'
        :return: the value of the attribute
        :raises: Tool type exception: if an the attribute is not found
        """
        _method_name = '_get_required_attribute'

        result = dictionary_utils.get_element(dictionary, name)
        if result is None:
            pwe = exception_helper.create_exception(self._exception_type,
                                                    'WLSDPLY-01791', name,
                                                    mapping_type, mapping_name)
            self._logger.throwing(class_name=self._class_name,
                                  method_name=_method_name,
                                  error=pwe)
            raise pwe
        return result

    def _create_cn(self, resource_name, user):
        """
        Create a CN string from the specified resource name and user name.
        The result should be escaped for use as a CN.
        :param resource_name: the name of the resource
        :param user: the user name
        :return: the CN string
        """
        name = resource_name + "." + user
        return self._resource_escaper.escapeString(name)
Esempio n. 10
0
class ValidationTestCase(unittest.TestCase):
    _program_name = 'validation_test'
    _class_name = 'ValidationTestCase'
    _resources_dir = '../../test-classes'
    # Model persistence file
    _wlsdeply_store_model = os.path.abspath(
        os.getcwd()) + '/' + _resources_dir + '/validate-mii-model.json'

    # _variable_file = _resources_dir + "/test_sub_variable_file.properties"
    # _model_file = _resources_dir + '/test_empty.json'
    # _variable_file = _resources_dir + "/test_invalid_variable_file.properties"
    # _archive_file = _resources_dir + "/test_jms_archive.zip"

    def setUp(self):
        self.name = 'ValidationTestCase'
        self._logger = PlatformLogger('wlsdeploy.validate')
        self.wls_helper = WebLogicHelper(self._logger)

        # add summary handler to validate logger to check results
        self._summary_handler = SummaryHandler()
        self._logger.logger.addHandler(self._summary_handler)

        # Define custom configuration path for WDT
        os.environ['WDT_CUSTOM_CONFIG'] = self._resources_dir
        # Indicate that WDT should persist model file
        os.environ['__WLSDEPLOY_STORE_MODEL__'] = self._wlsdeply_store_model

    def tearDown(self):
        # remove summary handler for next test suite
        self._logger.logger.removeHandler(self._summary_handler)

        # Clean up temporary WDT custom configuration environment variables
        # and model persistence files
        del os.environ['WDT_CUSTOM_CONFIG']
        del os.environ['__WLSDEPLOY_STORE_MODEL__']
        self.deleteFile(self._wlsdeply_store_model)

    def testModelValidation(self):
        _method_name = 'testModelValidation'

        _model_file = self._resources_dir + '/variablestest.yaml'
        _variable_file = self._resources_dir + '/variablestest.properties'
        _archive_file = self._resources_dir + '/variablestest.zip'

        mw_home = os.environ['MW_HOME']
        args_map = {
            '-oracle_home': mw_home,
            '-model_file': _model_file,
            '-variable_file': _variable_file,
            '-archive_file': _archive_file
        }

        model_context = ModelContext('ValidationTestCase', args_map)

        try:
            model_dictionary = FileToPython(
                model_context.get_model_file()).parse()
            model_validator = Validator(model_context,
                                        wlst_mode=WlstModes.ONLINE)
            return_code = model_validator.validate_in_tool_mode(
                model_dictionary, model_context.get_variable_file(),
                model_context.get_archive_file_name())
            self._logger.info(
                'The Validator.validate_in_tool_mode() call returned {0}',
                Validator.ReturnCode.from_value(return_code),
                class_name=self._class_name,
                method_name=_method_name)
        except TranslateException, te:
            return_code = Validator.ReturnCode.STOP
            self._logger.severe('WLSDPLY-20009',
                                self._program_name,
                                model_context.get_model_file(),
                                te.getLocalizedMessage(),
                                error=te,
                                class_name=self._class_name,
                                method_name=_method_name)

        self.assertNotEqual(return_code, Validator.ReturnCode.STOP)