def __clear_archive_file(model_context):
    """
    Remove any binaries already in the archive file.
    :param model_context: the model context
    :raises DiscoverException: if an error occurs while removing the binaries
    """
    _method_name = '__clear_archive_file'
    __logger.entering(class_name=_class_name, method_name=_method_name)

    archive_file = model_context.get_archive_file()

    if archive_file is None:
        de = exception_helper.create_discover_exception(
            'WLSDPLY-06004', model_context.get_archive_file_name())
        __logger.throwing(class_name=_class_name,
                          method_name=_method_name,
                          error=de)
        raise de

    try:
        archive_file.removeAllBinaries()
    except WLSDeployArchiveIOException, wioe:
        de = exception_helper.create_discover_exception(
            'WLSDPLY-06005', wioe.getLocalizedMessage())
        __logger.throwing(class_name=_class_name,
                          method_name=_method_name,
                          error=de)
        raise de
 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
    def _add_library(self, server_name, classpath_name):
        """
        This is a private method.

        Collect the binary and directories from the classpath string into the archive file.
        If the binary or directory cannot be collected into the archive file, the entry will remain in the
        classpath string, but a warning will be logged about the problem.
        :param server_name: for the classpath files being collected
        :param classpath_name: string containing the classpath entries
        :return: original name modified for the new location and tokenized
        """
        _method_name = '_add_library'
        _logger.entering(server_name, classpath_name, class_name=_class_name, method_name=_method_name)
        return_name = classpath_name
        if self._is_oracle_home_file(classpath_name):
            _logger.info('WLSDPLY-06618', classpath_name, server_name, class_name=_class_name, method_name=_method_name)
            return_name = self._model_context.tokenize_path(classpath_name)
        else:
            _logger.finer('WLSDPLY-06619', classpath_name, server_name, class_name=_class_name,
                          method_name=_method_name)
            archive_file = self._model_context.get_archive_file()
            file_name_path = self._convert_path(classpath_name)
            new_source_name = None
            try:
                new_source_name = archive_file.addClasspathLibrary(File(file_name_path))
            except IllegalArgumentException, iae:
                _logger.warning('WLSDPLY-06620', server_name, file_name_path, iae.getLocalizedMessage(),
                                class_name=_class_name, method_name=_method_name)
            except WLSDeployArchiveIOException, wioe:
                de = exception_helper.create_discover_exception('WLSDPLY-06621', server_name, file_name_path,
                                                                wioe.getLocalizedMessage())
                _logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
                raise de
def __connect_to_domain(model_context):
    """
    Connects WLST to the domain by either connecting to the Admin Server or reading the domain from disk.
    :param model_context: the model context
    :raises DiscoverException: if a WLST error occurs while connecting to or reading the domain
    """
    _method_name = '__connect_to_domain'

    __logger.entering(class_name=_class_name, method_name=_method_name)
    if __wlst_mode == WlstModes.ONLINE:
        try:
            wlst_helper.connect(model_context.get_admin_user(),
                                model_context.get_admin_password(),
                                model_context.get_admin_url())
        except PyWLSTException, wlst_ex:
            ex = exception_helper.create_discover_exception(
                'WLSDPLY-06001',
                model_context.get_admin_url(),
                model_context.get_admin_user(),
                wlst_ex.getLocalizedMessage(),
                error=wlst_ex)
            __logger.throwing(ex,
                              class_name=_class_name,
                              method_name=_method_name)
            raise ex
