def __init__(self, model, model_context, aliases, exception_type=ExceptionType.CREATE, logger=PlatformLogger('wlsdeploy.create')): self.logger = logger self.aliases = aliases self._exception_type = exception_type self.wlst_helper = WlstHelper(exception_type) self.model = Model(model) self.model_context = model_context self.wls_helper = WebLogicHelper(self.logger) self.attribute_setter = AttributeSetter(self.aliases, self.logger, exception_type) self.custom_folder_helper = CustomFolderHelper(self.aliases, self.logger, self.model_context, exception_type) # Must be initialized by the subclass since only it has # the knowledge required to compute the domain name. self.archive_helper = None self.files_to_extract_from_archive = list() return
def __init__(self, model_context, base_location, wlst_mode, aliases=None, variable_injector=None): """ :param model_context: context about the model for this instance of discover domain :param base_location: to look for common weblogic resources. By default this is the global path or '/' """ self._model_context = model_context self._base_location = base_location self._wlst_mode = wlst_mode if aliases: self._aliases = aliases else: self._aliases = Aliases(self._model_context, wlst_mode=self._wlst_mode) self._alias_helper = AliasHelper(self._aliases, _logger, ExceptionType.DISCOVER) self._variable_injector = variable_injector self._att_handler_map = OrderedDict() self._custom_folder = CustomFolderHelper(self._aliases, _logger, self._model_context, ExceptionType.DISCOVER, self._variable_injector) self._weblogic_helper = WebLogicHelper(_logger) self._wlst_helper = WlstHelper(ExceptionType.DISCOVER) self._mbean_utils = MBeanUtils(self._model_context, self._alias_helper, ExceptionType.DISCOVER) self._wls_version = self._weblogic_helper.get_actual_weblogic_version()
def __init__(self, aliases, logger, exception_type): self.logger = logger self.exception_type = exception_type self.alias_helper = AliasHelper(aliases, self.logger, self.exception_type) self.weblogic_helper = WebLogicHelper(self.logger) self.wlst_helper = WlstHelper(self.logger, self.exception_type)
def __init__(self, model_context, base_location, wlst_mode, aliases=None, credential_injector=None): """ :param model_context: context about the model for this instance of discover domain :param base_location: to look for common weblogic resources. By default this is the global path or '/' :param wlst_mode: offline or online :param aliases: optional, aliases object to use :param credential_injector: optional, injector to collect credentials """ self._model_context = model_context self._base_location = base_location self._wlst_mode = wlst_mode if aliases: self._aliases = aliases else: self._aliases = Aliases(self._model_context, wlst_mode=self._wlst_mode, exception_type=ExceptionType.DISCOVER) self._credential_injector = credential_injector self._att_handler_map = OrderedDict() self._custom_folder = CustomFolderHelper(self._aliases, _logger, self._model_context, ExceptionType.DISCOVER, self._credential_injector) self._weblogic_helper = WebLogicHelper(_logger) self._wlst_helper = WlstHelper(ExceptionType.DISCOVER) self._mbean_utils = MBeanUtils(self._model_context, self._aliases, ExceptionType.DISCOVER) self._wls_version = self._weblogic_helper.get_actual_weblogic_version()
def __init__(self, model_context, alias_helper, exception_type): self.__model_context = model_context self.__exception_type = exception_type self.__alias_helper = alias_helper self.__wlst_helper = WlstHelper(_logger, exception_type) self.__helper = self.__get_helper() self.__ignore_list = None
def __init__(self, aliases, logger, exception_type, wlst_mode=WlstModes.OFFLINE): self.__logger = logger self.__exception_type = exception_type self.__wlst_mode = wlst_mode self.__alias_helper = AliasHelper(aliases, self.__logger, exception_type) self.__wlst_helper = WlstHelper(self.__logger, exception_type) return
def main(args): """ The main entry point for the discoverDomain tool. :param args: :return: """ _method_name = 'main' __logger.entering(class_name=_class_name, method_name=_method_name) for index, arg in enumerate(args): __logger.finer('sys.argv[{0}] = {1}', str(index), str(arg), class_name=_class_name, method_name=_method_name) helper = WlstHelper(ExceptionType.DISCOVER) helper.silence() exit_code = CommandLineArgUtil.PROG_OK_EXIT_CODE try: model_context = __process_args(args) except CLAException, ex: exit_code = ex.getExitCode() 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) # create a minimal model for summary logging model_context = model_context_helper.create_exit_context(_program_name) __log_and_exit(model_context, exit_code, _class_name, _method_name)
def __init__(self, aliases, logger, model_context, exception_type): self.aliases = aliases self.logger = logger self.model_context = model_context self.exception_type = exception_type self.weblogic_helper = WebLogicHelper(self.logger) self.wlst_helper = WlstHelper(self.exception_type)
def __init__(self, model_context, alias_helper, exception_type, location, mbean_interface_name): self.__model_context = model_context self.__exception_type = exception_type self.__location = location self.__alias_helper = alias_helper self.__mbean_interface = mbean_interface_name self.__wlst_helper = WlstHelper(_logger, exception_type) self.__mbean_instance = None self.__mbean_name = ''
def __init__(self, model, model_context, aliases, exception_type, logger): self.logger = logger self.model = model self.model_context = model_context self.alias_helper = AliasHelper(aliases, self.logger, exception_type) self.wlst_helper = WlstHelper(self.logger, exception_type) topology = model.get_model_topology() if ADMIN_SERVER_NAME in topology: self._admin_server_name = topology[ADMIN_SERVER_NAME] else: self._admin_server_name = DEFAULT_ADMIN_SERVER_NAME
def __init__(self, model_context, exception_type, location): self.__model_context = model_context self.__exception_type = exception_type self.__location = location self.__aliases = Aliases( self.__model_context, wlst_mode=self.__model_context.get_target_wlst_mode()) self.__alias_helper = AliasHelper(self.__aliases, _logger, exception_type) self.__wlst_helper = WlstHelper(_logger, exception_type) self.__mbean_instance = None self.__mbean_name = ''
def set_single_folder_token(location, aliases): """ Determine the name of the MBean at the specified WLST location, and set the corresponding token. :param location: the single-folder location to be updated :param aliases: the aliases object to use for name and path resolution """ exception_type = aliases.get_exception_type() wlst_helper = WlstHelper(exception_type) list_path = aliases.get_wlst_list_path(location) existing_names = wlst_helper.get_existing_object_list(list_path) if len(existing_names) > 0: mbean_name = existing_names[0] token = aliases.get_name_token(location) location.add_name_token(token, mbean_name)
def __init__(self, model, model_context, aliases, exception_type, logger): self.logger = logger self.model = model self.model_context = model_context self.aliases = aliases self.wlst_helper = WlstHelper(exception_type) self.wls_helper = WebLogicHelper(self.logger) self.exception_type = exception_type self.domain_typedef = self.model_context.get_domain_typedef() topology = model.get_model_topology() if ADMIN_SERVER_NAME in topology: self._admin_server_name = topology[ADMIN_SERVER_NAME] else: self._admin_server_name = DEFAULT_ADMIN_SERVER_NAME
def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE): self.name = self._class_name self.model = model self.wlst_mode = wlst_mode self.model_context = model_context self.aliases = aliases self.logger = PlatformLogger('wlsdeploy.deploy') self.alias_helper = AliasHelper(aliases, self.logger, ExceptionType.DEPLOY) self.wls_helper = WebLogicHelper(self.logger) self.wlst_helper = WlstHelper(self.logger, ExceptionType.DEPLOY) self.attribute_setter = AttributeSetter(self.aliases, self.logger, ExceptionType.DEPLOY, wlst_mode=wlst_mode) self.topology_helper = TopologyHelper(self.aliases, ExceptionType.DEPLOY, self.logger) self.archive_helper = None archive_file_name = self.model_context.get_archive_file_name() if archive_file_name is not None: self.archive_helper = ArchiveHelper( archive_file_name, self.model_context.get_domain_home(), self.logger, exception_helper.ExceptionType.DEPLOY) return
def main(args): """ The main entry point for the encryptModel tool. :param args: :return: """ _method_name = 'main' __logger.entering(args[0], class_name=_class_name, method_name=_method_name) for index, arg in enumerate(args): __logger.finer('sys.argv[{0}] = {1}', str(index), str(arg), class_name=_class_name, method_name=_method_name) WlstHelper(ExceptionType.ENCRYPTION).silence() exit_code = _process_request(args) __logger.exiting(class_name=_class_name, method_name=_method_name, result=exit_code) sys.exit(exit_code)
def __init__(self, aliases, logger, model_context, exception_type, variable_injector=None): global _logger self._exception_type = exception_type self._model_context = model_context if logger is not None: _logger = logger self._alias_helper = AliasHelper(aliases, _logger, self._exception_type) self._weblogic_helper = WebLogicHelper(_logger) self._wlst_helper = WlstHelper(_logger, self._exception_type) self._info_helper = MBeanUtils(self._model_context, self._alias_helper, self._exception_type) self._variable_injector = variable_injector
def __init__(self, model, model_context, aliases, domain_home, exception_type, logger): self.logger = logger self.model = model self.model_context = model_context self.domain_home = domain_home self.alias_helper = AliasHelper(aliases, self.logger, exception_type) self.wlst_helper = WlstHelper(self.logger, exception_type) self.archive_helper = None archive_file_name = self.model_context.get_archive_file_name() if archive_file_name is not None: self.archive_helper = ArchiveHelper(archive_file_name, self.domain_home, self.logger, exception_type)
def __init__(self, model_dictionary, model_context, aliases, exception_type, logger): Creator.__init__(self, model_dictionary, model_context, aliases, exception_type, logger) self.logger = logger self.alias_helper = AliasHelper(aliases, self.logger, exception_type) self.wlst_helper = WlstHelper(self.logger, exception_type) self.wls_helper = WebLogicHelper(self.logger) self._topology = self.model.get_model_topology() # # Creating domains with the wls.jar template is busted for pre-12.1.2 domains with regards to the # names of the default authentication providers (both the DefaultAuthenticator and the # DefaultIdentityAsserter names are 'Provider', making it impossible to work with in WLST. If # the WLS version is earlier than fix this as part of domain creation... # self.__fix_default_authentication_provider_names = \ self.wls_helper.do_default_authentication_provider_names_need_fixing() return
def __init__(self, model_context, topology_dictionary, base_location, wlst_mode=WlstModes.OFFLINE, aliases=None, variable_injector=None): """ Instantiate an instance of the TopologyDiscoverer class with the runtime information provided by the init parameters. :param model_context: containing the arguments for this discover :param topology_dictionary: dictionary in which to add discovered topology information :param wlst_mode: indicates whether this discover is run in online or offline mode """ Discoverer.__init__(self, model_context, base_location, wlst_mode, aliases, variable_injector) self._dictionary = topology_dictionary self._add_att_handler(model_constants.CLASSPATH, self._add_classpath_libraries_to_archive) self._add_att_handler(model_constants.CUSTOM_IDENTITY_KEYSTORE_FILE, self._add_keystore_file_to_archive) self._add_att_handler(model_constants.CUSTOM_TRUST_KEYSTORE_FILE, self._add_keystore_file_to_archive) self._wlst_helper = WlstHelper(ExceptionType.DISCOVER)
def __init__(self, aliases, logger, model_context, exception_type, credential_injector=None): global _logger self._exception_type = exception_type self._model_context = model_context if logger is not None: _logger = logger self._weblogic_helper = WebLogicHelper(_logger) self._wlst_helper = WlstHelper(self._exception_type) self._info_helper = MBeanUtils(self._model_context, aliases, self._exception_type) self._credential_injector = credential_injector
from wlsdeploy.util import cla_helper from wlsdeploy.util import getcreds from wlsdeploy.util import tool_exit from wlsdeploy.util import variables from wlsdeploy.util import wlst_extended from wlsdeploy.util.cla_utils import CommandLineArgUtil from wlsdeploy.util.model import Model from wlsdeploy.util.weblogic_helper import WebLogicHelper wlst_extended.wlst_functions = globals() _program_name = 'deployApps' _class_name = 'deploy' __logger = PlatformLogger('wlsdeploy.deploy') __wls_helper = WebLogicHelper(__logger) __wlst_helper = WlstHelper(__logger, ExceptionType.DEPLOY) __wlst_mode = WlstModes.OFFLINE __required_arguments = [ CommandLineArgUtil.ORACLE_HOME_SWITCH, CommandLineArgUtil.DOMAIN_HOME_SWITCH ] __optional_arguments = [ # Used by shell script to locate WLST CommandLineArgUtil.DOMAIN_TYPE_SWITCH, CommandLineArgUtil.ARCHIVE_FILE_SWITCH, CommandLineArgUtil.MODEL_FILE_SWITCH, CommandLineArgUtil.PREVIOUS_MODEL_FILE_SWITCH, CommandLineArgUtil.VARIABLE_FILE_SWITCH, CommandLineArgUtil.ADMIN_URL_SWITCH,
from oracle.weblogic.deploy.util import FileUtils from oracle.weblogic.deploy.util import PyWLSTException from oracle.weblogic.deploy.util import WLSDeployArchive from wlsdeploy.aliases.wlst_modes import WlstModes from wlsdeploy.exception import exception_helper from wlsdeploy.exception.expection_types import ExceptionType from wlsdeploy.logging import platform_logger from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.aliases.model_constants import RESOURCE_GROUP from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE _class_name = "deployer_utils" _logger = platform_logger.PlatformLogger('wlsdeploy.deploy.utils') _wlst_helper = WlstHelper(_logger, ExceptionType.DEPLOY) def get_existing_object_list(location, alias_helper): """ Get a list of the existing names at the specified location. :param location: the location to be examined, for example, location MACHINE returns names under /Machines :param alias_helper: the alias helper used to determine path names """ method_name = 'get_existing_object_list' list_path = alias_helper.get_wlst_list_path(location) existing_names = _wlst_helper.get_existing_object_list(list_path) _logger.finer("WLSDPLY-09100", existing_names, class_name=_class_name, method_name=method_name)
class MBeanAttributes(object): """ The MBeanAttributes class is a wrapper class encapsulating MBean information for the different types of MBean attribute collections. An instance of this class contains all attributes for an MBean at a specific location. The methods in this class operates on the attributes the class encapsulates to provide attribute specific information. """ __interface_matcher = re.compile('Bean') def __init__(self, model_context, alias_helper, exception_type, location): self.__model_context = model_context self.__exception_type = exception_type self.__location = location self.__alias_helper = alias_helper self.__wlst_helper = WlstHelper(_logger, exception_type) self.__mbean_interface_name = None self.__mbean_instance = None self.__mbean_interface = None self.__mbean_name = '' def mbean_string(self): """ Return a string representing the MBean encapsulated by the helper class. :return: Printable string identifying the MBean """ return 'MBean %s at location %s' % (self.get_mbean_name(), self._get_mbean_path()) def get_mbean_name(self): """ Return the MBean "type" (i.e. JDBCSystemResource) :return: mbean type """ return self.__mbean_name def get_mbean_interface_name(self): """ Return the full name of the MBean interface class. :return: Interface name """ self._get_mbean_interface() return self.__mbean_interface_name def get_mbean_instance(self): _method_name = 'get_mbean_instance' if self.__mbean_instance is None: attribute_path = self.__alias_helper.get_wlst_attributes_path( self.__location) self.__mbean_instance = self.__wlst_helper.get_mbean( attribute_path) if self.__mbean_instance is None: ex = exception_helper.create_exception( self._get_exception_type(), 'WLSDPLY-01775', attribute_path) _logger.throwing(ex, class_name=self.__class__.__name__, method_name=_method_name) raise ex return self.__mbean_instance def _get_mbean_interface(self): _method_name = '__get_mbean_interface' if self.__mbean_interface is None: _logger.entering(class_name=self.__class__.__name__, method_name=_method_name) interfaces = [ interface for interface in self._get_mbean_interfaces() if re.search( self.__interface_matcher, str(interface)) is not None ] if len(interfaces) == 0: ex = exception_helper.create_exception( self._get_exception_type(), 'WLSDPLY-01777', str(self._get_mbean_interfaces()), self.get_mbean_instance()) _logger.throwing(ex, class_name=self.__class__.__name__, method_name=_method_name) raise ex else: if len(interfaces) > 1: _logger.fine('WLSDPLY-01770', interfaces, self.get_mbean_instance(), class_name=self.__class__.__name__, method_name=_method_name) self.__mbean_interface = interfaces[0] self.__mbean_name = str(self.__mbean_interface.getSimpleName()) self.__mbean_interface_name = get_interface_name( self._get_mbean_interface()) _logger.exiting(class_name=self.__class__.__name__, method_name=_method_name, result=self.__mbean_interface_name) return self.__mbean_interface def _get_mbean_methods(self): return self.__get_mbean_class().getDeclaredMethods() def _get_mbean_name(self): return self.__mbean_name def _get_mbean_interfaces(self): return self.__get_mbean_class().getInterfaces() def _get_exception_type(self): return self.__exception_type def __get_mbean_class(self): _method_name = '__get_mbean_class' mbean_class = None mbean_instance = self.get_mbean_instance() try: getter = getattr(mbean_instance, 'getClass') mbean_class = getter() except AttributeError: pass if mbean_class is None: ex = exception_helper.create_exception(self._get_exception_type(), 'WLSDPLY-01776', mbean_instance) _logger.throwing(ex, class_name=self.__class__.__name__, method_name=_method_name) raise ex return mbean_class def _get_from_bean_proxy(self, getter): _method_name = '__get_from_bean_proxy' success = False value = None try: get_method = getattr(self.get_mbean_instance(), getter) if get_method is not None: value = get_method() _logger.finest('WLSDPLY-01784', getter, self._get_mbean_name(), class_name=self.__class__.__name__, method_name=_method_name) success = True else: _logger.finer('WLSDPLY-01786', self._get_mbean_name(), getter, class_name=self.__class__.__name__, method_name=_method_name) except (Exception, JException), e: _logger.finest('WLSDPLY-01785', self._get_mbean_name(), getter, str(e), class_name=self.__class__.__name__, method_name=_method_name) return success, value
class MBeanUtils(object): """ Utility class used to provide information about WLST attributes as retrieved from the MBeans MBeanInfo or Interface methods. This class has methods to provide the information stored in different combinations. All methods that want to combine the information from the MBeans helpers into different combinations are located in this class. """ def __init__(self, model_context, alias_helper, exception_type): self.__model_context = model_context self.__exception_type = exception_type self.__alias_helper = alias_helper self.__wlst_helper = WlstHelper(_logger, exception_type) self.__helper = self.__get_helper() self.__ignore_list = None def get_attributes_not_in_lsa_map(self, location, lsa_map=None): """ Return a list of all attributes from the MBeans MBeanInfo or Interface methods that are not contained in the LSA attributes for the location in the location context. :param location: current location context of the MBean :param lsa_map: map returned from WLST ls('a') or None to get the LSA map from the current location context :return: Any additional attributes or empty list if None found """ _method_name = 'get_attributes_not_in_lsa_map' _logger.entering(location.get_folder_path(), class_name=self.__class__.__name__, method_name=_method_name) mbean_attributes = self.__collapse_attributes(location) lsa_attributes = self.__get_lsa_attributes(location, lsa_map) loose_attributes = [ attribute for attribute in mbean_attributes if not self.__helper.is_attribute_in_lsa_map( attribute, lsa_attributes) ] _logger.exiting(class_name=self.__class__.__name__, method_name=_method_name, result=loose_attributes) return loose_attributes def get_info_attribute_helper(self, location): """ Get a wrapper for the MBeanInfo attribute information for the current MBean designated in the location context. :param location: containing the current MBean context :return: MBeanAttributes class wrapping the MBeanInfo attributes with convenience methods """ return self.__get_info_helper(location) def get_mbean_info_attributes(self, location=None, helper=None): """ Get a list of attribute names for the MBean using the MBeanInfoAttributes wrapper class. If the helper is not provided, use the location arg to create an instance of the helper for the MBean designated in the location context. :param location: If helper is None, the location is required to create the helper instance :param helper: If not None, the provided helper is used to return the attribute information. The location arg is not required if helper is provided. :return: List of attribute names for the MBean """ if helper is None: helper = self.get_info_attribute_helper(location) return self.get_mbean_attributes(helper) def get_interface_attribute_helper(self, location): """ Return an instance of the InterfaceAttributes helper class for the MBean indicated in the location context. :param location: context for the current MBean location :return: InterfaceAttributes helper instance """ return self.__get_interface_helper(location) def get_interface_attributes(self, location=None, helper=None): """ Get a list of attribute names for the MBean using the InterfaceAttributes wrapper class. If the helper is not provided, use the location arg to create an instance of the helper for the MBean designated in the location context. :param location: If helper is None, the location is required to create the helper instance :param helper: If not None, the provided helper is used to return the attribute information. The location arg is not required if helper is provided. :return: List of attribute names for the MBean """ if helper is None: helper = self.get_interface_attribute_helper(location) return self.get_mbean_attributes(helper) def get_mbean_attributes(self, helper): """ Return a list of the MBean attribute names through the MBean attribute helper. :param helper: MBeanAttributes helper class :return: list of MBean attribute names """ return helper.get_mbean_attributes() def __collapse_attributes(self, location): _method_name = '__filter_attributes' info_helper = self.__get_info_helper(location) info_attributes = self.get_mbean_attributes(info_helper) interface_helper = self.__get_interface_helper(location) interface_attributes = self.get_mbean_attributes(interface_helper) self.__remove_duplicates(interface_attributes, str(interface_helper), info_attributes, str(info_helper)) # This is the main list to drive from info_attributes = self.__slim_list(info_attributes, info_helper) # Because there are very few valid attributes in the Interface methods that are not in either the LSA map # or MBeanInfo PropertyDescriptors, remove all the read_only attributes interface_attributes = self.__slim_list(interface_attributes, interface_helper, remove_readonly=True) consolidated = list() consolidated.extend(info_attributes) consolidated.extend(interface_attributes) _logger.finer('WLSDPLY-01787', consolidated, class_name=self.__class__.__name__, method_name=_method_name) return consolidated def __slim_list(self, attributes, attribute_helper, remove_readonly=False): return [ attribute for attribute in attributes if not (self.__in_ignore(attribute) or attribute_helper.is_child_mbean(attribute) or (remove_readonly and attribute_helper.is_read_only(attribute)) or self. __is_clear_text_encrypted(attribute, attribute_helper) or # The following should always be the final elimination step not attribute_helper.is_valid_getter(attribute)) ] def __get_info_helper(self, location): return MBeanInfoAttributes(self.__model_context, self.__alias_helper, self.__exception_type, location) def __get_interface_helper(self, location): return InterfaceAttributes(self.__model_context, self.__alias_helper, self.__exception_type, location) def __remove_duplicates(self, check_list, check_list_type, main_list, main_list_type): _method_name = '__remove_duplicates' _logger.entering(len(check_list), len(main_list), class_name=self.__class__.__name__, method_name=_method_name) for attribute in main_list: if attribute in check_list: check_list.remove(attribute) else: _logger.fine('WLSDPLY-01788', attribute, check_list_type, main_list_type, class_name=self.__class__.__name__, method_name=_method_name) _logger.exiting(class_name=self.__class__.__name__, method_name=_method_name, result=len(check_list)) def __is_clear_text_encrypted(self, attribute_name, attribute_helper): if not attribute_name.endswith('Encrypted'): return attribute_helper.is_encrypted(attribute_name + 'Encrypted') return False def __get_ignore_attributes(self): _method_name = '__get_ignore_attributes' if self.__ignore_list is None: self.__ignore_list = self.__alias_helper.get_ignore_attribute_names( ) _logger.finer('WLSDPLY-01779', self.__ignore_list, class_name=self.__class__.__name__, method_name=_method_name) return self.__ignore_list def __in_ignore(self, attribute_name): return attribute_name in self.__get_ignore_attributes() def __get_helper(self): if self.__model_context.get_target_wlst_mode() == WlstModes.OFFLINE: helper = OfflineMBeanHelper(self.__model_context, self.__exception_type) else: helper = OnlineMBeanHelper(self.__model_context, self.__exception_type) return helper def __get_lsa_attributes(self, location, lsa_map=None): _method_name = '__get_lsa_attributes' attributes = None attribute_path = self.__alias_helper.get_wlst_attributes_path(location) if lsa_map is None: if location is not None: if attribute_path is not None: try: return_map = self.__wlst_helper.lsa(attribute_path) if return_map is not None: attributes = return_map.keys() else: attributes = list() except BundleAwareException: pass if attributes is None: ex = exception_helper.create_exception(self.__exception_type, 'WLSDPLY-01771', attribute_path) _logger.throwing(ex, class_name=self.__class__.__name__, method_name=_method_name) raise ex return attributes
class TargetHelper(object): """ Shared code for targeting clusters and servers. Domain create and update use this code. """ __class_name = 'TargetHelper' def __init__(self, model, model_context, aliases, exception_type, logger): self.logger = logger self.model = model self.model_context = model_context self.alias_helper = AliasHelper(aliases, self.logger, exception_type) self.wlst_helper = WlstHelper(self.logger, exception_type) self.exception_type = exception_type topology = model.get_model_topology() if ADMIN_SERVER_NAME in topology: self._admin_server_name = topology[ADMIN_SERVER_NAME] else: self._admin_server_name = DEFAULT_ADMIN_SERVER_NAME def target_jrf_groups_to_clusters_servers(self, should_update=True): """ Call applyJRF to for those versions of wlst that cannot target servers to server groups. This assigns the JRF resources to all managed servers. If the managed server is in a cluster, this method assigns the JRF resources are assigned to the cluster. Else, if the managed server is stand-alone, the resources are assigned to the managed server. :param should_update: Control how the applyJRF applies the changes. By default, allow the applyJRF to automatically update the values """ _method_name = 'target_jrf_groups_to_clusters_servers' self.logger.entering(should_update, class_name=self.__class_name, method_name=_method_name) location = LocationContext() root_path = self.alias_helper.get_wlst_attributes_path(location) self.wlst_helper.cd(root_path) admin_server_name = self.wlst_helper.get(ADMIN_SERVER_NAME) # We need to get the effective list of servers for the domain. Since any servers # referenced in the model have already been created but the templates may have # defined new servers not listed in the model, get the list from WLST. server_names = self.get_existing_server_names() if admin_server_name in server_names: server_names.remove(admin_server_name) # Get the clusters and and their members cluster_map = self._get_clusters_and_members_map() self.wlst_helper.save_and_close(self.model_context) # Get the clusters and and their members for cluster_name, cluster_servers in cluster_map.iteritems(): self.logger.info('WLSDPLY-12233', 'Cluster', cluster_name, class_name=self.__class_name, method_name=_method_name) self.wlst_helper.apply_jrf(cluster_name, self.model_context, should_update=should_update) for member in cluster_servers: if member in server_names: server_names.remove(member) for ms_name in server_names: self.logger.info('WLSDPLY-12233', 'Managed Server', ms_name, class_name=self.__class_name, method_name=_method_name) self.wlst_helper.apply_jrf(ms_name, self.model_context, should_update=should_update) self.wlst_helper.reopen(self.model_context) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return def target_server_groups_to_servers(self, server_groups_to_target): """ Target the server groups to the servers. :param server_groups_to_target: the list of server groups to target :raises: BundleAwareException of the specified type: if an error occurs """ _method_name = 'target_server_groups_to_servers' self.logger.entering(server_groups_to_target, class_name=self.__class_name, method_name=_method_name) if len(server_groups_to_target) == 0: return list(), list() location = LocationContext() root_path = self.alias_helper.get_wlst_attributes_path(location) self.wlst_helper.cd(root_path) # We need to get the effective list of servers for the domain. Since any servers # referenced in the model have already been created but the templates may have # defined new servers not listed in the model, get the list from WLST. server_names = self._get_existing_server_names() # Get the clusters and and their members cluster_map = self._get_clusters_and_members_map() dynamic_cluster_names = list() for cluster_name in cluster_map: if DYNAMIC_SERVERS in cluster_map[cluster_name]: dynamic_cluster_names.append(cluster_name) # Get any limits that may have been defined in the model domain_info = self.model.get_model_domain_info() server_group_targeting_limits = \ dictionary_utils.get_dictionary_element(domain_info, SERVER_GROUP_TARGETING_LIMITS) if len(server_group_targeting_limits) > 0: server_group_targeting_limits = \ self._get_server_group_targeting_limits(server_group_targeting_limits, cluster_map) self.logger.finer('WLSDPLY-12240', str(server_group_targeting_limits), class_name=self.__class_name, method_name=_method_name) # Get the map of server names to server groups to target server_to_server_groups_map =\ self._get_server_to_server_groups_map(self._admin_server_name, server_names, dynamic_cluster_names, server_groups_to_target, server_group_targeting_limits) # type: dict self.logger.finer('WLSDPLY-12242', str(server_to_server_groups_map), class_name=self.__class_name, method_name=_method_name) final_assignment_map = dict() dynamic_cluster_assigns = dict() # Target servers and dynamic clusters to the server group resources if len(server_names) > 0 or len(dynamic_cluster_names) > 0: for server, server_groups in server_to_server_groups_map.iteritems(): if len(server_groups) > 0: if server in server_names: final_assignment_map[server] = server_groups elif server in dynamic_cluster_names: dynamic_cluster_assigns[server] = server_groups # # Domain has not targeted the server groups to managed servers (configured), or the # domain has no managed servers (configured) but has user server groups. The resources for the # user server groups must be targeted before the write/update domain or the write/update will fail. # Thus assign the user server groups to the admin server. # # Because of the interaction of the working context in the different wlst helpers, the dynamic # clusters will be applied to the resources separately and after the write/update domain. # # (From original blurb) # This is really a best effort attempt. It works for JRF domains but it is certainly possible # that it may cause problems with other custom domain types. Of course, creating a domain with # no managed servers is not a primary use case of this tool so do it and hope for the best... # # (New comment) # As we have added the intricacies of the dynamic clusters, if the targeting is to dynamic # clusters only, the set server groups with the admin server will get through the write/update domain # and the applyJRF with the dynamic cluster should theoretically unset the AdminServer on the user server # groups. It works with JRF type domains. if len(server_groups_to_target) > 0: if len(final_assignment_map) == 0: # This is a quickie to fix the issue where server groups are not targeted because no configured # managed servers exist in the domain final_assignment_map[server_names[0]] = server_groups_to_target else: # If a server group or groups is not targeted in the assignments, log it to stdout no_targets = [server_target for server_target in server_groups_to_target if server_target not in [server_target for row in final_assignment_map.itervalues() for server_target in server_groups_to_target if server_target in row]] if len(no_targets) > 0: self.logger.info('WLSDPLY-12248', no_targets, class_name=self.__class_name, method_name=_method_name) self.logger.exiting(result=str(dynamic_cluster_assigns), class_name=self.__class_name, method_name=_method_name) return final_assignment_map, dynamic_cluster_assigns def target_server_groups(self, server_assigns): """ Perform the targeting of the server groups to server from the list of assignments made in the target helper assignment step. This is separate from creating the list of assignments in order to control the state of the domain when the target is done. :param server_assigns: map of server to server group """ _method_name = 'target_server_groups' self.logger.entering(str(server_assigns), class_name=self.__class_name, method_name=_method_name) for server, server_groups in server_assigns.iteritems(): server_name = self.wlst_helper.get_quoted_name_for_wlst(server) self.logger.info('WLSDPLY-12224', str(server_groups), server_name, class_name=self.__class_name, method_name=_method_name) self.wlst_helper.set_server_groups(server_name, server_groups) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) def target_server_groups_to_dynamic_clusters(self, dynamic_cluster_assigns): """ Dynamic clusters need special handling to assign the server group resources to the dynamic cluster. You cannot assign servergroups to a server template. So must search each templates that contain the server group for resources and specifically add the dynamic target to the resource target. If JRF or RestrictedJRF skip the check and do the applyJRF function to automatically target to the cluster. :param dynamic_cluster_assigns: The assignments from domainInfo targeting limits applied to dynamic lusters """ _method_name = 'target_server_group_resources_to_dyanamic_cluster' self.logger.entering(str(dynamic_cluster_assigns), class_name=self.__class_name, method_name=_method_name) domain_typedef = self.model_context.get_domain_typedef() if len(dynamic_cluster_assigns) > 0: self.logger.info('WLSDPLY-12247', class_name=self.__class_name, method_name=_method_name) # TBD assign server group resources to cluster. The JRF resources could still be applied separately # using this technique - or remove this technique and replace with the resource targeting if domain_typedef.has_jrf_resources(): self._target_jrf_resources(dynamic_cluster_assigns) else: self.logger.warning('WLSDPLY-12238', domain_typedef.get_domain_type(), class_name=self.__class_name, method_name=_method_name) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return def _target_jrf_resources(self, dynamic_cluster_assigns): # Target the JRF resources directly using the applyJRF method. _method_name = '_target_jrf_resources' names_only = list() for name in dynamic_cluster_assigns: names_only.append(name) if self.model_context.is_wlst_online() and \ self.model_context.get_domain_typedef().is_restricted_jrf_domain_type(): self.logger.warning('WLSDPLY-12244', str(names_only), class_name=self.__class_name, _method_name=_method_name) else: self.logger.info('WLSDPLY-12236', str(names_only), class_name=self.__class_name, method_name=_method_name) self.wlst_helper.apply_jrf_control_updates(names_only, self.model_context) def _get_existing_server_names(self): """ Get the list of server names from WLST. :return: the list of server names :raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST """ _method_name = '_get_existing_server_names' self.logger.entering(class_name=self.__class_name, method_name=_method_name) server_location = LocationContext().append_location(SERVER) server_list_path = self.alias_helper.get_wlst_list_path(server_location) result = self.wlst_helper.get_existing_object_list(server_list_path) self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result) return result def _get_clusters_and_members_map(self): """ Get a map keyed by cluster name with values that are a list of member server names :return: the cluster name to member server names map :raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST """ _method_name = '_get_clusters_and_members_map' self.logger.entering(class_name=self.__class_name, method_name=_method_name) server_location = LocationContext().append_location(SERVER) server_list_path = self.alias_helper.get_wlst_list_path(server_location) server_names = self.wlst_helper.get_existing_object_list(server_list_path) server_token = self.alias_helper.get_name_token(server_location) cluster_map = OrderedDict() for server_name in server_names: server_location.add_name_token(server_token, server_name) server_attributes_path = self.alias_helper.get_wlst_attributes_path(server_location) self.wlst_helper.cd(server_attributes_path) server_attributes_map = self.wlst_helper.lsa() cluster_name = dictionary_utils.get_element(server_attributes_map, CLUSTER) if string_utils.is_empty(cluster_name): # if server is not part of a cluster, continue with the next server continue if cluster_name not in cluster_map: cluster_map[cluster_name] = list() cluster_map[cluster_name].append(server_name) clusters_location = LocationContext().append_location(CLUSTER) cluster_list_path = self.alias_helper.get_wlst_list_path(clusters_location) cluster_names = self.wlst_helper.get_existing_object_list(cluster_list_path) cluster_token = self.alias_helper.get_name_token(clusters_location) # Add the cluster with dynamic servers, if not already in the cluster member list. # A cluster may contain both dynamic and configured servers (referred to as mixed cluster). # Add a token marking DYNAMIC SERVERS in the member list. for cluster_name in cluster_names: cluster_location = LocationContext(clusters_location) cluster_location.add_name_token(cluster_token, cluster_name) cluster_attributes_path = self.alias_helper.get_wlst_attributes_path(cluster_location) self.wlst_helper.cd(cluster_attributes_path) cluster_location.append_location(DYNAMIC_SERVERS) wlst_subfolder_name = self.alias_helper.get_wlst_mbean_type(cluster_location) if self.wlst_helper.subfolder_exists(wlst_subfolder_name): if cluster_name not in cluster_map: cluster_map[cluster_name] = list() cluster_map[cluster_name].append(DYNAMIC_SERVERS) self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=cluster_map) return cluster_map def get_existing_server_names(self): """ Get the list of server names from WLST. :return: the list of server names :raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST """ _method_name = '_get_existing_server_names' self.logger.entering(class_name=self.__class_name, method_name=_method_name) server_location = LocationContext().append_location(SERVER) server_list_path = self.alias_helper.get_wlst_list_path(server_location) result = self.wlst_helper.get_existing_object_list(server_list_path) self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result) return result def get_existing_cluster_names(self): """ Get the list of cluster names from WLST. :return: the list of cluster names :raises: BundleAwareException of the specified type: is an error occurs reading from the aliases or WLST """ _method_name = 'get_existing_cluster_names' self.logger.entering(class_name=self.__class_name, method_name=_method_name) cluster_location = LocationContext().append_location(CLUSTER) cluster_list_path = self.alias_helper.get_wlst_list_path(cluster_location) result = self.wlst_helper.get_existing_object_list(cluster_list_path) self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result) return result def _get_server_group_targeting_limits(self, server_group_targeting_limits, clusters_map): """ Get any server group targeting limits specified in the model, converting any cluster names to the list of members. This method assumes that the limits dictionary is not None or empty. :param server_group_targeting_limits: the raw server group targeting_limits from the model :param clusters_map: the map of cluster names to member server names :return: the map of server groups to server names to target """ _method_name = '_get_server_group_targeting_limits' self.logger.entering(str(server_group_targeting_limits), str(clusters_map), class_name=self.__class_name, method_name=_method_name) sg_targeting_limits = copy.deepcopy(server_group_targeting_limits) for server_group_name, sg_targeting_limit in sg_targeting_limits.iteritems(): if type(sg_targeting_limit) is str: if MODEL_LIST_DELIMITER in sg_targeting_limit: sg_targeting_limit = sg_targeting_limit.split(MODEL_LIST_DELIMITER) else: # convert a single value into a list of one... new_list = list() new_list.append(sg_targeting_limit) sg_targeting_limit = new_list # Convert any references to a cluster name into the list of member server names new_list = list() for target_name in sg_targeting_limit: target_name = target_name.strip() if target_name in clusters_map: cluster_members = dictionary_utils.get_element(clusters_map, target_name) if DYNAMIC_SERVERS in cluster_members: # This will need special handling to target server group resources cluster_members.remove(DYNAMIC_SERVERS) cluster_members.append(target_name) new_list.extend(cluster_members) else: # Assume it is a server name and add it to the new list # Stand-alone Managed Servers were not added to the cluster: server_name_list map # which was built from the existing servers and clusters. new_list.append(target_name) sg_targeting_limits[server_group_name] = new_list self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=sg_targeting_limits) return sg_targeting_limits def _get_server_to_server_groups_map(self, admin_server_name, server_names, dynamic_cluster_names, server_groups, sg_targeting_limits): """ Get the map of server names to the list of server groups to target to that server. :param admin_server_name: the admin server name :param server_names: the list of server names :param server_groups: the complete list of server groups that will, by default, be targeted to all managed servers unless the server is listed in the targeting limits map :param sg_targeting_limits: the targeting limits map :return: the map of server names to the list of server groups to target to that server """ _method_name = '_get_server_to_server_groups_map' self.logger.entering(admin_server_name, str(server_names), str(server_groups), str(sg_targeting_limits), class_name=self.__class_name, method_name=_method_name) result = OrderedDict() revised_server_groups = self._revised_list_server_groups(server_groups, sg_targeting_limits) for server_name in server_names: server_groups_for_server = self.__get_server_groups_for_entity(server_name, sg_targeting_limits) if len(server_groups_for_server) > 0: result[server_name] = server_groups_for_server elif server_name != admin_server_name: # By default, we only target managed servers unless explicitly listed in the targeting limits result[server_name] = list(revised_server_groups) else: result[admin_server_name] = list() for cluster_name in dynamic_cluster_names: server_groups_for_cluster = \ self.__get_server_groups_for_entity(cluster_name, sg_targeting_limits) if len(server_groups_for_cluster) > 0: result[cluster_name] = server_groups_for_cluster else: result[cluster_name] = list(revised_server_groups) self.logger.finer('WLSDPLY-12239', result[cluster_name], cluster_name, class_name=self.__class_name, method_name=_method_name) if admin_server_name not in result: result[admin_server_name] = list() self.logger.exiting(class_name=self.__class_name, method_name=_method_name, result=result) return result def _revised_list_server_groups(self, server_groups, sg_targeting_limits): """ Remove all server groups that are explicitly targeted to a cluster, server set or stand-alone managed server. :param server_groups: list of server groups applied by the extension templates :param sg_targeting_limits: list of targeting from the domainInfo section :return: server group list with the specific targeted server groups removed """ _method_name = '_revised_list_server_groups' self.logger.entering(sg_targeting_limits, class_name=self.__class_name, method_name=_method_name) result = list() targeted_server_groups = sg_targeting_limits.keys() for server_group in server_groups: if server_group not in targeted_server_groups: result.append(server_group) return result def __get_server_groups_for_entity(self, entity_name, sg_targeting_limits): """ Get the servers groups to target for a given server or dynamic cluster name. :param entity_name: the server or dynamic_cluster name :param sg_targeting_limits: the targeting limits :return: the list of server groups to target to the specified entity name, or None if the entity name does not appear in the targeting limits """ _method_name = '__get_server_groups_for_entity' result = list() for server_group, entity_names_list in sg_targeting_limits.iteritems(): if entity_name in entity_names_list: result.append(server_group) if len(result) > 0: self.logger.fine('WLSDPLY-12243', entity_name, result, class_name=self.__class_name, method_name=_method_name) return result
from wlsdeploy.tool.util import wlst_helper from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.tool.util.rcu_helper import RCUHelper from wlsdeploy.util import cla_helper from wlsdeploy.util import tool_exit from wlsdeploy.util.cla_utils import CommandLineArgUtil from wlsdeploy.util.model import Model from wlsdeploy.util.weblogic_helper import WebLogicHelper wlst_helper.wlst_functions = globals() _program_name = UPDATE_DOMAIN _class_name = 'update' __logger = PlatformLogger('wlsdeploy.update') __wls_helper = WebLogicHelper(__logger) __wlst_helper = WlstHelper(ExceptionType.DEPLOY) __wlst_mode = WlstModes.OFFLINE __required_arguments = [ CommandLineArgUtil.ORACLE_HOME_SWITCH, CommandLineArgUtil.DOMAIN_HOME_SWITCH ] __optional_arguments = [ # Used by shell script to locate WLST CommandLineArgUtil.DOMAIN_TYPE_SWITCH, CommandLineArgUtil.ARCHIVE_FILE_SWITCH, CommandLineArgUtil.MODEL_FILE_SWITCH, CommandLineArgUtil.PREVIOUS_MODEL_FILE_SWITCH, CommandLineArgUtil.VARIABLE_FILE_SWITCH, CommandLineArgUtil.ADMIN_URL_SWITCH,
class Discoverer(object): """ Discoverer contains the private methods used to facilitate discovery of the domain information by its subclasses. """ def __init__(self, model_context, base_location, wlst_mode, aliases=None): """ :param model_context: context about the model for this instance of discover domain :param base_location: to look for common weblogic resources. By default this is the global path or '/' """ self._model_context = model_context self._base_location = base_location self._wlst_mode = wlst_mode if aliases: self._aliases = aliases else: self._aliases = Aliases(self._model_context, wlst_mode=self._wlst_mode) self._alias_helper = AliasHelper(self._aliases, _logger, ExceptionType.DISCOVER) self._att_handler_map = OrderedDict() self._wls_version = WebLogicHelper( _logger).get_actual_weblogic_version() self._wlst_helper = WlstHelper(_logger, ExceptionType.DISCOVER) # methods for use only by the subclasses def _populate_model_parameters(self, dictionary, location): """ Populate the model dictionary with the attribute values discovered at the current location. Perform any special processing for a specific attribute before storing into the model dictionary. :param dictionary: where to store the discovered attributes :param location: context containing current location information :return: dictionary of model attribute name and wlst value """ _method_name = '_populate_model_parameters' wlst_path = self._alias_helper.get_wlst_attributes_path(location) _logger.finer('WLSDPLY-06100', wlst_path, class_name=_class_name, method_name=_method_name) if not self.wlst_cd(wlst_path, location): return wlst_params = self._get_attributes_for_current_location(location) _logger.finest('WLSDPLY-06102', self._wlst_helper.get_pwd(), wlst_params, class_name=_class_name, method_name=_method_name) wlst_get_params = self._get_required_attributes(location) _logger.finest('WLSDPLY-06103', str(location), wlst_get_params, class_name=_class_name, method_name=_method_name) attr_dict = OrderedDict() if wlst_params: for wlst_param in wlst_params: if wlst_param in wlst_get_params: _logger.finest('WLSDPLY-06104', wlst_param, class_name=_class_name, method_name=_method_name) try: wlst_value = wlst_helper.get(wlst_param) except PyWLSTException, pe: _logger.warning('WLSDPLY-06127', wlst_param, wlst_path, pe.getLocalizedMessage(), class_name=_class_name, method_name=_method_name) continue else: _logger.finer('WLSDPLY-06131', wlst_param, class_name=_class_name, method_name=_method_name) wlst_value = wlst_params[wlst_param] # if type(wlst_value) == str and len(wlst_value) == 0: # wlst_value = None _logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name, method_name=_method_name) try: model_param, model_value = self._aliases.get_model_attribute_name_and_value( location, wlst_param, wlst_value) except AliasException, de: _logger.info('WLSDPLY-06106', wlst_param, wlst_path, de.getLocalizedMessage(), class_name=_class_name, method_name=_method_name) continue attr_dict[model_param] = wlst_value model_value = self._check_attribute(model_param, model_value, location) if model_value is not None: _logger.finer('WLSDPLY-06107', model_param, model_value, class_name=_class_name, method_name=_method_name) dictionary[model_param] = model_value elif model_param is None: _logger.finest('WLSDPLY-06108', model_param, class_name=_class_name, method_name=_method_name)
def __init__(self, aliases, exception_type, logger): self.logger = logger self.alias_helper = AliasHelper(aliases, self.logger, exception_type) self.wlst_helper = WlstHelper(self.logger, exception_type) self._coherence_cluster_elements = [CLUSTER, SERVER, SERVER_TEMPLATE]
class TopologyHelper(object): """ Shared code for topology section of model. Domain create and update use this code. """ __class_name = 'TopologyHelper' def __init__(self, aliases, exception_type, logger): self.logger = logger self.alias_helper = AliasHelper(aliases, self.logger, exception_type) self.wlst_helper = WlstHelper(self.logger, exception_type) self._coherence_cluster_elements = [CLUSTER, SERVER, SERVER_TEMPLATE] def check_coherence_cluster_references(self, type_name, model_nodes): """ If the specified type has a Coherence cluster system resource attribute, verify that any referenced resource exists. If the resource does not exist, create an empty placeholder resource to allow assignment. :param type_name: the model folder type :param model_nodes: a dictionary containing the named model elements :raises: BundleAwareException of the specified type: if an error occurs """ if type_name in self._coherence_cluster_elements: for name in model_nodes.keys(): child_nodes = dictionary_utils.get_dictionary_element( model_nodes, name) resource_name = dictionary_utils.get_element( child_nodes, COHERENCE_CLUSTER_SYSTEM_RESOURCE) if resource_name is not None: self._create_placeholder_coherence_cluster(resource_name) def _create_placeholder_coherence_cluster(self, cluster_name): """ Create a placeholder Coherence cluster system resource to be referenced from a topology element. The new cluster will be created at the root domain level. :param cluster_name: the name of the Coherence cluster system resource to be added """ _method_name = '_create_placeholder_coherence_cluster' original_location = self.wlst_helper.get_pwd() cluster_location = LocationContext().append_location( COHERENCE_CLUSTER_SYSTEM_RESOURCE) existing_names = deployer_utils.get_existing_object_list( cluster_location, self.alias_helper) if cluster_name not in existing_names: self.logger.info('WLSDPLY-12230', cluster_name, class_name=self.__class_name, method_name=_method_name) cluster_token = self.alias_helper.get_name_token(cluster_location) cluster_location.add_name_token(cluster_token, cluster_name) deployer_utils.create_and_cd(cluster_location, existing_names, self.alias_helper) self.wlst_helper.cd(original_location) def create_placeholder_servers_in_cluster(self, topology): """ Create a placeholder for servers that are in a cluster, as these are migratable entities that can reference other servers in the cluster. :param topology: The topology model nodes containing the full set of Servers to add for the create / update """ _method_name = 'create_placeholder_servers_in_cluster' self.logger.entering(class_name=self.__class_name, method_name=_method_name) self.create_placeholder_named_elements(LocationContext(), SERVER, topology) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) def create_placeholder_server_templates(self, topology): """ Create a placeholder server template for each name in the topology. This is necessary because there is a circular dependency between clusters and server templates. :param topology: the topology model nodes """ self.create_placeholder_named_elements(LocationContext(), SERVER_TEMPLATE, topology) def create_placeholder_jdbc_resources(self, resources): """ Create a placeholder JDBC resource for each name in the resources section. This is necessary because cluster attributes may reference JDBC resources. :param resources: the resource model nodes """ self.create_placeholder_named_elements(LocationContext(), JDBC_SYSTEM_RESOURCE, resources) def create_placeholder_named_elements(self, location, model_type, model_nodes): """ Create a placeholder entry for each element in the specified named element nodes. This is necessary when there can be circular references with other elements. :param location: the location for the nodes to be added :param model_type: the type of the specified model nodes :param model_nodes: the model nodes """ _method_name = 'create_placeholder_named_elements' original_location = self.wlst_helper.get_pwd() resource_location = LocationContext(location).append_location( model_type) if self.alias_helper.get_wlst_mbean_type( resource_location) is not None: existing_names = deployer_utils.get_existing_object_list( resource_location, self.alias_helper) name_nodes = dictionary_utils.get_dictionary_element( model_nodes, model_type) for name in name_nodes.keys(): if model_helper.is_delete_name(name): # don't create placeholder for delete names continue if name not in existing_names: self.logger.info('WLSDPLY-19403', model_type, name, class_name=self.__class_name, method_name=_method_name) token = self.alias_helper.get_name_token(resource_location) resource_location.add_name_token(token, name) deployer_utils.create_and_cd(resource_location, existing_names, self.alias_helper) self.wlst_helper.cd(original_location) 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 is_clustered_server(self, server_name, servers_dictionary): """ Return true if the server's Cluster attribute is set. :param server_name: name of the server in the dictionary :param servers_dictionary: model topology section of servers :return: True if a clustered server """ server_dictionary = dictionary_utils.get_dictionary_element( servers_dictionary, server_name) if dictionary_utils.is_empty_dictionary_element( server_dictionary, CLUSTER): return False return True
from wlsdeploy.aliases.wlst_modes import WlstModes from wlsdeploy.exception import exception_helper from wlsdeploy.exception.expection_types import ExceptionType from wlsdeploy.logging import platform_logger from wlsdeploy.tool.util.string_output_stream import StringOutputStream from wlsdeploy.tool.util.wlst_helper import WlstHelper from wlsdeploy.util import dictionary_utils from wlsdeploy.util import model_helper from wlsdeploy.util.cla_utils import CommandLineArgUtil from wlsdeploy.aliases.model_constants import RESOURCE_GROUP from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE _class_name = "deployer_utils" _logger = platform_logger.PlatformLogger('wlsdeploy.deploy.utils') _wlst_helper = WlstHelper(ExceptionType.DEPLOY) def get_existing_object_list(location, aliases): """ Get a list of the existing names at the specified location. :param location: the location to be examined, for example, location MACHINE returns names under /Machines :param aliases: the alias helper used to determine path names """ method_name = 'get_existing_object_list' list_path = aliases.get_wlst_list_path(location) existing_names = _wlst_helper.get_existing_object_list(list_path) _logger.finer("WLSDPLY-09100", existing_names, class_name=_class_name, method_name=method_name) return existing_names