Skip to content

Commit 5e9e887

Browse files
further updates for running online discover
1 parent 4760d0f commit 5e9e887

File tree

5 files changed

+64
-47
lines changed

5 files changed

+64
-47
lines changed

core/src/main/python/wlsdeploy/aliases/alias_utils.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -590,22 +590,22 @@ def compute_read_data_type_and_delimiter_from_attribute_info(attribute_info, val
590590
if WLST_TYPE in attribute_info:
591591
data_type = attribute_info[WLST_TYPE]
592592
delimiter = compute_delimiter_from_data_type(data_type, value)
593-
594-
if WLST_READ_TYPE in attribute_info:
595-
data_type = attribute_info[WLST_READ_TYPE]
596-
read_delimiter = compute_delimiter_from_data_type(data_type, value)
597-
if read_delimiter is not None:
598-
delimiter = read_delimiter
599-
600-
if PREFERRED_MODEL_TYPE in attribute_info:
601-
data_type = attribute_info[PREFERRED_MODEL_TYPE]
602-
#
603-
# This code does not consider the delimiter defined by the preferred_model_type field unless there is
604-
# no other delimiter defined by wlst_type or wlst_read_type. This is required to handle the use case
605-
# where the value read from WLST had a different separator than the preferred_model_type.
606-
#
607-
if delimiter is None:
608-
delimiter = compute_delimiter_from_data_type(data_type, value)
593+
else:
594+
if WLST_READ_TYPE in attribute_info:
595+
data_type = attribute_info[WLST_READ_TYPE]
596+
read_delimiter = compute_delimiter_from_data_type(data_type, value)
597+
if read_delimiter is not None:
598+
delimiter = read_delimiter
599+
600+
if PREFERRED_MODEL_TYPE in attribute_info:
601+
data_type = attribute_info[PREFERRED_MODEL_TYPE]
602+
#
603+
# This code does not consider the delimiter defined by the preferred_model_type field unless there is
604+
# no other delimiter defined by wlst_type or wlst_read_type. This is required to handle the use case
605+
# where the value read from WLST had a different separator than the preferred_model_type.
606+
#
607+
if delimiter is None:
608+
delimiter = compute_delimiter_from_data_type(data_type, value)
609609

610610
return data_type, delimiter
611611

@@ -653,12 +653,13 @@ def convert_to_type(data_type, value, subtype=None, delimiter=None):
653653
raise ex
654654

655655
if new_value is not None:
656+
_logger.warning('data type {0} value {1}', data_type, new_value)
656657
if data_type == LONG:
657658
new_value = Long(new_value)
658659
elif data_type == JAVA_LANG_BOOLEAN:
659660
new_value = Boolean(new_value)
660661
elif data_type == JARRAY:
661-
if subtype is None or subtype == 'java.lang.String':
662+
if subtype == 'java.lang.String':
662663
new_value = _create_string_array(new_value)
663664
else:
664665
new_value = _create_mbean_array(new_value, subtype)

core/src/main/python/wlsdeploy/tool/discover/discoverer.py

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def _populate_model_parameters(self, dictionary, location):
8484
else:
8585
wlst_value = wlst_params[wlst_param]
8686

87-
_logger.finest('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
87+
_logger.finer('WLSDPLY-06105', wlst_param, wlst_value, wlst_path, class_name=_class_name,
8888
method_name=_method_name)
8989
try:
9090
model_param, model_value = self._alias_helper.get_model_attribute_name_and_value(location,
@@ -112,8 +112,14 @@ def _get_attributes_for_current_location(self, location):
112112
:param location: context with the current location information
113113
:return: list of attributes
114114
"""
115-
_method_name = '_get_attributes_for_current_location'
116-
attributes = None
115+
if self._wlst_mode == WlstModes.OFFLINE:
116+
return self._get_attributes_for_current_location_offline(location)
117+
else:
118+
return self._get_attributes_for_current_location_online(location)
119+
120+
def _get_attributes_for_current_location_offline(self, location):
121+
_method_name = '_get_attributes_for_current_location_offline'
122+
attributes = []
117123
path = self._alias_helper.get_wlst_attributes_path(location)
118124
try:
119125
attributes = wlst_helper.lsa(path)
@@ -123,31 +129,36 @@ def _get_attributes_for_current_location(self, location):
123129
method_name=_method_name)
124130
return attributes
125131

126-
def _get_required_attributes(self, location):
127-
if self._wlst_mode == WlstModes.OFFLINE:
128-
return self._get_required_attributes_offline(location)
129-
else:
130-
return self._get_required_attributes_online(location)
131-
132-
def _get_required_attributes_offline(self, location):
133-
return self._alias_helper.get_wlst_get_required_attribute_names(location)
132+
def _get_attributes_for_current_location_online(self, location):
133+
_method_name = '_get_attributes_for_current_location_online'
134+
attributes = []
135+
path = self._alias_helper.get_wlst_attributes_path(location)
136+
try:
137+
attributes = wlst_helper.lsa(path)
138+
mbean_attributes = wlst_helper.get_mbi().getAttributes()
139+
for mbean_attribute in mbean_attributes:
140+
name = mbean_attribute.getName()
141+
if name not in attributes:
142+
attributes[name] = wlst_helper.get(name)
143+
except PyWLSTException, pe:
144+
name = location.get_model_folders()[-1]
145+
_logger.fine('WLSDPLY-06109', name, str(location), pe.getLocalizedMessage(), class_name=_class_name,
146+
method_name=_method_name)
147+
return attributes
134148

135-
def _get_required_attributes_online(self, location):
149+
def _get_required_attributes(self, location):
136150
"""
137151
Use get for all online attributes, and use the attribute names in the
138152
:param location:
139153
:return:
140154
"""
141-
_method_name = '_get_required_attributes_online'
155+
_method_name = '_get_required_attributes'
142156
attributes = []
143157
try:
144-
mbi = wlst_helper.get_mbi()
145-
mbean_attribute_info = mbi.getAttributes()
146-
for mbean_attribute in mbean_attribute_info:
147-
attributes.append(mbean_attribute.getName())
148-
except PyWLSTException, pe:
158+
attributes = self._alias_helper.get_wlst_get_required_attribute_names(location)
159+
except DiscoverException, de:
149160
name = location.get_model_folders()[-1]
150-
_logger.warning('WLSDPLY-06109', name, str(location), pe.getLocalizedMessage(), class_name=_class_name,
161+
_logger.warning('WLSDPLY-06109', name, str(location), de.getLocalizedMessage(), class_name=_class_name,
151162
method_name=_method_name)
152163
return attributes
153164

@@ -176,7 +187,10 @@ def _check_attribute(self, model_name, model_value, location):
176187
:param location: context containing current location information
177188
:return: new value if modified by the handler or the original value if not a special attribute
178189
"""
179-
new_value = model_value
190+
if model_value == 'null ':
191+
new_value = None
192+
else:
193+
new_value = model_value
180194
if model_name in self._att_handler_map:
181195
type_method = self._att_handler_map[model_name]
182196
if type_method is not None:

core/src/main/python/wlsdeploy/tool/discover/multi_tenant_resources_discoverer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class MultiTenantResourcesDiscoverer(Discoverer):
2121
"""
2222

2323
def __init__(self, model_context, resources_dictionary, base_location, wlst_mode=WlstModes.OFFLINE, aliases=None):
24-
Discoverer.__init__(self, model_context, wlst_mode, base_location)
24+
Discoverer.__init__(self, model_context, base_location, wlst_mode, aliases)
2525
self._dictionary = resources_dictionary
2626

2727
def discover(self):

core/src/main/python/wlsdeploy/util/wlst_helper.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,14 +229,16 @@ def lsa(path=None, log_throwing=True):
229229
"""
230230
_method_name = 'lsa'
231231
result = _ls(_method_name, 'a', path, log_throwing)
232-
if wlst.WLS_ON.isConnected() and result is not None and type(result) is dict:
233-
for key, value in result.iteritems():
234-
if value is not None and type(value) is str:
235-
new_value = value.rstrip()
236-
if new_value == 'null':
237-
result[key] = None
238-
else:
239-
result[key] = new_value
232+
if result:
233+
if wlst.WLS_ON.isConnected():
234+
for key, value in result.iteritems():
235+
if value is not None and type(value) is str:
236+
new_value = value.rstrip()
237+
_logger.info('what type is it {0}', new_value)
238+
if new_value == 'null':
239+
result[key] = None
240+
else:
241+
result[key] = new_value
240242
return result
241243

242244
def lsc(path=None, log_throwing=True):

core/src/main/resources/oracle/weblogic/deploy/aliases/category_modules/SelfTuning.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"DeploymentOrder": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "DeploymentOrder", "wlst_path": "WP001", "value": {"default": 1000 }, "wlst_type": "integer" } ],
1515
"Notes": [ {"version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "value": {"default": "None"}, "wlst_type": "string" } ],
1616
"Target": [ {"version": "[10,)", "wlst_mode": "offline", "wlst_name": "Target", "wlst_path": "WP001", "value": {"default": "None"}, "wlst_type": "delimited_string" },
17-
{"version": "[10,)", "wlst_mode": "online", "wlst_name": "Targets", "wlst_path": "WP002", "value": {"default": "None"}, "wlst_type": "jarray", "preferred_model_type": "delimited_string", "set_method": "MBEAN.set_target_mbeans", "set_mbean_type": "weblogic.management.configuration.TargetMBean"} ]
17+
{"version": "[10,)", "wlst_mode": "online", "wlst_name": "Targets", "wlst_path": "WP002", "value": {"default": "None"}, "wlst_type": "jarray", "set_method": "MBEAN.set_target_mbeans", "set_mbean_type": "weblogic.management.configuration.TargetMBean"} ]
1818
},
1919
"wlst_attributes_path": "WP001",
2020
"wlst_paths": {

0 commit comments

Comments
 (0)