aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java346
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/ResponseObject.java (renamed from generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/ErrorObject.java)4
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/BrgTopologyOperationRPCTest.java146
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java271
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericResourceApiProviderTest.java6
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java341
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java185
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java185
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java272
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java249
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TunnelxconnTopologyOperationRPCTest.java146
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java232
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java203
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java129
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java196
-rwxr-xr-xvnfapi/model/src/main/yang/VNF-API.yang1771
16 files changed, 3403 insertions, 1279 deletions
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
index 9673515c..50367ce5 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
@@ -1,5 +1,8 @@
package org.onap.sdnc.northbound;
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.Futures;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
@@ -9,7 +12,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
-
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
@@ -93,10 +95,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
-
/**
* Defines a base implementation for your provider. This class extends from a helper class which provides storage for
* the most commonly used components of the MD-SAL. Additionally the base class provides some basic logging and
@@ -134,14 +132,14 @@ import com.google.common.util.concurrent.Futures;
public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURCEAPIService {
- private static final String APP_NAME = "generic-resource-api";
+ protected static final String APP_NAME = "generic-resource-api";
private static final String CALLED_STR = "{} called.";
private static final String NULL_OR_EMPTY_ERROR_MESSAGE = "exiting {} because of null or empty service-instance-id";
- private static final String NULL_OR_EMPTY_ERROR_PARAM = "invalid input, null or empty service-instance-id";
+ protected static final String NULL_OR_EMPTY_ERROR_PARAM = "invalid input, null or empty service-instance-id";
private static final String ADDING_INPUT_DATA_LOG = "Adding INPUT data for {} [{}] input: {}";
private static final String ADDING_OPERATIONAL_DATA_LOG = "Adding OPERATIONAL data for {} [{}] operational-data: {}";
private static final String OPERATIONAL_DATA_PARAM = "operational-data";
- private static final String NO_SERVICE_LOGIC_ACTIVE = "No service logic active for ";
+ protected static final String NO_SERVICE_LOGIC_ACTIVE = "No service logic active for ";
private static final String SERVICE_LOGIC_SEARCH_ERROR_MESSAGE = "Caught exception looking for service logic";
private static final String ERROR_CODE_PARAM = "error-code";
private static final String ERROR_MESSAGE_PARAM = "error-message";
@@ -158,7 +156,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
private static final String SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE = "Caught exception executing service logic for {} ";
private static final String UPDATING_TREE_INFO_MESSAGE = "Updating OPERATIONAL tree.";
private static final String EMPTY_SERVICE_INSTANCE_MESSAGE = "exiting {} because the service-instance does not have any service data in SDNC";
- private static final String INVALID_INPUT_ERROR_MESSAGE = "invalid input: the service-instance does not have any service data in SDNC";
+ protected static final String INVALID_INPUT_ERROR_MESSAGE = "invalid input: the service-instance does not have any service data in SDNC";
private static final String ALLOTTED_RESOURCE_ID_PARAM = "allotted-resource-id";
private static final String ERROR_NETWORK_ID = "error";
@@ -502,7 +500,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// create a new response object
ServiceTopologyOperationOutputBuilder responseBuilder = new ServiceTopologyOperationOutputBuilder();
- if (hasValidService(input)) {
+ if (hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
@@ -548,25 +546,25 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String serviceObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
}
- setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(svcOperation);
- if (isValidErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
ServiceBuilder serviceBuilder = new ServiceBuilder();
@@ -609,7 +607,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (Exception e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -622,9 +620,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -636,13 +634,13 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(ServiceTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(ServiceTopologyOperationOutputBuilder responseBuilder, ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
}
- private boolean hasValidService(ServiceTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(ServiceTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
@@ -665,30 +663,30 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
private Properties tryGetProperties(String svcOperation, Properties parms, ServiceDataBuilder serviceDataBuilder,
- ErrorObject error) {
+ ResponseObject responseObject) {
try {
if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
try {
return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
} catch (Exception e) {
log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
}
} else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
+ responseObject.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ responseObject.setStatusCode("503");
}
} catch (Exception e) {
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
}
return null;
}
- private boolean isValidErrorObject(ErrorObject error) {
+ private boolean failed(ResponseObject error) {
return
!error.getStatusCode().isEmpty() && !("0".equals(error.getStatusCode()) || "200"
.equals(error.getStatusCode()));
@@ -704,13 +702,13 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
final String svcOperation = "vnf-topology-operation";
ServiceData serviceData;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
+ Properties properties = new Properties();
log.info(CALLED_STR, svcOperation);
// create a new response object
VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder();
- if (hasInvalidService(input)) {
+ if (hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
responseBuilder.setResponseCode("404");
@@ -727,7 +725,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
trySetSvcRequestId(input, responseBuilder);
- if (hasInvalidVnf(input)) {
+ if (hasInvalidVnfId(input)) {
log.debug("exiting {} because of null or empty vnf-id", svcOperation);
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
@@ -770,34 +768,38 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
VnfTopologyOperationInputBuilder inputBuilder = new VnfTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+ GenericResourceApiUtil.toProperties(properties, inputBuilder.build());
log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid,
operDataBuilder.build());
- GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
+ GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String serviceObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+ Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject);
if (respProps != null) {
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty("vnf-object-path");
+
+ //FIXME if needed
+ /*before was "vfn-object-path", but it didn't make sense, since everywhere else,
+ when extracting service object path the "service-object-path" property is used*/
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
}
- setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(svcOperation);
- if (isValidErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
ServiceBuilder serviceBuilder = new ServiceBuilder();
@@ -847,7 +849,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (Exception e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -860,9 +862,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -875,7 +877,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(VnfTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(VnfTopologyOperationOutputBuilder responseBuilder, ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -892,12 +894,12 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
}
- private boolean hasInvalidVnf(VnfTopologyOperationInput input) {
+ private boolean hasInvalidVnfId(VnfTopologyOperationInput input) {
return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
|| input.getVnfInformation().getVnfId().length() == 0;
}
- private boolean hasInvalidService(VnfTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(VnfTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
@@ -927,7 +929,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// create a new response object
VfModuleTopologyOperationOutputBuilder responseBuilder = new VfModuleTopologyOperationOutputBuilder();
- if (hasInvalidService(input)) {
+ if (hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
@@ -942,7 +944,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- if (hasInvalidVnf(input)) {
+ if (hasInvalidVnfId(input)) {
log.debug("exiting {} because of null or empty vnf-id", svcOperation);
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
@@ -952,7 +954,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- if (hasInvalidVfModule(input)) {
+ if (hasInvalidVfModuleId(input)) {
log.debug("exiting {} because of null or empty vf-module-id", svcOperation);
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, vf-module-id is null or empty");
@@ -1009,25 +1011,30 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String serviceObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty("vf-module-object-path");
+
+
+ //FIXME if needed
+ /*before was "vf-module-object-path", but it didnt make sense, since everywhere else,
+ when extracting service object path the "service-object-path" property is used*/
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
}
- setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(svcOperation);
- if (isValidErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getStatusCode());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
ServiceBuilder serviceBuilder = new ServiceBuilder();
@@ -1071,7 +1078,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (Exception e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1084,9 +1091,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1099,7 +1106,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(VfModuleTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(VfModuleTopologyOperationOutputBuilder responseBuilder, ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -1123,17 +1130,17 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
}
- private boolean hasInvalidVfModule(VfModuleTopologyOperationInput input) {
+ private boolean hasInvalidVfModuleId(VfModuleTopologyOperationInput input) {
return input.getVfModuleInformation() == null || input.getVfModuleInformation().getVfModuleId() == null
|| input.getVfModuleInformation().getVfModuleId().length() == 0;
}
- private boolean hasInvalidVnf(VfModuleTopologyOperationInput input) {
+ private boolean hasInvalidVnfId(VfModuleTopologyOperationInput input) {
return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
|| input.getVnfInformation().getVnfId().length() == 0;
}
- private boolean hasInvalidService(VfModuleTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(VfModuleTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
@@ -1156,7 +1163,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// create a new response object
NetworkTopologyOperationOutputBuilder responseBuilder = new NetworkTopologyOperationOutputBuilder();
- if (this.hasInvalidService(input)) {
+ if (hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
}
@@ -1182,25 +1189,25 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String networkId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
String networkObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
networkId = respProps.getProperty("networkId");
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
networkObjectPath = respProps.getProperty("network-object-path");
}
- if (isValidErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1241,7 +1248,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (IllegalStateException e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1254,9 +1261,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1268,7 +1275,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(NetworkTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(NetworkTopologyOperationOutputBuilder responseBuilder, ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -1291,7 +1298,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
}
- private boolean hasInvalidService(NetworkTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(NetworkTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
@@ -1324,13 +1331,13 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
final String svcOperation = "contrail-route-topology-operation";
ServiceData serviceData;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
+ Properties properties = new Properties();
log.info(CALLED_STR, svcOperation);
// create a new response object
ContrailRouteTopologyOperationOutputBuilder responseBuilder = new ContrailRouteTopologyOperationOutputBuilder();
- if (hasInvalidService(input)) {
+ if (hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
}
@@ -1351,16 +1358,16 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
log.info("Adding INPUT data for " + svcOperation + " [" + siid + "] input: " + input);
ContrailRouteTopologyOperationInputBuilder inputBuilder = new ContrailRouteTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+ GenericResourceApiUtil.toProperties(properties, inputBuilder.build());
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject error = new ResponseObject("200", "");
String ackFinal = "Y";
String allottedResourceId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
String contrailRouteObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+ Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, error);
if (respProps != null) {
error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
@@ -1371,7 +1378,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
contrailRouteObjectPath = respProps.getProperty("contrail-route-object-path");
}
- if (isValidErrorObject(error)) {
+ if (failed(error)) {
responseBuilder.setResponseCode(error.getStatusCode());
responseBuilder.setResponseMessage(error.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1412,7 +1419,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (IllegalStateException e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1439,7 +1446,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(ContrailRouteTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(ContrailRouteTopologyOperationOutputBuilder responseBuilder,
+ ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -1462,14 +1470,14 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
}
- private boolean hasInvalidService(ContrailRouteTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(ContrailRouteTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private Future<RpcResult<ContrailRouteTopologyOperationOutput>>
- buildRpcResultFuture(ContrailRouteTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
+ buildRpcResultFuture(ContrailRouteTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(responseMessage);
@@ -1500,7 +1508,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// create a new response object
SecurityZoneTopologyOperationOutputBuilder responseBuilder = new SecurityZoneTopologyOperationOutputBuilder();
- if (this.hasInvalidService(input)) {
+ if (this.hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
}
@@ -1527,7 +1535,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
Properties respProps = null;
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String allottedResourceId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
@@ -1540,31 +1548,31 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
respProps = svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
} catch (Exception e) {
log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
}
} else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
+ responseObject.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ responseObject.setStatusCode("503");
}
} catch (Exception e) {
- error.setStatusCode("500");
- error.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
}
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
securityZoneObjectPath = respProps.getProperty("security-zone-object-path");
}
- if (isValidErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1604,7 +1612,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (IllegalStateException e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1617,9 +1625,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1631,7 +1639,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(SecurityZoneTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(SecurityZoneTopologyOperationOutputBuilder responseBuilder,
+ ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -1658,14 +1667,14 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return sd == null || sd.getServiceLevelOperStatus() == null;
}
- private boolean hasInvalidService(SecurityZoneTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(SecurityZoneTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private Future<RpcResult<SecurityZoneTopologyOperationOutput>>
- buildRpcResultFuture(SecurityZoneTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
+ buildRpcResultFuture(SecurityZoneTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(responseMessage);
@@ -1693,7 +1702,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// create a new response object
TunnelxconnTopologyOperationOutputBuilder responseBuilder = new TunnelxconnTopologyOperationOutputBuilder();
- if (hasInvalidService(input)) {
+ if (hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
@@ -1713,25 +1722,25 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String allottedResourceId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
String tunnelxconnObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, error);
+ Properties respProps = tryGetProperties(svcOperation, parms, responseObject);
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
tunnelxconnObjectPath = respProps.getProperty("tunnelxconn-object-path");
}
- if (isValidErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1772,9 +1781,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1786,19 +1795,20 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(TunnelxconnTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(TunnelxconnTopologyOperationOutputBuilder responseBuilder,
+ ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
}
- private boolean hasInvalidService(TunnelxconnTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(TunnelxconnTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
}
- private Properties tryGetProperties(String svcOperation, Properties parms, ErrorObject error) {
+ private Properties tryGetProperties(String svcOperation, Properties parms, ResponseObject responseObject) {
try {
if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
@@ -1806,16 +1816,16 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", parms);
} catch (Exception e) {
log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
}
} else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
+ responseObject.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ responseObject.setStatusCode("503");
}
} catch (Exception e) {
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
}
return null;
@@ -1830,7 +1840,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// create a new response object
BrgTopologyOperationOutputBuilder responseBuilder = new BrgTopologyOperationOutputBuilder();
- if (this.hasInvalidService(input)) {
+ if (this.hasInvalidServiceId(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
responseBuilder.setResponseCode("404");
@@ -1853,7 +1863,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
+ ResponseObject error = new ResponseObject("200", "");
String ackFinal = "Y";
String allottedResourceId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
@@ -1869,7 +1879,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
brgObjectPath = respProps.getProperty("brg-object-path");
}
- if (isValidErrorObject(error)) {
+ if (failed(error)) {
responseBuilder.setResponseCode(error.getStatusCode());
responseBuilder.setResponseMessage(error.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1926,13 +1936,13 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private void trySetResponseMessage(BrgTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(BrgTopologyOperationOutputBuilder responseBuilder, ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
}
- private boolean hasInvalidService(BrgTopologyOperationInput input) {
+ private boolean hasInvalidServiceId(BrgTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
|| input.getServiceInformation().getServiceInstanceId() == null
|| input.getServiceInformation().getServiceInstanceId().length() == 0;
@@ -1969,7 +1979,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
String preloadType = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType();
// Make sure we have a preload_name and preload_type
- if (isValidPreloadData(preloadName, preloadType)) {
+ if (invalidPreloadData(preloadName, preloadType)) {
log.debug("exiting {} vnf-name or vnf-type is null or empty", svcOperation);
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input: vnf-name or vnf-type is null or empty");
@@ -1983,7 +1993,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- this.trySetSvcRequestId(input, responseBuilder);
+ trySetSvcRequestId(input, responseBuilder);
PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
getPreloadData(preloadName, preloadType, preloadDataBuilder);
@@ -2014,14 +2024,14 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
- Properties respProps = tryGetProperties(svcOperation, parms, error);
- String ackFinal = resolveAckFinal(error, respProps);
+ ResponseObject responseObject = new ResponseObject("200", "");
+ Properties respProps = tryGetProperties(svcOperation, parms, responseObject);
+ String ackFinal = resolveAckFinal(responseObject, respProps);
- if (isValidErrorObject(error)) {
+ if (failed(responseObject)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
@@ -2029,7 +2039,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
preloadVnfListBuilder.setVnfType(preloadType);
preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName,
- preloadType, error.getStatusCode(), error.getMessage());
+ preloadType, responseObject.getStatusCode(), responseObject.getMessage());
try {
savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
@@ -2053,7 +2063,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType,
e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType,
responseBuilder.build());
@@ -2067,9 +2077,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType);
log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType,
@@ -2083,16 +2093,16 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
return Futures.immediateFuture(rpcResult);
}
- private String resolveAckFinal(ErrorObject error, Properties respProps) {
+ private String resolveAckFinal(ResponseObject responseObject, Properties respProps) {
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- return respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ return respProps.getProperty(ACK_FINAL_PARAM, "Y");
}
return "Y";
}
- private void trySetResponseMessage(PreloadVnfTopologyOperationOutputBuilder responseBuilder, ErrorObject error) {
+ private void trySetResponseMessage(PreloadVnfTopologyOperationOutputBuilder responseBuilder, ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -2159,10 +2169,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
String preloadType = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType();
// Make sure we have a preload_name and preload_type
- if (isValidPreloadData(preloadName, preloadType)) {
- log.debug("exiting {} because of invalid preload-name", svcOperation);
+ if (invalidPreloadData(preloadName, preloadType)) {
+ log.debug("exiting {} because of invalid preload-name or preload-type", svcOperation);
responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("input, invalid preload-name");
+ responseBuilder.setResponseMessage("invalid input: network-name or network-type is null or empty");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
@@ -2206,15 +2216,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
// Call SLI sync method
// Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
- Properties respProps = tryGetProperties(svcOperation, parms, error);
+ ResponseObject responseObject = new ResponseObject("200", "");
+ Properties respProps = tryGetProperties(svcOperation, parms, responseObject);
- String ackFinal = resolveAckFinal(error, respProps);
+ String ackFinal = resolveAckFinal(responseObject, respProps);
- if (isValidErrorObject(error)) {
+ if (failed(responseObject)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
@@ -2222,7 +2232,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
preloadVnfListBuilder.setVnfType(preloadType);
preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName,
- preloadType, error.getStatusCode(), error.getMessage());
+ preloadType, responseObject.getStatusCode(), responseObject.getMessage());
try {
savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
@@ -2246,7 +2256,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (Exception e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType,
responseBuilder.build());
@@ -2260,9 +2270,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType);
log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType,
@@ -2277,7 +2287,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
private void trySetResponseMessage(PreloadNetworkTopologyOperationOutputBuilder responseBuilder,
- ErrorObject error) {
+ ResponseObject error) {
if (!error.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(error.getMessage());
}
@@ -2290,7 +2300,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
}
- private boolean isValidPreloadData(String preloadName, String preloadType) {
+ private boolean invalidPreloadData(String preloadName, String preloadType) {
return preloadName == null || preloadName.length() == 0 || preloadType == null || preloadType.length() == 0;
}
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/ErrorObject.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/ResponseObject.java
index 5fe72cb4..a3ff2e2f 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/ErrorObject.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/ResponseObject.java
@@ -1,13 +1,13 @@
package org.onap.sdnc.northbound;
-public class ErrorObject {
+public class ResponseObject {
private static final String EMPTY_STRING = "";
private String statusCode;
private String message;
- public ErrorObject(String statusCode, String message) {
+ public ResponseObject(String statusCode, String message) {
this.statusCode = statusCode == null ? EMPTY_STRING : statusCode;
this.message = message == null ? EMPTY_STRING : message;
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/BrgTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/BrgTopologyOperationRPCTest.java
new file mode 100644
index 00000000..ec00c363
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/BrgTopologyOperationRPCTest.java
@@ -0,0 +1,146 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.brgResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.brgTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.brgTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class BrgTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+ private static final String SVC_OPERATION = "brg-topology-operation";
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_instance_id_not_present() throws Exception {
+
+ BrgTopologyOperationInput input = build(brgTopologyOperationInput());
+
+ BrgTopologyOperationOutput output =
+ exec(genericResourceApiProvider::brgTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecuteWoServiceData(new RuntimeException("test exception"));
+
+ BrgTopologyOperationInput input = build(brgTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ BrgTopologyOperationOutput output =
+ exec(genericResourceApiProvider::brgTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ BrgTopologyOperationInput input = build(brgTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ BrgTopologyOperationOutput output =
+ exec(genericResourceApiProvider::brgTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_success_when_no_errors_encountered() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcResultProp.set("security-zone-object-path", "securityZoneObjectPath: XYZ");
+ svcClient.mockExecuteWoServiceData(svcResultProp);
+
+ BrgTopologyOperationInput input = build(brgTopologyOperationInput()
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ BrgTopologyOperationOutput output =
+ exec(genericResourceApiProvider::brgTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ BrgTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+
+ }
+
+ private BrgTopologyOperationOutput createExpectedOutput(PropBuilder propBuilder,
+ BrgTopologyOperationInput input) {
+
+ return build(brgTopologyOperationOutput()
+ .setBrgResponseInformation(build(brgResponseInformation()
+ .setObjectPath(propBuilder.get("brg-object-path"))))
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java
new file mode 100644
index 00000000..55b7db44
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java
@@ -0,0 +1,271 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.INVALID_INPUT_ERROR_MESSAGE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.contrailRouteResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.contrailRouteTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.contrailRouteTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.service;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceData;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceLevelOperStatus;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
+
+import java.time.Instant;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastOrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastRpcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.OrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.Service;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+ private static final String SVC_OPERATION = "contrail-route-topology-operation";
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_instance_id_not_present() throws Exception {
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput());
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_service_data() throws Exception {
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(INVALID_INPUT_ERROR_MESSAGE, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_success_when_no_errors_encountered() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcResultProp.set("contrail-route-object-path", "contrailRouteObjectPath: XYZ");
+ svcClient.mockExecute(svcResultProp);
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ Service service = persistServiceInDataBroker(input);
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ ContrailRouteTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+
+ Service actualService = db
+ .read(input.getServiceInformation().getServiceInstanceId(), LogicalDatastoreType.CONFIGURATION);
+
+ Service expectedService = createExpectedService(input, service.getServiceData());
+ assertEquals(expectedService, actualService);
+ }
+
+ private Service persistServiceInDataBroker(ContrailRouteTopologyOperationInput input) throws Exception {
+
+ Service service = build(service()
+ .setServiceInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setServiceData(build(serviceData()
+ .setServiceLevelOperStatus(build(serviceLevelOperStatus()
+ .setOrderStatus(OrderStatus.Created)
+ .setModifyTimestamp(Instant.now().toString())
+ .setLastSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setLastRpcAction(LastRpcAction.Activate)
+ .setLastOrderStatus(LastOrderStatus.PendingAssignment)
+ .setLastAction(LastAction.ActivateNetworkInstance)
+ .setCreateTimestamp(Instant.now().toString())
+ ))
+ ))
+ );
+ db.write(true, service, LogicalDatastoreType.CONFIGURATION);
+ return service;
+ }
+
+ private ContrailRouteTopologyOperationOutput createExpectedOutput(PropBuilder propBuilder,
+ ContrailRouteTopologyOperationInput input) {
+
+ return build(contrailRouteTopologyOperationOutput()
+ .setContrailRouteResponseInformation(build(contrailRouteResponseInformation()
+ .setObjectPath(propBuilder.get("contrail-route-object-path"))))
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+
+ private Service createExpectedService(
+ ContrailRouteTopologyOperationInput expectedInput, ServiceData expectedServiceData) {
+
+ ServiceInformation expectedServiceInformation = expectedInput.getServiceInformation();
+
+ return build(service()
+ .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
+ .setServiceData(build(serviceData()))
+ .setServiceData(expectedServiceData)
+ .setServiceStatus(build(serviceStatus()))
+ );
+ }
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericResourceApiProviderTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericResourceApiProviderTest.java
index a6568005..6bf6959e 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericResourceApiProviderTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/GenericResourceApiProviderTest.java
@@ -22,6 +22,7 @@
package org.onap.sdnc.northbound;
import org.junit.Before;
+import org.junit.Test;
import org.mockito.Mock;
import org.onap.sdnc.northbound.util.DataBrokerUtil;
import org.onap.sdnc.northbound.util.GenericResourceApiSvcLogicServiceClientMockUtil;
@@ -36,12 +37,13 @@ import org.slf4j.LoggerFactory;
public class GenericResourceApiProviderTest extends AbstractConcurrentDataBrokerTest {
+ protected static final Logger LOG = LoggerFactory.getLogger(GenericResourceApiProvider.class);
protected GenericResourceApiProvider genericResourceApiProvider;
protected DataBroker dataBroker;
protected @Mock NotificationPublishService mockNotificationPublishService;
protected @Mock RpcProviderRegistry mockRpcProviderRegistry;
protected @Mock GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient;
- protected static final Logger LOG = LoggerFactory.getLogger(GenericResourceApiProvider.class);
+
protected DataBrokerUtil db;
@@ -70,6 +72,4 @@ public class GenericResourceApiProviderTest extends AbstractConcurrentDataBroker
public static PropBuilder prop(){
return (new PropBuilder());
}
-
-
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java
index 31ec9cd3..29436415 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java
@@ -21,27 +21,13 @@
package org.onap.sdnc.northbound;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.onap.sdnc.northbound.util.PropBuilder;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceData;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.Service;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatus;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import java.time.Instant;
-
import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.INVALID_INPUT_ERROR_MESSAGE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
import static org.onap.sdnc.northbound.util.MDSALUtil.build;
import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
import static org.onap.sdnc.northbound.util.MDSALUtil.networkInformation;
@@ -61,6 +47,28 @@ import static org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.reso
import static org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastRpcAction;
import static org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.OrderStatus;
+import java.time.Instant;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.Service;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatus;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
/**
* This class test the NetworkTopologyOperation mdsal RPC.
@@ -78,168 +86,261 @@ public class NetworkTopologyOperationRPCTest extends GenericResourceApiProviderT
svcClient.setScvOperation(SVC_OPERATION);
}
+ @Test
+ public void should_fail_when_service_instance_id_not_present() throws Exception {
+
+ NetworkTopologyOperationInput input = build(networkTopologyOperationInput());
+
+ NetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::networkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_service_data() throws Exception {
+
+ NetworkTopologyOperationInput input = build(networkTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ NetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::networkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(INVALID_INPUT_ERROR_MESSAGE, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ NetworkTopologyOperationInput input = build(networkTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ NetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::networkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ NetworkTopologyOperationInput input = build(networkTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ NetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::networkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ NetworkTopologyOperationInput input = build(networkTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+ NetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::networkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
/**
- * Verify ServiceTopologyOperation RPC executes a DG then produces the expected
- * {@link NetworkTopologyOperationOutput} and persisted the expected {@link Service} in the {@link DataBroker}
+ * Verify ServiceTopologyOperation RPC executes a DG then produces the expected {@link
+ * NetworkTopologyOperationOutput} and persisted the expected {@link Service} in the {@link DataBroker}
*/
@Test
- public void testNetworkTopologyOperation() throws Exception {
+ public void should_success_when_no_errors_encountered() throws Exception {
//mock svcClient to perform a successful execution with the expected parameters
svcClient.mockHasGraph(true);
PropBuilder svcResultProp = svcClient.createExecuteOKResult();
svcClient.mockExecute(svcResultProp);
-
//construct the input parameter for the NetworkTopologyOperation
- NetworkTopologyOperationInput networkTopologyOperationInput = createNTOI();
-
+ NetworkTopologyOperationInput input = createNTOI();
//pre-populate the DataBroke with the required ServiceData.
- Service service = persistServiceInDataBroker(networkTopologyOperationInput);
-
-
+ Service service = persistServiceInDataBroker(input);
//execute the mdsal exec
- NetworkTopologyOperationOutput actualNetworkTopologyOperationOutput = exec(
- genericResourceApiProvider::networkTopologyOperation
- , networkTopologyOperationInput
- , RpcResult::getResult
+ NetworkTopologyOperationOutput output = exec(
+ genericResourceApiProvider::networkTopologyOperation
+ , input
+ , RpcResult::getResult
);
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
//verify the returned NetworkTopologyOperationOutput
NetworkTopologyOperationOutput expectedNetworkTopologyOperationOutput
- = createExpectedNTOO(svcResultProp,networkTopologyOperationInput);
- assertEquals(expectedNetworkTopologyOperationOutput,actualNetworkTopologyOperationOutput);
-
+ = createExpectedNTOO(svcResultProp, input);
+ assertEquals(expectedNetworkTopologyOperationOutput, output);
//verify the persisted Service
Service actualService = db.read(
- networkTopologyOperationInput.getServiceInformation().getServiceInstanceId(),
- LogicalDatastoreType.CONFIGURATION
+ input.getServiceInformation().getServiceInstanceId(),
+ LogicalDatastoreType.CONFIGURATION
);
Service expectedService = createExpectedService(
- expectedNetworkTopologyOperationOutput,
- networkTopologyOperationInput,
- service.getServiceData(),
- actualService);
- assertEquals(expectedService,actualService);
+ expectedNetworkTopologyOperationOutput,
+ input,
+ service.getServiceData(),
+ actualService);
+ assertEquals(expectedService, actualService);
}
- private NetworkTopologyOperationInput createNTOI()
- {
+ private NetworkTopologyOperationInput createNTOI() {
return build(
- networkTopologyOperationInput()
- .setSdncRequestHeader(build(sdncRequestHeader()
- .setSvcRequestId("svc-request-id: xyz")
- .setSvcAction(SvcAction.Assign)
- ))
- .setRequestInformation(build(requestInformation()
- .setRequestId("request-id: xyz")
- .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
- ))
- .setServiceInformation(build(serviceInformationBuilder()
- .setServiceInstanceId("service-instance-id: xyz")
- ))
- .setNetworkInformation(build(
- networkInformation()
- ))
+ networkTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("svc-request-id: xyz")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("request-id: xyz")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("service-instance-id: xyz")
+ ))
+ .setNetworkInformation(build(
+ networkInformation()
+ ))
);
}
private Service persistServiceInDataBroker(
- NetworkTopologyOperationInput networkTopologyOperationInput
- ) throws Exception{
+ NetworkTopologyOperationInput networkTopologyOperationInput
+ ) throws Exception {
Service service = build(
- service()
- .setServiceInstanceId(
- networkTopologyOperationInput.getServiceInformation().getServiceInstanceId()
- )
- .setServiceData(build(
- serviceData()
- .setServiceLevelOperStatus(build(
- serviceLevelOperStatus()
- .setOrderStatus(OrderStatus.Created)
- .setModifyTimestamp(Instant.now().toString())
- .setLastSvcRequestId("svc-request-id: abc")
- .setLastRpcAction(LastRpcAction.Activate)
- .setLastOrderStatus(LastOrderStatus.PendingAssignment)
- .setLastAction(LastAction.ActivateNetworkInstance)
- .setCreateTimestamp(Instant.now().toString())
- ))
+ service()
+ .setServiceInstanceId(
+ networkTopologyOperationInput.getServiceInformation().getServiceInstanceId()
+ )
+ .setServiceData(build(
+ serviceData()
+ .setServiceLevelOperStatus(build(
+ serviceLevelOperStatus()
+ .setOrderStatus(OrderStatus.Created)
+ .setModifyTimestamp(Instant.now().toString())
+ .setLastSvcRequestId("svc-request-id: abc")
+ .setLastRpcAction(LastRpcAction.Activate)
+ .setLastOrderStatus(LastOrderStatus.PendingAssignment)
+ .setLastAction(LastAction.ActivateNetworkInstance)
+ .setCreateTimestamp(Instant.now().toString())
))
+ ))
);
- db.write(true,service, LogicalDatastoreType.CONFIGURATION);
+ db.write(true, service, LogicalDatastoreType.CONFIGURATION);
return service;
}
-
-
-
-
private NetworkTopologyOperationOutput createExpectedNTOO(
- PropBuilder expectedSvcResultProp,
- NetworkTopologyOperationInput expectedNetworkTopologyOperationInput){
+ PropBuilder expectedSvcResultProp,
+ NetworkTopologyOperationInput expectedNetworkTopologyOperationInput) {
return build(
- networkTopologyOperationOutput()
- .setSvcRequestId(expectedNetworkTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
- .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
- .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
- .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
- .setServiceResponseInformation(build(serviceResponseInformation()
- .setInstanceId(expectedNetworkTopologyOperationInput.getServiceInformation().getServiceInstanceId())
- .setObjectPath(expectedSvcResultProp.get(svcClient.serviceObjectPath))
- ))
- .setNetworkResponseInformation(build(
- networkResponseInformation()
- .setInstanceId(expectedSvcResultProp.get(svcClient.networkId))
- .setObjectPath(expectedSvcResultProp.get(svcClient.networkObjectPath))
- ))
+ networkTopologyOperationOutput()
+ .setSvcRequestId(expectedNetworkTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
+ .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(expectedNetworkTopologyOperationInput.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(expectedSvcResultProp.get(svcClient.serviceObjectPath))
+ ))
+ .setNetworkResponseInformation(build(
+ networkResponseInformation()
+ .setInstanceId(expectedSvcResultProp.get(svcClient.networkId))
+ .setObjectPath(expectedSvcResultProp.get(svcClient.networkObjectPath))
+ ))
);
}
private Service createExpectedService(
- NetworkTopologyOperationOutput expectedNetworkTopologyOperationOutput,
- NetworkTopologyOperationInput expectedNetworkTopologyOperationInput,
- ServiceData expectedServiceData,
- Service actualService
- ){
-
+ NetworkTopologyOperationOutput expectedNetworkTopologyOperationOutput,
+ NetworkTopologyOperationInput expectedNetworkTopologyOperationInput,
+ ServiceData expectedServiceData,
+ Service actualService
+ ) {
//We cannot predict the timeStamp value so just steal it from the actual
//we need this to prevent the equals method from returning false as a result of the timestamp
- String responseTimeStamp = actualService == null || actualService.getServiceStatus() == null?
- null : actualService.getServiceStatus().getResponseTimestamp();
+ String responseTimeStamp = actualService == null || actualService.getServiceStatus() == null ?
+ null : actualService.getServiceStatus().getResponseTimestamp();
SdncRequestHeader expectedSdncRequestHeader = expectedNetworkTopologyOperationInput.getSdncRequestHeader();
ServiceInformation expectedServiceInformation = expectedNetworkTopologyOperationInput.getServiceInformation();
RequestInformation expectedRequestInformation = expectedNetworkTopologyOperationInput.getRequestInformation();
return build(
- service()
- .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
- .setServiceData(build(serviceData()))
- .setServiceData(expectedServiceData)
- .setServiceStatus(
- build(
- serviceStatus()
- )
- )
+ service()
+ .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
+ .setServiceData(build(serviceData()))
+ .setServiceData(expectedServiceData)
+ .setServiceStatus(
+ build(
+ serviceStatus()
+ )
+ )
);
}
- public ServiceStatus.RpcAction toRpcAction(SvcAction fromEnum){
- return fromEnum == null? null : ServiceStatus.RpcAction.valueOf(fromEnum.name());
+ public ServiceStatus.RpcAction toRpcAction(SvcAction fromEnum) {
+ return fromEnum == null ? null : ServiceStatus.RpcAction.valueOf(fromEnum.name());
}
-
-
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java
new file mode 100644
index 00000000..b05f1b27
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadNetworkTopologyRPCTest.java
@@ -0,0 +1,185 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.networkTopologyIdentifierBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.networkTopologyInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.preloadNetworkTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.preloadNetworkTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PreloadNetworkTopologyRPCTest extends GenericResourceApiProviderTest {
+
+ private static final String SVC_OPERATION = "preload-network-topology-operation";
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_invalid_vnf_topology() throws Exception {
+
+ PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput());
+
+ PreloadNetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals("input is null", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_preload_data() throws Exception {
+
+ PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput()
+ .setNetworkTopologyInformation(build(networkTopologyInformationBuilder()
+ .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder()
+ .setNetworkName("test-network-name")))))
+ );
+
+ PreloadNetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals("invalid input: network-name or network-type is null or empty", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecuteWoServiceData(new RuntimeException("test exception"));
+
+ PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput()
+ .setNetworkTopologyInformation(build(networkTopologyInformationBuilder()
+ .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder()
+ .setNetworkName("test-network-name")
+ .setNetworkType("test-network-type")))))
+ );
+
+ PreloadNetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput()
+ .setNetworkTopologyInformation(build(networkTopologyInformationBuilder()
+ .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder()
+ .setNetworkName("test-network-name")
+ .setNetworkType("test-network-type")))))
+ );
+
+ PreloadNetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecuteWoServiceData(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput()
+ .setNetworkTopologyInformation(build(networkTopologyInformationBuilder()
+ .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder()
+ .setNetworkName("test-network-name")
+ .setNetworkType("test-network-type")))))
+ );
+
+ PreloadNetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_complete_with_success_when_no_errors() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+
+ PreloadNetworkTopologyOperationInput input = build(preloadNetworkTopologyOperationInput()
+ .setNetworkTopologyInformation(build(networkTopologyInformationBuilder()
+ .setNetworkTopologyIdentifier(build(networkTopologyIdentifierBuilder()
+ .setNetworkName("test-network-name")
+ .setNetworkType("test-network-type")))))
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ );
+
+ PreloadNetworkTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadNetworkTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ PreloadNetworkTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+ }
+
+ private PreloadNetworkTopologyOperationOutput createExpectedOutput(PropBuilder svcResultProp,
+ PreloadNetworkTopologyOperationInput input) {
+ return build(preloadNetworkTopologyOperationOutput()
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(svcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(svcResultProp.get(svcClient.ackFinal))
+ );
+ }
+
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java
new file mode 100644
index 00000000..8a854a91
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/PreloadVnfTopologyOperationRPCTest.java
@@ -0,0 +1,185 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVnfTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.preloadVnfTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyIdentifierBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyInformationBuilder;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class PreloadVnfTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+ private static final String SVC_OPERATION = "preload-vnf-topology-operation";
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_invalid_vnf_topology() throws Exception {
+
+ PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput());
+
+ PreloadVnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals("invalid input: input is null", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_preload_data() throws Exception {
+
+ PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput()
+ .setVnfTopologyInformation(build(vnfTopologyInformationBuilder()
+ .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder()
+ .setVnfName("test-vnf-name")))))
+ );
+
+ PreloadVnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals("invalid input: vnf-name or vnf-type is null or empty", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecuteWoServiceData(new RuntimeException("test exception"));
+
+ PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput()
+ .setVnfTopologyInformation(build(vnfTopologyInformationBuilder()
+ .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder()
+ .setVnfName("test-vnf-name")
+ .setVnfType("test-vnf-type")))))
+ );
+
+ PreloadVnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput()
+ .setVnfTopologyInformation(build(vnfTopologyInformationBuilder()
+ .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder()
+ .setVnfName("test-vnf-name")
+ .setVnfType("test-vnf-type")))))
+ );
+
+ PreloadVnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecuteWoServiceData(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput()
+ .setVnfTopologyInformation(build(vnfTopologyInformationBuilder()
+ .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder()
+ .setVnfName("test-vnf-name")
+ .setVnfType("test-vnf-type")))))
+ );
+
+ PreloadVnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_complete_with_success_when_no_errors() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+
+ PreloadVnfTopologyOperationInput input = build(preloadVnfTopologyOperationInput()
+ .setVnfTopologyInformation(build(vnfTopologyInformationBuilder()
+ .setVnfTopologyIdentifier(build(vnfTopologyIdentifierBuilder()
+ .setVnfName("test-vnf-name")
+ .setVnfType("test-vnf-type")))))
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ );
+
+ PreloadVnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::preloadVnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ PreloadVnfTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+ }
+
+ private PreloadVnfTopologyOperationOutput createExpectedOutput(PropBuilder svcResultProp,
+ PreloadVnfTopologyOperationInput input) {
+ return build(preloadVnfTopologyOperationOutput()
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(svcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(svcResultProp.get(svcClient.ackFinal))
+ );
+ }
+
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java
new file mode 100644
index 00000000..e7618937
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java
@@ -0,0 +1,272 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.INVALID_INPUT_ERROR_MESSAGE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.securityZoneResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.securityZoneTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.securityZoneTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.service;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceData;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceLevelOperStatus;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
+
+import java.time.Instant;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastOrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastRpcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.OrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.Service;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SecurityZoneTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+
+ private static final String SVC_OPERATION = "security-zone-topology-operation";
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_instance_id_not_present() throws Exception {
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput());
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_service_data() throws Exception {
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(INVALID_INPUT_ERROR_MESSAGE, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_success_when_no_errors_encountered() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcResultProp.set("security-zone-object-path", "securityZoneObjectPath: XYZ");
+ svcClient.mockExecute(svcResultProp);
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ Service service = persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ SecurityZoneTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+
+ Service actualService = db
+ .read(input.getServiceInformation().getServiceInstanceId(), LogicalDatastoreType.CONFIGURATION);
+
+ Service expectedService = createExpectedService(input, service.getServiceData());
+ assertEquals(expectedService, actualService);
+ }
+
+ private Service persistServiceInDataBroker(SecurityZoneTopologyOperationInput input) throws Exception {
+
+ Service service = build(service()
+ .setServiceInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setServiceData(build(serviceData()
+ .setServiceLevelOperStatus(build(serviceLevelOperStatus()
+ .setOrderStatus(OrderStatus.Created)
+ .setModifyTimestamp(Instant.now().toString())
+ .setLastSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setLastRpcAction(LastRpcAction.Activate)
+ .setLastOrderStatus(LastOrderStatus.PendingAssignment)
+ .setLastAction(LastAction.ActivateNetworkInstance)
+ .setCreateTimestamp(Instant.now().toString())
+ ))
+ ))
+ );
+ db.write(true, service, LogicalDatastoreType.CONFIGURATION);
+ return service;
+ }
+
+ private SecurityZoneTopologyOperationOutput createExpectedOutput(PropBuilder propBuilder,
+ SecurityZoneTopologyOperationInput input) {
+
+ return build(securityZoneTopologyOperationOutput()
+ .setSecurityZoneResponseInformation(build(securityZoneResponseInformation()
+ .setObjectPath(propBuilder.get("security-zone-object-path"))))
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+
+ private Service createExpectedService(
+ SecurityZoneTopologyOperationInput expectedInput, ServiceData expectedServiceData) {
+
+ ServiceInformation expectedServiceInformation = expectedInput.getServiceInformation();
+
+ return build(service()
+ .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
+ .setServiceData(build(serviceData()))
+ .setServiceData(expectedServiceData)
+ .setServiceStatus(build(serviceStatus()))
+ );
+ }
+
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
index 9a34c253..faacd220 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
@@ -21,13 +21,34 @@
package org.onap.sdnc.northbound;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.service;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceData;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceTopologyOperationOutput;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mockito;
import org.mockito.runners.MockitoJUnitRunner;
import org.onap.sdnc.northbound.util.PropBuilder;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
@@ -38,19 +59,6 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatus;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import static org.junit.Assert.assertEquals;
-import static org.onap.sdnc.northbound.util.MDSALUtil.build;
-import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
-import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
-import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
-import static org.onap.sdnc.northbound.util.MDSALUtil.service;
-import static org.onap.sdnc.northbound.util.MDSALUtil.serviceData;
-import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
-import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
-import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
-import static org.onap.sdnc.northbound.util.MDSALUtil.serviceTopologyOperationInput;
-import static org.onap.sdnc.northbound.util.MDSALUtil.serviceTopologyOperationOutput;
-
/**
* This class test the ServiceTopologyOperation mdsal RPC.
@@ -58,132 +66,219 @@ import static org.onap.sdnc.northbound.util.MDSALUtil.serviceTopologyOperationOu
@RunWith(MockitoJUnitRunner.class)
public class ServiceTopologyOperationRPCTest extends GenericResourceApiProviderTest {
-
final String SVC_OPERATION = "service-topology-operation";
-
@Before
public void setUp() throws Exception {
super.setUp();
svcClient.setScvOperation(SVC_OPERATION);
}
-
/**
- * Verify ServiceTopologyOperation RPC executes a DG then produces the expected
- * {@link ServiceTopologyOperationOutput} and persisted the expected {@link Service} in the {@link DataBroker}
+ * Verify ServiceTopologyOperation RPC executes a DG then produces the expected {@link
+ * ServiceTopologyOperationOutput} and persisted the expected {@link Service} in the {@link DataBroker}
*/
@Test
public void testServiceTopologyOperationRPC_ExecuteDG_Success() throws Exception {
-
//mock svcClient to perform a successful execution with the expected parameters
svcClient.mockHasGraph(true);
PropBuilder svcResultProp = svcClient.createExecuteOKResult();
svcClient.mockExecute(svcResultProp);
// create the ServiceTopologyOperationInput from the template
- ServiceTopologyOperationInput serviceTopologyOperationInput = createSTOI();
+ ServiceTopologyOperationInput input = createSTOI();
//execute the mdsal exec
- ServiceTopologyOperationOutput actualServiceTopologyOperationOutput = exec(
- genericResourceApiProvider::serviceTopologyOperation
- , serviceTopologyOperationInput
- , RpcResult::getResult
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
);
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
//verify the returned ServiceTopologyOperationOutput
- ServiceTopologyOperationOutput expectedServiceTopologyOperationOutput = createExpectedSTOO(svcResultProp,serviceTopologyOperationInput);
- assertEquals(expectedServiceTopologyOperationOutput,actualServiceTopologyOperationOutput);
-
+ ServiceTopologyOperationOutput expectedServiceTopologyOperationOutput = createExpectedSTOO(svcResultProp,
+ input);
+ assertEquals(expectedServiceTopologyOperationOutput, output);
//verify the persisted Service
- Service actualService = db.read(serviceTopologyOperationInput.getServiceInformation().getServiceInstanceId(), LogicalDatastoreType.CONFIGURATION);
+ Service actualService = db.read(input.getServiceInformation().getServiceInstanceId(),
+ LogicalDatastoreType.CONFIGURATION);
Service expectedService = createExpectedService(
- expectedServiceTopologyOperationOutput,
- serviceTopologyOperationInput,
- actualService);
- assertEquals(expectedService,actualService);
+ expectedServiceTopologyOperationOutput,
+ input,
+ actualService);
+ assertEquals(expectedService, actualService);
LOG.debug("done");
}
+ @Test
+ public void should_fail_when_service_info_not_present() throws Exception {
+ // create the ServiceTopologyOperationInput from the template
+ ServiceTopologyOperationInput input = build(
+ serviceTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("svc-request-id: xyz")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("request-id: xyz")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ )));
+
+ //execute the mdsal exec
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
+ );
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ ServiceTopologyOperationInput input = createSTOI();
+
+ //execute the mdsal exec
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
+ );
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+ svcClient.mockHasGraph(false);
+
+ ServiceTopologyOperationInput input = createSTOI();
+
+ //execute the mdsal exec
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
+ );
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
- private ServiceTopologyOperationInput createSTOI()
- {
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ ServiceTopologyOperationInput input = createSTOI();
+
+ //execute the mdsal exec
+ ServiceTopologyOperationOutput output = exec(
+ genericResourceApiProvider::serviceTopologyOperation
+ , input
+ , RpcResult::getResult
+ );
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ private ServiceTopologyOperationInput createSTOI() {
return build(
- serviceTopologyOperationInput()
- .setSdncRequestHeader(build(sdncRequestHeader()
- .setSvcRequestId("svc-request-id: xyz")
- .setSvcAction(SvcAction.Assign)
- ))
- .setRequestInformation(build(requestInformation()
- .setRequestId("request-id: xyz")
- .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
- ))
- .setServiceInformation(build(serviceInformationBuilder()
- .setServiceInstanceId("service-instance-id: xyz")
- ))
+ serviceTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("svc-request-id: xyz")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("request-id: xyz")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("service-instance-id: xyz")
+ ))
);
}
- private ServiceTopologyOperationOutput createExpectedSTOO(PropBuilder expectedSvcResultProp,ServiceTopologyOperationInput expectedServiceTopologyOperationInput){
+ private ServiceTopologyOperationOutput createExpectedSTOO(PropBuilder expectedSvcResultProp,
+ ServiceTopologyOperationInput expectedServiceTopologyOperationInput) {
return build(
- serviceTopologyOperationOutput()
- .setSvcRequestId(expectedServiceTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
- .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
- .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
- .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
- .setServiceResponseInformation(build(serviceResponseInformation()
- .setInstanceId(expectedServiceTopologyOperationInput.getServiceInformation().getServiceInstanceId())
- .setObjectPath(expectedSvcResultProp.get(svcClient.serviceObjectPath))
- ))
+ serviceTopologyOperationOutput()
+ .setSvcRequestId(expectedServiceTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
+ .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(expectedServiceTopologyOperationInput.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(expectedSvcResultProp.get(svcClient.serviceObjectPath))
+ ))
);
}
private Service createExpectedService(
- ServiceTopologyOperationOutput expectedServiceTopologyOperationOutput,
- ServiceTopologyOperationInput expectedServiceTopologyOperationInput,
- Service actualService
- ){
-
+ ServiceTopologyOperationOutput expectedServiceTopologyOperationOutput,
+ ServiceTopologyOperationInput expectedServiceTopologyOperationInput,
+ Service actualService
+ ) {
//We cannot predict the timeStamp value so just steal it from the actual
//we need this to prevent the equals method from returning false as a result of the timestamp
- String responseTimeStamp = actualService == null || actualService.getServiceStatus() == null?
- null : actualService.getServiceStatus().getResponseTimestamp();
+ String responseTimeStamp = actualService == null || actualService.getServiceStatus() == null ?
+ null : actualService.getServiceStatus().getResponseTimestamp();
SdncRequestHeader expectedSdncRequestHeader = expectedServiceTopologyOperationInput.getSdncRequestHeader();
ServiceInformation expectedServiceInformation = expectedServiceTopologyOperationInput.getServiceInformation();
RequestInformation expectedRequestInformation = expectedServiceTopologyOperationInput.getRequestInformation();
return build(
- service()
+ service()
.setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
.setServiceData(build(serviceData()))
.setServiceStatus(
- build(
- serviceStatus()
- .setAction(expectedRequestInformation.getRequestAction().name())
- .setFinalIndicator(expectedServiceTopologyOperationOutput.getAckFinalIndicator())
- .setResponseCode(expectedServiceTopologyOperationOutput.getResponseCode())
- .setResponseMessage(expectedServiceTopologyOperationOutput.getResponseMessage())
- .setRpcAction(toRpcAction(expectedSdncRequestHeader.getSvcAction()))
- .setRpcName(SVC_OPERATION)
- .setRequestStatus(ServiceStatus.RequestStatus.Synccomplete)
- .setResponseTimestamp(responseTimeStamp)
- )
+ build(
+ serviceStatus()
+ .setAction(expectedRequestInformation.getRequestAction().name())
+ .setFinalIndicator(expectedServiceTopologyOperationOutput.getAckFinalIndicator())
+ .setResponseCode(expectedServiceTopologyOperationOutput.getResponseCode())
+ .setResponseMessage(expectedServiceTopologyOperationOutput.getResponseMessage())
+ .setRpcAction(toRpcAction(expectedSdncRequestHeader.getSvcAction()))
+ .setRpcName(SVC_OPERATION)
+ .setRequestStatus(ServiceStatus.RequestStatus.Synccomplete)
+ .setResponseTimestamp(responseTimeStamp)
+ )
)
);
}
- public ServiceStatus.RpcAction toRpcAction(SvcAction fromEnum){
- return fromEnum == null? null : ServiceStatus.RpcAction.valueOf(fromEnum.name());
+ public ServiceStatus.RpcAction toRpcAction(SvcAction fromEnum) {
+ return fromEnum == null ? null : ServiceStatus.RpcAction.valueOf(fromEnum.name());
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TunnelxconnTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TunnelxconnTopologyOperationRPCTest.java
new file mode 100644
index 00000000..2e1f1cb1
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TunnelxconnTopologyOperationRPCTest.java
@@ -0,0 +1,146 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.tunnelxconnResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.tunnelxconnTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.tunnelxconnTopologyOperationOutput;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class TunnelxconnTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+
+ private static final String SVC_OPERATION = "tunnelxconn-topology-operation";
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_instance_id_not_present() throws Exception {
+
+ TunnelxconnTopologyOperationInput input = build(tunnelxconnTopologyOperationInput());
+
+ TunnelxconnTopologyOperationOutput output =
+ exec(genericResourceApiProvider::tunnelxconnTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecuteWoServiceData(new RuntimeException("test exception"));
+
+ TunnelxconnTopologyOperationInput input = build(tunnelxconnTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ TunnelxconnTopologyOperationOutput output =
+ exec(genericResourceApiProvider::tunnelxconnTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ TunnelxconnTopologyOperationInput input = build(tunnelxconnTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ TunnelxconnTopologyOperationOutput output =
+ exec(genericResourceApiProvider::tunnelxconnTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_success_when_no_errors_encountered() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcResultProp.set("security-zone-object-path", "securityZoneObjectPath: XYZ");
+ svcClient.mockExecuteWoServiceData(svcResultProp);
+
+ TunnelxconnTopologyOperationInput input = build(tunnelxconnTopologyOperationInput()
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ TunnelxconnTopologyOperationOutput output =
+ exec(genericResourceApiProvider::tunnelxconnTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ TunnelxconnTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+
+ }
+
+ private TunnelxconnTopologyOperationOutput createExpectedOutput(PropBuilder propBuilder,
+ TunnelxconnTopologyOperationInput input) {
+
+ return build(tunnelxconnTopologyOperationOutput()
+ .setTunnelxconnResponseInformation(build(tunnelxconnResponseInformation()
+ .setObjectPath(propBuilder.get("tunnelxconn-object-path"))))
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java
new file mode 100644
index 00000000..facf71d6
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java
@@ -0,0 +1,232 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vfModuleTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfInformationBuilder;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VfModuleTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+ private static final String SVC_OPERATION = "vf-module-topology-operation";
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_info_not_present() throws Exception {
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput());
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_vnf_id() throws Exception {
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals("invalid input, null or empty vnf-id", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_invalid_vf_module_id() throws Exception {
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")))
+ );
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("403", output.getResponseCode());
+ assertEquals("invalid input, vf-module-id is null or empty", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ .setVfModuleInformation(build(vfModuleInformationBuilder()
+ .setVfModuleId("test-vf-module-id")
+ ))
+ );
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ .setVfModuleInformation(build(vfModuleInformationBuilder()
+ .setVfModuleId("test-vf-module-id")
+ ))
+ );
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ .setVfModuleInformation(build(vfModuleInformationBuilder()
+ .setVfModuleId("test-vf-module-id")
+ ))
+ );
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_complete_with_success_when_no_errors() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+
+ VfModuleTopologyOperationInput input = build(vfModuleTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ .setVfModuleInformation(build(vfModuleInformationBuilder()
+ .setVfModuleId("test-vf-module-id")
+ ))
+ );
+
+ VfModuleTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vfModuleTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ VfModuleTopologyOperationOutput expectedOutput = createExpectedVMTOO(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+ }
+
+ private VfModuleTopologyOperationOutput createExpectedVMTOO(PropBuilder propBuilder,
+ VfModuleTopologyOperationInput input) {
+ return build(vfModuleTopologyOperationOutput()
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java
new file mode 100644
index 00000000..645cbf29
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java
@@ -0,0 +1,203 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyOperationOutput;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class VnfTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+ private static final String SVC_OPERATION = "vnf-topology-operation";
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_info_not_present() throws Exception {
+
+ VnfTopologyOperationInput input = build(vnfTopologyOperationInput());
+
+ VnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_vnf_id() throws Exception {
+
+ VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder().
+ setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ VnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals("invalid input, null or empty vnf-id", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ );
+
+ VnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ );
+
+ VnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ );
+
+ VnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_complete_with_success_when_no_errors() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+
+ VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ .setVnfInformation(build(vnfInformationBuilder()
+ .setVnfId("test-vnf-id")
+ ))
+ );
+
+ VnfTopologyOperationOutput output =
+ exec(genericResourceApiProvider::vnfTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ VnfTopologyOperationOutput expectedVnfTopologyOperationOutput = createExpectedOutput(svcResultProp,
+ input);
+ assertEquals(expectedVnfTopologyOperationOutput, output);
+ }
+
+ private VnfTopologyOperationOutput createExpectedOutput(PropBuilder svcResultProp,
+ VnfTopologyOperationInput vnfTopologyOperationInput) {
+ return build(
+ vnfTopologyOperationOutput()
+ .setSvcRequestId(vnfTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(svcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(svcResultProp.get(svcClient.ackFinal))
+ .setResponseMessage(svcResultProp.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(vnfTopologyOperationInput.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(svcResultProp.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java
index 2e73cce7..784717d9 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/GenericResourceApiSvcLogicServiceClientMockUtil.java
@@ -21,17 +21,16 @@
package org.onap.sdnc.northbound.util;
-import org.onap.sdnc.northbound.GenericResourceApiSvcLogicServiceClient;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
-
-import java.util.Properties;
-
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.isA;
import static org.mockito.Mockito.when;
import static org.onap.sdnc.northbound.util.MDSALUtil.build;
import static org.onap.sdnc.northbound.util.PropBuilder.propBuilder;
+import java.util.Properties;
+import org.onap.sdnc.northbound.GenericResourceApiSvcLogicServiceClient;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
+
/**
* GenericResourceApiSvcLogicServiceClientMockUtil provides a set of util methods for quickly configuring method
@@ -57,74 +56,110 @@ public class GenericResourceApiSvcLogicServiceClientMockUtil {
private final GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient;
-
- public GenericResourceApiSvcLogicServiceClientMockUtil(GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient) {
+ public GenericResourceApiSvcLogicServiceClientMockUtil(
+ GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient) {
this.mockGenericResourceApiSvcLogicServiceClient = mockGenericResourceApiSvcLogicServiceClient;
}
- /** @param scvOperation - The scvOperation parameter to use on the {@link GenericResourceApiSvcLogicServiceClient} methods */
+ /**
+ * @param scvOperation - The scvOperation parameter to use on the {@link GenericResourceApiSvcLogicServiceClient}
+ * methods
+ */
public void setScvOperation(String scvOperation) {
this.scvOperation = scvOperation;
}
/**
- * Configure {@link GenericResourceApiSvcLogicServiceClient#hasGraph(String, String, String, String)}
- * to return the specified value when when invoked with the parameters
- * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
+ * Configure {@link GenericResourceApiSvcLogicServiceClient#hasGraph(String, String, String, String)} to return the
+ * specified value when when invoked with the parameters {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link
+ * #scvOperation}
*/
public void mockHasGraph(Boolean isHasGraph) throws Exception {
when(
- mockGenericResourceApiSvcLogicServiceClient
- .hasGraph(
- eq(MODULE),
- eq(scvOperation),
- eq(VERSION),
- eq(MODE)
- )
- )
- .thenReturn(isHasGraph);
+ mockGenericResourceApiSvcLogicServiceClient
+ .hasGraph(
+ eq(MODULE),
+ eq(scvOperation),
+ eq(VERSION),
+ eq(MODE))
+ ).thenReturn(isHasGraph);
}
/**
- * @return
- * PropBuilder - A PropBuilder populated with the expected properties returned from
- * {@link GenericResourceApiSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
+ * @return PropBuilder - A PropBuilder populated with the expected properties returned from {@link
+ * GenericResourceApiSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
*/
- public PropBuilder createExecuteOKResult(){
+ public PropBuilder createExecuteOKResult() {
return propBuilder()
- .set(errorCode,"200")
- .set(errorMessage,"OK")
- .set(ackFinal,"Y")
- .set(serviceObjectPath,"serviceObjectPath: XYZ")
- .set(networkObjectPath,"networkObjectPath: XYZ")
- .set(networkId,"networkId: XYZ");
+ .set(errorCode, "200")
+ .set(errorMessage, "OK")
+ .set(ackFinal, "Y")
+ .set(serviceObjectPath, "serviceObjectPath: XYZ")
+ .set(networkObjectPath, "networkObjectPath: XYZ")
+ .set(networkId, "networkId: XYZ");
}
/**
- * Configure
- * {@link GenericResourceApiSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
- * to return the specified svcResultProp when when invoked with the parameters
+ * Configure {@link GenericResourceApiSvcLogicServiceClient#execute(String, String, String, String,
+ * ServiceDataBuilder, Properties)} to return the specified svcResultProp when when invoked with the parameters
* {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
*/
- public void mockExecute(PropBuilder svcResultProp) throws Exception{
+ public void mockExecute(PropBuilder svcResultProp) throws Exception {
+ when(
+ mockGenericResourceApiSvcLogicServiceClient
+ .execute(
+ eq(MODULE),
+ eq(scvOperation),
+ eq(VERSION),
+ eq(MODE),
+ isA(ServiceDataBuilder.class),
+ isA(Properties.class))
+ ).thenReturn(build(svcResultProp));
+ }
+
+ public void mockExecute(RuntimeException exception) throws Exception {
+ when(
+ mockGenericResourceApiSvcLogicServiceClient
+ .execute(
+ eq(MODULE),
+ eq(scvOperation),
+ eq(VERSION),
+ eq(MODE),
+ isA(ServiceDataBuilder.class),
+ isA(Properties.class)
+ )
+ ).thenThrow(exception);
+ }
+
+
+ public void mockExecuteWoServiceData(PropBuilder svcResultProp) throws Exception {
+ when(
+ mockGenericResourceApiSvcLogicServiceClient
+ .execute(
+ eq(MODULE),
+ eq(scvOperation),
+ eq(VERSION),
+ eq(MODE),
+ isA(Properties.class))
+ ).thenReturn(build(svcResultProp));
+ }
+
+ public void mockExecuteWoServiceData(RuntimeException exception) throws Exception {
when(
- mockGenericResourceApiSvcLogicServiceClient
- .execute(
- eq(MODULE),
- eq(scvOperation),
- eq(VERSION),
- eq(MODE),
- isA(ServiceDataBuilder.class),
- isA(Properties.class)
- )
- )
- .thenReturn(build(
- svcResultProp
- ));
+ mockGenericResourceApiSvcLogicServiceClient
+ .execute(
+ eq(MODULE),
+ eq(scvOperation),
+ eq(VERSION),
+ eq(MODE),
+ isA(Properties.class)
+ )
+ ).thenThrow(exception);
}
+
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
index 11610659..fd9a7f32 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
@@ -21,27 +21,53 @@
package org.onap.sdnc.northbound.util;
+import java.util.concurrent.Future;
+import java.util.function.Consumer;
+import java.util.function.Function;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVnfTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.brg.response.information.BrgResponseInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.information.NetworkInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.identifier.NetworkTopologyIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.topology.information.NetworkTopologyInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.security.zone.response.information.SecurityZoneResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.level.oper.status.ServiceLevelOperStatusBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.ServiceBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.response.information.ServiceResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatusBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.tunnelxconn.response.information.TunnelxconnResponseInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.information.VfModuleInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.information.VnfInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.identifier.VnfTopologyIdentifierBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.topology.information.VnfTopologyInformationBuilder;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.common.RpcResult;
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
/**
* This uill class provides utility to build yang objects using a recursive syntax that resembles the tree structure
@@ -70,12 +96,75 @@ import java.util.function.Function;
*/
public class MDSALUtil {
+ public static PreloadVnfTopologyOperationInputBuilder preloadVnfTopologyOperationInput() {
+ return new PreloadVnfTopologyOperationInputBuilder();
+ }
+
+ public static PreloadVnfTopologyOperationOutputBuilder preloadVnfTopologyOperationOutput() {
+ return new PreloadVnfTopologyOperationOutputBuilder();
+ }
+
+ public static PreloadNetworkTopologyOperationInputBuilder preloadNetworkTopologyOperationInput() {
+ return new PreloadNetworkTopologyOperationInputBuilder();
+ }
+
+ public static PreloadNetworkTopologyOperationOutputBuilder preloadNetworkTopologyOperationOutput() {
+ return new PreloadNetworkTopologyOperationOutputBuilder();
+ }
+
+ public static BrgTopologyOperationInputBuilder brgTopologyOperationInput() {
+ return new BrgTopologyOperationInputBuilder();
+ }
+
+ public static BrgTopologyOperationOutputBuilder brgTopologyOperationOutput() {
+ return new BrgTopologyOperationOutputBuilder();
+ }
+
+ public static TunnelxconnTopologyOperationInputBuilder tunnelxconnTopologyOperationInput() {
+ return new TunnelxconnTopologyOperationInputBuilder();
+ }
+
+ public static TunnelxconnTopologyOperationOutputBuilder tunnelxconnTopologyOperationOutput() {
+ return new TunnelxconnTopologyOperationOutputBuilder();
+ }
+
+ public static SecurityZoneTopologyOperationInputBuilder securityZoneTopologyOperationInput() {
+ return new SecurityZoneTopologyOperationInputBuilder();
+ }
+
+ public static SecurityZoneTopologyOperationOutputBuilder securityZoneTopologyOperationOutput() {
+ return new SecurityZoneTopologyOperationOutputBuilder();
+ }
+
+ public static ContrailRouteTopologyOperationInputBuilder contrailRouteTopologyOperationInput() {
+ return new ContrailRouteTopologyOperationInputBuilder();
+ }
+
+ public static ContrailRouteTopologyOperationOutputBuilder contrailRouteTopologyOperationOutput() {
+ return new ContrailRouteTopologyOperationOutputBuilder();
+ }
+
+ public static VfModuleTopologyOperationInputBuilder vfModuleTopologyOperationInput() {
+ return new VfModuleTopologyOperationInputBuilder();
+ }
+
+ public static VfModuleTopologyOperationOutputBuilder vfModuleTopologyOperationOutput() {
+ return new VfModuleTopologyOperationOutputBuilder();
+ }
+
+ public static VnfTopologyOperationInputBuilder vnfTopologyOperationInput() {
+ return new VnfTopologyOperationInputBuilder();
+ }
+
+ public static VnfTopologyOperationOutputBuilder vnfTopologyOperationOutput() {
+ return new VnfTopologyOperationOutputBuilder();
+ }
+
public static ServiceTopologyOperationInputBuilder serviceTopologyOperationInput() {
return new ServiceTopologyOperationInputBuilder();
}
-
- public static ServiceTopologyOperationOutputBuilder serviceTopologyOperationOutput(){
+ public static ServiceTopologyOperationOutputBuilder serviceTopologyOperationOutput() {
return new ServiceTopologyOperationOutputBuilder();
}
@@ -89,47 +178,107 @@ public class MDSALUtil {
return new RequestInformationBuilder();
}
- public static ServiceResponseInformationBuilder serviceResponseInformation(){
- return new ServiceResponseInformationBuilder();
+ public static ServiceResponseInformationBuilder serviceResponseInformation() {
+ return new ServiceResponseInformationBuilder();
+ }
+
+ public static SecurityZoneResponseInformationBuilder securityZoneResponseInformation() {
+ return new SecurityZoneResponseInformationBuilder();
+ }
+
+ public static TunnelxconnResponseInformationBuilder tunnelxconnResponseInformation() {
+ return new TunnelxconnResponseInformationBuilder();
+ }
+
+ public static BrgResponseInformationBuilder brgResponseInformation() {
+ return new BrgResponseInformationBuilder();
+ }
+
+ public static ContrailRouteResponseInformationBuilder contrailRouteResponseInformation() {
+ return new ContrailRouteResponseInformationBuilder();
+ }
+
+ public static VnfResponseInformationBuilder vnfResponseInformation() {
+ return new VnfResponseInformationBuilder();
}
public static ServiceInformationBuilder serviceInformationBuilder() {
- return new ServiceInformationBuilder();
+ return new ServiceInformationBuilder();
+ }
+
+ public static VnfTopologyInformationBuilder vnfTopologyInformationBuilder() {
+ return new VnfTopologyInformationBuilder();
}
+ public static NetworkTopologyInformationBuilder networkTopologyInformationBuilder() {
+ return new NetworkTopologyInformationBuilder();
+ }
- public static ServiceBuilder service(){return new ServiceBuilder();}
+ public static NetworkTopologyIdentifierBuilder networkTopologyIdentifierBuilder(){
+ return new NetworkTopologyIdentifierBuilder();
+ }
+ public static VnfTopologyIdentifierBuilder vnfTopologyIdentifierBuilder() {
+ return new VnfTopologyIdentifierBuilder();
+ }
- public static ServiceDataBuilder serviceData(){return new ServiceDataBuilder();}
+ public static VnfInformationBuilder vnfInformationBuilder() {
+ return new VnfInformationBuilder();
+ }
+ public static VfModuleInformationBuilder vfModuleInformationBuilder() {
+ return new VfModuleInformationBuilder();
+ }
- public static ServiceStatusBuilder serviceStatus(){return new ServiceStatusBuilder();}
+ public static ServiceBuilder service() {
+ return new ServiceBuilder();
+ }
- public static NetworkInformationBuilder networkInformation(){return new NetworkInformationBuilder();}
- public static NetworkTopologyOperationInputBuilder networkTopologyOperationInput() {return new NetworkTopologyOperationInputBuilder();}
+ public static ServiceDataBuilder serviceData() {
+ return new ServiceDataBuilder();
+ }
- public static NetworkTopologyOperationOutputBuilder networkTopologyOperationOutput() {return new NetworkTopologyOperationOutputBuilder();}
- public static NetworkResponseInformationBuilder networkResponseInformation(){return new NetworkResponseInformationBuilder();}
+ public static ServiceStatusBuilder serviceStatus() {
+ return new ServiceStatusBuilder();
+ }
- public static ServiceLevelOperStatusBuilder serviceLevelOperStatus() {return new ServiceLevelOperStatusBuilder();}
+ public static NetworkInformationBuilder networkInformation() {
+ return new NetworkInformationBuilder();
+ }
+
+ public static NetworkTopologyOperationInputBuilder networkTopologyOperationInput() {
+ return new NetworkTopologyOperationInputBuilder();
+ }
+
+ public static NetworkTopologyOperationOutputBuilder networkTopologyOperationOutput() {
+ return new NetworkTopologyOperationOutputBuilder();
+ }
+
+ public static NetworkResponseInformationBuilder networkResponseInformation() {
+ return new NetworkResponseInformationBuilder();
+ }
+
+ public static ServiceLevelOperStatusBuilder serviceLevelOperStatus() {
+ return new ServiceLevelOperStatusBuilder();
+ }
public static <P> P build(Builder<P> b) {
- return b == null? null :b.build();
+ return b == null ? null : b.build();
}
- public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject){
- if(sourceDataObject == null){
+ public static <P, B extends Builder<P>> P build(Function<P, B> builderConstructor, P sourceDataObject) {
+ if (sourceDataObject == null) {
return null;
}
B bp = builderConstructor.apply(sourceDataObject);
return bp.build();
}
- public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject,Consumer<B> builder){
- if(sourceDataObject == null){
+ public static <P, B extends Builder<P>> P build(Function<P, B> builderConstructor, P sourceDataObject,
+ Consumer<B> builder) {
+ if (sourceDataObject == null) {
return null;
}
B bp = builderConstructor.apply(sourceDataObject);
@@ -137,7 +286,8 @@ public class MDSALUtil {
return bp.build();
}
- public static <I,O> O exec(Function<I,Future<RpcResult<O>>> rpc,I rpcParameter,Function<RpcResult<O>,O> rpcResult) throws Exception {
+ public static <I, O> O exec(Function<I, Future<RpcResult<O>>> rpc, I rpcParameter,
+ Function<RpcResult<O>, O> rpcResult) throws Exception {
Future<RpcResult<O>> future = rpc.apply(rpcParameter);
return rpcResult.apply(future.get());
}
diff --git a/vnfapi/model/src/main/yang/VNF-API.yang b/vnfapi/model/src/main/yang/VNF-API.yang
index 9b621aa2..2648a381 100755
--- a/vnfapi/model/src/main/yang/VNF-API.yang
+++ b/vnfapi/model/src/main/yang/VNF-API.yang
@@ -1,839 +1,932 @@
-module VNF-API {
-
- yang-version 1;
-
- namespace "org:onap:sdnctl:vnf";
-
- prefix vnfapi;
-
- import ietf-inet-types { prefix "ietf"; revision-date "2010-09-24"; }
-
- include "vnfsubmodule";
-
- organization "ONAP";
-
- contact
- "Network Controller <onap-sdnc@lists.onap.org>";
-
- description
- "Defines API interface for VNF Orchestration";
-
- revision "2015-07-20" {
- description
- "Initial draft";
- }
-
- // Last updated on 8-17-2016
- grouping sdnc-request-header {
- container sdnc-request-header {
- leaf svc-request-id {
- type string;
- }
- leaf svc-action {
- type enumeration {
- enum "reserve";
- enum "assign";
- enum "activate"; // equal to commit
- enum "delete"; // equal to commit
- enum "changeassign";
- enum "changedelete";
- enum "rollback";
- }
- }
- leaf svc-notification-url {
- type string;
- }
- }
- }
-
- grouping request-information {
- container request-information {
- leaf request-id {
- type string;
- }
- leaf request-action {
- type enumeration {
- enum "PreloadNetworkRequest";
- enum "DeletePreloadNetworkRequest";
- enum "NetworkActivateRequest";
- enum "DisconnectNetworkRequest";
- enum "PreloadVNFRequest";
- enum "DeletePreloadVNFRequest";
- enum "VNFActivateRequest";
- enum "ChangeVNFActivateRequest";
- enum "DisconnectVNFRequest";
- enum "PreloadVnfInstanceRequest";
- enum "DeletePreloadVnfInstanceRequest";
- enum "VnfInstanceActivateRequest";
- enum "ChangeVnfInstanceActivateRequest";
- enum "DisconnectVnfInstanceRequest";
- enum "PreloadVfModuleRequest";
- enum "DeletePreloadVfModuleRequest";
- enum "VfModuleActivateRequest";
- enum "ChangeVfModuleActivateRequest";
- enum "DisconnectVfModuleRequest";
- }
- }
- leaf request-sub-action {
- type enumeration {
- enum "SUPP";
- enum "CANCEL";
- }
- }
- leaf source {
- type string;
- }
- leaf notification-url {
- type string;
- }
- leaf order-number {
- type string;
- }
- leaf order-version {
- type string;
- }
- }
- }
-
- grouping service-information {
- container service-information {
- // 1610 use for AnAI subscription-service-type
- leaf service-type {
- type string;
- description "AnAI subscription-service-type";
- }
- leaf service-id {
- type string;
- }
- leaf service-instance-id {
- type string;
- description "A service instance that a VNF or a l3-network is associated with";
- }
- // 1610 use for global-customer-id
- leaf subscriber-name {
- type string;
- description "AnAI global-customer-id";
- }
- }
- }
-
-
- grouping vnf-request-information {
- container vnf-request-information {
- leaf vnf-request-version {
- type string;
- }
- leaf model-customization-uuid {
- type string;
- description "customized resource, i.e. vf-module, for use within a given service";
- }
- leaf use-preload {
- type enumeration {
- enum "Y";
- enum "N";
- }
- description "orchestrate vf-module with full preload data or TOSCA lookup plus EIPAM automation";
- }
- leaf vnf-id {
- type string;
- description "vf-module-id";
- }
- leaf vnf-type {
- type string;
- description "vf-module-type";
- }
- leaf vnf-name {
- type string;
- description "vf-module-name";
- }
- leaf generic-vnf-id {
- type string;
- description "generic vnf-id";
- }
- leaf generic-vnf-type {
- type string;
- description "generic vnf type";
- }
- leaf generic-vnf-name {
- type string;
- description "generic vnf name";
- }
- leaf tenant {
- type string;
- }
- leaf aic-clli {
- type string;
- }
- leaf aic-cloud-region {
- type string;
- description "The AIC cloud region which maps to contrail versions";
- }
- list vnf-networks {
- key network-role;
- uses vnf-network;
- description "Network List";
- }
- }
- }
-
- grouping network-request-information {
- container network-request-information {
- leaf network-id {
- type string;
- }
- leaf network-type {
- type string;
- }
- leaf network-name {
- type string;
- }
- leaf tenant {
- type string;
- }
- leaf aic-clli {
- type string;
- }
- leaf aic-cloud-region {
- type string;
- description "The AIC cloud region which maps to contrail versions";
- }
- }
- }
-
- /***********************************************************/
- /* PRELOAD DATA */
- /***********************************************************/
-
- container preload-vnfs {
- uses preload-model-information;
- }
- grouping preload-model-information {
- list vnf-preload-list {
- key "vnf-name vnf-type";
- leaf vnf-name {
- type string;
- description "vf-module-name";
- }
- leaf vnf-type {
- type string;
- description "vf-module-type";
- }
- uses preload-data;
- }
- }
-
- // For preload networks it will have network-topology-information
- // For preload vnfs, it will have vnf-topology-information
- grouping preload-data {
- container preload-data {
- uses vnf-topology-information;
- uses network-topology-information;
- uses oper-status;
- }
- }
-
-
- grouping vnf-topology-information {
- container vnf-topology-information {
- uses vnf-topology-identifier;
- uses vnf-assignments;
- uses vnf-parameters;
- }
- }
-
- grouping vnf-topology-identifier {
- container vnf-topology-identifier {
- leaf service-type {
- type string;
- }
- leaf service-id {
- type string;
- }
- leaf vnf-name {
- type string;
- description "vf-module-name";
- }
- leaf vnf-type {
- type string;
- description "vf-module-type";
- }
- leaf generic-vnf-name {
- type string;
- }
- leaf generic-vnf-type {
- type string;
- }
- leaf generic-vnf-id {
- type string;
- }
- }
- }
-
- grouping vnf-assignments {
- container vnf-assignments {
- leaf vnf-status {
- type string;
- description "Orchestration Status from AAI - to be set by SDNC";
- }
- list availability-zones {
- key "availability-zone";
- ordered-by user;
- leaf availability-zone {
- type string;
- description "Openstack availability zone name or UUID";
- }
- }
- list vnf-networks {
- key network-role;
- uses vnf-network;
- // 1610
- uses sriov-vlan-filter-list;
- description "Network List";
- }
- uses vm-topology;
- }
- }
-
- grouping vm-topology {
- list vnf-vms {
- key vm-type;
- leaf vm-type {
- type string;
- }
- leaf vm-count {
- type uint8;
- }
- list vm-names {
- key "vm-name";
- ordered-by user;
- leaf vm-name {
- type string;
- }
- }
- //leaf-list vm-names {
- // type string;
- // ordered-by user;
- //}
- list vm-networks {
- key network-role;
- uses vm-network;
- description "Network List";
- }
- }
- }
-
- grouping vnf-network {
- leaf network-role {
- type string;
- description "A Network Role to which a VNF must connect";
- }
- leaf network-name {
- type string;
- description "Unique Neutron UUID of an instance of the network role ";
- }
- leaf neutron-id {
- type string;
- description "Unique Neutron UUID of an instance of the network role ";
- }
- leaf network-id {
- type string;
- description "Unique Neutron UUID of an instance of the network role ";
- }
- leaf subnet-id {
- type string;
- description "ipv4 subnet UUID to be passed into the HEAT template for DHCP assignment";
- }
- leaf contrail-network-fqdn {
- type string;
- description "contrail network policy object";
- }
- // 1610
- leaf ipv6-subnet-id {
- type string;
- description "ipv6 subnet UUID to be passed into the HEAT template for DHCP assignment";
- }
- leaf ipv6-subnet-name {
- type string;
- description "ipv6 subnet-name that corresponds to the ipv6 subnet-id";
- }
- leaf subnet-name {
- type string;
- description "ipv4 subnet-name that corresponds to the ipv4 subnet-id";
- }
- }
-
- // 1610
- grouping sriov-vlan-filter-list {
- list sriov-vlan-filter-list {
- key "sriov-vlan-filter";
- leaf sriov-vlan-filter {
- type string;
- }
- }
- }
-
- grouping vm-network {
- leaf network-role {
- type string;
- description "network (identified by role) that this VM connects to. Should also be included in the vnf-networks for the containing VNF";
-
- }
- leaf use-dhcp {
- type enumeration {
- enum "Y";
- enum "N";
- }
- description "Indicator to use DHCP on this network for this VM";
- }
- leaf ip-count {
- type uint8;
- description "The number of ip addresses to be assigned per vm for this network role";
- }
- list network-ips {
- key "ip-address";
- ordered-by user;
- leaf ip-address {
- //type string;
- type ietf:ip-address;
- description "List of assigned ipv4 addresses on a network";
- }
- }
- list network-ips-v6 {
- key "ip-address-ipv6";
- ordered-by user;
- leaf ip-address-ipv6 {
- //type string;
- type ietf:ipv6-address;
- description "List of assigned ipv6 addresses on a network";
- }
- }
- list network-macs {
- key "mac-address";
- ordered-by user;
- leaf mac-address {
- type string;
- description "List of network assignments for this VM (one per network)";
- }
- }
- leaf floating-ip {
- //type string;
- type ietf:ip-address;
- description "Floating ipv4 for VMs of a given type on this network";
- }
- leaf floating-ip-v6 {
- //type string;
- type ietf:ipv6-address;
- description "Floating ipv6 for VMs of a given type on this network";
- }
- list interface-route-prefixes {
- key "interface-route-prefix-cidr";
- ordered-by user;
- leaf interface-route-prefix {
- type ietf:ip-address;
- description "OBSOLETE, route prefixes (CIDRs) to be provided to MSO in vnf-topology as a list of static routes";
- }
- leaf interface-route-prefix-cidr {
- type string;
- description "route prefixes (CIDRs) in ip/cidr format to be provided to MSO in vnf-topology as a list of static routes";
- }
- }
- }
-
- grouping vnf-parameters {
- list vnf-parameters {
- key vnf-parameter-name;
- leaf vnf-parameter-name {
- type string;
- description "The name of an arbitrary instance-specific vnf-parameters";
- }
- leaf vnf-parameter-value {
- type string;
- description "The value of an arbitrary instance-specific vnf-parameters ";
- }
- }
- }
-
- grouping network-topology-information {
- container network-topology-information {
- uses network-topology-identifier;
- uses subnets;
- uses vpn-bindings;
- uses network-policy;
- uses route-table-reference;
- uses provider-network-information;
- }
- }
-
- grouping network-topology-identifier {
- container network-topology-identifier {
- leaf service-type {
- type string;
- }
- leaf network-name {
- type string;
- }
- leaf network-role {
- type string;
- }
- leaf network-type {
- type string;
- }
- leaf network-technology{
- type string;
- }
- }
- }
- grouping subnets {
- list subnets {
- key start-address;
- leaf start-address{
- type ietf:ip-address;
- //type string;
- }
- leaf gateway-address{
- //type string;
- type ietf:ip-address;
- }
- leaf cidr-mask{
- type string;
- }
- leaf ip-version {
- type string;
- }
- leaf dhcp-enabled {
- type enumeration {
- enum "Y";
- enum "N";
- }
- }
- leaf dhcp-start-address {
- type string;
- }
- leaf dhcp-end-address {
- type string;
- }
- // 1610
- leaf subnet-name {
- type string;
- }
-
- }
- }
-
- grouping vpn-bindings {
- list vpn-bindings {
- key vpn-binding-id;
- leaf vpn-binding-id {
- type string;
- }
- leaf global-route-target {
- type string;
- }
- }
- }
-
- grouping network-policy {
- list network-policy {
- key network-policy-fqdn;
- leaf network-policy-fqdn {
- type string;
- }
- leaf network-policy-id {
- type string;
- }
- }
- }
-
- //1610
- grouping route-table-reference {
- list route-table-reference {
- key "route-table-reference-id";
- leaf route-table-reference-id {
- type string;
- }
- leaf route-table-reference-fqdn {
- type string;
- }
- }
- }
-
- // 1610
- grouping provider-network-information {
- container provider-network-information {
- leaf physical-network-name {
- type string;
- }
- leaf is-provider-network {
- type boolean;
- }
- leaf is-shared-network {
- type boolean;
- }
- leaf is-external-network {
- type boolean;
- }
- }
- }
-
- /***********************************************************/
- /* SERVICE_DATA */
- /***********************************************************/
- container vnfs {
- uses vnf-model-infrastructure;
- }
- grouping vnf-model-infrastructure {
- list vnf-list {
- key vnf-id;
- leaf vnf-id {
- type string;
- mandatory true;
- description "vf-module-id";
- }
- uses service-data;
- uses service-status;
- }
- }
- grouping service-data {
- container service-data {
- uses vnf-configuration-information;
- uses oper-status;
- }
- }
- grouping service-status {
- container service-status {
- leaf response-code {
- type string;
- }
- leaf response-message {
- type string;
- }
- leaf final-indicator {
- type string;
- }
- leaf request-status {
- type enumeration {
- enum "synccomplete";
- enum "asynccomplete";
- enum "notifycomplete";
- }
- }
- leaf vnfsdn-action {
- type enumeration {
- enum "PreloadNetworkRequest";
- enum "DeletePreloadNetworkRequest";
- enum "NetworkActivateRequest";
- enum "DisconnectNetworkRequest";
- enum "PreloadVNFRequest";
- enum "DeletePreloadVNFRequest";
- enum "VNFActivateRequest";
- enum "ChangeVNFActivateRequest";
- enum "DisconnectVNFRequest";
- enum "PreloadVnfInstanceRequest";
- enum "DeletePreloadVnfInstanceRequest";
- enum "VnfInstanceActivateRequest";
- enum "ChangeVnfInstanceActivateRequest";
- enum "DisconnectVnfInstanceRequest";
- enum "PreloadVfModuleRequest";
- enum "DeletePreloadVfModuleRequest";
- enum "VfModuleActivateRequest";
- enum "ChangeVfModuleActivateRequest";
- enum "DisconnectVfModuleRequest";
- }
- }
- leaf vnfsdn-subaction {
- type enumeration {
- enum "SUPP";
- enum "CANCEL";
- }
- }
- leaf rpc-name {
- type enumeration {
- enum "vnf-topology-operation";
- enum "preload-vnf-topology-operation";
- enum "vnf-instance-topology-operation";
- enum "preload-vnf-instance-topology-operation";
- enum "vf-module-topology-operation";
- enum "preload-vf-module-topology-operation";
- }
- }
- leaf rpc-action {
- type enumeration {
- enum "reserve";
- enum "assign";
- enum "activate"; // equal to commit
- enum "delete"; // equal to commit
- enum "changeassign";
- enum "changedelete";
- enum "rollback";
- }
- }
- leaf response-timestamp {
- type string;
- }
- }
- }
- grouping vnf-configuration-information {
- uses sdnc-request-header;
- uses request-information;
- uses service-information;
- uses vnf-request-information;
- uses vnf-topology;
- }
- grouping vnf-topology-response-body {
- leaf svc-request-id {
- type string;
- }
- leaf response-code {
- type string;
- }
- leaf response-message {
- type string;
- }
- leaf ack-final-indicator {
- type string;
- }
- }
-
- grouping vnf-information {
- container vnf-information {
- leaf vnf-service-type {
- type string;
- }
- leaf vnf-id {
- type string;
- description "vf-module-id";
- }
- }
- }
-
- grouping network-information {
- container network-information {
- leaf network-service-type {
- type string;
- }
- leaf network-id {
- type string;
- }
- }
- }
-
-
- // Carried over from l3sdn and potentially not needed
- grouping oper-status {
- container oper-status {
- leaf order-status {
- type enumeration {
- enum "Active";
- enum "PendingAssignment";
- enum "PendingCreate";
- enum "PendingUpdate";
- enum "PendingDelete";
- enum "Deleted";
-
- }
- }
- leaf last-action {
- type enumeration {
- enum "VNFActivateRequest";
- enum "ChangeVNFActivateRequest";
- enum "VnfInstanceActivateRequest";
- enum "ChangeVnfInstanceActivateRequest";
- enum "VfModuleActivateRequest";
- enum "ChangeVfModuleActivateRequest";
- enum "DisconnectVNFRequest";
- enum "DisconnectVnfInstanceRequest";
- enum "DisconnectVfModuleRequest";
- enum "PreloadVNFRequest";
- enum "DeletePreloadVNFRequest";
- enum "PreloadVnfInstanceRequest";
- enum "DeletePreloadVnfInstanceRequest";
- enum "PreloadVfModuleRequest";
- enum "DeletePreloadVfModuleRequest";
- }
- }
- leaf last-svc-request-id {
- type string;
- }
- leaf last-order-status {
- type enumeration {
- enum "Active";
- enum "PendingAssignment";
- enum "PendingCreate";
- enum "PendingUpdate";
- enum "PendingDelete";
- enum "Deleted";
- }
- }
- leaf create-timestamp {
- type string;
- }
- leaf modify-timestamp {
- type string;
- }
- leaf maintenance-indicator {
- type enumeration {
- enum "Y";
- enum "N";
- }
- }
- }
- }
- grouping vnf-topology {
- leaf vnf-id {
- type string;
- description "vf-module-id";
- }
- uses vnf-topology-information;
- }
-
-
- rpc vnf-topology-operation {
- input {
- uses sdnc-request-header;
- uses request-information;
- uses service-information;
- uses vnf-request-information;
- }
- output {
- uses vnf-topology-response-body;
- uses vnf-information;
- uses service-information;
- }
- }
-
- rpc network-topology-operation {
- input {
- uses sdnc-request-header;
- uses request-information;
- uses service-information;
- uses network-request-information;
- }
- output {
- uses vnf-topology-response-body;
- uses network-information;
- uses service-information;
- }
- }
-
- rpc preload-vnf-topology-operation {
- input {
- uses sdnc-request-header;
- uses request-information;
- uses vnf-topology-information;
- }
- output {
- uses vnf-topology-response-body;
- }
- }
-
- rpc preload-network-topology-operation {
- input {
- uses sdnc-request-header;
- uses request-information;
- uses network-topology-information;
- }
- output {
- uses vnf-topology-response-body;
- }
- }
-}
+module VNF-API {
+
+ yang-version 1;
+
+ namespace "org:onap:sdnctl:vnf";
+
+ prefix vnfapi;
+
+ import ietf-inet-types { prefix "ietf"; revision-date "2010-09-24"; }
+
+ include "vnfsubmodule";
+
+ organization "ONAP";
+
+ contact
+ "Network Controller <onap-sdnc@lists.onap.org>";
+
+ description
+ "Defines API interface for VNF Orchestration";
+
+ revision "2015-07-20" {
+ description
+ "Initial draft";
+ }
+ // Last updated on 8-17-2016
+ grouping sdnc-request-header {
+ container sdnc-request-header {
+ leaf svc-request-id {
+ type string;
+ }
+ leaf svc-action {
+ type enumeration {
+ enum "reserve";
+ enum "assign";
+ enum "activate"; // equal to commit
+ enum "delete"; // equal to commit
+ enum "changeassign";
+ enum "changedelete";
+ enum "rollback";
+ }
+ }
+ leaf svc-notification-url {
+ type string;
+ }
+ }
+ }
+
+ grouping request-information {
+ container request-information {
+ leaf request-id {
+ type string;
+ }
+ leaf request-action {
+ type enumeration {
+ enum "PreloadNetworkRequest";
+ enum "DeletePreloadNetworkRequest";
+ enum "NetworkActivateRequest";
+ enum "DisconnectNetworkRequest";
+ enum "PreloadVNFRequest";
+ enum "DeletePreloadVNFRequest";
+ enum "VNFActivateRequest";
+ enum "ChangeVNFActivateRequest";
+ enum "DisconnectVNFRequest";
+ enum "PreloadVnfInstanceRequest";
+ enum "DeletePreloadVnfInstanceRequest";
+ enum "VnfInstanceActivateRequest";
+ enum "ChangeVnfInstanceActivateRequest";
+ enum "DisconnectVnfInstanceRequest";
+ enum "PreloadVfModuleRequest";
+ enum "DeletePreloadVfModuleRequest";
+ enum "VfModuleActivateRequest";
+ enum "ChangeVfModuleActivateRequest";
+ enum "DisconnectVfModuleRequest";
+ }
+ }
+ leaf request-sub-action {
+ type enumeration {
+ enum "SUPP";
+ enum "CANCEL";
+ enum "RetainResource";
+ }
+ }
+ leaf source {
+ type string;
+ }
+ leaf notification-url {
+ type string;
+ }
+ leaf order-number {
+ type string;
+ }
+ leaf order-version {
+ type string;
+ }
+ }
+ }
+
+ grouping service-information {
+ container service-information {
+ leaf service-type {
+ type string;
+ description "AnAI subscription-service-type";
+ }
+ leaf service-id {
+ type string;
+ }
+ leaf service-instance-id {
+ type string;
+ description "A service instance that a VNF or a l3-network is associated with";
+ }
+ leaf subscriber-name {
+ type string;
+ description "AnAI global-customer-id";
+ }
+ }
+ }
+
+
+ grouping vnf-request-information {
+ container vnf-request-information {
+ leaf vnf-request-version {
+ type string;
+ }
+ leaf model-customization-uuid {
+ type string;
+ description "customized resource, i.e. vf-module, for use within a given service";
+ }
+ leaf use-preload {
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ description "orchestrate vf-module with full preload data or TOSCA lookup plus EIPAM automation";
+ }
+ leaf vnf-id {
+ type string;
+ description "vf-module-id";
+ }
+ leaf vnf-type {
+ type string;
+ description "vf-module-type";
+ }
+ leaf vnf-name {
+ type string;
+ description "vf-module-name";
+ }
+ leaf generic-vnf-id {
+ type string;
+ description "generic vnf-id";
+ }
+ leaf generic-vnf-type {
+ type string;
+ description "generic vnf type";
+ }
+ leaf generic-vnf-name {
+ type string;
+ description "generic vnf name";
+ }
+ leaf tenant {
+ type string;
+ }
+ leaf aic-clli {
+ type string;
+ }
+ leaf aic-cloud-region {
+ type string;
+ description "The AIC cloud region which maps to contrail versions";
+ }
+ list vnf-networks {
+ key network-role;
+ uses vnf-network;
+ description "Network List";
+ }
+ }
+ }
+
+ grouping network-request-information {
+ container network-request-information {
+ leaf network-id {
+ type string;
+ }
+ leaf network-type {
+ type string;
+ }
+ leaf network-name {
+ type string;
+ }
+ leaf tenant {
+ type string;
+ }
+ leaf aic-clli {
+ type string;
+ }
+ leaf aic-cloud-region {
+ type string;
+ description "The AIC cloud region which maps to contrail versions";
+ }
+ }
+ }
+
+ /***********************************************************/
+ /* PRELOAD DATA */
+ /***********************************************************/
+
+ container preload-vnfs {
+ uses preload-model-information;
+ }
+ grouping preload-model-information {
+ list vnf-preload-list {
+ key "vnf-name vnf-type";
+ leaf vnf-name {
+ type string;
+ description "vf-module-name";
+ }
+ leaf vnf-type {
+ type string;
+ description "vf-module-type";
+ }
+ uses preload-data;
+ }
+ }
+
+ // For preload networks it will have network-topology-information
+ // For preload vnfs, it will have vnf-topology-information
+ grouping preload-data {
+ container preload-data {
+ uses vnf-topology-information;
+ uses network-topology-information;
+ uses oper-status;
+ }
+ }
+
+
+ grouping vnf-topology-information {
+ container vnf-topology-information {
+ uses vnf-topology-identifier;
+ uses vnf-assignments;
+ uses vnf-parameters;
+ }
+ }
+
+ grouping vnf-topology-identifier {
+ container vnf-topology-identifier {
+ leaf service-type {
+ type string;
+ }
+ leaf service-id {
+ type string;
+ }
+ leaf vnf-name {
+ type string;
+ description "vf-module-name";
+ }
+ leaf vnf-type {
+ type string;
+ description "vf-module-type";
+ }
+ leaf generic-vnf-name {
+ type string;
+ }
+ leaf generic-vnf-type {
+ type string;
+ }
+ leaf generic-vnf-id {
+ type string;
+ }
+ }
+ }
+
+ grouping vnf-assignments {
+ container vnf-assignments {
+ leaf vnf-status {
+ type string;
+ description "Orchestration Status from AAI - to be set by SDNC";
+ }
+ list availability-zones {
+ key "availability-zone";
+ ordered-by user;
+ leaf availability-zone {
+ type string;
+ description "Openstack availability zone name or UUID";
+ }
+ }
+ list vnf-networks {
+ key network-role;
+ uses vnf-network;
+ uses sriov-vlan-filter-list;
+ description "Network List";
+ }
+ uses vm-topology;
+ }
+ }
+
+ grouping vm-topology {
+ list vnf-vms {
+ key vm-type;
+ leaf vm-type {
+ type string;
+ }
+ leaf vm-count {
+ type uint8;
+ }
+ list vm-names {
+ ordered-by user;
+ key "vm-name";
+ leaf vm-name {
+ type string;
+ }
+ list vnfc-names {
+ ordered-by user;
+ key "vnfc-name";
+ leaf vnfc-name {
+ type string;
+ }
+ list vnfc-networks {
+ key vnfc-network-role;
+ uses vnfc-network;
+ }
+ }
+ }
+ list vm-networks {
+ key network-role;
+ uses vm-network;
+ description "Network List";
+ }
+ }
+ }
+
+ grouping vnfc-network {
+ leaf vnfc-network-role {
+ type string;
+ }
+ list vnfc-subnets {
+ key "vnfc-subnet-role";
+ leaf vnfc-subnet-role {
+ type string;
+ }
+ list vnfc-ipassignments {
+ key "vnfc-address-family";
+ leaf vnfc-address-family {
+ description "Subnet Version tells if this is IpV4 or IpV6";
+ type enumeration {
+ enum "ipv4";
+ enum "ipv6";
+ }
+ }
+ leaf vnfc-subnet-dhcp {
+ description "Indicator to use DHCP on this network for this VNFC. Unless dhcp=N, we wouldnt have any address, since they would not be sdnc assigned ";
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
+ leaf vnfc-subnet-ipcount {
+ description "The number of ip addresses to be assigned per vnfc for this subnet role";
+ type uint8;
+ }
+ list vnfc-subnet-ips {
+ key "vnfc-client-key";
+ leaf vnfc-client-key {
+ type string;
+ }
+ leaf ip-type {
+ description "Capture what type of IP this is, if is virtual IP (AKA, floating IP) or Fixed IP. ";
+ type enumeration {
+ enum "FIXED";
+ enum "VIP";
+ }
+ }
+ leaf vnfc-address-ipv4 {
+ description "Either IpV4 IP addresses or IpV6 IP addresses should be present, but not both within one VnfcVersion. ";
+ type inet:ip-address;
+ }
+ leaf vnfc-address-ipv6 {
+ description "Either IpV4 IP addresses or IpV6 IP addresses should be present, but not both within one VnfcVersion.";
+ type inet:ipv6-address;
+ }
+ }
+ }
+ }
+ }
+
+ grouping vnf-network {
+ leaf network-role {
+ type string;
+ description "A Network Role to which a VNF must connect";
+ }
+ leaf network-role-tag {
+ type string;
+ description "The network-role that maps to the HEAT parameter {network-role}_net_id";
+ }
+ leaf network-name {
+ type string;
+ description "Unique Neutron UUID of an instance of the network role ";
+ }
+ leaf neutron-id {
+ type string;
+ description "Unique Neutron UUID of an instance of the network role ";
+ }
+ leaf network-id {
+ type string;
+ description "Unique Neutron UUID of an instance of the network role ";
+ }
+ leaf subnet-id {
+ type string;
+ description "ipv4 subnet UUID to be passed into the HEAT template for DHCP assignment";
+ }
+ leaf contrail-network-fqdn {
+ type string;
+ description "contrail network policy object";
+ }
+ leaf ipv6-subnet-id {
+ type string;
+ description "ipv6 subnet UUID to be passed into the HEAT template for DHCP assignment";
+ }
+ leaf ipv6-subnet-name {
+ type string;
+ description "ipv6 subnet-name that corresponds to the ipv6 subnet-id";
+ }
+ leaf subnet-name {
+ type string;
+ description "ipv4 subnet-name that corresponds to the ipv4 subnet-id";
+ }
+ leaf ipv4-key-subnet-id {
+ description "Unique SDN-C generated UUID of the ipv4 subnet.Key into A&AI instance.";
+ type string;
+ }
+ leaf ipv6-key-subnet-id {
+ description "Unique SDN-C generated UUID of the ipv6 subnet.Key into A&AI instance.";
+ type string;
+ }
+ leaf subnet-role {
+ type string;
+ }
+ }
+
+ grouping sriov-vlan-filter-list {
+ list sriov-vlan-filter-list {
+ key "sriov-vlan-filter";
+ leaf sriov-vlan-filter {
+ type string;
+ }
+ }
+ }
+
+ grouping vm-network {
+ leaf network-role {
+ type string;
+ description "network (identified by role) that this VM connects to. Should also be included in the vnf-networks for the containing VNF";
+ }
+ leaf network-role-tag {
+ type string;
+ description "The network-role that maps to the HEAT parameter {network-role}_net_id";
+ }
+ leaf use-dhcp {
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ description "Indicator to use DHCP on this network for this VM";
+ }
+ leaf ip-count {
+ type uint8;
+ description "The number of ip addresses to be assigned per vm for this network role";
+ }
+ leaf ip-count-ipv6 {
+ type uint8;
+ description "The number of ipv6 addresses to be assigned per vm for this network role";
+ }
+ list network-ips {
+ ordered-by user;
+ key ip-address;
+ leaf ip-address {
+ type ietf:ip-address;
+ description "List of assigned ipv4 addresses on a network";
+ }
+ }
+ list network-ips-v6 {
+ ordered-by user;
+ key ip-address-ipv6;
+ leaf ip-address-ipv6 {
+ type ietf:ipv6-address;
+ description "List of assigned ipv6 addresses on a network";
+ }
+ }
+ list network-macs {
+ ordered-by user;
+ key mac-address;
+ leaf mac-address {
+ type string;
+ description "List of network assignments for this VM (one per network)";
+ }
+ }
+ leaf floating-ip {
+ type ietf:ip-address;
+ description "Floating ipv4 for VMs of a given type on this network";
+ }
+ leaf floating-ip-v6 {
+ type ietf:ipv6-address;
+ description "Floating ipv6 for VMs of a given type on this network";
+ }
+ list interface-route-prefixes {
+ ordered-by user;
+ key interface-route-prefix;
+ leaf interface-route-prefix {
+ type ietf:ip-address;
+ description "OBSOLETE, route prefixes (CIDRs) to be provided to MSO in vnf-topology as a list of static routes";
+ }
+ leaf interface-route-prefix-cidr {
+ type string;
+ description "route prefixes (CIDRs) in ip/cidr format to be provided to MSO in vnf-topology as a list of static routes";
+ }
+ }
+ }
+
+ grouping vnf-parameters {
+ list vnf-parameters {
+ key vnf-parameter-name;
+ leaf vnf-parameter-name {
+ type string;
+ description "The name of an arbitrary instance-specific vnf-parameters";
+ }
+ leaf vnf-parameter-value {
+ type string;
+ description "The value of an arbitrary instance-specific vnf-parameters ";
+ }
+ }
+ }
+
+ grouping network-topology-information {
+ container network-topology-information {
+ uses network-topology-identifier;
+ uses subnets;
+ uses vpn-bindings;
+ uses network-policy;
+ uses route-table-reference;
+ uses provider-network-information;
+ }
+ }
+
+ grouping network-topology-identifier {
+ container network-topology-identifier {
+ leaf service-type {
+ type string;
+ }
+ leaf network-name {
+ type string;
+ }
+ leaf network-role {
+ type string;
+ }
+ leaf network-type {
+ type string;
+ }
+ leaf network-technology{
+ type string;
+ }
+ }
+ }
+ grouping subnets {
+ list subnets {
+ key start-address;
+ leaf start-address{
+ type ietf:ip-address;
+ }
+ leaf gateway-address{
+ type ietf:ip-address;
+ }
+ leaf cidr-mask{
+ type string;
+ }
+ leaf ip-version {
+ type string;
+ }
+ leaf dhcp-enabled {
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
+ leaf dhcp-start-address {
+ type string;
+ }
+ leaf dhcp-end-address {
+ type string;
+ }
+ leaf subnet-name {
+ type string;
+ }
+ leaf addr-from-start {
+ description "Default is N";
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
+ leaf subnet-role {
+ type string;
+ }
+ uses host-routes;
+ }
+ }
+
+ grouping vpn-bindings {
+ list vpn-bindings {
+ key vpn-binding-id;
+ leaf vpn-binding-id {
+ type string;
+ }
+ leaf global-route-target {
+ type string;
+ }
+ }
+ }
+
+ grouping network-policy {
+ list network-policy {
+ key network-policy-fqdn;
+ leaf network-policy-fqdn {
+ type string;
+ }
+ leaf network-policy-id {
+ type string;
+ }
+ }
+ }
+
+ grouping route-table-reference {
+ list route-table-reference {
+ key "route-table-reference-id";
+ leaf route-table-reference-id {
+ type string;
+ }
+ leaf route-table-reference-fqdn {
+ type string;
+ }
+ }
+ }
+
+ grouping provider-network-information {
+ container provider-network-information {
+ leaf physical-network-name {
+ type string;
+ }
+ leaf is-provider-network {
+ type boolean;
+ }
+ leaf is-shared-network {
+ type boolean;
+ }
+ leaf is-external-network {
+ type boolean;
+ }
+ }
+ }
+
+ grouping host-routes {
+ list host-routes {
+ key "route-prefix";
+ leaf route-prefix {
+ type string;
+ }
+ leaf next-hop {
+ description "Could be ip-address or hostname or service-instance";
+ type string;
+ }
+ }
+ }
+
+ /***********************************************************/
+ /* SERVICE_DATA */
+ /***********************************************************/
+ container vnfs {
+ uses vnf-model-infrastructure;
+ }
+ grouping vnf-model-infrastructure {
+ list vnf-list {
+ key vnf-id;
+ leaf vnf-id {
+ type string;
+ mandatory true;
+ description "vf-module-id";
+ }
+ uses service-data;
+ uses service-status;
+ }
+ }
+ grouping service-data {
+ container service-data {
+ uses vnf-configuration-information;
+ uses oper-status;
+ }
+ }
+ grouping service-status {
+ container service-status {
+ leaf response-code {
+ type string;
+ }
+ leaf response-message {
+ type string;
+ }
+ leaf final-indicator {
+ type string;
+ }
+ leaf request-status {
+ type enumeration {
+ enum "synccomplete";
+ enum "asynccomplete";
+ enum "notifycomplete";
+ }
+ }
+ leaf vnfsdn-action {
+ type enumeration {
+ enum "PreloadNetworkRequest";
+ enum "DeletePreloadNetworkRequest";
+ enum "NetworkActivateRequest";
+ enum "DisconnectNetworkRequest";
+ enum "PreloadVNFRequest";
+ enum "DeletePreloadVNFRequest";
+ enum "VNFActivateRequest";
+ enum "ChangeVNFActivateRequest";
+ enum "DisconnectVNFRequest";
+ enum "PreloadVnfInstanceRequest";
+ enum "DeletePreloadVnfInstanceRequest";
+ enum "VnfInstanceActivateRequest";
+ enum "ChangeVnfInstanceActivateRequest";
+ enum "DisconnectVnfInstanceRequest";
+ enum "PreloadVfModuleRequest";
+ enum "DeletePreloadVfModuleRequest";
+ enum "VfModuleActivateRequest";
+ enum "ChangeVfModuleActivateRequest";
+ enum "DisconnectVfModuleRequest";
+ }
+ }
+ leaf vnfsdn-subaction {
+ type enumeration {
+ enum "SUPP";
+ enum "CANCEL";
+ enum "RetainResource";
+ }
+ }
+ leaf rpc-name {
+ type enumeration {
+ enum "vnf-topology-operation";
+ enum "preload-vnf-topology-operation";
+ enum "vnf-instance-topology-operation";
+ enum "preload-vnf-instance-topology-operation";
+ enum "vf-module-topology-operation";
+ enum "preload-vf-module-topology-operation";
+ }
+ }
+ leaf rpc-action {
+ type enumeration {
+ enum "reserve";
+ enum "assign";
+ enum "activate"; // equal to commit
+ enum "delete"; // equal to commit
+ enum "changeassign";
+ enum "changedelete";
+ enum "rollback";
+ }
+ }
+ leaf response-timestamp {
+ type string;
+ }
+ }
+ }
+ grouping vnf-configuration-information {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses vnf-request-information;
+ uses vnf-topology;
+ }
+ grouping vnf-topology-response-body {
+ leaf svc-request-id {
+ type string;
+ }
+ leaf response-code {
+ type string;
+ }
+ leaf response-message {
+ type string;
+ }
+ leaf ack-final-indicator {
+ type string;
+ }
+ }
+
+ grouping vnf-information {
+ container vnf-information {
+ leaf vnf-service-type {
+ type string;
+ }
+ leaf vnf-id {
+ type string;
+ description "vf-module-id";
+ }
+ }
+ }
+
+ grouping network-information {
+ container network-information {
+ leaf network-service-type {
+ type string;
+ }
+ leaf network-id {
+ type string;
+ }
+ }
+ }
+
+
+ // Carried over from l3sdn and potentially not needed
+ grouping oper-status {
+ container oper-status {
+ leaf order-status {
+ type enumeration {
+ enum "Active";
+ enum "PendingAssignment";
+ enum "PendingCreate";
+ enum "PendingUpdate";
+ enum "PendingDelete";
+ enum "Deleted";
+
+ }
+ }
+ leaf last-action {
+ type enumeration {
+ enum "VNFActivateRequest";
+ enum "ChangeVNFActivateRequest";
+ enum "VnfInstanceActivateRequest";
+ enum "ChangeVnfInstanceActivateRequest";
+ enum "VfModuleActivateRequest";
+ enum "ChangeVfModuleActivateRequest";
+ enum "DisconnectVNFRequest";
+ enum "DisconnectVnfInstanceRequest";
+ enum "DisconnectVfModuleRequest";
+ enum "PreloadVNFRequest";
+ enum "DeletePreloadVNFRequest";
+ enum "PreloadVnfInstanceRequest";
+ enum "DeletePreloadVnfInstanceRequest";
+ enum "PreloadVfModuleRequest";
+ enum "DeletePreloadVfModuleRequest";
+ }
+ }
+ leaf last-svc-request-id {
+ type string;
+ }
+ leaf last-order-status {
+ type enumeration {
+ enum "Active";
+ enum "PendingAssignment";
+ enum "PendingCreate";
+ enum "PendingUpdate";
+ enum "PendingDelete";
+ enum "Deleted";
+ }
+ }
+ leaf create-timestamp {
+ type string;
+ }
+ leaf modify-timestamp {
+ type string;
+ }
+ leaf maintenance-indicator {
+ type enumeration {
+ enum "Y";
+ enum "N";
+ }
+ }
+ }
+ }
+ grouping vnf-topology {
+ leaf vnf-id {
+ type string;
+ description "vf-module-id";
+ }
+ uses vnf-topology-information;
+ }
+
+
+ rpc vnf-topology-operation {
+ input {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses vnf-request-information;
+ }
+ output {
+ uses vnf-topology-response-body;
+ uses vnf-information;
+ uses service-information;
+ }
+ }
+
+ rpc network-topology-operation {
+ input {
+ uses sdnc-request-header;
+ uses request-information;
+ uses service-information;
+ uses network-request-information;
+ }
+ output {
+ uses vnf-topology-response-body;
+ uses network-information;
+ uses service-information;
+ }
+ }
+
+ rpc preload-vnf-topology-operation {
+ input {
+ uses sdnc-request-header;
+ uses request-information;
+ uses vnf-topology-information;
+ }
+ output {
+ uses vnf-topology-response-body;
+ }
+ }
+
+ rpc preload-network-topology-operation {
+ input {
+ uses sdnc-request-header;
+ uses request-information;
+ uses network-topology-information;
+ }
+ output {
+ uses vnf-topology-response-body;
+ }
+ }
+}