From: Pamela Dragosh Date: Fri, 5 Apr 2019 12:43:33 +0000 (-0400) Subject: Update SDNC changes X-Git-Tag: 3.0.2-ONAP~44 X-Git-Url: https://gerrit.onap.org/r/gitweb?a=commitdiff_plain;h=97ff0d774d4c41f5ca968d9ea5df07c978e77032;p=policy%2Fmodels.git 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 --- 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 recipes = ImmutableList.of(RECIPE_REROUTE); private static final ImmutableMap> targets = new ImmutableMap.Builder>().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()); diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java index 88645d517..70e81d89f 100644 --- a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealRequest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2018 Huawei. All rights reserved. + * Copyright (C) 2018-2019 Huawei. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,6 +39,12 @@ public class SdncHealRequest implements Serializable { @SerializedName("network-information") private SdncHealNetworkInfo networkInfo; + @SerializedName("vnf-information") + private SdncHealVnfInfo vnfInfo; + + @SerializedName("vf-module-request-input") + private SdncHealVfModuleRequestInput vfModuleRequestInput; + public SdncHealRequest() { // Default constructor for SdncHealRequest } @@ -75,4 +81,19 @@ public class SdncHealRequest implements Serializable { this.networkInfo = networkInfo; } + public SdncHealVnfInfo getVnfInfo() { + return vnfInfo; + } + + public void setVnfInfo(SdncHealVnfInfo vnfInfo) { + this.vnfInfo = vnfInfo; + } + + public SdncHealVfModuleRequestInput getVfModuleRequestInput() { + return vfModuleRequestInput; + } + + public void setVfModuleRequestInput(SdncHealVfModuleRequestInput input) { + this.vfModuleRequestInput = input; + } } diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParameter.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParameter.java new file mode 100644 index 000000000..0fe82bb44 --- /dev/null +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParameter.java @@ -0,0 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class SdncHealVfModuleParameter implements Serializable { + + private static final long serialVersionUID = 3208673205100673119L; + + @SerializedName("name") + private String name; + + @SerializedName("value") + private String value; + + public SdncHealVfModuleParameter() { + // Default constructor for SdncHealVfModuleParameter + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } +} diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParametersInfo.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParametersInfo.java new file mode 100644 index 000000000..4515b9790 --- /dev/null +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleParametersInfo.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; + +public class SdncHealVfModuleParametersInfo implements Serializable { + + private static final long serialVersionUID = 3208673205100673119L; + + @SerializedName("param") + private List parameters; + + public SdncHealVfModuleParametersInfo() { + // Default constructor for SdncHealVfModuleParametersInfo + parameters = new LinkedList<>(); + } + + public List getParameters() { + return parameters; + } + + public void setParameters(List parameters) { + this.parameters = parameters; + } + + public void addParameters(SdncHealVfModuleParameter parameter) { + parameters.add(parameter); + } +} diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleRequestInput.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleRequestInput.java new file mode 100644 index 000000000..c903c77fa --- /dev/null +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVfModuleRequestInput.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class SdncHealVfModuleRequestInput implements Serializable { + + private static final long serialVersionUID = 3208673205100673119L; + + @SerializedName("vf-module-input-parameters") + private SdncHealVfModuleParametersInfo vfModuleParametersInfo; + + public SdncHealVfModuleRequestInput() { + // Default constructor for SdncHealVfModuleRequestInput + } + + public SdncHealVfModuleParametersInfo getVfModuleParametersInfo() { + return vfModuleParametersInfo; + } + + public void setVfModuleParametersInfo(SdncHealVfModuleParametersInfo info) { + this.vfModuleParametersInfo = info; + } +} diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVnfInfo.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVnfInfo.java new file mode 100644 index 000000000..67eaa3b93 --- /dev/null +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncHealVnfInfo.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.policy.sdnc; + +import com.google.gson.annotations.SerializedName; + +import java.io.Serializable; + +public class SdncHealVnfInfo implements Serializable { + + private static final long serialVersionUID = 3208673205100673119L; + + @SerializedName("vnf-id") + private String vnfId; + + public SdncHealVnfInfo() { + // Default constructor for SdncHealVnfInfo + } + + public String getVnfId() { + return vnfId; + } + + public void setVnfId(String vnfId) { + this.vnfId = vnfId; + } +} diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java index 5770a23c5..864ddf506 100644 --- a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncManager.java @@ -97,7 +97,7 @@ public final class SdncManager implements Runnable { responseError.setResponseOutput(responseOutput); headers.put("Accept", "application/json"); - String sdncUrl = sdncUrlBase + "/GENERIC-RESOURCE-API:network-topology-operation"; + String sdncUrl = sdncUrlBase + sdncRequest.getUrl(); try { String sdncRequestJson = Serialization.gsonPretty.toJson(sdncRequest); diff --git a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java index 4aaa844cd..b2be02035 100644 --- a/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java +++ b/models-interactions/model-impl/sdnc/src/main/java/org/onap/policy/sdnc/SdncRequest.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Huawei. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2019 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,7 @@ package org.onap.policy.sdnc; import com.google.gson.annotations.SerializedName; + import java.io.Serializable; import java.util.UUID; @@ -29,6 +31,7 @@ public class SdncRequest implements Serializable { // These fields are not serialized and not part of JSON private transient String nsInstanceId; private transient UUID requestId; + private transient String url; @SerializedName("input") private SdncHealRequest healRequest; @@ -60,4 +63,12 @@ public class SdncRequest implements Serializable { public void setHealRequest(SdncHealRequest healRequest) { this.healRequest = healRequest; } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } }