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