Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix multiple models problem
  • Loading branch information
Johnny Shum committed May 18, 2020
commit c771e05a620f4aa9bd9e32b7dac0612a60e96539
11 changes: 6 additions & 5 deletions core/src/main/python/prepare_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ def walk(self):

model_file_list = self.model_files.split(',')
for model_file in model_file_list:
self.cache.clear()
if os.path.splitext(model_file)[1].lower() == ".yaml":
model_file_name = model_file
FileToPython(model_file_name, True).parse()
Expand Down Expand Up @@ -497,11 +498,11 @@ def main():
model_context = __process_args(sys.argv, __logger)
_outputdir = model_context.get_kubernetes_output_dir()
model1 = model_context.get_model_file()
for f in [ model1 ]:
if not os.path.exists(f):
raise CLAException("Model %s does not exists" % f)
if os.path.isdir(f):
raise CLAException("Model %s is a directory" % f)
# for f in [ model1 ]:
# if not os.path.exists(f):
# raise CLAException("Model %s does not exists" % f)
# if os.path.isdir(f):
# raise CLAException("Model %s is a directory" % f)


obj = PrepareModel(model1, model_context, __logger, _outputdir)
Expand Down
81 changes: 45 additions & 36 deletions core/src/main/python/wlsdeploy/util/target_configuration_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,51 @@ def generate_k8s_script(file_location, token_dictionary):
NL = '\n'
par_dir = os.path.abspath(os.path.join(file_location,os.pardir))
k8s_file = os.path.join(par_dir, "create_k8s_secrets.sh")
k8s_create_script_handle = open(k8s_file, 'w')
k8s_create_script_handle.write('#!/bin/bash')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('set -eu')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('NAMESPACE=default')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('DOMAIN_UID=domain1')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('ADMIN_USER=wlsAdminUser')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('ADMIN_PWD=wlsAdminPwd')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('function create_k8s_secret {')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE delete secret ${DOMAIN_UID}-$1 --ignore-not-found')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE create secret generic ${DOMAIN_UID}-$1 ' +
'--from-literal=$2=$3')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE label secret ${DOMAIN_UID}-$1 ' +
'weblogic.domainUID=${DOMAIN_UID}')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('}')
k8s_create_script_handle.write(NL)
# Only write the function and wls crednetials if it does not exists
if not os.path.exists(k8s_file):
k8s_create_script_handle = open(k8s_file, 'w')
k8s_create_script_handle.write('#!/bin/bash')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('set -eu')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('NAMESPACE=default')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('DOMAIN_UID=domain1')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('ADMIN_USER=wlsAdminUser')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('ADMIN_PWD=wlsAdminPwd')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('function create_k8s_secret {')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE delete secret ${DOMAIN_UID}-$1 --ignore-not-found')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE create secret generic ${DOMAIN_UID}-$1 ' +
'--from-literal=$2=$3')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE label secret ${DOMAIN_UID}-$1 ' +
'weblogic.domainUID=${DOMAIN_UID}')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('}')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write("kubectl -n $NAMESPACE delete secret ${DOMAIN_UID}-weblogic-credentials "
+ "--ignore-not-found")
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write("kubectl -n $NAMESPACE create secret generic "
+ "${DOMAIN_UID}-weblogic-credentials "
+ "--from-literal=username=${ADMIN_USER} --from-literal=password=${ADMIN_PWD}")
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE label secret ${DOMAIN_UID}-weblogic-credentials ' +
'weblogic.domainUID=${DOMAIN_UID}')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write(NL)
k8s_create_script_handle.close()

k8s_create_script_handle = open(k8s_file, "a+")
k8s_create_script_handle.write(NL)
for property_name in token_dictionary:
# AdminPassword handle differently and SecurityConfig.NodeManagerPasswordEncrypted is the short name
Expand All @@ -50,17 +70,6 @@ def generate_k8s_script(file_location, token_dictionary):
k8s_create_script_handle.write(command_string)
k8s_create_script_handle.write(NL)

k8s_create_script_handle.write(NL)
k8s_create_script_handle.write("kubectl -n $NAMESPACE delete secret ${DOMAIN_UID}-weblogic-credentials "
+ "--ignore-not-found")
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write("kubectl -n $NAMESPACE create secret generic "
+ "${DOMAIN_UID}-weblogic-credentials "
+ "--from-literal=username=${ADMIN_USER} --from-literal=password=${ADMIN_PWD}")
k8s_create_script_handle.write(NL)
k8s_create_script_handle.write('kubectl -n $NAMESPACE label secret ${DOMAIN_UID}-weblogic-credentials ' +
'weblogic.domainUID=${DOMAIN_UID}')
k8s_create_script_handle.write(NL)
k8s_create_script_handle.close()

def format_as_secret(prop_name):
Expand Down