def _create_named_mbeans(self, type_name, model_nodes, base_location, log_created=False): """ Create the specified type of MBeans that support multiple instances in the specified location. :param type_name: the model folder type :param model_nodes: the model dictionary of the specified model folder type :param base_location: the base location object to use to create the MBeans :param log_created: whether or not to log created at INFO level, by default it is logged at the FINE level :raises: CreateException: if an error occurs """ _method_name = '_create_named_mbeans' self.logger.entering(type_name, str(base_location), log_created, class_name=self.__class_name, method_name=_method_name) if model_nodes is None or len(model_nodes) == 0 or not self._is_type_valid(base_location, type_name): return location = LocationContext(base_location).append_location(type_name) self._process_flattened_folder(location) token_name = self.alias_helper.get_name_token(location) create_path = self.alias_helper.get_wlst_create_path(location) list_path = self.alias_helper.get_wlst_list_path(location) existing_folder_names = self._get_existing_folders(list_path) for model_name in model_nodes: name = self.wlst_helper.get_quoted_name_for_wlst(model_name) if deployer_utils.is_delete_name(name): deployer_utils.delete_named_element(location, name, existing_folder_names, self.alias_helper) continue if token_name is not None: location.add_name_token(token_name, name) wlst_type, wlst_name = self.alias_helper.get_wlst_mbean_type_and_name(location) if wlst_name not in existing_folder_names: if log_created: self.logger.info('WLSDPLY-12100', type_name, name, class_name=self.__class_name, method_name=_method_name) else: self.logger.fine('WLSDPLY-12100', type_name, name, class_name=self.__class_name, method_name=_method_name) self.wlst_helper.create_and_cd(self.alias_helper, wlst_type, wlst_name, location, create_path) else: if log_created: self.logger.info('WLSDPLY-12101', type_name, name, class_name=self.__class_name, method_name=_method_name) else: self.logger.fine('WLSDPLY-12101', type_name, name, class_name=self.__class_name, method_name=_method_name) attribute_path = self.alias_helper.get_wlst_attributes_path(location) self.wlst_helper.cd(attribute_path) child_nodes = dictionary_utils.get_dictionary_element(model_nodes, name) self._process_child_nodes(location, child_nodes) self.logger.exiting(class_name=self.__class_name, method_name=_method_name) return
def _add_named_elements(self, type_name, model_nodes, location, delete_now=True): """ Add each named element from the specified nodes in WLST and set its attributes. Sub-folders are processed in a generic manner if present. It is assumed that there are no attributes or sub-folders with special processing. :param type_name: the type name of the child nodes :param model_nodes: the child nodes of a model element :param location: the location where elements should be added :param delete_now: Flag to determine whether to delay delete of element """ _method_name = '_add_named_elements' if len(model_nodes) == 0: return parent_type, parent_name = self.get_location_type_and_name(location) location = LocationContext(location).append_location(type_name) if not self._check_location(location): return deployer_utils.check_flattened_folder(location, self.aliases) existing_names = deployer_utils.get_existing_object_list( location, self.aliases) token = self.aliases.get_name_token(location) for name in model_nodes: if model_helper.is_delete_name(name): if delete_now: deployer_utils.delete_named_element( location, name, existing_names, self.aliases) continue is_add = name not in existing_names log_helper.log_updating_named_folder(type_name, name, parent_type, parent_name, is_add, self._class_name, _method_name) if token is not None: location.add_name_token(token, name) deployer_utils.create_and_cd(location, existing_names, self.aliases) child_nodes = dictionary_utils.get_dictionary_element( model_nodes, name) self._set_attributes_and_add_subfolders(location, child_nodes) return
def remove_deleted_clusters_and_servers(self, domain_location, model_topology): """ Remove clusters, servers, server templates, and migratable targets that were flagged for deletion in the model. The deletions are intentionally skipped when these elements are first created. :param domain_location: the location for the root of the domain :param model_topology: the topology folder from the model """ _method_name = 'remove_deleted_clusters_and_servers' self.logger.entering(str(domain_location), class_name=self.__class_name, method_name=_method_name) for folder_name in [CLUSTER, SERVER_TEMPLATE, SERVER, MIGRATABLE_TARGET]: location = LocationContext(domain_location).append_location(folder_name) existing_names = deployer_utils.get_existing_object_list(location, self.aliases) folder_nodes = dictionary_utils.get_dictionary_element(model_topology, folder_name) for mbean_name in folder_nodes: if model_helper.is_delete_name(mbean_name): deployer_utils.delete_named_element(location, mbean_name, existing_names, self.aliases) self.logger.exiting(class_name=self.__class_name, method_name=_method_name)