Skip to content

Commit

Permalink
Merge pull request #12074 from GihanAyesh/master
Browse files Browse the repository at this point in the history
Get all policies from CP before undeploying
  • Loading branch information
npamudika authored Jul 6, 2023
2 parents 5af7105 + 7ec68cd commit 59f84fe
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,18 @@ public static void deployPolicy(Policy policy, PolicyEvent policyEvent) {
* Deploy all the throttle policies retrieved from the database in the Traffic Manager.
*/
public static void deployAllPolicies() {
// Undeploy all existing policies
undeployAllPolicies();
PolicyRetriever policyRetriever = new PolicyRetriever();
try {
// Deploy all the policies retrieved from the database
SubscriptionPolicyList subscriptionPolicies = new SubscriptionPolicyList();
if (migrationEnabled == null) {
subscriptionPolicies = policyRetriever.getAllSubscriptionPolicies();
}
ApplicationPolicyList applicationPolicies = policyRetriever.getAllApplicationPolicies();
ApiPolicyList apiPolicies = policyRetriever.getAllApiPolicies();
GlobalPolicyList globalPolicies = policyRetriever.getAllGlobalPolicies();
// Undeploy all existing policies
undeployAllPolicies();
for (SubscriptionPolicy subscriptionPolicy : subscriptionPolicies.getList()) {
if (!(APIConstants.UNLIMITED_TIER.equalsIgnoreCase(subscriptionPolicy.getName())
|| APIConstants.DEFAULT_SUB_POLICY_ASYNC_UNLIMITED.
Expand All @@ -170,19 +173,16 @@ public static void deployAllPolicies() {
deployPolicy(subscriptionPolicy, null);
}
}
ApplicationPolicyList applicationPolicies = policyRetriever.getAllApplicationPolicies();
for (ApplicationPolicy applicationPolicy : applicationPolicies.getList()) {
if (!APIConstants.UNLIMITED_TIER.equalsIgnoreCase(applicationPolicy.getName())) {
deployPolicy(applicationPolicy, null);
}
}
ApiPolicyList apiPolicies = policyRetriever.getAllApiPolicies();
for (ApiPolicy apiPolicy : apiPolicies.getList()) {
if (!APIConstants.UNLIMITED_TIER.equalsIgnoreCase(apiPolicy.getName())) {
deployPolicy(apiPolicy, null);
}
}
GlobalPolicyList globalPolicies = policyRetriever.getAllGlobalPolicies();
for (GlobalPolicy globalPolicy : globalPolicies.getList()) {
deployPolicy(globalPolicy, null);
}
Expand Down

0 comments on commit 59f84fe

Please sign in to comment.