Beispiel #5
0
def __discover(model_context, aliases, injector, helper):
    """
    Populate the model from the domain.
    :param model_context: the model context
    :param aliases: aliases instance for discover
    :param injector: variable injector instance
    :param helper: wlst_helper instance
    :return: the fully-populated model
    :raises DiscoverException: if an error occurred while discover the domain
    """
    _method_name = '__discover'
    model = Model()
    base_location = LocationContext()
    __connect_to_domain(model_context, helper)
    try:
        _add_domain_name(base_location, aliases, helper)
        DomainInfoDiscoverer(model_context, model.get_model_domain_info(), base_location, wlst_mode=__wlst_mode,
                             aliases=aliases, variable_injector=injector).discover()
        TopologyDiscoverer(model_context, model.get_model_topology(), base_location, wlst_mode=__wlst_mode,
                           aliases=aliases, variable_injector=injector).discover()
        ResourcesDiscoverer(model_context, model.get_model_resources(), base_location, wlst_mode=__wlst_mode,
                            aliases=aliases, variable_injector=injector).discover()
        DeploymentsDiscoverer(model_context, model.get_model_app_deployments(), base_location, wlst_mode=__wlst_mode,
                              aliases=aliases, variable_injector=injector).discover()
        __discover_multi_tenant(model, model_context, base_location, aliases, injector)
    except AliasException, ae:
        wls_version = WebLogicHelper(__logger).get_actual_weblogic_version()
        wlst_mode = WlstModes.from_value(__wlst_mode)
        ex = exception_helper.create_discover_exception('WLSDPLY-06000', model_context.get_domain_name(),
                                                        model_context.get_domain_home(), wls_version, wlst_mode,
                                                        ae.getLocalizedMessage(), error=ae)
        __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
        raise ex
Beispiel #6
0
 def _add_wldf_script(self, model_name, model_value, location):
     """
     Add the WLDF WatchNotification ScriptAction script for attribute PathToScript to the archive file.
     Modify the model_value to reflect the new name after the archive file has been deployed.
     :param model_name: name of the  attribute
     :param model_value: containing the Script Action script
     :param location: context containing the current location of the ScriptAction
     :return: modified model value reflecting new PathToScript location
     """
     _method_name = '_add_wldf_script'
     _logger.entering(model_name, class_name=_class_name, method_name=_method_name)
     new_script_name = model_value
     if model_value is not None:
         _logger.info('WLSDPLY-06359', model_value, self._alias_helper.get_model_folder_path(location),
                      class_name=_class_name, method_name=_method_name)
         archive_file = self._model_context.get_archive_file()
         # Set model_value to None if unable to add it to archive file
         modified_name = None
         try:
             modified_name = archive_file.addScript(File(model_value))
         except IllegalArgumentException, iae:
             _logger.warning('WLSDPLY-06360', self._alias_helper.get_model_folder_path(location), model_value,
                             iae.getLocalizedMessage(), class_name=_class_name,
                             method_name=_method_name)
         except WLSDeployArchiveIOException, wioe:
             de = exception_helper.create_discover_exception('WLSDPLY-06354',
                                                             self._alias_helper.get_model_folder_path(location),
                                                             model_value, wioe.getLocalizedMessage())
             _logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
             raise de
Beispiel #7
0
 def archive_jdbc_create_script(self, jdbc_store_name, jdbc_store_dictionary):
     """
     Add the JDBC store create DDL file to the archive.
     :param jdbc_store_name: name of the JDBC Store
     :param jdbc_store_dictionary: dictionary containing the discovered store attributes
     """
     _method_name = 'get_jdbc_create_script'
     _logger.entering(jdbc_store_name, class_name=_class_name, method_name=_method_name)
     if model_constants.CREATE_TABLE_DDL_FILE in jdbc_store_dictionary:
         archive_file = self._model_context.get_archive_file()
         file_name = jdbc_store_dictionary[model_constants.CREATE_TABLE_DDL_FILE]
         _logger.info('WLSDPLY-06352', jdbc_store_name, file_name, class_name=_class_name, method_name=_method_name)
         try:
             new_source_name = archive_file.addScript(File(file_name))
         except IllegalArgumentException, iae:
             _logger.warning('WLSDPLY-06353', jdbc_store_name, file_name,
                             iae.getLocalizedMessage(), class_name=_class_name,
                             method_name=_method_name)
             _logger.exiting(class_name=_class_name, method_name=_method_name)
             return
         except WLSDeployArchiveIOException, wioe:
             de = exception_helper.create_discover_exception('WLSDPLY-06354', jdbc_store_name, file_name,
                                                             wioe.getLocalizedMessage())
             _logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
             raise de
