From bb34137b85575dd36121d8cfc63b469e9a2ebf08 Mon Sep 17 00:00:00 2001 From: Rob Daugherty Date: Tue, 24 Apr 2018 13:53:25 -0400 Subject: Create VF Module Error There are multiple issues here. 1) The LCM healthcheck and config-scale-out should be made conditional upon the VNF orchestration status being Active or Activated. I'm not going to do that with this commit, since the logic will probably need to be moved to the DoCreateVfModule flow. What I will do is bypass the LCM operations to unblock testing. Another ticket will need to address the real solution. 2) APP-C gave us an API where the controller type is configured in their client object, which is NOT what we wanted. As a result, we have to keep a client object for each controller type. Our implementation did not do this. 3) Need to support the APP-C client configuration properties for specifying the SDN-C topic names. I'm refactoring the APP-C client urn mapping names to make it clear that they are for configuring the APP-C *client* and not necessarily for APP-C itself. Change-Id: I588f3b98b4ee44ba53b4931f9f1a7938ee70bebf Issue-ID: SO-577 Signed-off-by: Rob Daugherty --- .../client/appc/ApplicationControllerClient.java | 99 +++++++--- .../appc/ApplicationControllerClientTest.java | 16 +- .../src/test/resources/mso.bpmn.urn.properties | 14 +- .../resources/process/CreateVfModuleInfra.bpmn | 219 +++++++++++++-------- .../src/test/resources/mso.bpmn.urn.properties | 12 +- 5 files changed, 234 insertions(+), 126 deletions(-) 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 8c57b9255c..3cd26be631 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 @@ -26,9 +26,7 @@ import java.time.Instant; import java.util.Map; import java.util.Properties; import java.util.UUID; - -import org.openecomp.mso.bpmn.core.PropertyConfiguration; -import org.springframework.beans.factory.annotation.Autowired; +import java.util.concurrent.ConcurrentHashMap; import org.onap.appc.client.lcm.api.AppcClientServiceFactoryProvider; import org.onap.appc.client.lcm.api.AppcLifeCycleManagerServiceFactory; @@ -44,11 +42,16 @@ import org.onap.appc.client.lcm.model.Flags.Mode; import org.onap.appc.client.lcm.model.Payload; import org.onap.appc.client.lcm.model.Status; import org.onap.appc.client.lcm.model.ZULU; +import org.openecomp.mso.bpmn.core.PropertyConfiguration; +import org.springframework.beans.factory.annotation.Autowired; + import com.att.eelf.configuration.EELFLogger; import com.att.eelf.configuration.EELFLogger.Level; import com.att.eelf.configuration.EELFManager; public class ApplicationControllerClient { + + public static final String DEFAULT_CONTROLLER_TYPE = "appc"; private static final String CLIENT_NAME = "MSO"; @@ -60,18 +63,68 @@ public class ApplicationControllerClient { @Autowired public ApplicationControllerSupport appCSupport; - private static LifeCycleManagerStateful client; + // APPC gave us an API where the controllerType is configured in the + // client object, which is not what we asked for. We asked for an API + // in which the client would have additional methods that could take + // the controllerType as a parameter, so that we would not need to + // maintain multiple client objects. This map should be removed when + // the (hopefully short-term) controllerType becomes obsolete. + + private final String controllerType; + + private static ConcurrentHashMap appCClients = new ConcurrentHashMap<>(); + /** + * Creates an ApplicationControllerClient for communication with APP-C. + */ + public ApplicationControllerClient() { + this(DEFAULT_CONTROLLER_TYPE); + } + + /** + * Creates an ApplicationControllerClient for the specified controller type. + * @param controllerType the controller type: "appc" or "sndnc". + */ public ApplicationControllerClient(String controllerType) { + this.controllerType = controllerType; appCSupport = new ApplicationControllerSupport(); - client = this.getAppCClient(controllerType); + } + + /** + * Gets the controller type. + * @return the controllertype + */ + public String getControllerType() { + return controllerType; } - public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, org.onap.appc.client.lcm.model.Payload payload, String requestID) + /** + * Returns the AppC client object associated with this ApplicationControllerClient. + * AppC client objects are shared objects. One is created if it does not exist. + * @return the client object, or null if creation failed + */ + public LifeCycleManagerStateful getAppCClient() { + return appCClients.computeIfAbsent(controllerType, k -> createAppCClient(k)); + } + + protected LifeCycleManagerStateful createAppCClient(String controllerType) { + try { + return AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) + .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties()); + } catch (AppcClientException e) { + auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage()); + // This null value will cause NullPointerException when used later. + // Error handling could certainly be improved here. + return null; + } + } + + public Status runCommand(Action action, org.onap.appc.client.lcm.model.ActionIdentifiers actionIdentifiers, + org.onap.appc.client.lcm.model.Payload payload, String requestID) throws ApplicationControllerOrchestratorException { - Object requestObject; - requestObject = createRequest(action, actionIdentifiers, payload, requestID); + Object requestObject = createRequest(action, actionIdentifiers, payload, requestID); appCSupport.logLCMMessage(requestObject); + LifeCycleManagerStateful client = getAppCClient(); Method lcmMethod = appCSupport.getAPIMethod(action.name(), client, false); try { Object response = lcmMethod.invoke(client, requestObject); @@ -81,35 +134,21 @@ public class ApplicationControllerClient { } } - public LifeCycleManagerStateful getAppCClient(String controllerType) { - if (client == null) - try { - client = AppcClientServiceFactoryProvider.getFactory(AppcLifeCycleManagerServiceFactory.class) - .createLifeCycleManagerStateful(new ApplicationContext(), getLCMProperties(controllerType)); - } catch (AppcClientException e) { - auditLogger.log(Level.ERROR, "Error in getting LifeCycleManagerStateful: ", e, e.getMessage()); - } - return client; - } - - protected Properties getLCMProperties(String controllerType) { + protected Properties getLCMProperties() { 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("topic.read", globalProperties.get("appc.client.topic.read")); + properties.put("topic.write", globalProperties.get("appc.client.topic.write")); + properties.put("topic.sdnc.read", globalProperties.get("appc.client.topic.sdnc.read")); + properties.put("topic.sdnc.write", globalProperties.get("appc.client.topic.sdnc.write")); + properties.put("topic.read.timeout", globalProperties.get("appc.client.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("poolMembers", globalProperties.get("appc.client.poolMembers")); properties.put("client.key", globalProperties.get("appc.client.key")); properties.put("client.secret", globalProperties.get("appc.client.secret")); properties.put("client.name", CLIENT_NAME); - properties.put("service", globalProperties.get("appc.service")); + properties.put("service", globalProperties.get("appc.client.service")); return properties; } 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 e737f5da16..ec093bebbd 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 @@ -21,6 +21,7 @@ package org.openecomp.mso.client.appc; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import java.util.Properties; import java.util.UUID; @@ -28,7 +29,6 @@ import java.util.UUID; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; - import org.onap.appc.client.lcm.model.Action; import org.onap.appc.client.lcm.model.ActionIdentifiers; import org.onap.appc.client.lcm.model.CheckLockInput; @@ -41,6 +41,13 @@ public class ApplicationControllerClientTest { System.setProperty("mso.config.path", "src/test/resources"); } + @Test + public void testClientCreation() { + ApplicationControllerClient client = new ApplicationControllerClient("appc"); + assertEquals(client.getControllerType(), "appc"); + assertNotNull(client.getAppCClient()); + } + @Test public void createRequest_CheckLock_RequestBuilt() { ApplicationControllerClient client = new ApplicationControllerClient("appc"); @@ -89,14 +96,15 @@ public class ApplicationControllerClientTest { @Test public void test_getLCMPropertiesHelper() { ApplicationControllerClient client = new ApplicationControllerClient("appc"); - Properties properties = client.getLCMProperties("appc"); + Properties properties = client.getLCMProperties(); + assertEquals(properties.get("topic.read"), "APPC-TEST-AMDOCS2"); assertEquals(properties.get("topic.write"), "APPC-TEST-AMDOCS1-DEV3"); + assertEquals(properties.get("topic.sdnc.read"), "SDNC-LCM-READ"); + assertEquals(properties.get("topic.sdnc.write"), "SDNC-LCM-WRITE"); 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/resources/mso.bpmn.urn.properties b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties index 539d365150..4b338aed0c 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOCommonBPMN/src/test/resources/mso.bpmn.urn.properties @@ -33,14 +33,16 @@ policy.client.auth=Basic bTAzNzQzOnBvbGljeVIwY2sk policy.auth=Basic dGVzdHBkcDphbHBoYTEyMw== policy.environment=TEST -appc.topic.read=APPC-TEST-AMDOCS2 -appc.topic.write=APPC-TEST-AMDOCS1-DEV3 -appc.topic.read.timeout=120000 +appc.client.topic.read=APPC-TEST-AMDOCS2 +appc.client.topic.write=APPC-TEST-AMDOCS1-DEV3 +appc.client.topic.sdnc.read=SDNC-LCM-READ +appc.client.topic.sdnc.write=SDNC-LCM-WRITE +appc.client.topic.read.timeout=120000 appc.client.response.timeout=120000 -appc.service=ueb -appc.poolMembers=uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904 +appc.client.poolMembers=uebsb93kcdc.it.att.com:3904,uebsb92kcdc.it.att.com:3904,uebsb91kcdc.it.att.com:3904 appc.client.key=iaEMAfjsVsZnraBP appc.client.secret=wcivUjsjXzmGFBfxMmyJu9dz +appc.client.service=ueb mso.adapters.sdnc.endpoint=http://localhost:28090/SDNCAdapter mso.adapters.sdnc.rest.endpoint=http://localhost:28090/SDNCAdapter/v1/sdnc @@ -134,4 +136,4 @@ log.debug.vnfAdapterRestV1=true sdno.health-check.dmaap.username=m04768@mso.ecomp.att.com sdno.health-check.dmaap.password=eHQ1cUJrOUc sdno.health-check.dmaap.subscriber.topic=com.att.sdno.test-health-diagnostic-v02 -sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 \ No newline at end of file +sdno.health-check.dmaap.publisher.topic=com.att.sdno.test-health-diagnostic-v02 diff --git a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn index 70cfa7dfcf..841dec96bd 100644 --- a/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn +++ b/bpmn/MSOInfrastructureBPMN/src/main/resources/process/CreateVfModuleInfra.bpmn @@ -1,5 +1,5 @@ - + SequenceFlow_1 @@ -39,6 +39,7 @@ + SequenceFlow_1y7d5qk SequenceFlow_1vx081s SequenceFlow_4 @@ -91,6 +92,7 @@ createVfModule.prepareUpdateInfraRequest(execution)]]> SequenceFlow_0td7d9m + SequenceFlow_0u8zesf SequenceFlow_12 updateInfraRequestResponseGood - + @@ -206,7 +208,7 @@ exceptionUtil.processJavaException(execution)]]> - + @@ -220,11 +222,11 @@ exceptionUtil.processJavaException(execution)]]> - SequenceFlow_0e2ta6w + SequenceFlow_1xggje5 SequenceFlow_07llpjo - - + + SequenceFlow_07llpjo SequenceFlow_1vx081s SequenceFlow_0nszq2o @@ -238,7 +240,7 @@ exceptionUtil.processJavaException(execution)]]> - + @@ -253,7 +255,7 @@ exceptionUtil.processJavaException(execution)]]> - updateInfraRequestResponseGood + SequenceFlow_020dbkp SequenceFlow_1tk5ru7 @@ -271,50 +273,69 @@ exceptionUtil.processJavaException(execution)]]> + + SequenceFlow_0e2ta6w + SequenceFlow_1xggje5 + SequenceFlow_1y7d5qk + + + + + + + updateInfraRequestResponseGood + SequenceFlow_020dbkp + SequenceFlow_0u8zesf + + + + + - + + + + - - + + - + - + - + - - + + - + - + - + - + - - - - + + - + @@ -332,19 +353,19 @@ exceptionUtil.processJavaException(execution)]]> - + - + - + - + - + @@ -368,21 +389,21 @@ exceptionUtil.processJavaException(execution)]]> - + - + - + - + - - + + - + @@ -440,20 +461,20 @@ exceptionUtil.processJavaException(execution)]]> - + - - + + - + - - + + - + @@ -508,54 +529,52 @@ exceptionUtil.processJavaException(execution)]]> - + - - + + - + - + - + - - - - + + + + - + - - - - + + - + - + - + - - + + - + - + @@ -565,38 +584,76 @@ exceptionUtil.processJavaException(execution)]]> - + - + - - + + - + - - + + - + - + - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + diff --git a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties index c8ec2dfbb0..fc84d9ea85 100644 --- a/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties +++ b/bpmn/MSOInfrastructureBPMN/src/test/resources/mso.bpmn.urn.properties @@ -114,14 +114,16 @@ policy.environment=TEST policy.endpoint=http://localhost:28090/pdp/api/ policy.default.disposition=Skip -appc.topic.read=APPC-CL-FUSION-LCM-RESPONSE -appc.topic.read.timeout=100 +appc.client.topic.read=APPC-CL-FUSION-LCM-RESPONSE +appc.client.topic.write=APPC-CL-FUSION-LCM +appc.client.topic.sdnc.read=SDNC-LCM-READ +appc.client.topic.sdnc.write=SDNC-LCM-WRITE +appc.client.topic.read.timeout=100 appc.client.response.timeout=300 -appc.topic.write=APPC-CL-FUSION-LCM -appc.poolMembers=localhost:28090 +appc.client.poolMembers=localhost:28090 appc.client.key=iaEMAfjsVsZnraBP appc.client.secret=wcivUjsjXzmGFBfxMmyJu9dz -#appc.service=ueb +#appc.client.service=ueb sdnc.si.sv.types=PORT-MIRROR,PPROBES mso.bpmn.optimisticlockingexception.retrycount=3 -- cgit 1.2.3-korg