def __process_archive_filename_arg(argument_map): """ Validate the archive file name and load the archive file object. :param argument_map: the optional arguments map :raises CLAException: if a validation error occurs while loading the archive file object """ _method_name = '__process_archive_filename_arg' if CommandLineArgUtil.SKIP_ARCHIVE_FILE_SWITCH in argument_map: archive_file = WLSDeployArchive.noArchiveFile() else: archive_file_name = argument_map[ CommandLineArgUtil.ARCHIVE_FILE_SWITCH] archive_dir_name = path_utils.get_parent_directory(archive_file_name) if os.path.exists(archive_dir_name) is False: ex = exception_helper.create_cla_exception('WLSDPLY-06026', archive_file_name) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex try: archive_file = WLSDeployArchive(archive_file_name) except (IllegalArgumentException, IllegalStateException), ie: ex = exception_helper.create_cla_exception( 'WLSDPLY-06013', _program_name, archive_file_name, ie.getLocalizedMessage(), error=ie) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def validateRCUArgsAndModel(model_context, model, alias_helper): has_atpdbinfo = 0 domain_info = model[model_constants.DOMAIN_INFO] if domain_info is not None: if model_constants.RCU_DB_INFO in domain_info: rcu_db_info = RcuDbInfo(alias_helper, domain_info[model_constants.RCU_DB_INFO]) has_tns_admin = rcu_db_info.has_tns_admin() has_regular_db = rcu_db_info.is_regular_db() has_atpdbinfo = rcu_db_info.has_atpdbinfo() if model_context.get_archive_file_name() and not has_regular_db: System.setProperty('oracle.jdbc.fanEnabled', 'false') # 1. If it does not have the oracle.net.tns_admin specified, then extract to domain/atpwallet # 2. If it is plain old regular oracle db, do nothing # 3. If it deos not have tns_admin in the model, then the wallet must be in the archive if not has_tns_admin: # extract the wallet first archive_file = WLSDeployArchive( model_context.get_archive_file_name()) atp_wallet_zipentry = None if archive_file: atp_wallet_zipentry = archive_file.getATPWallet() if atp_wallet_zipentry and model[ model_constants.TOPOLOGY]['Name']: extract_path = atp_helper.extract_walletzip( model, model_context, archive_file, atp_wallet_zipentry) # update the model to add the tns_admin model[model_constants.DOMAIN_INFO][ model_constants.RCU_DB_INFO][ model_constants. DRIVER_PARAMS_NET_TNS_ADMIN] = extract_path else: __logger.severe('WLSDPLY-12411', error=None, class_name=_class_name, method_name="validateRCUArgsAndModel") __clean_up_temp_files() tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE) else: if model_context.get_domain_typedef().required_rcu(): if not model_context.get_rcu_database( ) or not model_context.get_rcu_prefix(): __logger.severe('WLSDPLY-12408', model_context.get_domain_type(), CommandLineArgUtil.RCU_DB_SWITCH, CommandLineArgUtil.RCU_PREFIX_SWITCH) __clean_up_temp_files() tool_exit.end(model_context, CommandLineArgUtil.PROG_ERROR_EXIT_CODE) return has_atpdbinfo
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
def _archive_contains_model_file(archive_file_name, logger): _method_name = '__archive_contains_model_file' try: archive = WLSDeployArchive(archive_file_name) logger.finer('archive_file={0}', archive.getArchiveFileName(), class_name=_class_name, method_name=_method_name) response = archive.containsModel() except (IllegalArgumentException, WLSDeployArchiveIOException), e: ex = exception_helper.create_integration_test_exception('WLSDPLY-19300', archive_file_name, e.getLocalizedMessage(), error=e) raise ex
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
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
def is_path_into_archive(path): """ Is the path specified a path into the archive file? :param path: the path to test :return: True if the path is into the archive file, False otherwise """ _method_name = 'is_path_into_archive' _logger.entering(path, class_name=_class_name, method_name=_method_name) result = WLSDeployArchive.isPathIntoArchive(path) _logger.exiting(class_name=_class_name, method_name=_method_name, result=result) return result
def qualify_nm_properties(self, type_name, model_nodes, base_location, model_context, attribute_setter): """ For the NM properties MBean, update the keystore file path to be fully qualified with the domain directory. :param type_name: the type name of the MBean to be checked :param model_nodes: the model nodes of the MBean to be checked :param base_location: the parent location of the MBean :param model_context: the model context of the tool :param attribute_setter: the attribute setter to be used for update """ if type_name == NM_PROPERTIES: location = LocationContext(base_location).append_location(type_name) keystore_file = dictionary_utils.get_element(model_nodes, CUSTOM_IDENTITY_KEYSTORE_FILE) if keystore_file and WLSDeployArchive.isPathIntoArchive(keystore_file): value = model_context.get_domain_home() + "/" + keystore_file attribute_setter.set_attribute(location, CUSTOM_IDENTITY_KEYSTORE_FILE, value)
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
def __init__(self, archive_file_name, domain_home, logger, exception_type): _method_name = '__init__' self.__archive_file_name = archive_file_name self.__domain_home = File(domain_home) self.__logger = logger self.__exception_type = exception_type try: self.__archive_file = WLSDeployArchive(archive_file_name) except (IllegalArgumentException, IllegalStateException), e: ex = exception_helper.create_exception(exception_type, 'WLSDPLY-19300', self.__archive_file_name, e.getLocalizedMessage(), error=e) self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex
def __process_archive_filename_arg(required_arg_map): """ Validate the archive file name and load the archive file object. :param required_arg_map: the required arguments map :raises CLAException: if a validation error occurs while loading the archive file object """ _method_name = '__process_archive_filename_arg' archive_file_name = required_arg_map[ CommandLineArgUtil.ARCHIVE_FILE_SWITCH] try: archive_file = WLSDeployArchive(archive_file_name) except (IllegalArgumentException, IllegalStateException), ie: ex = exception_helper.create_cla_exception('WLSDPLY-06013', _program_name, archive_file_name, ie.getLocalizedMessage(), error=ie) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex
def __init__(self, archive_files_text, domain_home, logger, exception_type): """ :param archive_files_text: a comma-separated list of one or more file names :param domain_home: the domain home :param logger: the logger to use :param exception_type: the exception type for the associated tool """ _method_name = '__init__' # used for logging only, comma-separated text is OK self.__archive_files_text = archive_files_text self.__domain_home = None if domain_home: self.__domain_home = File(domain_home) self.__logger = logger self.__exception_type = exception_type self.__archive_files = [] file_names = archive_files_text.split( CommandLineArgUtil.ARCHIVE_FILES_SEPARATOR) for file_name in file_names: try: self.__archive_files.append(WLSDeployArchive(file_name)) except (IllegalArgumentException, IllegalStateException), e: ex = exception_helper.create_exception(exception_type, 'WLSDPLY-19300', file_name, e.getLocalizedMessage(), error=e) self.__logger.throwing(ex, class_name=self.__class_name, method_name=_method_name) raise ex
'WLSDPLY-20006', _program_name, model_file_name, iae.getLocalizedMessage(), error=iae) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif CommandLineArgUtil.ARCHIVE_FILE_SWITCH in optional_arg_map: archive_file_name = optional_arg_map[ CommandLineArgUtil.ARCHIVE_FILE_SWITCH] try: archive_file = WLSDeployArchive(archive_file_name) __tmp_model_dir = FileUtils.createTempDirectory(_program_name) tmp_model_raw_file = archive_file.extractModel(__tmp_model_dir) if not tmp_model_raw_file: ex = exception_helper.create_cla_exception( 'WLSDPLY-20026', _program_name, archive_file_name, CommandLineArgUtil.MODEL_FILE_SWITCH) ex.setExitCode( CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex tmp_model_file = FileUtils.fixupFileSeparatorsForJython( tmp_model_raw_file.getAbsolutePath())
aliases = Aliases(model_context, wlst_mode=__wlst_mode) alias_helper = AliasHelper(aliases, __logger, ExceptionType.CREATE) validate_model(model, model_context, aliases) if filter_helper.apply_filters(model, "create"): # if any filters were applied, re-validate the model validate_model(model, model_context, aliases) try: has_atp = validateRCUArgsAndModel(model_context, model, alias_helper) # check if there is an atpwallet and extract in the domain dir # it is to support non JRF domain but user wants to use ATP database archive_file_name = model_context.get_archive_file_name() if not has_atp and archive_file_name and os.path.exists( archive_file_name): archive_file = WLSDeployArchive(archive_file_name) if archive_file: atp_wallet_zipentry = archive_file.getATPWallet() if atp_wallet_zipentry: atp_helper.extract_walletzip(model, model_context, archive_file, atp_wallet_zipentry) creator = DomainCreator(model, model_context, aliases) creator.create() if has_atp: rcu_properties_map = model[model_constants.DOMAIN_INFO][ model_constants.RCU_DB_INFO] rcu_db_info = RcuDbInfo(alias_helper, rcu_properties_map) atp_helper.fix_jps_config(rcu_db_info, model_context)
ex = exception_helper.create_cla_exception( 'WLSDPLY-20006', _program_name, model_file_name, iae.getLocalizedMessage(), error=iae) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif CommandLineArgUtil.ARCHIVE_FILE_SWITCH in optional_arg_map: archive_file_name = optional_arg_map[ CommandLineArgUtil.ARCHIVE_FILE_SWITCH] try: archive_file = WLSDeployArchive(archive_file_name) # # If the model file was not specified, check to see if the archive contains one. # If so, extract it and use it; otherwise, validate will only validate the archive structure. # if archive_file.containsModel(): __tmp_model_dir = FileUtils.createTempDirectory(_program_name) model_file = archive_file.extractModel(__tmp_model_dir) optional_arg_map[ CommandLineArgUtil.MODEL_FILE_SWITCH] = model_file except (IllegalArgumentException, IllegalStateException, WLSDeployArchiveIOException), archex: ex = exception_helper.create_cla_exception( 'WLSDPLY-20010', _program_name, archive_file_name,
FileUtils.validateExistingFile(model_file_name) except IllegalArgumentException, iae: ex = exception_helper.create_cla_exception( 'WLSDPLY-20006', _program_name, model_file_name, iae.getLocalizedMessage(), error=iae) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif archive_file_name is not None: try: archive_file = WLSDeployArchive(archive_file_name) __tmp_model_dir = FileUtils.createTempDirectory(_program_name) tmp_model_raw_file = archive_file.extractModel(__tmp_model_dir) if not tmp_model_raw_file: ex = exception_helper.create_cla_exception( 'WLSDPLY-20026', _program_name, archive_file_name, CommandLineArgUtil.MODEL_FILE_SWITCH) ex.setExitCode( CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex model_file_name = FileUtils.fixupFileSeparatorsForJython( tmp_model_raw_file.getAbsolutePath())
if CommandLineArgUtil.MODEL_FILE_SWITCH in optional_arg_map: model_file_name = optional_arg_map[CommandLineArgUtil.MODEL_FILE_SWITCH] try: FileUtils.validateExistingFile(model_file_name) except IllegalArgumentException, iae: ex = exception_helper.create_cla_exception('WLSDPLY-20006', _program_name, model_file_name, iae.getLocalizedMessage(), error=iae) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif CommandLineArgUtil.ARCHIVE_FILE_SWITCH in optional_arg_map: archive_file_name = optional_arg_map[CommandLineArgUtil.ARCHIVE_FILE_SWITCH] try: archive_file = WLSDeployArchive(archive_file_name) contains_model = archive_file.containsModel() if not contains_model: ex = exception_helper.create_cla_exception('WLSDPLY-19603', archive_file_name) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex else: __tmp_model_dir = FileUtils.createTempDirectory(_program_name) tmp_model_file = \ FileUtils.fixupFileSeparatorsForJython(archive_file.extractModel(__tmp_model_dir).getAbsolutePath()) except (IllegalArgumentException, IllegalStateException, WLSDeployArchiveIOException), archex: ex = exception_helper.create_cla_exception('WLSDPLY-20010', _program_name, archive_file_name, archex.getLocalizedMessage(), error=archex) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
FileUtils.validateExistingFile(model_file_name) except IllegalArgumentException, iae: ex = exception_helper.create_cla_exception( 'WLSDPLY-20006', _program_name, model_file_name, iae.getLocalizedMessage(), error=iae) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name) raise ex elif archive_file_name is not None: try: archive_file = WLSDeployArchive(archive_file_name) __tmp_model_dir = FileUtils.createTempDirectory(_program_name) model_file_name = \ FileUtils.fixupFileSeparatorsForJython(archive_file.extractModel(__tmp_model_dir).getAbsolutePath()) except (IllegalArgumentException, IllegalStateException, WLSDeployArchiveIOException), archex: ex = exception_helper.create_cla_exception( 'WLSDPLY-20010', _program_name, archive_file_name, archex.getLocalizedMessage(), error=archex) ex.setExitCode(CommandLineArgUtil.ARG_VALIDATION_ERROR_EXIT_CODE) __logger.throwing(ex, class_name=_class_name, method_name=_method_name)