aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java44
-rw-r--r--runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java7
2 files changed, 30 insertions, 21 deletions
diff --git a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java
index 9239b3ae9..09f1b09cd 100644
--- a/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java
+++ b/models/src/main/java/org/onap/policy/clamp/models/acm/persistence/provider/AcInstanceStateResolver.java
@@ -100,19 +100,12 @@ public class AcInstanceStateResolver {
DEPLOYED, LOCKED, SUB_STATE_NONE, NO_ERROR}, MIGRATE_PRECHECK);
// make an order in a failed scenario
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
- UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, DEPLOY);
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
- DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, DEPLOY);
-
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
- UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, UNDEPLOY);
+ setAllowed(DEPLOY);
+ setAllowed(UNDEPLOY);
this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
UPDATING, LOCKED, SUB_STATE_NONE, FAILED}, UNDEPLOY);
this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
MIGRATING, LOCKED, SUB_STATE_NONE, FAILED}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
- DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, UNDEPLOY);
this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE,
DELETING, LOCK_NONE, SUB_STATE_NONE, FAILED}, DELETE);
@@ -131,23 +124,12 @@ public class AcInstanceStateResolver {
DEPLOYED, LOCKED, MIGRATION_PRECHECKING, FAILED}, MIGRATE_PRECHECK);
// timeout
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
- UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, DEPLOY);
- this.graph.put(new String[] {DEPLOY, LOCK_NONE, SUB_NONE,
- DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, DEPLOY);
-
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
- UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
- UNDEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
UPDATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
MIGRATING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
MIGRATION_PRECHECKING, LOCKED, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
- this.graph.put(new String[] {UNDEPLOY, LOCK_NONE, SUB_NONE,
- DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, UNDEPLOY);
this.graph.put(new String[] {DELETE, LOCK_NONE, SUB_NONE,
DELETING, LOCK_NONE, SUB_STATE_NONE, TIMEOUT}, DELETE);
@@ -168,6 +150,28 @@ public class AcInstanceStateResolver {
DEPLOYED, LOCKED, MIGRATION_PRECHECKING, TIMEOUT}, MIGRATE_PRECHECK);
}
+ private void setAllowed(String deployOrder) {
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, deployOrder);
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, LOCKED, SUB_STATE_NONE, FAILED}, deployOrder);
+
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, deployOrder);
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ UNDEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, deployOrder);
+
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, FAILED}, deployOrder);
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ DEPLOYING, LOCKED, SUB_STATE_NONE, FAILED}, deployOrder);
+
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ DEPLOYING, STATE_LOCKED_NONE, SUB_STATE_NONE, TIMEOUT}, deployOrder);
+ this.graph.put(new String[] {deployOrder, LOCK_NONE, SUB_NONE,
+ DEPLOYING, LOCKED, SUB_STATE_NONE, TIMEOUT}, deployOrder);
+ }
+
/**
* Check if Deploy Order and Lock Order are consistent with current DeployState and LockState.
*
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
index 42af70596..0979a811b 100644
--- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
+++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java
@@ -68,6 +68,8 @@ import org.springframework.transaction.annotation.Transactional;
public class AutomationCompositionInstantiationProvider {
private static final String DO_NOT_MATCH = " do not match with ";
private static final String ELEMENT_ID_NOT_PRESENT = "Element id not present ";
+ private static final String NOT_VALID_ORDER =
+ "Not valid order %s; DeployState: %s; LockState: %s; SubState: %s; StateChangeResult: %s";
private static final Logger LOGGER = LoggerFactory.getLogger(AutomationCompositionInstantiationProvider.class);
@@ -472,7 +474,10 @@ public class AutomationCompositionInstantiationProvider {
break;
default:
- throw new PfModelRuntimeException(Status.BAD_REQUEST, "Not valid " + acInstanceStateUpdate);
+ var msg = String.format(NOT_VALID_ORDER, acInstanceStateUpdate,
+ automationComposition.getDeployState(), automationComposition.getLockState(),
+ automationComposition.getSubState(), automationComposition.getStateChangeResult());
+ throw new PfModelRuntimeException(Status.BAD_REQUEST, msg);
}
}
}