aboutsummaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.sdnc
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2019-04-05 08:43:33 -0400
committerPamela Dragosh <pdragosh@research.att.com>2019-04-05 08:43:39 -0400
commit97ff0d774d4c41f5ca968d9ea5df07c978e77032 (patch)
tree0d28a64b727235f14790b2a6696377faf5bbb819 /models-interactions/model-actors/actor.sdnc
parentb0bb6076e2298c7a016a00adcaefb7ed75eac641 (diff)
Update SDNC changes
Per this review: https://gerrit.onap.org/r/#/c/83945/ Copying those changes into policy/models before removal in drools-applications. Issue-ID: POLICY-1264 Change-Id: I151816e78293af813d24ca1164ca364a3c54f87c Signed-off-by: Pamela Dragosh <pdragosh@research.att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.sdnc')
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java83
-rw-r--r--models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java21
2 files changed, 86 insertions, 18 deletions
diff --git a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java
index 423839188..4de3ed96b 100644
--- a/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.sdnc/src/main/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProvider.java
@@ -2,8 +2,9 @@
* ============LICENSE_START=======================================================
* SdncActorServiceProvider
* ================================================================================
- * Copyright (C) 2018 Huawei Intellectual Property. All rights reserved.
+ * Copyright (C) 2018-2019 Huawei Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
+ * Modifications Copyright (C) 2019 AT&T Intellectual Property.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +39,11 @@ 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.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;
@@ -56,6 +62,9 @@ public class SdncActorServiceProvider implements Actor {
// 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();
@@ -88,28 +97,86 @@ public class SdncActorServiceProvider implements Actor {
* @param policy the policy
* @return the constructed request
*/
- public static SdncRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
+ 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;
+ }
+ }
- if (!policy.getRecipe().equalsIgnoreCase(RECIPE_REROUTE)) {
+ 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("SdwanBWPolicyChange");
+
+ 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:vnf-topology-operation");
+
+ SdncHealVnfInfo vnfInfo = new SdncHealVnfInfo();
+ vnfInfo.setVnfId(onset.getAai().get("vnfId"));
+
+ SdncHealRequest healRequest = new SdncHealRequest();
+ healRequest.setVnfInfo(vnfInfo);
+ 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.
+ // 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.
+ // This indicates that AAI Enrichment needs to be done by event producer.
return null;
}
- SdncHealNetworkInfo networkInfo = new SdncHealNetworkInfo();
+ SdncHealNetworkInfo networkInfo = new SdncHealNetworkInfo();
networkInfo.setNetworkId(networkId);
SdncHealRequestInfo requestInfo = new SdncHealRequestInfo();
@@ -122,6 +189,7 @@ public class SdncActorServiceProvider implements Actor {
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);
@@ -129,7 +197,6 @@ public class SdncActorServiceProvider implements Actor {
healRequest.setRequestInfo(requestInfo);
healRequest.setServiceInfo(serviceInfo);
request.setHealRequest(healRequest);
-
return request;
}
} \ No newline at end of file
diff --git a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
index 7b64b87d2..7288ec126 100644
--- a/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
+++ b/models-interactions/model-actors/actor.sdnc/src/test/java/org/onap/policy/controlloop/actor/sdnc/SdncActorServiceProviderTest.java
@@ -2,8 +2,8 @@
* ============LICENSE_START=======================================================
* TestSdncActorServiceProvider
* ================================================================================
- * Copyright (C) 2018 Huawei. All rights reserved.
- * Modifications Copyright (C) 2018 AT&T Corp. All rights reserved.
+ * Copyright (C) 2018-2019 Huawei. All rights reserved.
+ * Modifications Copyright (C) 2018-2019 AT&T Corp. All rights reserved.
* Modifications Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -69,31 +69,32 @@ public class SdncActorServiceProviderTest {
Policy policy = new Policy();
policy.setRecipe("Reroute");
- assertNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ SdncActorServiceProvider provider = new SdncActorServiceProvider();
+ assertNull(provider.constructRequest(onset, operation, policy));
onset.getAai().put("network-information.network-id", "network-5555");
- assertNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ assertNull(provider.constructRequest(onset, operation, policy));
PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
- assertNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ assertNull(provider.constructRequest(onset, operation, policy));
UUID requestId = UUID.randomUUID();
onset.setRequestId(requestId);
- assertNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ assertNull(provider.constructRequest(onset, operation, policy));
PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
- assertNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ assertNull(provider.constructRequest(onset, operation, policy));
onset.getAai().put("service-instance.service-instance-id", "service-instance-01");
- assertNotNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ assertNotNull(provider.constructRequest(onset, operation, policy));
policy.setRecipe("Reroute");
- assertNotNull(SdncActorServiceProvider.constructRequest(onset, operation, policy));
+ assertNotNull(provider.constructRequest(onset, operation, policy));
SdncRequest request =
- SdncActorServiceProvider.constructRequest(onset, operation, policy);
+ provider.constructRequest(onset, operation, policy);
assertEquals(requestId, Objects.requireNonNull(request).getRequestId());
assertEquals("reoptimize", request.getHealRequest().getRequestHeaderInfo().getSvcAction());