def __persist_model(model, model_context):
    """
    Save the model to the specified model file name or to the archive if the file name was not specified.
    :param model: the model to save
    :param model_context: the model context
    :raises DiscoverException: if an error occurs while create a temporary file for the model
                               or while adding it to the archive
    :raises TranslateException: if an error occurs while serializing the model or writing it to disk
    """
    _method_name = '__persist_model'

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

    add_to_archive = False
    model_file_name = model_context.get_model_file()
    if model_file_name is None:
        add_to_archive = True
        try:
            domain_name = model_context.get_domain_name()
            model_file = File.createTempFile(domain_name,
                                             '.yaml').getCanonicalFile()
            model_file_name = model_context.get_domain_name() + '.yaml'
        except (IllegalArgumentException, IOException), ie:
            ex = exception_helper.create_discover_exception(
                'WLSDPLY-06008', ie.getLocalizedMessage(), error=ie)
            __logger.throwing(ex,
                              class_name=_class_name,
                              method_name=_method_name)
            raise ex
    def add_application_plan_to_archive(self, application_name,
                                        application_dict):
        """
        Add the application deployment plan to the archive file. Create a unique name for the deployment plan from
        the application name and the plan name. If the plan cannot be located and added to the archive file, the
        plan will remain in the model, but a warning message will be generated about the problem.
        :param application_name: name of the application in the model
        :param application_dict: containing the application information
        :raise: DiscoverException: An unexpected exception occurred trying to write the plan to the archive file
        """
        _method_name = 'add_application_plan_to_archive'
        _logger.entering(application_name,
                         class_name=_class_name,
                         method_name=_method_name)
        archive_file = self._model_context.get_archive_file()
        if model_constants.PLAN_PATH in application_dict:
            app_source_name = application_dict[model_constants.SOURCE_PATH]
            plan_path = application_dict[model_constants.PLAN_PATH]
            if plan_path:
                _logger.info('WLSDPLY-06402',
                             application_name,
                             plan_path,
                             class_name=_class_name,
                             method_name=_method_name)
                plan_dir = None
                if model_constants.PLAN_DIR in application_dict:
                    plan_dir = application_dict[model_constants.PLAN_DIR]
                    del application_dict[model_constants.PLAN_DIR]
                plan_file_name = self._resolve_deployment_plan_path(
                    plan_dir, plan_path)
                new_plan_name = None
                try:
                    new_plan_name = archive_file.addApplicationDeploymentPlan(
                        File(plan_file_name),
                        _generate_new_plan_name(app_source_name,
                                                plan_file_name))
                except IllegalArgumentException, iae:
                    _logger.warning('WLSDPLY-06395',
                                    application_name,
                                    plan_file_name,
                                    iae.getLocalizedMessage(),
                                    class_name=_class_name,
                                    method_name=_method_name)

                except WLSDeployArchiveIOException, wioe:
                    de = exception_helper.create_discover_exception(
                        'WLSDPLY-06397', application_dict, plan_file_name,
                        wioe.getLocalizedMessage())
                    _logger.throwing(class_name=_class_name,
                                     method_name=_method_name,
                                     error=de)
                    raise de
                if new_plan_name is not None:
                    _logger.finer('WLSDPLY-06399',
                                  application_name,
                                  new_plan_name,
                                  class_name=_class_name,
                                  method_name=_method_name)
                    application_dict[model_constants.PLAN_PATH] = new_plan_name
Beispiel #10
0
def _add_domain_name(location, aliases, helper):
    _method_name = '_get_domain_name'
    try:
        helper.cd('/')
        domain_name = 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
