summaryrefslogtreecommitdiffstats
path: root/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java
diff options
context:
space:
mode:
authormojahidi <mojahidul.islam@amdocs.com>2017-09-12 18:53:34 +0530
committerPatrick Brady <pb071s@att.com>2017-09-13 07:17:03 +0000
commit17a1e0e30e3a35ed4ad2ef91960bb58799b208b3 (patch)
tree3bcdc2a640c4668fc0d3a2a744ae1be9f3db5a65 /appc-sequence-generator/appc-sequence-generator-bundle/src/main/java
parentf0852a8174e38cc0c203a21a59af98e6c3889d5f (diff)
validate mandatry vnfc vm info is absent in invent
when the vnfc SMP is mandatory in the dependency-info block but its corresponding vm details/info is not present in the inventory info validation error should be thrown Issue-ID:APPC-204 Change-Id: I606da8ce086423cf3f23c87ab0166bfb9935875b Signed-off-by: mojahidi <mojahidul.islam@amdocs.com>
Diffstat (limited to 'appc-sequence-generator/appc-sequence-generator-bundle/src/main/java')
-rw-r--r--appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java146
-rw-r--r--appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java2
2 files changed, 66 insertions, 82 deletions
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java
index acdeddd30..73e1b843f 100644
--- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java
+++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StartSequenceGenerator.java
@@ -101,93 +101,77 @@ public class StartSequenceGenerator implements SequenceGenerator {
for (Vnfc vnfc : vnfcs) {
List<Vserver> vms = vnfc.getVserverList();
List<Integer> transactionIds = new LinkedList<>();
- transactionId = updateTransactions(input, transactionList, transactionId, vms, transactionIds);
+ if(!vms.isEmpty()) {
+ for (Vserver vm : vms) {
+ Transaction transaction = new Transaction();
+ transaction.setTransactionId(transactionId);
+ transactionIds.add(transactionId++);
+ transaction.setAction(Action.START.getActionType());
+ transaction.setActionLevel(ActionLevel.VM.getAction());
+ ActionIdentifier actionIdentifier = new ActionIdentifier();
+ actionIdentifier.setvServerId(vm.getId());
+ transaction.setActionIdentifier(actionIdentifier);
+ transaction.setPayload(input.getRequestInfo().getPayload());
+ updateResponse(transaction);
+ transactionList.add(transaction);
+ }
+ boolean startApplicationSupported = readApplicationStartCapability(input);
+ if (startApplicationSupported) {
+ Transaction startAppTransaction = new Transaction();
+ startAppTransaction.setTransactionId(transactionId++);
+ startAppTransaction.setAction(Action.START_APPLICATION.getActionType());
+ startAppTransaction.setActionLevel(ActionLevel.VNFC.getAction());
+ ActionIdentifier startActionIdentifier = new ActionIdentifier();
+ startActionIdentifier.setVnfcName(vnfc.getVnfcName());
+ startAppTransaction.setActionIdentifier(startActionIdentifier);
+ startAppTransaction.setPayload(input.getRequestInfo().getPayload());
- boolean startApplicationSupported = readApplicationStartCapability(input);
- transactionId = checkAndUpdateStartApplication(input, transactionList, transactionId, vnfc, transactionIds, startApplicationSupported);
+ List<PreCheckOption> preCheckOptions = new LinkedList<>();
+ for (Integer vmTransactionId : transactionIds) {
+ setPreCheckOptions(preCheckOptions, vmTransactionId);
+ }
+ startAppTransaction.setPreCheckOperator(PreCheckOperator.ANY.getOperator());
+ startAppTransaction.setPrecheckOptions(preCheckOptions);
+ transactionList.add(startAppTransaction);
+ }
+ boolean healthCheckSupported = readHealthCheckCapabilites(input.getCapability());
+ if (healthCheckSupported) {
+ Transaction healthCheckTransaction = new Transaction();
+ healthCheckTransaction.setTransactionId(transactionId++);
+ healthCheckTransaction.setAction(Action.HEALTH_CHECK.getActionType());
+ healthCheckTransaction.setActionLevel(ActionLevel.VNFC.getAction());
+ ActionIdentifier healthCheckActionIdentifier = new ActionIdentifier();
+ healthCheckActionIdentifier.setVnfcName(vnfc.getVnfcName());
+ healthCheckTransaction.setActionIdentifier(healthCheckActionIdentifier);
+ healthCheckTransaction.setPayload(input.getRequestInfo().getPayload());
- boolean healthCheckSupported = readHealthCheckCapabilites(input.getCapability());
- transactionId = checkAndUpdateHealthCheck(input, waitTime, retryCount, transactionList, transactionId, vnfc, healthCheckSupported);
- }
- }
- return transactionList;
- }
-
- private Integer checkAndUpdateHealthCheck(SequenceGeneratorInput input, Integer waitTime, Integer retryCount, List<Transaction> transactionList, Integer transactionId, Vnfc vnfc, boolean healthCheckSupported) {
- if (healthCheckSupported) {
- Transaction healthCheckTransaction = new Transaction();
- healthCheckTransaction.setTransactionId(transactionId++);
- healthCheckTransaction.setAction(Action.HEALTH_CHECK.getActionType());
- healthCheckTransaction.setActionLevel(ActionLevel.VNFC.getAction());
- ActionIdentifier healthCheckActionIdentifier = new ActionIdentifier();
- healthCheckActionIdentifier.setVnfcName(vnfc.getVnfcName());
- healthCheckTransaction.setActionIdentifier(healthCheckActionIdentifier);
- healthCheckTransaction.setPayload(input.getRequestInfo().getPayload());
-
- Response retryResponse = new Response();
- retryResponse.setResponseMessage(ResponseMessage.UNHEALTHY.getResponse());
- Map<String, String> retryAction = new HashMap<>();
- retryAction.put(ResponseAction.RETRY.getAction(), retryCount.toString());
- retryAction.put(ResponseAction.WAIT.getAction(), waitTime.toString());
- retryResponse.setResponseAction(retryAction);
- healthCheckTransaction.addResponse(retryResponse);
-
- Response healthyResponse = new Response();
- healthyResponse.setResponseMessage(ResponseMessage.HEALTHY.getResponse());
- Map<String, String> healthyAction = new HashMap<>();
- healthyAction.put(ResponseAction.CONTINUE.getAction().toLowerCase(), Boolean.TRUE.toString());
- healthyResponse.setResponseAction(healthyAction);
- healthCheckTransaction.addResponse(healthyResponse);
-
- Response failureResponse = new Response();
- failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse());
- Map<String, String> failureResonseAction = new HashMap<>();
- failureResonseAction.put(ResponseAction.STOP.getAction(), Boolean.TRUE.toString());
- failureResponse.setResponseAction(failureResonseAction);
- healthCheckTransaction.addResponse(failureResponse);
- transactionList.add(healthCheckTransaction);
- }
- return transactionId;
- }
+ Response retryResponse = new Response();
+ retryResponse.setResponseMessage(ResponseMessage.UNHEALTHY.getResponse());
+ Map<String, String> retryAction = new HashMap<>();
+ retryAction.put(ResponseAction.RETRY.getAction(), retryCount.toString());
+ retryAction.put(ResponseAction.WAIT.getAction(), waitTime.toString());
+ retryResponse.setResponseAction(retryAction);
+ healthCheckTransaction.addResponse(retryResponse);
- private Integer checkAndUpdateStartApplication(SequenceGeneratorInput input, List<Transaction> transactionList, Integer transactionId, Vnfc vnfc, List<Integer> transactionIds, boolean startApplicationSupported) {
- if (startApplicationSupported) {
- Transaction startAppTransaction = new Transaction();
- startAppTransaction.setTransactionId(transactionId++);
- startAppTransaction.setAction(Action.START_APPLICATION.getActionType());
- startAppTransaction.setActionLevel(ActionLevel.VNFC.getAction());
- ActionIdentifier startActionIdentifier = new ActionIdentifier();
- startActionIdentifier.setVnfcName(vnfc.getVnfcName());
- startAppTransaction.setActionIdentifier(startActionIdentifier);
- startAppTransaction.setPayload(input.getRequestInfo().getPayload());
+ Response healthyResponse = new Response();
+ healthyResponse.setResponseMessage(ResponseMessage.HEALTHY.getResponse());
+ Map<String, String> healthyAction = new HashMap<>();
+ healthyAction.put(ResponseAction.CONTINUE.getAction().toLowerCase(), Boolean.TRUE.toString());
+ healthyResponse.setResponseAction(healthyAction);
+ healthCheckTransaction.addResponse(healthyResponse);
- List<PreCheckOption> preCheckOptions = new LinkedList<>();
- for (Integer vmTransactionId : transactionIds) {
- setPreCheckOptions(preCheckOptions, vmTransactionId);
+ Response failureResponse = new Response();
+ failureResponse.setResponseMessage(ResponseMessage.FAILURE.getResponse());
+ Map<String, String> failureResonseAction = new HashMap<>();
+ failureResonseAction.put(ResponseAction.STOP.getAction(), Boolean.TRUE.toString());
+ failureResponse.setResponseAction(failureResonseAction);
+ healthCheckTransaction.addResponse(failureResponse);
+ transactionList.add(healthCheckTransaction);
+ }
+ }
}
- startAppTransaction.setPreCheckOperator(PreCheckOperator.ANY.getOperator());
- startAppTransaction.setPrecheckOptions(preCheckOptions);
- transactionList.add(startAppTransaction);
- }
- return transactionId;
- }
-
- private Integer updateTransactions(SequenceGeneratorInput input, List<Transaction> transactionList, Integer transactionId, List<Vserver> vms, List<Integer> transactionIds) {
- for (Vserver vm : vms) {
- Transaction transaction = new Transaction();
- transaction.setTransactionId(transactionId);
- transactionIds.add(transactionId++);
- transaction.setAction(Action.START.getActionType());
- transaction.setActionLevel(ActionLevel.VM.getAction());
- ActionIdentifier actionIdentifier = new ActionIdentifier();
- actionIdentifier.setvServerId(vm.getId());
- transaction.setActionIdentifier(actionIdentifier);
- transaction.setPayload(input.getRequestInfo().getPayload());
-
- updateResponse(transaction);
- transactionList.add(transaction);
}
- return transactionId;
+ return transactionList;
}
private void setPreCheckOptions(List<PreCheckOption> preCheckOptions, Integer vmTransactionId) {
diff --git a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java
index 6dec0e61f..51edb99bf 100644
--- a/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java
+++ b/appc-sequence-generator/appc-sequence-generator-bundle/src/main/java/org/openecomp/appc/seqgen/impl/StopSequenceGenerator.java
@@ -113,7 +113,7 @@ public class StopSequenceGenerator implements SequenceGenerator {
List<Vnfc> vnfcs = itr.next();
for(Vnfc vnfc:vnfcs){
boolean stopApplicationSupported = readApplicationStopCapability(input);
- if(stopApplicationSupported){
+ if(stopApplicationSupported && !vnfc.getVserverList().isEmpty()){
Transaction stopAppTransaction = new Transaction();
stopAppTransaction.setTransactionId(transactionId++);
stopAppTransaction.setAction(Action.STOP_APPLICATION.getActionType());