oracle / weblogic-deploy-tooling

WebLogic Deploy Tooling
https://oracle.github.io/weblogic-deploy-tooling/
Universal Permissive License v1.0
152 stars 90 forks source link

Concatenate values to properties in YAML config #1530

Closed tdferreira closed 5 months ago

tdferreira commented 5 months ago

Hello,

It would be very useful if we could concatenate any value before or after any property placeholder.

For example, if I want to use a fixed server port number prefix and always keep the last number, I would like to be able to do this:

ListenPort: '@@PROP:Server.Port.Prefix@@2'

Or even concatenate multiple properties:

ListenPort: '@@PROP:Server.Port.Prefix@@@@PROP:MyServer.Port@@'

Currently I get this error:

SEVERE Messages:

    1. WLSDPLY-12409: createDomain failed to create the domain: Failed to set attribute ListenPort in path /Server/MyServer to value 75,300: 60922: Invalid port value.

60922: The listen port value 75300 of Server "MyServer" is out of range. It must be between 1 and 65535. 60922: Enter a valid port value.

Would it be possible for you to implement this?

robertpatrick commented 5 months ago

@tdferreira The variable substitution capability you are requesting already exists. The error seems to be because the ListenPort value you have constructed is out of the valid port ranges...not because the variable substitution is not working.

Here is my model:

domainInfo:
    AdminUserName: 'web@@PROP:prop1@@ic'
    AdminPassword: '@@PROP:pass1@@@@PROP:pass2@@'
topology:
    Name: mydomain
    Server:
        AdminServer:
            ListenPort: '7@@PROP:digit2@@@@PROP:digit3@@1'

and here is my variables file:

prop1=log
pass1=wel
pass2=come1
digit2=8
digit3=9

Create Domain works fine:

JDK version is 1.8.0_351-b10
JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk1.8.0_351.jdk/Contents/Home
WLST_EXT_CLASSPATH = /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/weblogic-deploy-core.jar
CLASSPATH = /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/weblogic-deploy-core.jar
WLST_PROPERTIES = -Dcom.oracle.cie.script.throwException=true -Djava.util.logging.config.class=oracle.weblogic.deploy.logging.WLSDeployLoggingConfig 
/opt/weblogic/wls12214/oracle_common/common/bin/wlst.sh /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/python/create.py -oracle_home /opt/weblogic/wls12214 -domain_parent /Users/rpatrick/tmp/concat-props -model_file model.yaml -variable_file variables.properties

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