Beispiel #11
0
    def _inspect_security_folder_name(self, folder_name, location):
        # This is clunky - Some security providers in 11g offline have the name "Provider", and cannot be discovered.
        # If found, log and throw an exception here, and the SecurityConfiguration will be omitted from the model.

        if (not self._weblogic_helper.is_version_in_12c()) and self._wlst_mode == WlstModes.OFFLINE and \
                self._aliases.is_security_provider_type(location) and 'Provider' == folder_name:
            raise exception_helper.create_discover_exception('WLSDPLY-06201', folder_name, location.get_folder_path())

        return folder_name
 def _add_shared_libray_plan_to_archive(self, library_name, library_dict):
     """
     Add the shared library deployment plan to the archive file. Create a unique name for the deployment plan from
     the library binary name and the plan name. If the plan cannot be added to the archive file, the plan
     information will remain in the model library entry, but a warning will be generated.
     :param library_name: shared library name in the model
     :param library_dict: containing the library information
     :raise: DiscoverException: An unexpected exception occurred trying to write the plan to the archive file
     """
     _method_name = 'add_application_plan_to_archive'
     _logger.entering(library_name,
                      class_name=_class_name,
                      method_name=_method_name)
     archive_file = self._model_context.get_archive_file()
     if model_constants.PLAN_PATH in library_dict:
         library_source_name = library_dict[model_constants.SOURCE_PATH]
         plan_path = library_dict[model_constants.PLAN_PATH]
         if plan_path:
             new_plan_name = None
             _logger.info('WLSDPLY-06389',
                          library_name,
                          plan_path,
                          class_name=_class_name,
                          method_name=_method_name)
             plan_dir = None
             if model_constants.PLAN_DIR in library_dict:
                 plan_dir = library_dict[model_constants.PLAN_DIR]
                 del library_dict[model_constants.PLAN_DIR]
             plan_file_name = self._resolve_deployment_plan_path(
                 plan_dir, plan_path)
             try:
                 new_plan_name = archive_file.addApplicationDeploymentPlan(
                     File(plan_file_name),
                     _generate_new_plan_name(library_source_name,
                                             plan_file_name))
             except IllegalArgumentException, iae:
                 _logger.warning('WLSDPLY-06385',
                                 library_name,
                                 plan_file_name,
                                 iae.getLocalizedMessage(),
                                 class_name=_class_name,
                                 method_name=_method_name)
             except WLSDeployArchiveIOException, wioe:
                 de = exception_helper.create_discover_exception(
                     'WLSDPLY-06387', library_name, plan_file_name,
                     wioe.getLocalizedMessage())
                 _logger.throwing(class_name=_class_name,
                                  method_name=_method_name,
                                  error=de)
                 raise de
             if new_plan_name is not None:
                 _logger.finer('WLSDPLY-06390',
                               library_name,
                               new_plan_name,
                               class_name=_class_name,
                               method_name=_method_name)
                 library_dict[model_constants.PLAN_PATH] = new_plan_name
Beispiel #13
0
def __disconnect_domain(helper):
    """
    Disconnects WLST from the domain by either disconnecting from the Admin Server or closing the domain read from disk.
    :param helper: wlst_helper instance
    :raises DiscoverException: if a WLST error occurred while disconnecting or closing the domain
    """
    _method_name = '__disconnect_domain'

    __logger.entering(class_name=_class_name, method_name=_method_name)
    if __wlst_mode == WlstModes.ONLINE:
        try:
            helper.disconnect()
        except PyWLSTException, wlst_ex:
            ex = exception_helper.create_discover_exception('WLSDPLY-06006',
                                                            wlst_ex.getLocalizedMessage(), error=wlst_ex)
            __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
            raise ex
    def _add_shared_libraries_to_archive(self, library_name, library_dict):
        """
        Add the binary or directory referenced by the shared library to the archive file.
        If the binary can not be located and added to the archive file, un-target the library and log the problem.
        :param library_name: name of the shared library
        :param library_dict: containing the shared library information
        :raise DiscoverException: An unexpected exception occurred trying to write the library to the archive
        """
        _method_name = 'add_shared_library_to_archive'
        _logger.entering(library_name, class_name=_class_name, method_name=_method_name)

        archive_file = self._model_context.get_archive_file()
        if model_constants.SOURCE_PATH in library_dict:
            file_name = library_dict[model_constants.SOURCE_PATH]
            if file_name:
                file_name_path = self._convert_path(file_name)
                if self._is_oracle_home_file(file_name_path):
                    _logger.info('WLSDPLY-06383', library_name, class_name=_class_name, method_name=_method_name)
                else:
                    _logger.info('WLSDPLY-06384', library_name, file_name_path, class_name=_class_name,
                                 method_name=_method_name)
                    new_source_name = None
                    try:
                        new_source_name = archive_file.addSharedLibrary(File(file_name_path))
                    except IllegalArgumentException, iae:
                        if model_constants.TARGET in library_dict:
                            target = library_dict[model_constants.TARGET]
                            del library_dict[model_constants.TARGET]
                            _logger.warning('WLSDPLY-06385', library_name, target, iae.getLocalizedMessage(),
                                            file_name_path, class_name=_class_name, method_name=_method_name)
                        else:
                            _logger.warning('WLSDPLY-06386', library_name, iae.getLocalizedMessage(), file_name_path,
                                            class_name=_class_name, method_name=_method_name)
                    except WLSDeployArchiveIOException, wioe:
                        de = exception_helper.create_discover_exception('WLSDPLY-06387', library_name, file_name_path,
                                                                        wioe.getLocalizedMessage())
                        _logger.throwing(class_name=_class_name, method_name=_method_name, error=de)
                        raise de
                    if new_source_name is not None:
                        library_dict[model_constants.SOURCE_PATH] = new_source_name
                        _logger.finer('WLSDPLY-06388', library_name, new_source_name, class_name=_class_name,
                                      method_name=_method_name)
                        self._add_shared_libray_plan_to_archive(library_name, library_dict)
 def _find_singleton_name_in_folder(self, location):
     """
     The top folder is a singleton. Find the single name for the folder.
     :param location: context containing current location informationget_mbean_folders
     :return: The single name for the folder, or None if the top folder does not exist in the domain
     """
     _method_name = '_find_singleton_name_in_top_folder'
     name = None
     names = self._find_names_in_folder(location)
     if names is not None:
         names_len = len(names)
         if names_len > 1:
             ex = exception_helper.create_discover_exception('WLSDPLY-06112', location.get_model_folders(),
                                                             self._alias_helper.get_model_folder_path(location),
                                                             len(names))
             _logger.throwing(ex, class_name=_class_name, method_name=_method_name)
             raise ex
         if names_len > 0:
             name = names[0]
     return name
