Skip to content

Commit

Permalink
Merge branch 'jira-wdt-915-snmp-agent' into 'main'
Browse files Browse the repository at this point in the history
Add aliases for SNMPAgent, SnmpAgentDeployment, EJBContainer, and Cluster JtaRemoteDomain

See merge request weblogic-cloud/weblogic-deploy-tooling!1739
  • Loading branch information
robertpatrick committed Sep 30, 2024
2 parents 9481916 + 84b7620 commit e4b71bf
Show file tree
Hide file tree
Showing 12 changed files with 560 additions and 46 deletions.
6 changes: 6 additions & 0 deletions core/src/main/python/wlsdeploy/aliases/alias_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
from wlsdeploy.aliases.model_constants import CALLOUT
from wlsdeploy.aliases.model_constants import DOMAIN_INFO
from wlsdeploy.aliases.model_constants import DOMAIN_INFO_ALIAS
from wlsdeploy.aliases.model_constants import EJB_CONTAINER
from wlsdeploy.aliases.model_constants import HEALTH_SCORE
from wlsdeploy.aliases.model_constants import JOLT_CONNECTION_POOL
from wlsdeploy.aliases.model_constants import JPA
Expand All @@ -66,6 +67,8 @@
from wlsdeploy.aliases.model_constants import REMOTE_CONSOLE_HELPER
from wlsdeploy.aliases.model_constants import RESOURCE_MANAGER
from wlsdeploy.aliases.model_constants import RESOURCES
from wlsdeploy.aliases.model_constants import SNMP_AGENT
from wlsdeploy.aliases.model_constants import SNMP_AGENT_DEPLOYMENT
from wlsdeploy.aliases.model_constants import SYSTEM_COMPONENT
from wlsdeploy.aliases.model_constants import TOPOLOGY
from wlsdeploy.aliases.model_constants import WLS_POLICIES
Expand Down Expand Up @@ -131,6 +134,7 @@ class AliasEntries(object):

