From 19efd68c8f8babdaf8a2eb7f78b4522940339da2 Mon Sep 17 00:00:00 2001 From: Elena Kuleshov Date: Wed, 28 Mar 2018 11:25:31 -0400 Subject: ControllerType update for CM flows Change-Id: I42c60ba45baaf29fa5fe54a8bb7ffc0aab5622c7 Signed-off-by: Elena Kuleshov Issue-ID: SO-526 --- .../mso/bpmn/common/scripts/AppCClient.groovy | 7 +++- .../client/appc/ApplicationControllerAction.java | 47 +++++++++++----------- .../client/appc/ApplicationControllerClient.java | 18 +++++---- .../appc/ApplicationControllerOrchestrator.java | 4 +- .../appc/ApplicationControllerClientTest.java | 11 ++--- .../ApplicationControllerOrchestratorTest.java | 4 +- 6 files changed, 49 insertions(+), 42 deletions(-) (limited to 'bpmn/MSOCommonBPMN') diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy index 8df6af7adb..ca7eef8aa1 100644 --- a/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy +++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/openecomp/mso/bpmn/common/scripts/AppCClient.groovy @@ -27,6 +27,8 @@ import java.util.UUID; * @param - vnfId * @param - action * @param - payload + * @param - vnfName + * @param - controllerType * * Outputs: * @param - errorcode @@ -72,7 +74,8 @@ public class AppCClient extends AbstractServiceTaskProcessor{ String vnfHostIpAddress = execution.getVariable('vnfHostIpAddress') String vmIdList = execution.getVariable("vmIdList") String identityUrl = execution.getVariable("identityUrl") - HashMap payloadInfo = new HashMap(); + String controllerType = execution.getVariable("controllerType") + HashMap payloadInfo = new HashMap(); payloadInfo.put("vnfName", vnfName) payloadInfo.put("aicIdentity", aicIdentity) payloadInfo.put("vnfHostIpAddress", vnfHostIpAddress) @@ -96,7 +99,7 @@ public class AppCClient extends AbstractServiceTaskProcessor{ ApplicationControllerAction client = new ApplicationControllerAction() utils.log("DEBUG", "Created Application Controller Action Object", isDebugLogEnabled) //PayloadInfo contains extra information that adds on to payload before making request to appc - client.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo) + client.runAppCCommand(action, msoRequestId, vnfId, payload, payloadInfo, controllerType) utils.log("DEBUG", "ran through the main method for Application Contoller", isDebugLogEnabled) appcCode = client.getErrorCode() appcMessage = client.getErrorMessage() diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java index 8b870889ac..44da566ec7 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerAction.java @@ -46,8 +46,7 @@ public class ApplicationControllerAction { private String errorMessage = "Unable to reach App C Servers"; protected final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger(); - public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional payload, HashMap payloadInfo){ - Status appCStatus = null; + public void runAppCCommand(Action action, String msoRequestId, String vnfId, Optional payload, HashMap payloadInfo, String controllerType){ Status appCStatus = null; try{ String vnfName = payloadInfo.getOrDefault("vnfName", ""); String aicIdentity = payloadInfo.getOrDefault("vnfName",""); @@ -56,21 +55,21 @@ public class ApplicationControllerAction { String identityUrl = payloadInfo.getOrDefault("identityUrl", ""); switch(action){ case ResumeTraffic: - appCStatus = resumeTrafficAction(msoRequestId, vnfId, vnfName); + appCStatus = resumeTrafficAction(msoRequestId, vnfId, vnfName, controllerType); break; case Start: case Stop: - appCStatus = startStopAction(action, msoRequestId, vnfId, aicIdentity); + appCStatus = startStopAction(action, msoRequestId, vnfId, aicIdentity, controllerType); break; case Unlock: case Lock: - appCStatus = client.vnfCommand(action, msoRequestId, vnfId, Optional.empty()); + appCStatus = client.vnfCommand(action, msoRequestId, vnfId, Optional.empty(), controllerType); break; case QuiesceTraffic: - appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName); + appCStatus = quiesceTrafficAction(msoRequestId, vnfId, payload, vnfName, controllerType); break; case HealthCheck: - appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress); + appCStatus = healthCheckAction(msoRequestId, vnfId, vnfName, vnfHostIpAddress, controllerType); break; case Snapshot: String vmIds = JsonUtils.getJsonValue(vmIdList, "vmIds"); @@ -80,18 +79,18 @@ public class ApplicationControllerAction { int i = 0; while(i < vmIdJsonList.size()){ vmId = vmIdJsonList.get(i); - appCStatus = snapshotAction(msoRequestId, vnfId, vmId, identityUrl); + appCStatus = snapshotAction(msoRequestId, vnfId, vmId, identityUrl, controllerType); i++; } break; case ConfigModify: - appCStatus = payloadAction(action, msoRequestId, vnfId, payload); + appCStatus = payloadAction(action, msoRequestId, vnfId, payload, controllerType); break; case UpgradePreCheck: case UpgradePostCheck: case UpgradeSoftware: case UpgradeBackup: - appCStatus = upgradeAction(action,msoRequestId, vnfId, payload, vnfName); + appCStatus = upgradeAction(action,msoRequestId, vnfId, payload, vnfName, controllerType); break; default: errorMessage = "Unable to idenify Action request for AppCClient"; @@ -125,47 +124,47 @@ public class ApplicationControllerAction { } } - private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional payload) throws JsonProcessingException, Exception{ + private Status payloadAction(Action action, String msoRequestId, String vnfId, Optional payload, String controllerType) throws JsonProcessingException, Exception{ if(!(payload.isPresent())){ throw new IllegalArgumentException("Payload is not present for " + action.toString()); } - return client.vnfCommand(action, msoRequestId, vnfId, payload); + return client.vnfCommand(action, msoRequestId, vnfId, payload, controllerType); } - private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional payload, String vnfName) throws JsonProcessingException, Exception{ + private Status quiesceTrafficAction(String msoRequestId, String vnfId, Optional payload, String vnfName, String controllerType) throws JsonProcessingException, Exception{ if(!(payload.isPresent())){ throw new IllegalArgumentException("Payload is not present for " + Action.QuiesceTraffic.toString()); } payload = PayloadClient.quiesceTrafficFormat(payload, vnfName); - return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, payload); + return client.vnfCommand(Action.QuiesceTraffic, msoRequestId, vnfId, payload, controllerType); } - private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional payload, String vnfName) throws JsonProcessingException, Exception{ + private Status upgradeAction(Action action, String msoRequestId, String vnfId, Optional payload, String vnfName, String controllerType) throws JsonProcessingException, Exception{ if(!(payload.isPresent())){ throw new IllegalArgumentException("Payload is not present for " + action.toString()); } payload = PayloadClient.upgradeFormat(payload, vnfName); - return client.vnfCommand(action, msoRequestId, vnfId, payload); + return client.vnfCommand(action, msoRequestId, vnfId, payload, controllerType); } - private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName)throws JsonProcessingException, Exception{ + private Status resumeTrafficAction(String msoRequestId, String vnfId, String vnfName, String controllerType)throws JsonProcessingException, Exception{ Optional payload = PayloadClient.resumeTrafficFormat(vnfName); - return client.vnfCommand(Action.ResumeTraffic, msoRequestId, vnfId, payload); + return client.vnfCommand(Action.ResumeTraffic, msoRequestId, vnfId, payload, controllerType); } - private Status startStopAction(Action action, String msoRequestId, String vnfId, String aicIdentity)throws JsonProcessingException, Exception{ + private Status startStopAction(Action action, String msoRequestId, String vnfId, String aicIdentity, String controllerType)throws JsonProcessingException, Exception{ Optional payload = PayloadClient.startStopFormat(aicIdentity); - return client.vnfCommand(action, msoRequestId, vnfId, payload); + return client.vnfCommand(action, msoRequestId, vnfId, payload, controllerType); } - private Status healthCheckAction(String msoRequestId, String vnfId, String vnfName, String vnfHostIpAddress)throws JsonProcessingException, Exception{ + private Status healthCheckAction(String msoRequestId, String vnfId, String vnfName, String vnfHostIpAddress, String controllerType)throws JsonProcessingException, Exception{ Optional payload = PayloadClient.healthCheckFormat(vnfName, vnfHostIpAddress); - return client.vnfCommand(Action.HealthCheck, msoRequestId, vnfId, payload); + return client.vnfCommand(Action.HealthCheck, msoRequestId, vnfId, payload, controllerType); } - private Status snapshotAction(String msoRequestId, String vnfId, String vmId, String identityUrl) throws JsonProcessingException, Exception{ + private Status snapshotAction(String msoRequestId, String vnfId, String vmId, String identityUrl, String controllerType) throws JsonProcessingException, Exception{ Optional payload = PayloadClient.snapshotFormat(vmId, identityUrl); - return client.vnfCommand(Action.Snapshot, msoRequestId, vnfId, payload); + return client.vnfCommand(Action.Snapshot, msoRequestId, vnfId, payload, controllerType); } public String getErrorMessage(){ diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java index c383408488..8c57b9255c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerClient.java @@ -60,11 +60,11 @@ public class ApplicationControllerClient { @Autowired public ApplicationControllerSupport appCSupport; - private static LifeCycleManagerStateful client; + private static LifeCycleManagerStateful client; - public ApplicationControllerClient() { + public ApplicationControllerClient(String controllerType) { appCSupport = new ApplicationControllerSupport(); - client = this.getAppCClient(); + client = this.getAppCClient(controllerType); } public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, org.onap.appc.client.lcm.model.Payload payload, String requestID) @@ -81,27 +81,31 @@ public class ApplicationControllerClient { } } - public LifeCycleManagerStateful getAppCClient() { + public LifeCycleManagerStateful getAppCClient(String controllerType) { if (client == null) try { client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) - .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties()); + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); } catch (AppcClientException e) { auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage()); } return client; } - protected Properties getLCMProperties() { + protected Properties getLCMProperties(String controllerType) { Properties properties = new Properties(); Map globalProperties = PropertyConfiguration.getInstance() .getProperties("mso.bpmn.urn.properties"); - + String controllerTypeValue = controllerType; + if (controllerType == null) { + controllerTypeValue = ""; + } properties.put("topic.read", globalProperties.get("appc.topic.read")); properties.put("topic.read.timeout", globalProperties.get("appc.topic.read.timeout")); properties.put("client.response.timeout", globalProperties.get("appc.client.response.timeout")); properties.put("topic.write", globalProperties.get("appc.topic.write")); properties.put("poolMembers", globalProperties.get("appc.poolMembers")); + properties.put("client.controllerType", controllerTypeValue); properties.put("client.key", globalProperties.get("appc.client.key")); properties.put("client.secret", globalProperties.get("appc.client.secret")); properties.put("client.name", CLIENT_NAME); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java index 217525e56a..744be5f28f 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestrator.java @@ -31,8 +31,8 @@ import org.onap.appc.client.lcm.model.Status; public class ApplicationControllerOrchestrator { - public Status vnfCommand(Action action, String requestId, String vnfId, Optional request) throws ApplicationControllerOrchestratorException { - ApplicationControllerClient client = new ApplicationControllerClient(); + public Status vnfCommand(Action action, String requestId, String vnfId, Optional request, String controllerType) throws ApplicationControllerOrchestratorException { + ApplicationControllerClient client = new ApplicationControllerClient(controllerType); Status status; ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); actionIdentifiers.setVnfId(vnfId); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java index 7fe32880c6..e737f5da16 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerClientTest.java @@ -43,7 +43,7 @@ public class ApplicationControllerClientTest { @Test public void createRequest_CheckLock_RequestBuilt() { - ApplicationControllerClient client = new ApplicationControllerClient(); + ApplicationControllerClient client = new ApplicationControllerClient("appc"); ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); actionIdentifiers.setVnfId("vnfId"); CheckLockInput checkLockInput = (CheckLockInput) client.createRequest(Action.CheckLock, actionIdentifiers, null, @@ -54,7 +54,7 @@ public class ApplicationControllerClientTest { @Test @Ignore // 1802 merge public void runCommand_liveAppc() { - ApplicationControllerClient client = new ApplicationControllerClient(); + ApplicationControllerClient client = new ApplicationControllerClient("appc"); ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); //actionIdentifiers.setVnfId("ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f"); actionIdentifiers.setVnfId("2d2bf10e-81a5-"); @@ -72,7 +72,7 @@ public class ApplicationControllerClientTest { @Test @Ignore // 1802 merge public void runCommand_CheckLock_RequestBuilt() { - ApplicationControllerClient client = new ApplicationControllerClient(); + ApplicationControllerClient client = new ApplicationControllerClient("appc"); ActionIdentifiers actionIdentifiers = new ActionIdentifiers(); actionIdentifiers.setVnfId("fusion-vpp-vnf-001"); Status status; @@ -88,14 +88,15 @@ public class ApplicationControllerClientTest { @Test public void test_getLCMPropertiesHelper() { - ApplicationControllerClient client = new ApplicationControllerClient(); - Properties properties = client.getLCMProperties(); + ApplicationControllerClient client = new ApplicationControllerClient("appc"); + Properties properties = client.getLCMProperties("appc"); assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3"); assertEquals(properties.get("topic.read.timeout"), "120000"); assertEquals(properties.get("client.response.timeout"), "120000"); assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2"); assertEquals(properties.get("poolMembers"), "uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904"); + assertEquals(properties.get("client.controllerType"), "appc"); assertEquals(properties.get("client.key"), "iaEMAfjsVsZnraBP"); assertEquals(properties.get("client.secret"), "wcivUjsjXzmGFBfxMmyJu9dz"); } diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java index bd026d0b6d..d9c5654989 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/openecomp/mso/client/appc/ApplicationControllerOrchestratorTest.java @@ -46,7 +46,7 @@ public class ApplicationControllerOrchestratorTest { Status status; try { status = client.vnfCommand(Action.Lock, UUID.randomUUID().toString(), - "3ffdee3c-94d2-45fe-904d-fc1efa0f8b59", Optional.of("")); + "3ffdee3c-94d2-45fe-904d-fc1efa0f8b59", Optional.of(""), "appc"); } catch (ApplicationControllerOrchestratorException e) { status = new Status(); status.setCode(e.getAppcCode()); @@ -62,7 +62,7 @@ public class ApplicationControllerOrchestratorTest { Status status; try { status = client.vnfCommand(Action.Unlock, UUID.randomUUID().toString(), - "ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f", Optional.of("")); + "ca522254-2ba4-4fbd-b15b-0ef0d9cfda5f", Optional.of(""), "appc"); } catch (ApplicationControllerOrchestratorException e) { status = new Status(); status.setCode(e.getAppcCode()); -- cgit 1.2.3-korg