Beispiel #16
0
    def get_user_env_scripts(self):
        """
        Look for the user overrides scripts run in setDomainEnv in the domain bin directory
        :raise: DiscoverException: an unexpected exception occurred writing a jar file to the archive file
        """
        _method_name = 'get_user_env_scripts'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        archive_file = self._model_context.get_archive_file()
        domain_bin = self._convert_path('bin')
        entries = []
        if os.path.isdir(domain_bin):
            search_directory = FileUtils.fixupFileSeparatorsForJython(
                os.path.join(domain_bin, "setUserOverrides*.*"))
            _logger.finer('WLSDPLY-06425',
                          search_directory,
                          class_name=_class_name,
                          method_name=_method_name)
            file_list = glob.glob(search_directory)
            if file_list:
                _logger.finer('WLSDPLY-06423',
                              domain_bin,
                              class_name=_class_name,
                              method_name=_method_name)
                for entry in file_list:
                    try:
                        updated_name = archive_file.addDomainBinScript(
                            File(entry))
                    except WLSDeployArchiveIOException, wioe:
                        de = exception_helper.create_discover_exception(
                            'WLSDPLY-06426', entry, wioe.getLocalizedMessage())
                        _logger.throwing(class_name=_class_name,
                                         method_name=_method_name,
                                         error=de)
                        raise de

                    entries.append(updated_name)
                    _logger.finer('WLSDPLY-06424',
                                  entry,
                                  updated_name,
                                  class_name=_class_name,
                                  method_name=_method_name)
Beispiel #17
0
 def _add_keystore_file_to_archive(self, model_name, model_value, location):
     """
     Add the Server custom trust or identity keystore file to the archive.
     :param model_name: attribute name in the model
     :param model_value: converted model value for the attribute
     :param location: context containing the current location information
     :return: modified location and name for the model keystore file
     """
     _method_name = '_add_keystore_file_to_archive'
     _logger.entering(model_name,
                      str(location),
                      class_name=_class_name,
                      method_name=_method_name)
     new_name = None
     if not string_utils.is_empty(model_value):
         server_name = self._get_server_name_from_location(location)
         archive_file = self._model_context.get_archive_file()
         file_path = self._convert_path(model_value)
         _logger.finer('WLSDPLY-06623',
                       file_path,
                       server_name,
                       class_name=_class_name,
                       method_name=_method_name)
         try:
             new_name = archive_file.addServerKeyStoreFile(
                 server_name, File(file_path))
         except IllegalArgumentException, iae:
             _logger.warning('WLSDPLY-06624',
                             server_name,
                             file_path,
                             iae.getLocalizedMessage(),
                             class_name=_class_name,
                             method_name=_method_name)
         except WLSDeployArchiveIOException, wioe:
             de = exception_helper.create_discover_exception(
                 'WLSDPLY-06625', server_name, file_path,
                 wioe.getLocalizedMessage())
             _logger.throwing(class_name=_class_name,
                              method_name=_method_name,
                              error=de)
             raise de