__resources_top_level_folders = [
'CoherenceClusterSystemResource',
EJB_CONTAINER,
'FileStore',
'ForeignJNDIProvider',
'JDBCStore',
Expand All @@ -154,6 +158,8 @@ class AliasEntries(object):
'SelfTuning',
'ShutdownClass',
'SingletonService',
SNMP_AGENT,
SNMP_AGENT_DEPLOYMENT,
'StartupClass',
SYSTEM_COMPONENT,
'WebAppContainer',
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/python/wlsdeploy/aliases/model_constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
DYNAMIC_CLUSTER_SERVER_GROUP_TARGETING_LIMITS = 'DynamicClusterServerGroupTargetingLimits'
DOMAIN_VERSION = 'DomainVersion'
DYNAMIC_SERVERS = 'DynamicServers'
EJB_CONTAINER = 'EJBContainer'
EMBEDDED_LDAP = 'EmbeddedLDAP'
ENABLE_JMS_DB_PERSISTENCE = 'EnableJMSStoreDBPersistence'
ENABLE_JTALOG_DB_PERSISTENCE = 'EnableJTATLogDBPersistence'
Expand Down Expand Up @@ -302,6 +303,8 @@
SHUTDOWN_CLASS = 'ShutdownClass'
SINGLETON_SERVICE = 'SingletonService'
SMTP_NOTIFICATION = 'SMTPNotification'
SNMP_AGENT = 'SNMPAgent'
SNMP_AGENT_DEPLOYMENT = 'SnmpAgentDeployment'
SNMP_NOTIFICATION = 'SNMPNotification'
SOURCE_DESTINATION = 'SourceDestination'
SQL_AUTHENTICATOR = 'SQLAuthenticator'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
"""
Copyright (c) 2017, 2023, Oracle Corporation and/or its affiliates. All rights reserved.
Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved.
Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
"""
from wlsdeploy.aliases.model_constants import EJB_CONTAINER
from wlsdeploy.aliases.model_constants import FILE_STORE
from wlsdeploy.aliases.model_constants import FOREIGN_JNDI_PROVIDER
from wlsdeploy.aliases.model_constants import JDBC_STORE
Expand All @@ -14,6 +15,8 @@
from wlsdeploy.aliases.model_constants import PATH_SERVICE
from wlsdeploy.aliases.model_constants import SAF_AGENT
from wlsdeploy.aliases.model_constants import SELF_TUNING
from wlsdeploy.aliases.model_constants import SNMP_AGENT
from wlsdeploy.aliases.model_constants import SNMP_AGENT_DEPLOYMENT
from wlsdeploy.aliases.model_constants import WORK_MANAGER
from wlsdeploy.aliases.model_constants import WEBAPP_CONTAINER
from wlsdeploy.aliases.model_constants import WTC_SERVER
Expand Down Expand Up @@ -60,6 +63,16 @@ def _add_subfolders(self, model_nodes, location, excludes=None):

Deployer._add_subfolders(self, model_nodes, location, excludes=excludes)

def add_ejb_container(self, parent_dict, location):
"""
Deploy the EJB container elements in the dictionary at the specified location.
:param parent_dict: the dictionary possibly containing EJB container elements
:param location: the location to deploy the elements
"""
ejb_container = dictionary_utils.get_dictionary_element(parent_dict, EJB_CONTAINER)
if len(ejb_container) != 0:
self._add_model_elements(EJB_CONTAINER, ejb_container, location)

def add_file_stores(self, parent_dict, location):
"""
Deploy the file store elements in the dictionary at the specified location.
Expand Down Expand Up @@ -150,6 +163,26 @@ def add_saf_agents(self, parent_dict, location):
saf_agents = dictionary_utils.get_dictionary_element(parent_dict, SAF_AGENT)
self._add_named_elements(SAF_AGENT, saf_agents, location)

def add_snmp_agent(self, parent_dict, location):
"""
Deploy the SNMP agent elements in the dictionary at the specified location.
:param parent_dict: the dictionary possibly containing SNMP agent elements
:param location: the location to deploy the elements
"""
snmp_agent = dictionary_utils.get_dictionary_element(parent_dict, SNMP_AGENT)
if len(snmp_agent) != 0:
self._add_model_elements(SNMP_AGENT, snmp_agent, location)

def add_snmp_agent_deployments(self, parent_dict, location):
"""
Deploy the SNMP agent deployment elements in the dictionary at the specified location.
:param parent_dict: the dictionary possibly containing SNMP agent deployment elements
:param location: the location to deploy the elements
"""
deployments = dictionary_utils.get_dictionary_element(parent_dict, SNMP_AGENT_DEPLOYMENT)
if len(deployments) != 0:
self._add_named_elements(SNMP_AGENT_DEPLOYMENT, deployments, location)

def add_self_tuning(self, parent_dict, location):
"""
Deploy the self-tuning elements in the dictionary at the specified location.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,14 @@ def _add_resources(self, location):
self._add_startup_classes(location)
self._add_shutdown_classes(location)

common_deployer.add_ejb_container(self._resources, location)
common_deployer.add_foreign_jndi_providers(self._resources, location)
common_deployer.add_file_stores(self._resources, location)
common_deployer.add_jdbc_stores(self._resources, location)
common_deployer.add_jms_servers(self._resources, location)
common_deployer.add_saf_agents(self._resources, location)
common_deployer.add_snmp_agent(self._resources, location)
common_deployer.add_snmp_agent_deployments(self._resources, location)
common_deployer.add_path_services(self._resources, location)
common_deployer.add_jolt_connection_pools(self._resources, location)
common_deployer.add_wtc_servers(self._resources, location)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def discover(self):
_logger.entering(class_name=_class_name, method_name=_method_name)
model_folder_name, folder_result = self.get_datasources()
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)

self.discover_domain_single_mbean(model_constants.EJB_CONTAINER, self._dictionary)

model_folder_name, folder_result = self.get_foreign_jndi_providers()
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)
model_folder_name, folder_result = self.get_mail_sessions()
Expand All @@ -65,14 +68,20 @@ def discover(self):
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)
model_folder_name, folder_result = self.get_path_services()
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)

self.discover_domain_single_mbean(model_constants.SNMP_AGENT, self._dictionary)
self.discover_domain_named_mbeans(model_constants.SNMP_AGENT_DEPLOYMENT, self._dictionary)

JmsResourcesDiscoverer(self._model_context, self._dictionary, self._base_location, wlst_mode=self._wlst_mode,
aliases=self._aliases, credential_injector=self._get_credential_injector()).discover()

model_folder_name, folder_result = self.get_wldf_system_resources()
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)
model_folder_name, folder_result = self.get_system_component_resources()
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)
model_folder_name, folder_result = self.get_ohs_resources()
discoverer.add_to_model_if_not_empty(self._dictionary, model_folder_name, folder_result)

