7
7
import javaos as os
8
8
import sys
9
9
10
- from xml .dom .minidom import parse
11
10
12
11
from java .io import IOException
13
12
from java .lang import IllegalArgumentException
14
13
from java .lang import IllegalStateException
15
14
from java .lang import String
16
15
from java .io import File
17
- from java .nio .file import Files
18
- from java .io import FileInputStream
19
- from java .io import FileOutputStream
20
- from java .util .zip import ZipInputStream
21
- import jarray
22
16
23
17
from oracle .weblogic .deploy .create import CreateException
24
18
from oracle .weblogic .deploy .deploy import DeployException
54
48
from wlsdeploy .util .model_context import ModelContext
55
49
from wlsdeploy .util .model_translator import FileToPython
56
50
from wlsdeploy .util .weblogic_helper import WebLogicHelper
51
+ from wlsdeploy .tool .create import atp_helper
57
52
58
53
wlst_extended .wlst_functions = globals ()
59
54
@@ -282,15 +277,9 @@ def __process_rcu_args(optional_arg_map, domain_type, domain_typedef):
282
277
ex .setExitCode (CommandLineArgUtil .USAGE_ERROR_EXIT_CODE )
283
278
__logger .throwing (ex , class_name = _class_name , method_name = _method_name )
284
279
raise ex
285
- # elif CommandLineArgUtil.ATP_PROPERTIES_FILE_SWITCH in optional_arg_map:
286
- # pass
287
- # else:
288
- # ex = exception_helper.create_cla_exception('WLSDPLY-12408', domain_type, rcu_schema_count,
289
- # CommandLineArgUtil.RCU_DB_SWITCH,
290
- # CommandLineArgUtil.RCU_PREFIX_SWITCH)
291
- # ex.setExitCode(CommandLineArgUtil.USAGE_ERROR_EXIT_CODE)
292
- # __logger.throwing(ex, class_name=_class_name, method_name=_method_name)
293
- # raise ex
280
+
281
+ # Delay the checking later for rcu related parameters
282
+
294
283
return
295
284
296
285
@@ -347,86 +336,22 @@ def validate_model(model_dictionary, model_context, aliases):
347
336
__clean_up_temp_files ()
348
337
tool_exit .end (model_context , CommandLineArgUtil .PROG_ERROR_EXIT_CODE )
349
338
350
- def set_ssl_properties (xmlDoc , atp_creds_path , keystore_password , truststore_password ):
351
- '''
352
- Add SSL config properties to the specified XML document.
353
- :param xmlDoc: The XML document
354
- :param db_keystore_password: The DB keystore/truststore password (assumed to be same)
355
- :return: void
356
- '''
357
- DOMTree = parse (xmlDoc )
358
- collection = DOMTree .documentElement
359
- props = collection .getElementsByTagName ("propertySet" )
360
-
361
- for prop in props :
362
- if prop .getAttribute ('name' ) == 'props.db.1' :
363
- set_property (DOMTree , prop , 'javax.net.ssl.trustStoreType' , 'JKS' )
364
- set_property (DOMTree , prop , 'javax.net.ssl.trustStore' , atp_creds_path + '/truststore.jks' )
365
- set_property (DOMTree , prop , 'oracle.net.tns_admin' , atp_creds_path )
366
- set_property (DOMTree , prop , 'javax.net.ssl.keyStoreType' , 'JKS' )
367
- set_property (DOMTree , prop , 'javax.net.ssl.keyStore' , atp_creds_path + '/keystore.jks' )
368
- set_property (DOMTree , prop , 'javax.net.ssl.keyStorePassword' , keystore_password )
369
- set_property (DOMTree , prop , 'javax.net.ssl.trustStorePassword' , truststore_password )
370
- set_property (DOMTree , prop , 'oracle.net.ssl_server_dn_match' , 'true' )
371
- set_property (DOMTree , prop , 'oracle.net.ssl_version' , '1.2' )
372
- # Persist the changes in the xml file
373
- file_handle = open (xmlDoc ,"w" )
374
- DOMTree .writexml (file_handle )
375
- file_handle .close ()
376
-
377
- def set_property (DOMTree , prop , name , value ):
378
- '''
379
- Sets the property child element under prop parent node.
380
- :param DOMTree: The DOM document handle
381
- :param prop: The propertySet parent handle
382
- :param name: The property name
383
- :param value: The property value
384
- :return: void
385
- '''
386
- property = DOMTree .createElement ('property' )
387
- property .setAttribute ("name" , name )
388
- property .setAttribute ("value" , value )
389
- prop .appendChild (property )
390
- newline = DOMTree .createTextNode ('\n ' )
391
- prop .appendChild (newline )
392
-
393
-
394
- def unzip_atp_wallet (wallet_file , location ):
395
-
396
- if not os .path .exists (location ):
397
- os .mkdir (location )
398
-
399
- buffer = jarray .zeros (1024 , "b" )
400
- fis = FileInputStream (wallet_file )
401
- zis = ZipInputStream (fis )
402
- ze = zis .getNextEntry ()
403
- while ze :
404
- fileName = ze .getName ()
405
- newFile = File (location + File .separator + fileName )
406
- File (newFile .getParent ()).mkdirs ()
407
- fos = FileOutputStream (newFile )
408
- len = zis .read (buffer )
409
- while len > 0 :
410
- fos .write (buffer , 0 , len )
411
- len = zis .read (buffer )
412
-
413
- fos .close ()
414
- zis .closeEntry ()
415
- ze = zis .getNextEntry ()
416
- zis .closeEntry ()
417
- zis .close ()
418
- fis .close ()
419
-
420
339
421
340
def validateRCUArgsAndModel (model_context , model ):
422
341
has_atpdbinfo = 0
423
342
domain_info = model [model_constants .DOMAIN_INFO ]
424
343
if model_constants .RCU_DB_INFO in domain_info :
425
- has_tns_admin = model_constants .DRIVER_PARAMS_NET_TNS_ADMIN in domain_info [
426
- model_constants .RCU_DB_INFO ]
427
- has_regular_db = model_constants .RCU_DB_CONN in domain_info [model_constants .RCU_DB_INFO ]
344
+ rcu_db_info = domain_info [model_constants .RCU_DB_INFO ]
345
+ has_tns_admin = atp_helper .has_tns_admin (rcu_db_info )
428
346
429
- if model_constants .ATP_TNS_ENTRY in domain_info [model_constants .RCU_DB_INFO ]:
347
+ # has_tns_admin = model_constants.DRIVER_PARAMS_NET_TNS_ADMIN in domain_info[
348
+ # model_constants.RCU_DB_INFO]
349
+ # has_regular_db = model_constants.RCU_DB_CONN in domain_info[model_constants.RCU_DB_INFO]
350
+
351
+ has_regular_db = atp_helper .is_regular_db (rcu_db_info )
352
+
353
+ # if model_constants.ATP_TNS_ENTRY in domain_info[model_constants.RCU_DB_INFO]:
354
+ if atp_helper .has_atpdbinfo (rcu_db_info ):
430
355
has_atpdbinfo = 1
431
356
432
357
if model_context .get_archive_file_name () and not has_regular_db :
@@ -436,16 +361,9 @@ def validateRCUArgsAndModel(model_context, model):
436
361
if not has_tns_admin :
437
362
# extract the wallet first
438
363
archive_file = WLSDeployArchive (model_context .get_archive_file_name ())
439
- atp_path = archive_file .getATPWallet ()
440
- if atp_path and model [model_constants .TOPOLOGY ]['Name' ]:
441
- domain_path = model_context .get_domain_parent_dir () + os .sep + model [model_constants .TOPOLOGY ][
442
- 'Name' ]
443
- extract_path = domain_path + os .sep + 'atpwallet'
444
- extract_dir = File (extract_path )
445
- extract_dir .mkdirs ()
446
- wallet_zip = archive_file .extractFile (atp_path , File (domain_path ))
447
- unzip_atp_wallet (wallet_zip , extract_path )
448
- os .remove (wallet_zip )
364
+ atp_wallet_zipentry = archive_file .getATPWallet ()
365
+ if atp_wallet_zipentry and model [model_constants .TOPOLOGY ]['Name' ]:
366
+ extract_path = atp_helper .extract_walletzip (model , model_context , archive_file , atp_wallet_zipentry )
449
367
# update the model to add the tns_admin
450
368
model [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ][
451
369
model_constants .DRIVER_PARAMS_NET_TNS_ADMIN ] = extract_path
@@ -494,8 +412,6 @@ def main(args):
494
412
model_file = model_context .get_model_file ()
495
413
try :
496
414
model = FileToPython (model_file , True ).parse ()
497
- # if model_context.get_archive_file():
498
- # os.environ['oracle.net.fanEnabled'] = 'false'
499
415
except TranslateException , te :
500
416
__logger .severe ('WLSDPLY-20009' , _program_name , model_file , te .getLocalizedMessage (), error = te ,
501
417
class_name = _class_name , method_name = _method_name )
@@ -519,27 +435,14 @@ def main(args):
519
435
if filter_helper .apply_filters (model , "create" ):
520
436
# if any filters were applied, re-validate the model
521
437
validate_model (model , model_context , aliases )
522
-
523
438
try :
524
439
525
440
has_atp = validateRCUArgsAndModel (model_context , model )
526
441
creator = DomainCreator (model , model_context , aliases )
527
442
creator .create ()
528
443
529
444
if has_atp :
530
- #print model[model_constants.DOMAIN_INFO][model_constants.ATP_DB_INFO]
531
- tns_admin = model [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ][
532
- model_constants .DRIVER_PARAMS_NET_TNS_ADMIN ]
533
- keystore_password = model [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ][
534
- model_constants .DRIVER_PARAMS_KEYSTOREPWD_PROPERTY ]
535
-
536
- truststore_password = model [model_constants .DOMAIN_INFO ][model_constants .RCU_DB_INFO ][
537
- model_constants .DRIVER_PARAMS_TRUSTSTOREPWD_PROPERTY ]
538
-
539
- jsp_config = model_context .get_domain_home () + '/config/fmwconfig/jps-config.xml'
540
- jsp_config_jse = model_context .get_domain_home () + '/config/fmwconfig/jps-config-jse.xml'
541
- set_ssl_properties (jsp_config , tns_admin , keystore_password , truststore_password )
542
- set_ssl_properties (jsp_config_jse , tns_admin , keystore_password , truststore_password )
445
+ atp_helper .fix_jsp_config (model , model_context )
543
446
544
447
except (IOException | CreateException ), ex :
545
448
__logger .severe ('WLSDPLY-12409' , _program_name , ex .getLocalizedMessage (), error = ex ,
0 commit comments