summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnc
diff options
context:
space:
mode:
Diffstat (limited to 'models-interactions/model-actors/actor.sdnc')
-rw-r--r--models-interactions/model-actors/actor.sdnc/pom.xml2
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActor.java182
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java78
3 files changed, 2 insertions, 260 deletions
diff --git a/models-interactions/model-actors/actor.sdnc/pom.xml b/models-interactions/model-actors/actor.sdnc/pom.xml
index 7a657c0e3..5a90d33dd 100644
--- a/models-interactions/model-actors/actor.sdnc/pom.xml
+++ b/models-interactions/model-actors/actor.sdnc/pom.xml
@@ -27,7 +27,7 @@
<parent>
<groupId>org.onap.policy.models.policy-models-interactions.model-actors</groupId>
<artifactId>model-actors</artifactId>
- <version>2.3.0-SNAPSHOT</version>
+ <version>2.3.1-SNAPSHOT</version>
</parent>
<artifactId>actor.sdnc</artifactId>
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActor.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActor.java
index a5cf65f34..c67b58b8d 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActor.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActor.java
@@ -22,56 +22,13 @@
package org.onap.policy.controlloop.actor.sdnc;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import java.util.Collections;
-import java.util.List;
-import java.util.UUID;
-import org.onap.policy.controlloop.ControlLoopOperation;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpActor;
import org.onap.policy.controlloop.actorserviceprovider.impl.HttpOperator;
import org.onap.policy.controlloop.actorserviceprovider.parameters.HttpActorParams;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.sdnc.SdncHealNetworkInfo;
-import org.onap.policy.sdnc.SdncHealRequest;
-import org.onap.policy.sdnc.SdncHealRequestHeaderInfo;
-import org.onap.policy.sdnc.SdncHealRequestInfo;
-import org.onap.policy.sdnc.SdncHealServiceInfo;
-import org.onap.policy.sdnc.SdncHealVfModuleInfo;
-import org.onap.policy.sdnc.SdncHealVfModuleParameter;
-import org.onap.policy.sdnc.SdncHealVfModuleParametersInfo;
-import org.onap.policy.sdnc.SdncHealVfModuleRequestInput;
-import org.onap.policy.sdnc.SdncHealVnfInfo;
-import org.onap.policy.sdnc.SdncRequest;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class SdncActor extends HttpActor<HttpActorParams> {
- private static final Logger logger = LoggerFactory.getLogger(SdncActor.class);
-
public static final String NAME = "SDNC";
- // TODO old code: remove lines down to **HERE**
-
- // Strings for Sdnc Actor
- private static final String SDNC_ACTOR = "SDNC";
-
- // Strings for targets
- private static final String TARGET_VM = "VM";
-
- // Strings for recipes
- private static final String RECIPE_REROUTE = "Reroute";
-
- // Strings for recipes
- private static final String RECIPE_BW_ON_DEMAND = "BandwidthOnDemand";
-
- private static final ImmutableList<String> recipes = ImmutableList.of(RECIPE_REROUTE);
- private static final ImmutableMap<String, List<String>> targets = new ImmutableMap.Builder<String, List<String>>()
- .put(RECIPE_REROUTE, ImmutableList.of(TARGET_VM)).build();
-
- // **HERE**
-
/**
* Constructs the object.
*/
@@ -81,143 +38,4 @@ public class SdncActor extends HttpActor<HttpActorParams> {
addOperator(new HttpOperator(NAME, RerouteOperation.NAME, RerouteOperation::new));
addOperator(new HttpOperator(NAME, BandwidthOnDemandOperation.NAME, BandwidthOnDemandOperation::new));
}
-
-
- // TODO old code: remove lines down to **HERE**
-
- @Override
- public String actor() {
- return SDNC_ACTOR;
- }
-
- @Override
- public List<String> recipes() {
- return ImmutableList.copyOf(recipes);
- }
-
- @Override
- public List<String> recipeTargets(String recipe) {
- return ImmutableList.copyOf(targets.getOrDefault(recipe, Collections.emptyList()));
- }
-
- @Override
- public List<String> recipePayloads(String recipe) {
- return Collections.emptyList();
- }
-
- /**
- * Construct a request.
- *
- * @param onset the onset event
- * @param operation the control loop operation
- * @param policy the policy
- * @return the constructed request
- */
- public SdncRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
- switch (policy.getRecipe()) {
- case RECIPE_REROUTE:
- return constructReOptimizeRequest(onset);
- case RECIPE_BW_ON_DEMAND:
- logger.info("Construct request for receipe {}", RECIPE_BW_ON_DEMAND);
- return constructBwOnDemandRequest(onset);
- default:
- logger.info("Unsupported recipe {}", policy.getRecipe());
- return null;
- }
- }
-
- private SdncRequest constructBwOnDemandRequest(VirtualControlLoopEvent onset) {
- // Construct an Sdnc request
- String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
- if (serviceInstance == null || serviceInstance.isEmpty()) {
- // This indicates that AAI Enrichment needs to be done by event producer.
- return null;
- }
- SdncHealVfModuleParameter bandwidth = new SdncHealVfModuleParameter();
- bandwidth.setName("bandwidth");
- bandwidth.setValue(onset.getAai().get("bandwidth"));
-
- SdncHealVfModuleParameter timeStamp = new SdncHealVfModuleParameter();
- timeStamp.setName("bandwidth-change-time");
- timeStamp.setValue(onset.getAai().get("bandwidth-change-time"));
-
- SdncHealVfModuleParametersInfo vfParametersInfo = new SdncHealVfModuleParametersInfo();
- vfParametersInfo.addParameters(bandwidth);
- vfParametersInfo.addParameters(timeStamp);
-
- SdncHealVfModuleRequestInput vfRequestInfo = new SdncHealVfModuleRequestInput();
- vfRequestInfo.setVfModuleParametersInfo(vfParametersInfo);
-
- SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo();
- serviceInfo.setServiceInstanceId(serviceInstance);
-
- SdncHealRequestInfo requestInfo = new SdncHealRequestInfo();
- requestInfo.setRequestAction("SdwanBandwidthChange");
-
- SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
- headerInfo.setSvcAction("update");
- headerInfo.setSvcRequestId(UUID.randomUUID().toString());
-
- SdncRequest request = new SdncRequest();
- request.setNsInstanceId(serviceInstance);
- request.setRequestId(onset.getRequestId());
- request.setUrl("/GENERIC-RESOURCE-API:vf-module-topology-operation");
-
- SdncHealVnfInfo vnfInfo = new SdncHealVnfInfo();
- vnfInfo.setVnfId(onset.getAai().get("vnfId"));
-
- SdncHealVfModuleInfo vfModuleInfo = new SdncHealVfModuleInfo();
- vfModuleInfo.setVfModuleId("");
-
- SdncHealRequest healRequest = new SdncHealRequest();
- healRequest.setVnfInfo(vnfInfo);
- healRequest.setVfModuleInfo(vfModuleInfo);
- healRequest.setRequestHeaderInfo(headerInfo);
- healRequest.setVfModuleRequestInput(vfRequestInfo);
- healRequest.setRequestInfo(requestInfo);
- healRequest.setServiceInfo(serviceInfo);
- request.setHealRequest(healRequest);
- return request;
- }
-
- private SdncRequest constructReOptimizeRequest(VirtualControlLoopEvent onset) {
- // Construct an Sdnc request
- String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
- if (serviceInstance == null || serviceInstance.isEmpty()) {
- // This indicates that AAI Enrichment needs to be done by event producer.
- return null;
- }
- SdncHealServiceInfo serviceInfo = new SdncHealServiceInfo();
- serviceInfo.setServiceInstanceId(serviceInstance);
-
- String networkId = onset.getAai().get("network-information.network-id");
- if (networkId == null || networkId.isEmpty()) {
- // This indicates that AAI Enrichment needs to be done by event producer.
- return null;
- }
- SdncHealNetworkInfo networkInfo = new SdncHealNetworkInfo();
- networkInfo.setNetworkId(networkId);
-
- SdncHealRequestInfo requestInfo = new SdncHealRequestInfo();
- requestInfo.setRequestAction("ReoptimizeSOTNInstance");
-
- SdncHealRequestHeaderInfo headerInfo = new SdncHealRequestHeaderInfo();
- headerInfo.setSvcAction("reoptimize");
- headerInfo.setSvcRequestId(UUID.randomUUID().toString());
-
- SdncRequest request = new SdncRequest();
- request.setNsInstanceId(serviceInstance);
- request.setRequestId(onset.getRequestId());
- request.setUrl("/GENERIC-RESOURCE-API:network-topology-operation");
-
- SdncHealRequest healRequest = new SdncHealRequest();
- healRequest.setRequestHeaderInfo(headerInfo);
- healRequest.setNetworkInfo(networkInfo);
- healRequest.setRequestInfo(requestInfo);
- healRequest.setServiceInfo(serviceInfo);
- request.setHealRequest(healRequest);
- return request;
- }
-
- // **HERE**
}
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java
index 020b09e8c..f0f280cb6 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorTest.java
@@ -23,44 +23,16 @@
package org.onap.policy.controlloop.actor.sdnc;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import java.util.Arrays;
-import java.util.Objects;
-import java.util.UUID;
import java.util.stream.Collectors;
-import org.junit.AfterClass;
-import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.common.endpoints.http.server.HttpServletServerFactoryInstance;
-import org.onap.policy.controlloop.ControlLoopOperation;
-import org.onap.policy.controlloop.VirtualControlLoopEvent;
import org.onap.policy.controlloop.actor.test.BasicActor;
-import org.onap.policy.controlloop.policy.Policy;
-import org.onap.policy.sdnc.SdncRequest;
public class SdncActorTest extends BasicActor {
- private static final String REROUTE = RerouteOperation.NAME;
-
- /**
- * Set up before test class.
- *
- * @throws Exception if the A&AI simulator cannot be started
- */
- @BeforeClass
- public static void setUpSimulator() throws Exception {
- org.onap.policy.simulators.Util.buildAaiSim();
- }
-
- @AfterClass
- public static void tearDownSimulator() {
- HttpServletServerFactoryInstance.getServerFactory().destroy();
- }
-
@Test
- public void testSdncActorServiceProvider() {
+ public void testSdncActor() {
final SdncActor prov = new SdncActor();
// verify that it has the operators we expect
@@ -73,52 +45,4 @@ public class SdncActorTest extends BasicActor {
// verify that it all plugs into the ActorService
verifyActorService(SdncActor.NAME, "service.yaml");
}
-
- @Test
- public void testConstructRequest() {
- VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
- ControlLoopOperation operation = new ControlLoopOperation();
-
- Policy policy = new Policy();
- policy.setRecipe(REROUTE);
-
- SdncActor provider = new SdncActor();
- assertNull(provider.constructRequest(onset, operation, policy));
-
- onset.getAai().put("network-information.network-id", "network-5555");
- assertNull(provider.constructRequest(onset, operation, policy));
-
- assertNull(provider.constructRequest(onset, operation, policy));
-
- UUID requestId = UUID.randomUUID();
- onset.setRequestId(requestId);
- assertNull(provider.constructRequest(onset, operation, policy));
-
- assertNull(provider.constructRequest(onset, operation, policy));
-
- onset.getAai().put("service-instance.service-instance-id", "service-instance-01");
- assertNotNull(provider.constructRequest(onset, operation, policy));
-
- policy.setRecipe(REROUTE);
- assertNotNull(provider.constructRequest(onset, operation, policy));
-
- SdncRequest request = provider.constructRequest(onset, operation, policy);
-
- assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
- assertEquals("reoptimize", request.getHealRequest().getRequestHeaderInfo().getSvcAction());
- assertEquals("ReoptimizeSOTNInstance", request.getHealRequest().getRequestInfo().getRequestAction());
- assertEquals("network-5555", request.getHealRequest().getNetworkInfo().getNetworkId());
- assertEquals("service-instance-01", request.getHealRequest().getServiceInfo().getServiceInstanceId());
- }
-
- @Test
- public void testMethods() {
- SdncActor sp = new SdncActor();
-
- assertEquals("SDNC", sp.actor());
- assertEquals(1, sp.recipes().size());
- assertEquals(REROUTE, sp.recipes().get(0));
- assertEquals("VM", sp.recipeTargets(REROUTE).get(0));
- assertEquals(0, sp.recipePayloads(REROUTE).size());
- }
}