CoherenceResourcesDiscoverer(self._model_context, self._dictionary, self._base_location,
wlst_mode=self._wlst_mode, aliases=self._aliases,
credential_injector=self._get_credential_injector()).discover()
Expand Down Expand Up @@ -184,7 +193,7 @@ def _add_wallet_directory_to_archive(self, datasource, collected_wallet_dictiona
if onprem_wallet_parent_path not in collected_wallet_dictionary:
if onprem_wallet_dir_is_not_flat:
# collect the specific file
#
#
fixed_path = archive_file.addDatabaseWallet(wallet_name, property_value)
path_into_archive = os.path.dirname(fixed_path)
else:
Expand Down Expand Up @@ -572,39 +581,6 @@ def _add_wldf_script(self, model_name, model_value, location):
_logger.exiting(class_name=_class_name, method_name=_method_name, result=new_script_name)
return new_script_name

def _get_named_resources(self, folder_name):
"""
Discover each resource of the specified type in the domain.
:return: model name and dictionary for the discovered resources
"""
_method_name = '_get_named_resources'
_logger.entering(folder_name, class_name=_class_name, method_name=_method_name)

result = OrderedDict()
model_top_folder_name = folder_name
location = LocationContext(self._base_location)
location.append_location(model_top_folder_name)
resource_names = self._find_names_in_folder(location)
if resource_names is not None:
_logger.info('WLSDPLY-06364', len(resource_names), folder_name, class_name=_class_name,
method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._aliases.get_name_token(location)
for resource_name in resource_names:
if typedef.is_filtered(location, resource_name):
_logger.info('WLSDPLY-06362', typedef.get_domain_type(), folder_name, resource_name,
class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06365', folder_name, resource_name, class_name=_class_name,
method_name=_method_name)
location.add_name_token(name_token, resource_name)
result[resource_name] = OrderedDict()
self._populate_model_parameters(result[resource_name], location)
self._discover_subfolders(result[resource_name], location)
location.remove_name_token(name_token)
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
return model_top_folder_name, result

def _fix_passwords_in_mail_session_properties(self, mail_session_dict):
"""
Look for password properties in the mail session properties string, and replace the password with a fix me token.
Expand Down
41 changes: 41 additions & 0 deletions core/src/main/python/wlsdeploy/tool/discover/discoverer.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,14 @@ def add_to_remote_map(self, local_name, archive_name, file_type):
else:
_logger.todo('WLSDPLY-06041', file_type, local_name, archive_name)

def discover_domain_named_mbeans(self, model_top_folder_name, model_folder):
model_folder_name, folder_result = self._get_named_resources(model_top_folder_name)
add_to_model_if_not_empty(model_folder, model_folder_name, folder_result)

def discover_domain_single_mbean(self, model_top_folder_name, model_folder):
model_folder_name, folder_result = self.discover_domain_mbean(model_top_folder_name)
add_to_model_if_not_empty(model_folder, model_folder_name, folder_result)

def discover_domain_mbean(self, model_top_folder_name):
"""
Discover the domain specific MBean and its configuration attributes.
Expand Down Expand Up @@ -187,6 +195,39 @@ def _populate_model_parameters(self, dictionary, location):

_logger.exiting(class_name=_class_name, method_name=_method_name)

def _get_named_resources(self, folder_name):
"""
Discover each resource of the specified type in the domain.
:return: model name and dictionary for the discovered resources
"""
_method_name = '_get_named_resources'
_logger.entering(folder_name, class_name=_class_name, method_name=_method_name)

result = OrderedDict()
model_top_folder_name = folder_name
location = LocationContext(self._base_location)
location.append_location(model_top_folder_name)
resource_names = self._find_names_in_folder(location)
if resource_names is not None:
_logger.info('WLSDPLY-06364', len(resource_names), folder_name, class_name=_class_name,
method_name=_method_name)
typedef = self._model_context.get_domain_typedef()
name_token = self._aliases.get_name_token(location)
for resource_name in resource_names:
if typedef.is_filtered(location, resource_name):
_logger.info('WLSDPLY-06376', typedef.get_domain_type(), folder_name, resource_name,
class_name=_class_name, method_name=_method_name)
else:
_logger.info('WLSDPLY-06365', folder_name, resource_name, class_name=_class_name,
method_name=_method_name)
location.add_name_token(name_token, resource_name)
result[resource_name] = OrderedDict()
self._populate_model_parameters(result[resource_name], location)
self._discover_subfolders(result[resource_name], location)
location.remove_name_token(name_token)
_logger.exiting(class_name=_class_name, method_name=_method_name, result=model_top_folder_name)
return model_top_folder_name, result

def _uses_is_set(self, location, wlst_param):
"""
Determine if the specified attribute should call WLST.is_set() to be included in the model.
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/python/wlsdeploy/tool/util/wlst_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ def is_set(self, attribute):
return True
result = mbean.isSet(attribute)
else:
if not self.__has_global('isSet'):
return True
result = self.__load_global('isSet')(attribute)

except (self.__load_global('WLSTException'), offlineWLSTException), e:
Expand Down Expand Up @@ -1802,6 +1804,9 @@ def __ls(self, method_name, ls_type, path=None, log_throwing=True):
def __check_online_connection(self):
return self.__load_global('WLS_ON').isConnected()

def __has_global(self, global_name):
return wlst_functions is not None and global_name in wlst_functions

def __load_global(self, global_name):
"""
The WLST globals were stored on entry into the tool instance. Look for the provided name in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,23 @@
"version": "[12.1.3,)",
"child_folders_type": "single",
"default_name_value": "${NO_NAME_0:%CLUSTER%}",
"folders" : {},
"folders" : {
"JtaRemoteDomain": {
"wlst_type": "J${ta:TA}RemoteDomain${:s}",
"online_bean": "weblogic.management.configuration.JTARemoteDomainMBean",
"version": "[14.1.2,)",
"child_folders_type": "multiple",
"folders": {},
"attributes": {
"Notes": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"Url": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "U${rl:RL}", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ]
},
"wlst_attributes_path": "WP001",
"wlst_paths": {
"WP001": "/Cluster${:s}/%CLUSTER%/JTACluster/%JTACLUSTER%/JtaRemoteDomain${:s}/%JTAREMOTEDOMAIN%"
}
}
},
"attributes" : {
"AbandonTimeoutSeconds": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "AbandonTimeoutSeconds", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 86400, "wlst_type": "integer" } ],
"BeforeCompletionIterationLimit": [ {"version": "[12.1.3,)", "wlst_mode": "both", "wlst_name": "BeforeCompletionIterationLimit", "derived_default": "${:true}", "wlst_path": "WP001", "default_value": 10, "wlst_type": "integer" } ],
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"copyright": "Copyright (c) 2024, Oracle and/or its affiliates.",
"license": "Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl",
"wlst_type": "EJBContainer",
"online_bean": "weblogic.management.configuration.EJBContainerMBean",
"default_name_value": "${NO_NAME_0:%DOMAIN%}",
"folders": {
},
"attributes": {
"ExtraEjbcOptions": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "ExtraEjbcOptions", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"ExtraRmicOptions": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "ExtraRmicOptions", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"ForceGeneration": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "ForceGeneration", "wlst_path": "WP001", "default_value": false, "wlst_type": "boolean" } ],
"JavaCompiler": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "JavaCompiler", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"JavaCompilerPostClassPath": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "JavaCompilerPostClassPath", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"JavaCompilerPreClassPath": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "JavaCompilerPreClassPath", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"KeepGenerated": [
{ "version": "[10,14.1.2)", "wlst_mode": "both", "wlst_name": "KeepGenerated", "wlst_path": "WP001", "default_value": true, "wlst_type": "boolean" },
{ "version": "[14.1.2,)", "wlst_mode": "both", "wlst_name": "KeepGenerated", "wlst_path": "WP001", "default_value": true, "wlst_type": "boolean", "derived_default": "${true:}" }
],
"Notes": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "Notes", "wlst_path": "WP001", "default_value": null, "wlst_type": "string" } ],
"TmpPath": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "TmpPath", "wlst_path": "WP001", "default_value": "tmp_ejb", "wlst_type": "string", "uses_path_tokens": true } ],
"VerboseEJBDeploymentEnabled": [ { "version": "[10,)", "wlst_mode": "both", "wlst_name": "VerboseEJBDeploymentEnabled", "wlst_path": "WP001", "default_value": "false", "wlst_type": "string" } ]
},
"wlst_attributes_path": "WP001",
"wlst_paths": {
"WP001": "/EJBContainer/%EJBCONTAINER%"
}
}
Loading

0 comments on commit e4b71bf

Please sign in to comment.