Beispiel #18
0
    def get_domain_libs(self):
        """
        Add the java archive files stored in the domain lib into the archive file. Add the information for each
        domain library to the domain info dictionary.
        :raise DiscoverException: an unexpected exception occurred writing a jar file to the archive file
        """
        _method_name = 'get_domain_libs'
        _logger.entering(class_name=_class_name, method_name=_method_name)
        archive_file = self._model_context.get_archive_file()
        domain_lib = self._convert_path('lib')
        entries = []
        if os.path.isdir(domain_lib):
            _logger.finer('WLSDPLY-06420',
                          domain_lib,
                          class_name=_class_name,
                          method_name=_method_name)
            for entry in os.listdir(domain_lib):
                entry_path = os.path.join(domain_lib, entry)
                if path_utils.is_jar_file(entry_path):
                    try:
                        updated_name = archive_file.addDomainLibLibrary(
                            File(entry_path))
                    except WLSDeployArchiveIOException, wioe:
                        de = exception_helper.create_discover_exception(
                            'WLSDPLY-06421', entry, wioe.getLocalizedMessage())
                        _logger.throwing(class_name=_class_name,
                                         method_name=_method_name,
                                         error=de)
                        raise de

                    entries.append(updated_name)
                    _logger.finer('WLSDPLY-06422',
                                  entry,
                                  updated_name,
                                  class_name=_class_name,
                                  method_name=_method_name)
        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
    :raises DiscoverException: if an error occurs during discovery
    """
    MultiTenantDiscoverer(model,
                          model_context,
        model_translator.PythonToFile(model.get_model()).write_to_file(model_file.getAbsolutePath())
    except TranslateException, ex:
        # Jython 2.2.1 does not support finally so use this like a finally block...
        if add_to_archive and not model_file.delete():
            model_file.deleteOnExit()
        raise ex

    if add_to_archive:
        try:
            archive_file = model_context.get_archive_file()
            archive_file.addModel(model_file, model_file_name)
            if not model_file.delete():
                model_file.deleteOnExit()
        except (WLSDeployArchiveIOException, IllegalArgumentException), arch_ex:
            ex = exception_helper.create_discover_exception('WLSDPLY-20023', _program_name,
                                                            model_file.getAbsolutePath(), model_file_name,
                                                            arch_ex.getLocalizedMessage(),
                                                            error=arch_ex)
            __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
            if not model_file.delete():
                model_file.deleteOnExit()
            raise ex

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


def __log_and_exit(exit_code, class_name, _method_name):
    """
    Helper method to log the exiting message and call sys.exit()
    :param exit_code: the exit code to use
    :param class_name: the class name to pass  to the logger
Beispiel #21
0
                      class_name=_class_name,
                      method_name=_method_name)
        file_path = self._convert_path(model_value)
        new_name = None
        try:
            6
        except IllegalArgumentException, iae:
            _logger.warning('WLSDPLY-06624',
                            server_name,
                            file_path,
                            iae.getLocalizedMessage(),
                            class_name=_class_name,
                            method_name=_method_name)
        except WLSDeployArchiveIOException, wioe:
            de = exception_helper.create_discover_exception(
                'WLSDPLY-06625', server_name, file_path,
                wioe.getLocalizedMessage())
            _logger.throwing(class_name=_class_name,
                             method_name=_method_name,
                             error=de)
            raise de
        _logger.exiting(class_name=_class_name,
                        method_name=_method_name,
                        result=new_name)
        return new_name

    def _get_server_name_from_location(self, location):
        """
        Retrieve the server name from the location context file.
        :param location: context containing the server information
        :return: server name