aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvidhyasree <sn141y@att.com>2018-02-21 11:19:33 -0500
committerPatrick Brady <pb071s@att.com>2018-02-22 18:04:35 +0000
commit6cf060d13e4a06894db3050ed23e4e7667fb021f (patch)
tree078a7e8980cf73c23402f0637a93ab6ae2d90c1c
parent446bae37c2f6dabe842cb2b6585a17bcec327a17 (diff)
Task to add ConfigScaleOut to LCM API, Yang Model.
A new action ConfigScaleOut is added to LCM API and Yang model. Removed old action item configscaleout supporting VM action level which is no longer needed. Issue-ID: APPC-479 Change-Id: Ie5452f4d5625fc3be6b66c0f403d12baa64fa096 Signed-off-by: vidhyasree <sn141y@att.com>
-rw-r--r--appc-client/client-kit/src/test/java/org/onap/appc/client/lcm/model/TestModelPOJO.java4
-rw-r--r--appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/onap/appc/domainmodel/lcm/VNFOperation.java2
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/conv/Converter.java10
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java34
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java106
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java37
-rw-r--r--appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang44
7 files changed, 141 insertions, 96 deletions
diff --git a/appc-client/client-kit/src/test/java/org/onap/appc/client/lcm/model/TestModelPOJO.java b/appc-client/client-kit/src/test/java/org/onap/appc/client/lcm/model/TestModelPOJO.java
index a58b3e7ab..424dfdc59 100644
--- a/appc-client/client-kit/src/test/java/org/onap/appc/client/lcm/model/TestModelPOJO.java
+++ b/appc-client/client-kit/src/test/java/org/onap/appc/client/lcm/model/TestModelPOJO.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
@@ -51,8 +51,6 @@ public class TestModelPOJO {
pojoClassName.add(ConfigModifyOutput.class);
pojoClassName.add(ConfigRestoreInput.class);
pojoClassName.add(ConfigRestoreOutput.class);
- pojoClassName.add(ConfigScaleoutInput.class);
- pojoClassName.add(ConfigScaleoutOutput.class);
pojoClassName.add(ConfigureInput.class);
pojoClassName.add(ConfigureOutput.class);
pojoClassName.add(EvacuateInput.class);
diff --git a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/onap/appc/domainmodel/lcm/VNFOperation.java b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/onap/appc/domainmodel/lcm/VNFOperation.java
index 77ebe43b6..0e5dbb10a 100644
--- a/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/onap/appc/domainmodel/lcm/VNFOperation.java
+++ b/appc-dispatcher/appc-dispatcher-common/domain-model-lib/src/main/java/org/onap/appc/domainmodel/lcm/VNFOperation.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/conv/Converter.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/conv/Converter.java
index f169a7359..68352c1b1 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/conv/Converter.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/onap/appc/requesthandler/conv/Converter.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
@@ -125,10 +125,10 @@ public class Converter {
((ConfigModifyOutputBuilder)outObj).setPayload(payload);
return outObj;
case ConfigScaleOut:
- outObj = new ConfigScaleoutOutputBuilder();
- ((ConfigScaleoutOutputBuilder)outObj).setCommonHeader(commonHeader);
- ((ConfigScaleoutOutputBuilder)outObj).setStatus(status);
- ((ConfigScaleoutOutputBuilder)outObj).setPayload(payload);
+ outObj = new ConfigScaleOutOutputBuilder();
+ ((ConfigScaleOutOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigScaleOutOutputBuilder)outObj).setStatus(status);
+ ((ConfigScaleOutOutputBuilder)outObj).setPayload(payload);
return outObj;
case ConfigRestore:
outObj = new ConfigRestoreOutputBuilder();
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java
index 7901c6d83..a66aaaa7c 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/AppcProviderLcm.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
@@ -43,6 +43,7 @@ import org.onap.appc.provider.lcm.service.RequestExecutor;
import org.onap.appc.provider.lcm.service.ResumeTrafficService;
import org.onap.appc.provider.lcm.service.UpgradeService;
import org.onap.appc.provider.lcm.service.VolumeService;
+import org.onap.appc.provider.lcm.service.ConfigScaleOutService;
import org.onap.appc.provider.lcm.util.RequestInputBuilder;
import org.onap.appc.provider.lcm.util.ValidationService;
import org.onap.appc.requesthandler.objects.RequestHandlerInput;
@@ -643,35 +644,10 @@ public class AppcProviderLcm extends AbstractBaseUtils implements AutoCloseable,
}
@Override
- public Future<RpcResult<ConfigScaleoutOutput>> configScaleout(ConfigScaleoutInput input) {
+ public Future<RpcResult<ConfigScaleOutOutput>> configScaleOut(ConfigScaleOutInput input) {
logger.debug("Input received : " + input.toString());
- ConfigScaleoutOutputBuilder outputBuilder = new ConfigScaleoutOutputBuilder();
- Action myAction = Action.ConfigScaleOut;
- String action = myAction.toString();
- String rpcName = getRpcName(myAction);
- Status status =
- ValidationService.getInstance().validateInput(input.getCommonHeader(), input.getAction(), action);
- if (null == status) {
- try {
- RequestHandlerInput request = new RequestInputBuilder().requestContext()
- .commonHeader(input.getCommonHeader()).actionIdentifiers(input.getActionIdentifiers())
- .payload(input.getPayload()).action(action).rpcName(rpcName).build();
- status = buildStatusWithDispatcherOutput(executeRequest(request));
- logger.info(String.format("Execute of '%s' finished with status %s. Reason: %s",
- input.getActionIdentifiers(), status.getCode(), status.getMessage()));
- } catch (ParseException e) {
- status = buildStatusWithParseException(e);
-
- LoggingUtils.logErrorMessage(LoggingConstants.TargetNames.APPC_PROVIDER,
- String.format(COMMON_ERROR_MESSAGE_TEMPLATE, action, e.getMessage()),
- this.getClass().getName());
-
- }
- }
- outputBuilder.setCommonHeader(input.getCommonHeader());
- outputBuilder.setStatus(status);
- RpcResult<ConfigScaleoutOutput> result =
- RpcResultBuilder.<ConfigScaleoutOutput>status(true).withResult(outputBuilder.build()).build();
+ ConfigScaleOutOutputBuilder outputBuilder = new ConfigScaleOutService().process(input);
+ RpcResult<ConfigScaleOutOutput> result = RpcResultBuilder.<ConfigScaleOutOutput> status(true).withResult(outputBuilder.build()).build();
return Futures.immediateFuture(result);
}
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java
new file mode 100644
index 000000000..a61abf326
--- /dev/null
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java
@@ -0,0 +1,106 @@
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * =============================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.provider.lcm.service;
+
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Action;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleOutInput;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleOutOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.Payload;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
+import org.onap.appc.executor.objects.LCMCommandStatus;
+import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import org.onap.appc.util.JsonUtil;
+
+import java.io.IOException;
+import java.util.Map;
+
+public class ConfigScaleOutService extends AbstractBaseService {
+ /**
+ * Constructor
+ *
+ */
+ public ConfigScaleOutService() {
+ super(Action.ConfigScaleOut);
+ logger.debug("ConfigScaleOutService starts");
+ }
+ public ConfigScaleOutOutputBuilder process(ConfigScaleOutInput input) {
+ CommonHeader commonHeader = input.getCommonHeader();
+ ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
+ Payload payload = input.getPayload();
+
+ validate(commonHeader, input.getAction(), actionIdentifiers, payload);
+ if (status == null) {
+ proceedAction(commonHeader,actionIdentifiers,payload);
+ }
+
+ ConfigScaleOutOutputBuilder outputBuilder = new ConfigScaleOutOutputBuilder();
+ outputBuilder.setStatus(status);
+ outputBuilder.setCommonHeader(input.getCommonHeader());
+ return outputBuilder;
+ }
+
+
+ void validate(CommonHeader commonHeader,
+ Action action,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ status = validateVnfId(commonHeader, action, actionIdentifiers);
+ if (status != null) {
+ return;
+ }
+
+ // validate payload
+ String keyName = "payload";
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+ String payloadString = payload.getValue();
+ status = validateMustHaveParamValue(
+ payloadString == null ? payloadString : payloadString.trim(), "payload");
+ if (status != null) {
+ return;
+ }
+
+ try {
+ Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
+ validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ } catch (IOException e) {
+ logger.error(String.format("ConfigScaleOutService (%s) got IOException when converting payload", rpcName), e);
+ status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
+ }
+ }
+
+ void proceedAction(CommonHeader commonHeader,
+ ActionIdentifiers actionIdentifiers,
+ Payload payload) {
+ RequestHandlerInput requestHandlerInput =
+ getRequestHandlerInput(commonHeader, actionIdentifiers, payload, this.getClass().getName());
+ if (requestHandlerInput != null) {
+ executeAction(requestHandlerInput);
+ }
+ }
+}
+
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
index 064f5679f..1d0594837 100644
--- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/AppcProviderLcmTest.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
@@ -53,8 +53,6 @@ import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigModifyInpu
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigModifyOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigRestoreInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigRestoreOutput;
-import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleoutInput;
-import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigScaleoutOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigureInput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.ConfigureOutput;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.DetachVolumeInput;
@@ -596,39 +594,6 @@ public class AppcProviderLcmTest extends AbstractDataBrokerTest {
}
@Test
- public void testConfigScaleout() throws Exception {
- // Validation success
- doReturn("Success").when(successlcmStatus).getMessage();
- doReturn(responseContext).when(requestHandlerOutput).getResponseContext();
- doReturn(requestHandlerOutput).when(appcProviderLcm).executeRequest(any());
- doReturn(null).when(validationService).validateInput(any(), any(), any());
-
- ConfigScaleoutInput configScaleoutInput = mock(ConfigScaleoutInput.class);
- doReturn(newCommonHeader("request-id-test")).when(configScaleoutInput).getCommonHeader();
- doReturn(newActionIdentifier("vnf-id", "vnfc-id", "vserver-id"))
- .when(configScaleoutInput).getActionIdentifiers();
-
- Future<RpcResult<ConfigScaleoutOutput>> results = appcProviderLcm.configScaleout(configScaleoutInput);
- Assert.assertTrue(400 == results.get().getResult().getStatus().getCode());
- Assert.assertEquals("Success", results.get().getResult().getStatus().getMessage());
- verify(appcProviderLcm, times(1)).executeRequest(any());
-
- // Validation failed
- doReturn(failStatus).when(validationService).validateInput(any(), any(), any());
- results = appcProviderLcm.configScaleout(configScaleoutInput);
- Assert.assertEquals(failStatus, results.get().getResult().getStatus());
- verify(appcProviderLcm, times(1)).executeRequest(any());
-
- // parse exception
- doReturn(null).when(validationService).validateInput(any(), any(), any());
- doReturn(null).when(configScaleoutInput).getActionIdentifiers();
- results = appcProviderLcm.configScaleout(configScaleoutInput);
- Assert.assertTrue(LCMCommandStatus.REQUEST_PARSING_FAILED.getResponseCode()
- == results.get().getResult().getStatus().getCode());
- verify(appcProviderLcm, times(1)).executeRequest(any());
- }
-
- @Test
public void testConfigRestore() throws Exception {
// Validation success
doReturn("Success").when(successlcmStatus).getMessage();
diff --git a/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang b/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang
index 7c6df09f2..5ff992a08 100644
--- a/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang
+++ b/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP : APPC
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Copyright (C) 2017 Amdocs
* =============================================================================
@@ -774,30 +774,30 @@ module appc-provider-lcm {
}
}
- rpc config-scaleout {
- description "An operation to scaleout the configurations of a virtual network
- function (or VM)";
- input {
- uses common-header;
- leaf action {
- type action;
- mandatory true;
- }
- uses action-identifiers;
- leaf payload {
- type payload;
- mandatory false;
+ rpc config-scale-out {
+ description "An operation to Modify the configuration or other action to support
+ a ConfigScaleOut of a VNF.";
+ input {
+ uses common-header;
+ leaf action {
+ type action;
+ mandatory true;
+ }
+ uses action-identifiers;
+ leaf payload {
+ type payload;
+ mandatory false;
+ }
}
- }
- output {
- uses common-header;
- uses status;
- leaf payload {
- type payload;
- mandatory false;
+ output {
+ uses common-header;
+ uses status;
+ leaf payload {
+ type payload;
+ mandatory false;
+ }
}
}
- }
rpc config-restore {
description "An operation to restore the configurations of a virtual network