Skip to content

Commit 4b7a53f

Browse files
jshum2479ddsharpe
authored andcommitted
refactor store model and also store model when update (#421)
1 parent 49bc808 commit 4b7a53f

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

core/src/main/python/update.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from wlsdeploy.util.model_context import ModelContext
4848
from wlsdeploy.util.model_translator import FileToPython
4949
from wlsdeploy.util.weblogic_helper import WebLogicHelper
50+
from wlsdeploy.util import model as model_helper
5051

5152
wlst_extended.wlst_functions = globals()
5253

@@ -228,6 +229,9 @@ def __update(model, model_context, aliases):
228229
__update_online(model, model_context, aliases)
229230
else:
230231
__update_offline(model, model_context, aliases)
232+
233+
if os.environ.has_key('__WLSDEPLOY_STORE_MODEL__'):
234+
model_helper.persist_model(model_context, model)
231235
return
232236

233237

core/src/main/python/wlsdeploy/tool/create/domain_creator.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,7 @@ def __create_domain(self):
346346
self.library_helper.extract_classpath_libraries()
347347
self.wlsroles_helper.process_roles()
348348
if os.environ.has_key('__WLSDEPLOY_STORE_MODEL__'):
349-
os.makedirs(self.model_context.get_domain_home() + os.sep + 'wlsdeploy')
350-
fh = open(self.model_context.get_domain_home() + os.sep + 'wlsdeploy' + os.sep + 'domain_model.json', 'w')
351-
fh.write(str(self.model.get_model()))
352-
fh.close()
349+
model_helper.persist_model(self.model_context, self.model)
353350

354351
self.logger.exiting(class_name=self.__class_name, method_name=_method_name)
355352
return

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
This module serves as a wrapper for the model dictionary.
66
It has convenience methods for accessing top-level fields in the model.
77
"""
8-
import pprint
8+
import pprint, os
99

1010
import oracle.weblogic.deploy.util.PyOrderedDict as OrderedDict
1111

@@ -144,3 +144,12 @@ def get_model_top_level_keys():
144144
get_model_resources_key(),
145145
get_model_deployments_key()
146146
]
147+
148+
149+
def persist_model(model_context,model):
150+
base_dir = model_context.get_domain_home() + os.sep + 'wlsdeploy'
151+
if not os.path.exists(base_dir):
152+
os.makedirs(base_dir)
153+
fh = open(base_dir + os.sep + 'domain_model.json', 'w')
154+
fh.write(str(model.get_model()))
155+
fh.close()

0 commit comments

Comments
 (0)