####<Mar 12, 2024 10:13:48 AM> <INFO> <WebLogicDeployToolingVersion> <logVersionInfo> <WLSDPLY-01750> <The WebLogic Deploy Tooling createDomain version is 4.0.0-SNAPSHOT:develop-4.0.e7b980a:Mar 12, 2024 14:53 UTC>
####<Mar 12, 2024 10:13:48 AM> <INFO> <WLSDeployLoggingConfig> <logLoggingDirectory> <WLSDPLY-01755> <The createDomain program will write its log to directory /Users/rpatrick/tmp/concat-props/weblogic-deploy/logs>
####<Mar 12, 2024 10:13:48 AM> <INFO> <PathHelper> <__init__> <WLSDPLY-02100> <Setting local file system to use Posix-style paths>
####<Mar 12, 2024 10:13:48 AM> <INFO> <ModelContext> <__copy_from_args> <WLSDPLY-01050> <Local WebLogic version is 12.2.1.4.0.231010>
####<Mar 12, 2024 10:13:48 AM> <INFO> <DomainTypedef> <__finish_initialization> <WLSDPLY-12328> <Domain type WLS type definition file /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/typedefs/WLS.json version WLS_12CR2 does not contain a postCreateRcuSchemasScript section>
####<Mar 12, 2024 10:13:48 AM> <INFO> <DomainTypedef> <__finish_initialization> <WLSDPLY-12321> <Domain type WLS type definition file /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/typedefs/WLS.json version WLS_12CR2 does not contain a postCreateDomainScript section>
####<Mar 12, 2024 10:13:48 AM> <INFO> <DomainTypedef> <__finish_initialization> <WLSDPLY-12331> <Domain type WLS type definition file /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/typedefs/WLS.json version WLS_12CR2 does not contains any discoverExcludedLocationsBinariesToArchive entries>
####<Mar 12, 2024 10:13:48 AM> <INFO> <Aliases> <__init__> <WLSDPLY-19052> <Aliases loaded using WebLogic version 12.2.1.4.0.231010 and WLST OFFLINE mode>
####<Mar 12, 2024 10:13:48 AM> <INFO> <filter_helper> <apply_filters> <WLSDPLY-20017> <No filter configuration file /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/model_filters.json>
####<Mar 12, 2024 10:13:48 AM> <INFO> <filter_helper> <apply_filters> <WLSDPLY-20016> <No filters of type create found in filter configuration file /Users/rpatrick/tmp/concat-props/weblogic-deploy/lib/model_filters.json>
####<Mar 12, 2024 10:13:48 AM> <INFO> <Validator> <__validate_model_file> <WLSDPLY-05002> <Performing validation in TOOL mode for WebLogic Server version 12.2.1.4.0.231010 and WLST OFFLINE mode>
####<Mar 12, 2024 10:13:48 AM> <INFO> <Validator> <__validate_model_file> <WLSDPLY-05003> <Performing model validation on the /Users/rpatrick/tmp/concat-props/model.yaml model file>
####<Mar 12, 2024 10:13:48 AM> <INFO> <ModelValidator> <validate_model_section> <WLSDPLY-05008> <Validating the domainInfo section of the model file>
####<Mar 12, 2024 10:13:48 AM> <INFO> <ModelValidator> <validate_model_section> <WLSDPLY-05008> <Validating the topology section of the model file>
####<Mar 12, 2024 10:13:49 AM> <INFO> <ModelValidator> <validate_model_section> <WLSDPLY-05008> <Validating the resources section of the model file>
####<Mar 12, 2024 10:13:49 AM> <INFO> <ModelValidator> <validate_model_section> <WLSDPLY-05009> <Model file /Users/rpatrick/tmp/concat-props/model.yaml does not contain a resources section, validation of resources was skipped.>
####<Mar 12, 2024 10:13:49 AM> <INFO> <ModelValidator> <validate_model_section> <WLSDPLY-05008> <Validating the appDeployments section of the model file>
####<Mar 12, 2024 10:13:49 AM> <INFO> <ModelValidator> <validate_model_section> <WLSDPLY-05009> <Model file /Users/rpatrick/tmp/concat-props/model.yaml does not contain a appDeployments section, validation of appDeployments was skipped.>
####<Mar 12, 2024 10:13:49 AM> <INFO> <DomainCreator> <__create_domain> <WLSDPLY-12203> <Creating domain of type WLS>
####<Mar 12, 2024 10:13:49 AM> <INFO> <DomainCreator> <__create_base_domain_with_select_template> <WLSDPLY-12210> <Selecting base template named Basic WebLogic Server Domain>
####<Mar 12, 2024 10:13:50 AM> <INFO> <DomainCreator> <__extend_domain_with_select_template> <WLSDPLY-12212> <Loading selected templates>
####<Mar 12, 2024 10:13:52 AM> <INFO> <DomainCreator> <__set_domain_name> <WLSDPLY-12227> <Changing domain name from base_domain to mydomain>
####<Mar 12, 2024 10:13:52 AM> <INFO> <Creator> <_create_named_mbeans> <WLSDPLY-12101> <Updating Server with the name AdminServer>
####<Mar 12, 2024 10:13:52 AM> <INFO> <Creator> <_create_named_mbeans> <WLSDPLY-12101> <Updating Server with the name AdminServer>
####<Mar 12, 2024 10:13:52 AM> <INFO> <DomainCreator> <__extend_domain_with_select_template> <WLSDPLY-12205> <Writing base domain mydomain to directory /Users/rpatrick/tmp/concat-props/mydomain>
####<Mar 12, 2024 10:15:06 AM> <INFO> <DomainCreator> <__extend_domain_with_select_template> <WLSDPLY-12206> <Closing templates for domain mydomain>
####<Mar 12, 2024 10:15:06 AM> <INFO> <DefaultAuthenticatorHelper> <create_default_init_file> <WLSDPLY-01900> <Updating default authenticator initialization file /Users/rpatrick/tmp/concat-props/mydomain/security/DefaultAuthenticatorInit.ldift>
####<Mar 12, 2024 10:15:06 AM> <INFO> <LibraryHelper> <install_domain_libraries> <WLSDPLY-12213> <The model did not specify any domain libraries to install>
####<Mar 12, 2024 10:15:06 AM> <INFO> <LibraryHelper> <extract_classpath_libraries> <WLSDPLY-12216> <The archive file was not provided so there are no classpath libraries to extract>
####<Mar 12, 2024 10:15:06 AM> <INFO> <LibraryHelper> <install_domain_scripts> <WLSDPLY-12241> <The model did not specify any domain scripts to install>

Issue Log for createDomain version 4.0.0-SNAPSHOT running WebLogic version 12.2.1.4.0.231010 in offline mode:

Total:   SEVERE :    0  WARNING :    0

createDomain.sh completed successfully (exit code = 0)

The resulting config.xml shows that the ListenPort is being properly substituted:

  <server>
    <name>AdminServer</name>
    <listen-port>7891</listen-port>
    <listen-address/>
    <server-life-cycle-timeout-val>30</server-life-cycle-timeout-val>
    <startup-timeout>0</startup-timeout>
  </server>

If I start the resulting domain, I am able to log into the Console using my constructed username and password.

tdferreira commented 5 months ago

You're absolutely right, the error message was quite clear about that and I just didn't read it properly. Thank you for the thorough explanation ;)