def _add_named_elements(self, type_name, model_nodes, location): """ 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 """ _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.alias_helper) existing_names = deployer_utils.get_existing_object_list(location, self.alias_helper) token = self.alias_helper.get_name_token(location) for name in model_nodes: 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.alias_helper) child_nodes = dictionary_utils.get_dictionary_element(model_nodes, name) self._set_attributes_and_add_subfolders(location, child_nodes) return
def _add_group_params(self, group_name_nodes, location): """ Add each group param entry from group name nodes and set its attributes. A two-pass approach is required since the new folder's name does not always match the group name. Special processing for error destination attributes (build mbean) :param group_name_nodes: the nodes containing group parameter names :param location: the WLST location where the parameters should be added """ _method_name = '_add_group_params' if len(group_name_nodes) == 0: return # use a copy of the dictionary to remove items as they are deleted remaining_name_nodes = group_name_nodes.copy() parent_type, parent_name = self.get_location_type_and_name(location) template_path = self.alias_helper.get_wlst_subfolders_path(location) groups_location = LocationContext(location) groups_location.append_location(GROUP_PARAMS) groups_token = self.alias_helper.get_name_token(groups_location) name_attribute = self.alias_helper.get_wlst_attribute_name(groups_location, SUB_DEPLOYMENT_NAME) mbean_type = self.alias_helper.get_wlst_mbean_type(groups_location) for group_name in group_name_nodes: if model_helper.is_delete_name(group_name): group_nodes = group_name_nodes[group_name] name = model_helper.get_delete_item_name(group_name) sub_name = self._get_subdeployment_name(group_nodes, name) self._delete_mapped_mbean(groups_location, groups_token, mbean_type, name_attribute, sub_name) del remaining_name_nodes[group_name] # loop once to create and name any missing folders. folder_map = self._build_folder_map(groups_location, groups_token, name_attribute) for group_name in remaining_name_nodes: group_nodes = remaining_name_nodes[group_name] sub_deployment_name = self._get_subdeployment_name(group_nodes, group_name) folder_name = dictionary_utils.get_element(folder_map, sub_deployment_name) if folder_name is None: self.wlst_helper.cd(template_path) group = self.wlst_helper.create(sub_deployment_name, mbean_type) group.setSubDeploymentName(sub_deployment_name) # loop a second time to set attributes new_folder_map = self._build_folder_map(groups_location, groups_token, name_attribute) for group_name in remaining_name_nodes: group_nodes = remaining_name_nodes[group_name] sub_deployment_name = self._get_subdeployment_name(group_nodes, group_name) is_add = sub_deployment_name not in folder_map log_helper.log_updating_named_folder(GROUP_PARAMS, group_name, parent_type, parent_name, is_add, self._class_name, _method_name) folder_name = dictionary_utils.get_element(new_folder_map, sub_deployment_name) groups_location.add_name_token(groups_token, folder_name) self.wlst_helper.cd(self.alias_helper.get_wlst_attributes_path(groups_location)) self.set_attributes(groups_location, group_nodes)
def _add_jndi_properties(self, property_name_nodes, location): """ Add each property entry from property nodes and set its attributes. A two-pass approach is required since the new folder's name does not always match the property name. :param property_name_nodes: the nodes containing property names :param location: the WLST location where the properties should be added """ _method_name = '_add_jndi_properties' if len(property_name_nodes) == 0: return # use a copy of the dictionary to remove items as they are deleted remaining_name_nodes = property_name_nodes.copy() parent_type, parent_name = self.get_location_type_and_name(location) is_online = self.wlst_mode == WlstModes.ONLINE if is_online and deployer_utils.is_in_resource_group_or_template(location): self.logger.info('WLSDPLY-09501', JNDI_PROPERTY, parent_type, parent_name, class_name=self._class_name, method_name=_method_name) return foreign_server_path = self.alias_helper.get_wlst_subfolders_path(location) properties_location = LocationContext(location).append_location(JNDI_PROPERTY) properties_token = self.alias_helper.get_name_token(properties_location) name_attribute = self.alias_helper.get_wlst_attribute_name(properties_location, KEY) mbean_type = self.alias_helper.get_wlst_mbean_type(properties_location) for property_name in property_name_nodes: if model_helper.is_delete_name(property_name): name = model_helper.get_delete_item_name(property_name) self._delete_mapped_mbean(properties_location, properties_token, mbean_type, name_attribute, name) del remaining_name_nodes[property_name] # loop once to create and name any missing folders. folder_map = self._build_folder_map(properties_location, properties_token, name_attribute) for property_name in remaining_name_nodes: folder_name = dictionary_utils.get_element(folder_map, property_name) if folder_name is None: self.wlst_helper.cd(foreign_server_path) new_property = self.wlst_helper.create(property_name, mbean_type) new_property.setKey(property_name) # loop a second time to set attributes new_folder_map = self._build_folder_map(properties_location, properties_token, name_attribute) for property_name in remaining_name_nodes: is_add = property_name not in folder_map log_helper.log_updating_named_folder(JNDI_PROPERTY, property_name, parent_type, parent_name, is_add, self._class_name, _method_name) folder_name = dictionary_utils.get_element(new_folder_map, property_name) properties_location.add_name_token(properties_token, folder_name) self.wlst_helper.cd(self.alias_helper.get_wlst_attributes_path(properties_location)) property_nodes = remaining_name_nodes[property_name] self.set_attributes(properties_location, property_nodes)