4
4
"""
5
5
import copy
6
6
import os , re
7
- from java .io import ByteArrayOutputStream
8
7
from java .io import File
9
8
from java .io import FileInputStream
10
9
from java .io import FileNotFoundException
15
14
from java .util .jar import Manifest
16
15
from java .util .zip import ZipException
17
16
from sets import Set
17
+
18
+ from oracle .weblogic .deploy .aliases import TypeUtils
18
19
from wlsdeploy .aliases .location_context import LocationContext
19
20
from wlsdeploy .aliases .model_constants import ABSOLUTE_SOURCE_PATH
20
21
from wlsdeploy .aliases .model_constants import APPLICATION
@@ -418,6 +419,7 @@ def __get_existing_apps(self, base_location):
418
419
attributes_map = self .wlst_helper .lsa ()
419
420
absolute_sourcepath = attributes_map ['AbsoluteSourcePath' ]
420
421
absolute_planpath = attributes_map ['AbsolutePlanPath' ]
422
+ config_targets = self .__get_config_targets ()
421
423
422
424
# There are case in application where absolute source path is not set but sourepath is
423
425
# if source path is not absolute then we need to add the domain path
@@ -442,7 +444,7 @@ def __get_existing_apps(self, base_location):
442
444
else :
443
445
plan_hash = None
444
446
445
- _update_ref_dictionary (ref_dictionary , app , absolute_sourcepath , app_hash , None ,
447
+ _update_ref_dictionary (ref_dictionary , app , absolute_sourcepath , app_hash , config_targets ,
446
448
absolute_plan_path = absolute_planpath , deploy_order = deployment_order ,
447
449
plan_hash = plan_hash )
448
450
return ref_dictionary
@@ -641,7 +643,23 @@ def __build_app_deploy_strategy(self, location, model_apps, existing_apps, exist
641
643
existing_plan_hash = self .__get_file_hash (plan_path )
642
644
if model_src_hash == existing_src_hash :
643
645
if model_plan_hash == existing_plan_hash :
644
- self .__remove_app_from_deployment (model_apps , app )
646
+ # If model hashes match existing hashes, the application did not change.
647
+ # Unless targets were added, there's no need to redeploy.
648
+ model_targets = dictionary_utils .get_element (app_dict , TARGET )
649
+ model_targets_list = TypeUtils .convertToType (list , model_targets )
650
+ model_targets_set = Set (model_targets_list )
651
+
652
+ existing_app_targets = dictionary_utils .get_element (existing_app_ref , 'target' )
653
+ existing_app_targets_set = Set (existing_app_targets )
654
+
655
+ if existing_app_targets_set .issuperset (model_targets_set ):
656
+ self .__remove_app_from_deployment (model_apps , app )
657
+ else :
658
+ # Adjust the targets to only the new targets so that existing apps on
659
+ # already targeted servers are not impacted.
660
+ adjusted_set = model_targets_set .difference (existing_app_targets_set )
661
+ adjusted_targets = ',' .join (adjusted_set )
662
+ app_dict ['Target' ] = adjusted_targets
645
663
else :
646
664
# updated deployment plan
647
665
stop_and_undeploy_app_list .append (app )
0 commit comments