Skip to content

Commit e052ff6

Browse files
JIRA:WDT-58 add setter method for Quota mbean and make sure the Quota is created before the mbean is set in destination
1 parent 881c643 commit e052ff6

File tree

4 files changed

+94
-9
lines changed

4 files changed

+94
-9
lines changed

core/src/main/python/wlsdeploy/tool/deploy/jms_resources_deployer.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ class docstring
6464
UNIFORM_DISTRIBUTED_TOPIC
6565
]
6666

67+
quota_destination_type_names = [
68+
QUEUE,
69+
TEMPLATE,
70+
TOPIC,
71+
UNIFORM_DISTRIBUTED_QUEUE,
72+
UNIFORM_DISTRIBUTED_TOPIC
73+
]
74+
6775
def __init__(self, model, model_context, aliases, wlst_mode=WlstModes.OFFLINE):
6876
Deployer.__init__(self, model, model_context, aliases, wlst_mode)
6977

@@ -79,6 +87,8 @@ def _add_named_elements(self, type_name, model_nodes, location):
7987
1) Group params require special handling.
8088
2) Destinations may require placeholder templates.
8189
"""
90+
_method_name = '_add_named_elements'
91+
self.logger.entering(type_name, class_name=self._class_name, method_name=_method_name)
8292
if type_name == GROUP_PARAMS:
8393
self._add_group_params(model_nodes, location)
8494
return
@@ -89,6 +99,10 @@ def _add_named_elements(self, type_name, model_nodes, location):
8999

90100
if type_name in self.template_destination_type_names:
91101
self._check_destination_template(model_nodes, location)
102+
103+
if type_name in self.quota_destination_type_names:
104+
self._check_destination_quota(model_nodes, location)
105+
92106
# continue with regular processing
93107

94108
Deployer._add_named_elements(self, type_name, model_nodes, location)
@@ -288,3 +302,36 @@ def _create_placeholder_jms_template(self, template_name, resource_location):
288302

289303
self.wlst_helper.cd(original_location)
290304
return result
305+
306+
def _check_destination_quota(self, destination_nodes, location):
307+
"""
308+
Check the destination nodes for a quota element, and create a placeholder quota if required.
309+
:param destination_nodes: the destination nodes to be examined
310+
:param location: the location of the destination parent
311+
"""
312+
for name in destination_nodes:
313+
child_nodes = dictionary_utils.get_dictionary_element(destination_nodes, name)
314+
quota_name = dictionary_utils.get_element(child_nodes, QUOTA)
315+
if quota_name is not None:
316+
self._create_placeholder_jms_quota(quota_name, location)
317+
return
318+
319+
def _create_placeholder_jms_quota(self, quota_name, resource_location):
320+
"""
321+
:param template_name: the name of the template to be added
322+
:param resource_location: the location where the template should be added
323+
"""
324+
_method_name = '_create_placeholder_jms_quota'
325+
original_location = self.wlst_helper.get_pwd()
326+
quota_location = LocationContext(resource_location).append_location(QUOTA)
327+
existing_names = deployer_utils.get_existing_object_list(quota_location, self.alias_helper)
328+
329+
if quota_name not in existing_names:
330+
self.logger.info('WLSDPLY-09502', quota_name, class_name=self._class_name, method_name=_method_name)
331+
332+
quota_token = self.alias_helper.get_name_token(quota_location)
333+
quota_location.add_name_token(quota_token, quota_name)
334+
result = deployer_utils.create_and_cd(quota_location, existing_names, self.alias_helper)
335+
336+
self.wlst_helper.cd(original_location)
337+
return result

core/src/main/python/wlsdeploy/tool/util/attribute_setter.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from wlsdeploy.aliases.model_constants import PARTITION_WORK_MANAGER
4646
from wlsdeploy.aliases.model_constants import PERSISTENT_STORE
4747
from wlsdeploy.aliases.model_constants import QUEUE
48+
from wlsdeploy.aliases.model_constants import QUOTA
4849
from wlsdeploy.aliases.model_constants import REALM
4950
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP
5051
from wlsdeploy.aliases.model_constants import RESOURCE_GROUP_TEMPLATE
@@ -415,6 +416,20 @@ def set_jms_server_mbean(self, location, key, value, wlst_value):
415416
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
416417
return
417418

419+
def set_jms_quota_mbean(self, location, key, value, wlst_value):
420+
"""
421+
For those entities, queues, template, topics, that take a single Quota mbean.
422+
:param location: location to look for Quota mbean
423+
:param key: the attribute name
424+
:param value: the string value
425+
:param wlst_value: the existing value of the attribute from WLST
426+
:raises BundleAwareException of the specified type: if quota mbean is not found.
427+
"""
428+
resource_location = self.__get_parent_location(location, JMS_RESOURCE)
429+
mbean = self.__find_in_location(resource_location, QUOTA, value, required=True)
430+
self.set_attribute(location, key, mbean, wlst_merge_value=wlst_value, use_raw_value=True)
431+
return
432+
418433
def set_reliable_delivery_policy_mbean(self, location, key, value, wlst_value):
419434
"""
420435
Sets the ws soap reliable delivery policy mbean used by mbeans like Server and Server Template.

