diff options
author | Kuleshov, Elena <evn@att.com> | 2020-07-16 11:37:11 -0400 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@att.com> | 2020-07-16 11:37:12 -0400 |
commit | c1f414d5b3592a0740c6c4e4e264a7e6ab35e12d (patch) | |
tree | 1cce525c347cec26d25bfc7e7a2899b5a2862d2f | |
parent | 86270eae84f8178ada7649e4ce431aaf8da4ab81 (diff) |
Implement mapping of requestorId to
Implement mapping of requestorId to xOnapRequestorid in request to APPC.
Issue-ID: SO-3072
Signed-off-by: Benjamin, Max (mb388a) <mb388a@att.com>
Change-Id: Ia3b157b259f1f4f94b197bd07354157d1d5d86b7
10 files changed, 49 insertions, 29 deletions
diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java index 20093be6a4..1da6fc096f 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/client/ApplicationControllerClient.java @@ -52,7 +52,6 @@ import org.onap.appc.client.lcm.model.ZULU; @Component public class ApplicationControllerClient { - @Autowired public Environment env; @@ -117,6 +116,7 @@ public class ApplicationControllerClient { controllerType = DEFAULT_CONTROLLER_TYPE; } controllerType = controllerType.toUpperCase(); + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); } catch (AppcClientException e) { @@ -128,7 +128,7 @@ public class ApplicationControllerClient { } public Status vnfCommand(Action action, String requestId, String vnfId, Optional<String> vserverId, - Optional<String> request, String controllerType, ApplicationControllerCallback listener) + Optional<String> request, String controllerType, ApplicationControllerCallback listener, String requestorId) throws ApplicationControllerOrchestratorException { this.setControllerType(controllerType); Status status; @@ -142,7 +142,7 @@ public class ApplicationControllerClient { payload = new Payload(request.get()); } - status = runCommand(action, actionIdentifiers, payload, requestId, listener); + status = runCommand(action, actionIdentifiers, payload, requestId, listener, requestorId); if (appCSupport.getCategoryOf(status).equals(StatusCategory.ERROR)) { throw new ApplicationControllerOrchestratorException(status.getMessage(), status.getCode()); } else { @@ -152,11 +152,11 @@ public class ApplicationControllerClient { public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, - org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener) - throws ApplicationControllerOrchestratorException { + org.onap.appc.client.lcm.model.Payload payload, String requestID, ApplicationControllerCallback listener, + String requestorId) throws ApplicationControllerOrchestratorException { Status status; Object requestObject; - requestObject = createRequest(action, actionIdentifiers, payload, requestID); + requestObject = createRequest(action, actionIdentifiers, payload, requestID, requestorId); appCSupport.logLCMMessage(requestObject); LifeCycleManagerStateful client = getAppCClient(); Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, true); @@ -194,12 +194,13 @@ public class ApplicationControllerClient { return properties; } - public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId) { + public Object createRequest(Action action, ActionIdentifiers identifier, Payload payload, String requestId, + String requestorId) { Object requestObject = appCSupport.getInput(action.name()); try { - CommonHeader commonHeader = buildCommonHeader(requestId); + CommonHeader commonHeader = buildCommonHeader(requestId, requestorId); requestObject.getClass().getDeclaredMethod("setCommonHeader", CommonHeader.class).invoke(requestObject, commonHeader); requestObject.getClass().getDeclaredMethod("setAction", Action.class).invoke(requestObject, action); @@ -215,12 +216,13 @@ public class ApplicationControllerClient { return requestObject; } - private CommonHeader buildCommonHeader(String requestId) { + private CommonHeader buildCommonHeader(String requestId, String requestorId) { CommonHeader commonHeader = new CommonHeader(); commonHeader.setApiVer(API_VER); commonHeader.setOriginatorId(ORIGINATOR_ID); commonHeader.setRequestId(requestId == null ? UUID.randomUUID().toString() : requestId); commonHeader.setSubRequestId(UUID.randomUUID().toString()); + commonHeader.setXOnapRequestorid(requestorId); Flags flags = new Flags(); String flagsMode = "NORMAL"; Mode mode = Mode.valueOf(flagsMode); diff --git a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java index 8e38935441..e61053d043 100644 --- a/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java +++ b/adapters/so-appc-orchestrator/src/main/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImpl.java @@ -111,7 +111,7 @@ public class ApplicationControllerTaskImpl { status = appcClient.vnfCommand(request.getAction(), msoRequestId, request.getApplicationControllerVnf().getVnfId(), vserverId, payload, request.getControllerType(), - listener); + listener, request.getRequestorId()); return status; } diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java index 82b0695ed9..cac8e9e16a 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplITTest.java @@ -63,6 +63,7 @@ public class ApplicationControllerTaskImplITTest { @Before public void setup() { request = new ApplicationControllerTaskRequest(); + request.setRequestorId("testRequestorId"); request.setBookName("testBookName"); request.setControllerType("testControllerType"); request.setFileParameters("testFileParams"); diff --git a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java index ff979acf7b..fe2b4f84b5 100644 --- a/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java +++ b/adapters/so-appc-orchestrator/src/test/java/org/onap/so/adapters/appc/orchestrator/service/ApplicationControllerTaskImplTest.java @@ -52,6 +52,7 @@ public class ApplicationControllerTaskImplTest { request.setNewSoftwareVersion("2.0"); request.setExistingSoftwareVersion("1.0"); request.setOperationsTimeout("30"); + request.setRequestorId("testRequestorId"); Map<String, String> reqConfigParams = new HashMap<>(); reqConfigParams.put("name1", "value1"); reqConfigParams.put("name2", "value2"); @@ -77,13 +78,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(Action.HealthCheck, "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @@ -99,13 +100,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -118,13 +119,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -133,13 +134,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener)).thenReturn(new Status()); + "testControllerType", listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), Optional.empty(), - "testControllerType", listener); + "testControllerType", listener, "testRequestorId"); } @Test @@ -154,13 +155,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -179,13 +180,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -204,13 +205,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -224,13 +225,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test @@ -251,13 +252,13 @@ public class ApplicationControllerTaskImplTest { Mockito.when(applicationControllerClient.vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener)).thenReturn(new Status()); + listener, "testRequestorId")).thenReturn(new Status()); Status status = applicationControllerTaskImpl.execute("testRequestId", request, listener); Mockito.verify(applicationControllerClient).vnfCommand(request.getAction(), "testRequestId", request.getApplicationControllerVnf().getVnfId(), Optional.empty(), payload, "testControllerType", - listener); + listener, "testRequestorId"); } @Test diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java index b337564dab..1f05522011 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessor.java @@ -78,6 +78,9 @@ public class AppcOrchestratorPreProcessor { String identityUrl = execution.getVariable("identityUrl"); appcTaskRequest.setIdentityUrl(identityUrl); + String requestorId = gBBInput.getRequestContext().getRequestorId(); + appcTaskRequest.setRequestorId(requestorId); + if (gBBInput.getRequestContext().getRequestParameters() != null) { String payload = gBBInput.getRequestContext().getRequestParameters().getPayload(); if (payload == null) { diff --git a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java index 38c74eecc7..d7d6da209e 100644 --- a/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java +++ b/bpmn/so-bpmn-tasks/src/test/java/org/onap/so/bpmn/infrastructure/appc/tasks/AppcOrchestratorPreProcessorTest.java @@ -149,6 +149,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { private void fillRequiredAppcExecutionFields() { RequestContext context = new RequestContext(); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); @@ -192,6 +193,7 @@ public class AppcOrchestratorPreProcessorTest extends BaseTaskTest { "{\"request_parameters\":{\"host_ip_address\":\"10.10.10.10\"},\"configuration_parameters\":{\"name1\":\"value1\",\"name2\":\"value2\"}}"); context.setRequestParameters(requestParameters); context.setMsoRequestId("TEST-MSO-ID"); + context.setRequestorId("testRequestorId"); execution.setVariable("aicIdentity", "AIC-TEST"); execution.setVariable("vmIdList", "VM-ID-LIST-TEST"); execution.setVariable("vserverIdList", "VSERVER-ID-LIST"); diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json index 957c603dc9..191e0ac40e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequest.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "TEST-CONTROLLER-NAME", "action": "Lock", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json index 040c680d1c..724f096a4e 100644 --- a/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json +++ b/bpmn/so-bpmn-tasks/src/test/resources/__files/BuildingBlocks/appcTaskRequestConfigModify.json @@ -2,6 +2,7 @@ "ApplicationControllerTaskRequest": { "controllerType": "APPC", "action": "ConfigModify", + "requestorId": "testRequestorId", "identityUrl": "IDENTITY-URL-TEST", "applicationControllerVnf": { "vnfId": "TEST-VNF-ID", diff --git a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java index c240957ae9..010e184618 100644 --- a/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java +++ b/common/src/main/java/org/onap/so/appc/orchestrator/service/beans/ApplicationControllerTaskRequest.java @@ -11,6 +11,7 @@ public class ApplicationControllerTaskRequest implements Serializable { private static final long serialVersionUID = -3150320542857627682L; private Action action; + private String requestorId; private String controllerType; private String identityUrl; private String operationsTimeout; @@ -110,6 +111,14 @@ public class ApplicationControllerTaskRequest implements Serializable { this.newSoftwareVersion = newSoftwareVersion; } + public String getRequestorId() { + return requestorId; + } + + public void setRequestorId(String requestorId) { + this.requestorId = requestorId; + } + } @@ -74,7 +74,7 @@ <format.skipValidate>false</format.skipValidate> <format.skipExecute>true</format.skipExecute> <io.fabric8.version>0.33.0</io.fabric8.version> - <appc.client.version>1.7.1</appc.client.version> + <appc.client.version>1.8.0-SNAPSHOT</appc.client.version> <bowman.client.version>0.8.0</bowman.client.version> <aaf.cadi.version>2.1.15</aaf.cadi.version> </properties> |