* ============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.
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;
// 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();
* @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();
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.setRequestInfo(requestInfo);
healRequest.setServiceInfo(serviceInfo);
request.setHealRequest(healRequest);
-
return request;
}
}
\ No newline at end of file
* ============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");
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());
/*-
* ============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");
@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
}
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;
+ }
}
--- /dev/null
+/*-
+ * ============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;
+ }
+}
--- /dev/null
+/*-
+ * ============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<SdncHealVfModuleParameter> parameters;
+
+ public SdncHealVfModuleParametersInfo() {
+ // Default constructor for SdncHealVfModuleParametersInfo
+ parameters = new LinkedList<>();
+ }
+
+ public List<SdncHealVfModuleParameter> getParameters() {
+ return parameters;
+ }
+
+ public void setParameters(List<SdncHealVfModuleParameter> parameters) {
+ this.parameters = parameters;
+ }
+
+ public void addParameters(SdncHealVfModuleParameter parameter) {
+ parameters.add(parameter);
+ }
+}
--- /dev/null
+/*-
+ * ============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;
+ }
+}
--- /dev/null
+/*-
+ * ============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;
+ }
+}
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);
* ============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.
package org.onap.policy.sdnc;
import com.google.gson.annotations.SerializedName;
+
import java.io.Serializable;
import java.util.UUID;
// 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;
public void setHealRequest(SdncHealRequest healRequest) {
this.healRequest = healRequest;
}
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
}