core/src/main/resources/oracle/weblogic/deploy/messages/wlsdeploy_rb.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ WLSDPLY-09404=Failed to create directory for FileStore {0} at location {1}
882882
# wlsdeploy/tool/deploy/jms_resources_deployer.py
883883
WLSDPLY-09500=Creating placeholder for Template {0}
884884
WLSDPLY-09501=Skipping {0} for {1} {2}
885+
WLSDPLY-09502=Creating placeholder for Quota {0}
885886

886887
# wlsdeploy/tool/deploy/log_helper.py
887888
WLSDPLY-09600=Adding {0}

core/src/test/python/alias_json_file_test.py

Lines changed: 31 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@
4949
from wlsdeploy.aliases.alias_constants import WLST_SUBFOLDERS_PATH
5050
from wlsdeploy.aliases.alias_constants import WLST_TYPE
5151

52+
from wlsdeploy.exception.expection_types import ExceptionType
53+
from wlsdeploy.tool.util.attribute_setter import AttributeSetter
5254

5355
class ListTestCase(unittest.TestCase):
5456
_resources_dir = '../../test-classes/'
@@ -496,18 +498,33 @@ def _verify_attribute_set_method_attribute_value(self, folder_name, attribute_na
496498
SET_METHOD, alias_attribute_value)
497499
result.append(message)
498500
else:
499-
offline_value = self.alias_entries._resolve_curly_braces(alias_attribute_value)
500-
if len(offline_value) > 0 and not offline_value.startswith('MBEAN'):
501-
message = self._get_invalid_alias_attribute_value_message(folder_name, attribute_name, SET_METHOD,
502-
'offline', offline_value,
503-
'it does not start with MBEAN')
504-
result.append(message)
505-
online_value = self.alias_entries._resolve_curly_braces(alias_attribute_value)
506-
if offline_value != online_value and len(online_value) > 0 and not online_value.startswith('MBEAN'):
501+
result.extend(self._verify_attribute_set_method(folder_name, attribute_name, WlstModes.OFFLINE,
502+
alias_attribute_value, self.alias_entries))
503+
result.extend(self._verify_attribute_set_method(folder_name, attribute_name, WlstModes.ONLINE,
504+
alias_attribute_value, self.online_alias_entries))
505+
return result
506+
507+
def _verify_attribute_set_method(self, folder_name, attribute_name, wlst_mode, attribute_value, aliases):
508+
result = []
509+
resolved_attribute = aliases._resolve_curly_braces(attribute_value)
510+
if resolved_attribute:
511+
if not resolved_attribute.startswith('MBEAN'):
507512
message = self._get_invalid_alias_attribute_value_message(folder_name, attribute_name, SET_METHOD,
508-
'online', online_value,
513+
WlstModes.from_value(wlst_mode),
514+
resolved_attribute,
509515
'it does not start with MBEAN')
510516
result.append(message)
517+
else:
518+
set_method_value_components = resolved_attribute.split('.')
519+
if len(set_method_value_components) == 2:
520+
invoker = set_method_value_components[1]
521+
522+
instance = AttributeSetter(aliases, None, ExceptionType.ALIAS, wlst_mode)
523+
try:
524+
getattr(instance, invoker)
525+
except AttributeError:
526+
result.append(self.set_method_not_found_message(folder_name, attribute_name,
527+
WlstModes.from_value(wlst_mode), invoker))
511528
return result
512529

513530
def _verify_attribute_uses_path_tokens_attribute_value(self, folder_name, attribute_name, alias_attribute_value):
@@ -750,3 +767,8 @@ def _get_invalid_alias_attribute_value_message(self, folder_name, attribute_name
750767
text = 'Folder at path %s has a defined attribute %s with alias attribute %s whose ' \
751768
'%s value %s was not valid because %s'
752769
return text % (folder_name, attribute_name, alias_attribute_name, wlst_mode, alias_attribute_value, cause)
770+
771+
def set_method_not_found_message(self, folder_name, attribute_name, wlst_mode, alias_attribute_value):
772+
text = 'Folder at path %s has a %s defined attribute %s whose set_method %s was not found in the' \
773+
' attribute setter class'
774+
return text % (folder_name, attribute_name, wlst_mode, alias_attribute_value)

0 commit comments

Comments
 (0)