summaryrefslogtreecommitdiffstats
path: root/vnfapi/provider/src
diff options
context:
space:
mode:
authorHao Kuang <haok@amdocs.com>2017-10-16 12:22:15 -0400
committerHao Kuang <Hao.Kuang@amdocs.com>2017-10-16 12:26:25 -0400
commitf6688de2b3f487c631f06659bfd41a662780e57f (patch)
tree0715dc66cdb25b71bbae4335f6ab2b8b6a84e5d9 /vnfapi/provider/src
parent4728eada855f9162030f5b46a2513e3dbffa757c (diff)
Add junit test for vnfapiProvider
(1) added junit test for vnf apiProvider (2) formatted vnfapiProvider via using ONAP java code formatter (3) added license for VnfSdnUtilTest Issue-Id: SDNC-123 Change-Id: Ia0a12003a97331ae790224df14012b48d99af7d5 Signed-off-by: Hao Kuang <Hao.Kuang@amdocs.com>
Diffstat (limited to 'vnfapi/provider/src')
-rw-r--r--vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java1597
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java20
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/vnfapiProviderTest.java1509
3 files changed, 2283 insertions, 843 deletions
diff --git a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java
index f64cb0be..a94d5e3b 100644
--- a/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java
+++ b/vnfapi/provider/src/main/java/org/onap/sdnc/vnfapi/vnfapiProvider.java
@@ -21,19 +21,14 @@
package org.onap.sdnc.vnfapi;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Properties;
-import java.util.TimeZone;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.SettableFuture;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
@@ -41,7 +36,6 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.OptimisticLockFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationInput;
import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationInputBuilder;
@@ -141,52 +135,48 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.FutureCallback;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.SettableFuture;
-
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.Properties;
+import java.util.TimeZone;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
/**
* 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 initialization / clean up methods.
- *
*/
-
-public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeListener{
-
- private final Logger log = LoggerFactory.getLogger( vnfapiProvider.class );
- private final String appName = "vnfapi";
- private final ExecutorService executor;
-
-
- private ListenerRegistration<DataChangeListener> dclServices;
-
+public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeListener {
protected DataBroker dataBroker;
protected NotificationPublishService notificationService;
protected RpcProviderRegistry rpcRegistry;
protected BindingAwareBroker.RpcRegistration<VNFAPIService> rpcRegistration;
- private VNFSDNSvcLogicServiceClient svcLogicClient;
-
+ private final Logger log = LoggerFactory.getLogger(vnfapiProvider.class);
+ private final String appName = "vnfapi";
+ private final ExecutorService executor;
+ private VNFSDNSvcLogicServiceClient svcLogicClient;
+ private ListenerRegistration<DataChangeListener> dclServices;
public vnfapiProvider(DataBroker dataBroker2, NotificationPublishService notificationPublishService,
- RpcProviderRegistry rpcProviderRegistry, VNFSDNSvcLogicServiceClient client) {
- this.log.info( "Creating provider for " + appName );
+ RpcProviderRegistry rpcProviderRegistry, VNFSDNSvcLogicServiceClient client) {
+ this.log.info("Creating provider for " + appName);
executor = Executors.newFixedThreadPool(1);
dataBroker = dataBroker2;
notificationService = notificationPublishService;
rpcRegistry = rpcProviderRegistry;
this.svcLogicClient = client;
initialize();
-
}
- public void initialize(){
- log.info( "Initializing provider for " + appName );
+ public void initialize() {
+ log.info("Initializing provider for " + appName);
// Create the top level containers
createContainers();
try {
@@ -194,49 +184,46 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
} catch (Exception e) {
log.error("Caught Exception while trying to load properties file: ", e);
}
- // rpcRegistration = rpcRegistry.addRpcImplementation(VNFAPIService.class, this);
- log.info( "Initialization complete for " + appName );
+ log.info("Initialization complete for " + appName);
}
private void createContainers() {
final WriteTransaction t = dataBroker.newReadWriteTransaction();
// Create the Vnfs container
- t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Vnfs.class),
- new VnfsBuilder().build());
- t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Vnfs.class),
- new VnfsBuilder().build());
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Vnfs.class), new VnfsBuilder().build());
+ t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Vnfs.class), new VnfsBuilder().build());
// Create the PreloadVnfs container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadVnfs.class),
- new PreloadVnfsBuilder().build());
+ new PreloadVnfsBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadVnfs.class),
- new PreloadVnfsBuilder().build());
+ new PreloadVnfsBuilder().build());
// 1610 Create the PreloadVnfInstances container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadVnfInstances.class),
- new PreloadVnfInstancesBuilder().build());
+ new PreloadVnfInstancesBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadVnfInstances.class),
- new PreloadVnfInstancesBuilder().build());
+ new PreloadVnfInstancesBuilder().build());
// 1610 Create the VnfInstances container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(VnfInstances.class),
- new VnfInstancesBuilder().build());
+ new VnfInstancesBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(VnfInstances.class),
- new VnfInstancesBuilder().build());
+ new VnfInstancesBuilder().build());
// 1610 Create the PreloadVfModules container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadVfModules.class),
- new PreloadVfModulesBuilder().build());
+ new PreloadVfModulesBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadVfModules.class),
- new PreloadVfModulesBuilder().build());
+ new PreloadVfModulesBuilder().build());
// 1610 Create the VfModules container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(VfModules.class),
- new VfModulesBuilder().build());
+ new VfModulesBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(VfModules.class),
- new VfModulesBuilder().build());
+ new VfModulesBuilder().build());
try {
CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
@@ -248,38 +235,26 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
}
-
-
- protected void initializeChild() {
- //Override if you have custom initialization intelligence
- }
-
- @Override
- public void close() throws Exception {
- log.info( "Closing provider for " + appName );
+ @Override public void close() throws Exception {
+ log.info("Closing provider for " + appName);
executor.shutdown();
rpcRegistration.close();
- // dclServices.close();
- log.info( "Successfully closed provider for " + appName );
+ log.info("Successfully closed provider for " + appName);
}
// On data change not used
- @Override
- public void onDataChanged(
- AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
+ @Override public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
boolean changed = false;
log.info(" IN ON DATA CHANGE: ");
- WriteTransaction writeTransaction = dataBroker
- .newWriteOnlyTransaction();
+ WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
DataObject updatedSubTree = change.getUpdatedSubtree();
if (updatedSubTree != null) {
- if (log.isDebugEnabled())
- {
+ if (log.isDebugEnabled()) {
log.debug("updatedSubTree was non-null:" + updatedSubTree);
}
- if ( updatedSubTree instanceof Vnfs ) {
+ if (updatedSubTree instanceof Vnfs) {
ArrayList<VnfList> vnfList = (ArrayList<VnfList>) ((Vnfs) updatedSubTree).getVnfList();
if (vnfList != null) {
for (VnfList entry : vnfList) {
@@ -289,9 +264,9 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//
// ServiceData change detected, check the AckFinal indicator and request-status to see if we need to proceed.
//
- if ((! "Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete.equals(serviceStatus.getRequestStatus()))) {
- if (log.isDebugEnabled())
- {
+ if ((!"Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete
+ .equals(serviceStatus.getRequestStatus()))) {
+ if (log.isDebugEnabled()) {
log.debug("Final Indicator is not Y, calling handleServiceDataUpdated");
}
//handleServiceDataUpdated(serviceData, serviceStatus, writeTransaction);
@@ -301,54 +276,48 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
}
}
- if ( updatedSubTree instanceof PreloadVnfs ) {
- ArrayList<VnfPreloadList> vnfList = (ArrayList<VnfPreloadList>) ((PreloadVnfs) updatedSubTree).getVnfPreloadList();
+ if (updatedSubTree instanceof PreloadVnfs) {
+ ArrayList<VnfPreloadList> vnfList =
+ (ArrayList<VnfPreloadList>) ((PreloadVnfs) updatedSubTree).getVnfPreloadList();
if (vnfList != null) {
for (VnfPreloadList entry : vnfList) {
PreloadData preloadData = entry.getPreloadData();
- if (preloadData != null ) {
- //
- // PreloadData change detected
- //
- // handlePreloadDataUpdated(preloadData, writeTransaction);
+ if (preloadData != null) {
changed = true;
}
}
}
}
//1610
- if ( updatedSubTree instanceof PreloadVnfInstances ) {
- ArrayList<VnfInstancePreloadList> vnfInstanceList = (ArrayList<VnfInstancePreloadList>) ((PreloadVnfInstances) updatedSubTree).getVnfInstancePreloadList();
+ if (updatedSubTree instanceof PreloadVnfInstances) {
+ ArrayList<VnfInstancePreloadList> vnfInstanceList =
+ (ArrayList<VnfInstancePreloadList>) ((PreloadVnfInstances) updatedSubTree)
+ .getVnfInstancePreloadList();
if (vnfInstanceList != null) {
for (VnfInstancePreloadList entry : vnfInstanceList) {
VnfInstancePreloadData vnfInstancePreloadData = entry.getVnfInstancePreloadData();
- if (vnfInstancePreloadData != null ) {
- //
- // PreloadData change detected
- //
- // handlePreloadDataUpdated(preloadData, writeTransaction);
+ if (vnfInstancePreloadData != null) {
changed = true;
}
}
}
}
//1610
- if ( updatedSubTree instanceof VnfInstances ) {
- ArrayList<VnfInstanceList> vnfInstanceList = (ArrayList<VnfInstanceList>) ((VnfInstances) updatedSubTree).getVnfInstanceList();
+ if (updatedSubTree instanceof VnfInstances) {
+ ArrayList<VnfInstanceList> vnfInstanceList =
+ (ArrayList<VnfInstanceList>) ((VnfInstances) updatedSubTree).getVnfInstanceList();
if (vnfInstanceList != null) {
for (VnfInstanceList entry : vnfInstanceList) {
VnfInstanceServiceData vnfInstanceServiceData = entry.getVnfInstanceServiceData();
ServiceStatus serviceStatus = entry.getServiceStatus();
if (vnfInstanceServiceData != null && serviceStatus != null) {
- //
- // VnfInstanceServiceData change detected, check the AckFinal indicator and request-status to see if we need to proceed.
- //
- if ((! "Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete.equals(serviceStatus.getRequestStatus()))) {
- if (log.isDebugEnabled())
- {
+ // VnfInstanceServiceData change detected, check the AckFinal indicator and request-status
+ // to see if we need to proceed.
+ if ((!"Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete
+ .equals(serviceStatus.getRequestStatus()))) {
+ if (log.isDebugEnabled()) {
log.debug("Final Indicator is not Y, calling handleServiceDataUpdated");
}
- //handleServiceDataUpdated(serviceData, serviceStatus, writeTransaction);
changed = true;
}
}
@@ -356,38 +325,34 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
}
//1610
- if ( updatedSubTree instanceof PreloadVfModules ) {
- ArrayList<VfModulePreloadList> vnfInstanceList = (ArrayList<VfModulePreloadList>) ((PreloadVfModules) updatedSubTree).getVfModulePreloadList();
+ if (updatedSubTree instanceof PreloadVfModules) {
+ ArrayList<VfModulePreloadList> vnfInstanceList =
+ (ArrayList<VfModulePreloadList>) ((PreloadVfModules) updatedSubTree).getVfModulePreloadList();
if (vnfInstanceList != null) {
for (VfModulePreloadList entry : vnfInstanceList) {
VfModulePreloadData vnfInstancePreloadData = entry.getVfModulePreloadData();
- if (vnfInstancePreloadData != null ) {
- //
- // PreloadData change detected
- //
- // handlePreloadDataUpdated(preloadData, writeTransaction);
+ if (vnfInstancePreloadData != null) {
changed = true;
}
}
}
}
//1610
- if ( updatedSubTree instanceof VfModules ) {
- ArrayList<VfModuleList> vfModuleList = (ArrayList<VfModuleList>) ((VfModules) updatedSubTree).getVfModuleList();
+ if (updatedSubTree instanceof VfModules) {
+ ArrayList<VfModuleList> vfModuleList =
+ (ArrayList<VfModuleList>) ((VfModules) updatedSubTree).getVfModuleList();
if (vfModuleList != null) {
for (VfModuleList entry : vfModuleList) {
VfModuleServiceData vfModuleServiceData = entry.getVfModuleServiceData();
ServiceStatus serviceStatus = entry.getServiceStatus();
if (vfModuleServiceData != null && serviceStatus != null) {
- //
- // VfModuleServiceData change detected, check the AckFinal indicator and request-status to see if we need to proceed.
- //
- if ((! "Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete.equals(serviceStatus.getRequestStatus()))) {
- if (log.isDebugEnabled())
- {
+ // VfModuleServiceData change detected, check the AckFinal indicator and request-status to
+ // see if we need to proceed.
+ if ((!"Y".equals(serviceStatus.getFinalIndicator())) && (RequestStatus.Synccomplete
+ .equals(serviceStatus.getRequestStatus()))) {
+ if (log.isDebugEnabled()) {
log.debug("Final Indicator is not Y, calling handleServiceDataUpdated");
}
- //handleServiceDataUpdated(serviceData, serviceStatus, writeTransaction);
changed = true;
}
}
@@ -397,174 +362,158 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
// Do the write transaction only if something changed.
if (changed) {
- CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = writeTransaction
- .submit();
+ CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = writeTransaction.submit();
Futures.addCallback(checkedFuture, new FutureCallback<Void>() {
- @Override
- public void onSuccess(Void arg0) {
+ @Override public void onSuccess(Void arg0) {
log.debug("Successfully updated Service Status");
}
- @Override
- public void onFailure(Throwable ex) {
- log.debug(
- "Failed updating Service Status",
- ex);
+ @Override public void onFailure(Throwable ex) {
+ log.debug("Failed updating Service Status", ex);
}
}, executor);
}
}
- private static class Iso8601Util
- {
+ private static class Iso8601Util {
private static TimeZone tz = TimeZone.getTimeZone("UTC");
private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
- static
- {
+ static {
df.setTimeZone(tz);
}
- private static String now()
- {
+ private static String now() {
return df.format(new Date());
}
}
- private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, String errorCode, String errorMessage, String ackFinal)
- {
+ private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, String errorCode, String errorMessage,
+ String ackFinal) {
serviceStatusBuilder.setResponseCode(errorCode);
serviceStatusBuilder.setResponseMessage(errorMessage);
serviceStatusBuilder.setFinalIndicator(ackFinal);
serviceStatusBuilder.setResponseTimestamp(Iso8601Util.now());
}
- private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, RequestInformation requestInformation)
- {
+ private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, RequestInformation requestInformation) {
if (requestInformation != null && requestInformation.getRequestAction() != null) {
- switch (requestInformation.getRequestAction())
- {
- case VNFActivateRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.VNFActivateRequest);
- break;
- case ChangeVNFActivateRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.ChangeVNFActivateRequest);
- break;
- case DisconnectVNFRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DisconnectVNFRequest);
- break;
- case PreloadVNFRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.PreloadVNFRequest);
- break;
- case DeletePreloadVNFRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DeletePreloadVNFRequest);
- break;
- // 1610 vnf-instance Requests
- case VnfInstanceActivateRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.VnfInstanceActivateRequest);
- break;
- case ChangeVnfInstanceActivateRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.ChangeVnfInstanceActivateRequest);
- break;
- case DisconnectVnfInstanceRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DisconnectVnfInstanceRequest);
- break;
- case PreloadVnfInstanceRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.PreloadVnfInstanceRequest);
- break;
- // 1610 vf-module Requests
- case VfModuleActivateRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.VfModuleActivateRequest);
- break;
- case ChangeVfModuleActivateRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.ChangeVfModuleActivateRequest);
- break;
- case DisconnectVfModuleRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DisconnectVfModuleRequest);
- break;
- case PreloadVfModuleRequest:
- serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.PreloadVfModuleRequest);
- break;
- default:
- log.error("Unknown RequestAction: " + requestInformation.getRequestAction() );
- break;
+ switch (requestInformation.getRequestAction()) {
+ case VNFActivateRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.VNFActivateRequest);
+ break;
+ case ChangeVNFActivateRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.ChangeVNFActivateRequest);
+ break;
+ case DisconnectVNFRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DisconnectVNFRequest);
+ break;
+ case PreloadVNFRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.PreloadVNFRequest);
+ break;
+ case DeletePreloadVNFRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DeletePreloadVNFRequest);
+ break;
+ // 1610 vnf-instance Requests
+ case VnfInstanceActivateRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.VnfInstanceActivateRequest);
+ break;
+ case ChangeVnfInstanceActivateRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.ChangeVnfInstanceActivateRequest);
+ break;
+ case DisconnectVnfInstanceRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DisconnectVnfInstanceRequest);
+ break;
+ case PreloadVnfInstanceRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.PreloadVnfInstanceRequest);
+ break;
+ // 1610 vf-module Requests
+ case VfModuleActivateRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.VfModuleActivateRequest);
+ break;
+ case ChangeVfModuleActivateRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.ChangeVfModuleActivateRequest);
+ break;
+ case DisconnectVfModuleRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.DisconnectVfModuleRequest);
+ break;
+ case PreloadVfModuleRequest:
+ serviceStatusBuilder.setVnfsdnAction(VnfsdnAction.PreloadVfModuleRequest);
+ break;
+ default:
+ log.error("Unknown RequestAction: " + requestInformation.getRequestAction());
+ break;
}
}
if (requestInformation != null && requestInformation.getRequestSubAction() != null) {
- switch (requestInformation.getRequestSubAction())
- {
- case SUPP:
- serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.SUPP);
- break;
- case CANCEL:
- serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.CANCEL);
- break;
- default:
- log.error("Unknown RequestSubAction: " + requestInformation.getRequestSubAction() );
- break;
+ switch (requestInformation.getRequestSubAction()) {
+ case SUPP:
+ serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.SUPP);
+ break;
+ case CANCEL:
+ serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.CANCEL);
+ break;
+ default:
+ log.error("Unknown RequestSubAction: " + requestInformation.getRequestSubAction());
+ break;
}
}
}
- private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, SdncRequestHeader requestHeader)
- {
+ private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, SdncRequestHeader requestHeader) {
if (requestHeader != null && requestHeader.getSvcAction() != null) {
- switch (requestHeader.getSvcAction())
- {
- case Reserve:
- serviceStatusBuilder.setRpcAction(RpcAction.Reserve);
- break;
- case Activate:
- serviceStatusBuilder.setRpcAction(RpcAction.Activate);
- break;
- case Assign:
- serviceStatusBuilder.setRpcAction(RpcAction.Assign);
- break;
- case Delete:
- serviceStatusBuilder.setRpcAction(RpcAction.Delete);
- break;
- case Changeassign:
- serviceStatusBuilder.setRpcAction(RpcAction.Changeassign);
- break;
- case Changedelete:
- serviceStatusBuilder.setRpcAction(RpcAction.Changedelete);
- break;
- case Rollback:
- serviceStatusBuilder.setRpcAction(RpcAction.Rollback);
- break;
- default:
- log.error("Unknown SvcAction: " + requestHeader.getSvcAction() );
- break;
+ switch (requestHeader.getSvcAction()) {
+ case Reserve:
+ serviceStatusBuilder.setRpcAction(RpcAction.Reserve);
+ break;
+ case Activate:
+ serviceStatusBuilder.setRpcAction(RpcAction.Activate);
+ break;
+ case Assign:
+ serviceStatusBuilder.setRpcAction(RpcAction.Assign);
+ break;
+ case Delete:
+ serviceStatusBuilder.setRpcAction(RpcAction.Delete);
+ break;
+ case Changeassign:
+ serviceStatusBuilder.setRpcAction(RpcAction.Changeassign);
+ break;
+ case Changedelete:
+ serviceStatusBuilder.setRpcAction(RpcAction.Changedelete);
+ break;
+ case Rollback:
+ serviceStatusBuilder.setRpcAction(RpcAction.Rollback);
+ break;
+ default:
+ log.error("Unknown SvcAction: " + requestHeader.getSvcAction());
+ break;
}
}
}
- private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder)
- {
+ private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder) {
// default to config
- getServiceData(siid,serviceDataBuilder,LogicalDatastoreType.CONFIGURATION);
+ getServiceData(siid, serviceDataBuilder, LogicalDatastoreType.CONFIGURATION);
}
- private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder, LogicalDatastoreType type)
- {
+ private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder, LogicalDatastoreType type) {
// See if any data exists yet for this siid, if so grab it.
InstanceIdentifier serviceInstanceIdentifier =
- InstanceIdentifier.<Vnfs>builder(Vnfs.class)
- .child(VnfList.class, new VnfListKey(siid)).build();
+ InstanceIdentifier.<Vnfs>builder(Vnfs.class).child(VnfList.class, new VnfListKey(siid)).build();
ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<VnfList> data = null;
try {
data = (Optional<VnfList>) readTx.read(type, serviceInstanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ("+type+") for ["+siid+"] " ,e);
+ log.error("Caught Exception reading MD-SAL (" + type + ") for [" + siid + "] ", e);
}
if (data != null && data.isPresent()) {
ServiceData serviceData = (ServiceData) data.get().getServiceData();
if (serviceData != null) {
- log.info("Read MD-SAL ("+type+") data for ["+siid+"] ServiceData: " + serviceData);
+ log.info("Read MD-SAL (" + type + ") data for [" + siid + "] ServiceData: " + serviceData);
serviceDataBuilder.setSdncRequestHeader(serviceData.getSdncRequestHeader());
serviceDataBuilder.setRequestInformation(serviceData.getRequestInformation());
serviceDataBuilder.setServiceInformation(serviceData.getServiceInformation());
@@ -573,209 +522,222 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
serviceDataBuilder.setVnfTopologyInformation(serviceData.getVnfTopologyInformation());
serviceDataBuilder.setOperStatus(serviceData.getOperStatus());
} else {
- log.info("No service-data found in MD-SAL ("+type+") for ["+siid+"] ");
+ log.info("No service-data found in MD-SAL (" + type + ") for [" + siid + "] ");
}
} else {
- log.info("No data found in MD-SAL ("+type+") for ["+siid+"] ");
+ log.info("No data found in MD-SAL (" + type + ") for [" + siid + "] ");
}
}
//1610 vnf-instance
- private void getVnfInstanceServiceData(String siid, VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder)
- {
+ private void getVnfInstanceServiceData(String siid, VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder) {
// default to config
- getVnfInstanceServiceData(siid,vnfInstanceServiceDataBuilder,LogicalDatastoreType.CONFIGURATION);
+ getVnfInstanceServiceData(siid, vnfInstanceServiceDataBuilder, LogicalDatastoreType.CONFIGURATION);
}
+
//1610 vnf-instance
- private void getVnfInstanceServiceData(String siid, VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder, LogicalDatastoreType type)
- {
+ private void getVnfInstanceServiceData(String siid, VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder,
+ LogicalDatastoreType type) {
// See if any data exists yet for this siid, if so grab it.
- InstanceIdentifier vnfInstanceIdentifier =
- InstanceIdentifier.<VnfInstances>builder(VnfInstances.class)
- .child(VnfInstanceList.class, new VnfInstanceListKey(siid)).build();
+ InstanceIdentifier vnfInstanceIdentifier = InstanceIdentifier.<VnfInstances>builder(VnfInstances.class)
+ .child(VnfInstanceList.class, new VnfInstanceListKey(siid)).build();
ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<VnfInstanceList> data = null;
try {
data = (Optional<VnfInstanceList>) readTx.read(type, vnfInstanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ("+type+") for ["+siid+"] " ,e);
+ log.error("Caught Exception reading MD-SAL (" + type + ") for [" + siid + "] ", e);
}
if (data != null && data.isPresent()) {
- VnfInstanceServiceData vnfInstanceServiceData = (VnfInstanceServiceData) data.get().getVnfInstanceServiceData();
+ VnfInstanceServiceData vnfInstanceServiceData =
+ (VnfInstanceServiceData) data.get().getVnfInstanceServiceData();
if (vnfInstanceServiceData != null) {
- log.info("Read MD-SAL ("+type+") data for ["+siid+"] VnfInstanceServiceData: " + vnfInstanceServiceData);
+ log.info("Read MD-SAL (" + type + ") data for [" + siid + "] VnfInstanceServiceData: "
+ + vnfInstanceServiceData);
vnfInstanceServiceDataBuilder.setSdncRequestHeader(vnfInstanceServiceData.getSdncRequestHeader());
vnfInstanceServiceDataBuilder.setRequestInformation(vnfInstanceServiceData.getRequestInformation());
vnfInstanceServiceDataBuilder.setServiceInformation(vnfInstanceServiceData.getServiceInformation());
- vnfInstanceServiceDataBuilder.setVnfInstanceRequestInformation(vnfInstanceServiceData.getVnfInstanceRequestInformation());
+ vnfInstanceServiceDataBuilder
+ .setVnfInstanceRequestInformation(vnfInstanceServiceData.getVnfInstanceRequestInformation());
vnfInstanceServiceDataBuilder.setVnfInstanceId(vnfInstanceServiceData.getVnfInstanceId());
- vnfInstanceServiceDataBuilder.setVnfInstanceTopologyInformation(vnfInstanceServiceData.getVnfInstanceTopologyInformation());
+ vnfInstanceServiceDataBuilder
+ .setVnfInstanceTopologyInformation(vnfInstanceServiceData.getVnfInstanceTopologyInformation());
vnfInstanceServiceDataBuilder.setOperStatus(vnfInstanceServiceData.getOperStatus());
} else {
- log.info("No vnf-instance-service-data found in MD-SAL ("+type+") for ["+siid+"] ");
+ log.info("No vnf-instance-service-data found in MD-SAL (" + type + ") for [" + siid + "] ");
}
} else {
- log.info("No data found in MD-SAL ("+type+") for ["+siid+"] ");
+ log.info("No data found in MD-SAL (" + type + ") for [" + siid + "] ");
}
}
//1610 vf-module
- private void getVfModuleServiceData(String siid, VfModuleServiceDataBuilder vfModuleServiceDataBuilder)
- {
+ private void getVfModuleServiceData(String siid, VfModuleServiceDataBuilder vfModuleServiceDataBuilder) {
// default to config
- getVfModuleServiceData(siid,vfModuleServiceDataBuilder,LogicalDatastoreType.CONFIGURATION);
+ getVfModuleServiceData(siid, vfModuleServiceDataBuilder, LogicalDatastoreType.CONFIGURATION);
}
+
//1610 vf-module
- private void getVfModuleServiceData(String siid, VfModuleServiceDataBuilder vfModuleServiceDataBuilder, LogicalDatastoreType type)
- {
+ private void getVfModuleServiceData(String siid, VfModuleServiceDataBuilder vfModuleServiceDataBuilder,
+ LogicalDatastoreType type) {
// See if any data exists yet for this siid, if so grab it.
InstanceIdentifier vfModuleIdentifier =
- InstanceIdentifier.<VfModules>builder(VfModules.class)
- .child(VfModuleList.class, new VfModuleListKey(siid)).build();
+ InstanceIdentifier.<VfModules>builder(VfModules.class).child(VfModuleList.class, new VfModuleListKey(siid))
+ .build();
ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<VfModuleList> data = null;
try {
data = (Optional<VfModuleList>) readTx.read(type, vfModuleIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ("+type+") for ["+siid+"] " ,e);
+ log.error("Caught Exception reading MD-SAL (" + type + ") for [" + siid + "] ", e);
}
if (data != null && data.isPresent()) {
- VfModuleServiceData vfModuleServiceData = (VfModuleServiceData) data.get().getVfModuleServiceData();
+ VfModuleServiceData vfModuleServiceData = data.get().getVfModuleServiceData();
if (vfModuleServiceData != null) {
- log.info("Read MD-SAL ("+type+") data for ["+siid+"] VfModuleServiceData: " + vfModuleServiceData);
+ log.info(
+ "Read MD-SAL (" + type + ") data for [" + siid + "] VfModuleServiceData: " + vfModuleServiceData);
vfModuleServiceDataBuilder.setSdncRequestHeader(vfModuleServiceData.getSdncRequestHeader());
vfModuleServiceDataBuilder.setRequestInformation(vfModuleServiceData.getRequestInformation());
vfModuleServiceDataBuilder.setServiceInformation(vfModuleServiceData.getServiceInformation());
- vfModuleServiceDataBuilder.setVfModuleRequestInformation(vfModuleServiceData.getVfModuleRequestInformation());
+ vfModuleServiceDataBuilder
+ .setVfModuleRequestInformation(vfModuleServiceData.getVfModuleRequestInformation());
vfModuleServiceDataBuilder.setVfModuleId(vfModuleServiceData.getVfModuleId());
- vfModuleServiceDataBuilder.setVfModuleTopologyInformation(vfModuleServiceData.getVfModuleTopologyInformation());
+ vfModuleServiceDataBuilder
+ .setVfModuleTopologyInformation(vfModuleServiceData.getVfModuleTopologyInformation());
vfModuleServiceDataBuilder.setOperStatus(vfModuleServiceData.getOperStatus());
} else {
- log.info("No vf-module-service-data found in MD-SAL ("+type+") for ["+siid+"] ");
+ log.info("No vf-module-service-data found in MD-SAL (" + type + ") for [" + siid + "] ");
}
} else {
- log.info("No data found in MD-SAL ("+type+") for ["+siid+"] ");
+ log.info("No data found in MD-SAL (" + type + ") for [" + siid + "] ");
}
}
- private void getPreloadData(String vnf_name, String vnf_type, PreloadDataBuilder preloadDataBuilder)
- {
+ private void getPreloadData(String vnf_name, String vnf_type, PreloadDataBuilder preloadDataBuilder) {
// default to config
- getPreloadData(vnf_name, vnf_type ,preloadDataBuilder,LogicalDatastoreType.CONFIGURATION);
+ getPreloadData(vnf_name, vnf_type, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
}
- private void getPreloadData(String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type)
- {
+ private void getPreloadData(String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder,
+ LogicalDatastoreType type) {
// See if any data exists yet for this name/type, if so grab it.
- InstanceIdentifier preloadInstanceIdentifier =
- InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class)
- .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).build();
+ InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class)
+ .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).build();
ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<VnfPreloadList> data = null;
try {
data = (Optional<VnfPreloadList>) readTx.read(type, preloadInstanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] " ,e);
+ log.error("Caught Exception reading MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ",
+ e);
}
if (data != null && data.isPresent()) {
PreloadData preloadData = (PreloadData) data.get().getPreloadData();
if (preloadData != null) {
- log.info("Read MD-SAL ("+type+") data for ["+preload_name+","+preload_type+"] PreloadData: " + preloadData);
+ log.info("Read MD-SAL (" + type + ") data for [" + preload_name + "," + preload_type + "] PreloadData: "
+ + preloadData);
preloadDataBuilder.setVnfTopologyInformation(preloadData.getVnfTopologyInformation());
preloadDataBuilder.setNetworkTopologyInformation(preloadData.getNetworkTopologyInformation());
preloadDataBuilder.setOperStatus(preloadData.getOperStatus());
} else {
- log.info("No preload-data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+ log.info(
+ "No preload-data found in MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ");
}
} else {
- log.info("No data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+ log.info("No data found in MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ");
}
}
//1610 preload-vnf-instance
- private void getVnfInstancePreloadData(String vnf_name, String vnf_type, VnfInstancePreloadDataBuilder preloadDataBuilder)
- {
+ private void getVnfInstancePreloadData(String vnf_name, String vnf_type,
+ VnfInstancePreloadDataBuilder preloadDataBuilder) {
// default to config
- getVnfInstancePreloadData(vnf_name, vnf_type ,preloadDataBuilder,LogicalDatastoreType.CONFIGURATION);
+ getVnfInstancePreloadData(vnf_name, vnf_type, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
}
//1610 preload-vnf-instance
- private void getVnfInstancePreloadData(String preload_name, String preload_type, VnfInstancePreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type)
- {
+ private void getVnfInstancePreloadData(String preload_name, String preload_type,
+ VnfInstancePreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type) {
// See if any data exists yet for this name/type, if so grab it.
InstanceIdentifier preloadInstanceIdentifier =
- InstanceIdentifier.<PreloadVnfInstances>builder(PreloadVnfInstances.class)
+ InstanceIdentifier.<PreloadVnfInstances>builder(PreloadVnfInstances.class)
.child(VnfInstancePreloadList.class, new VnfInstancePreloadListKey(preload_name, preload_type)).build();
ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<VnfInstancePreloadList> data = null;
try {
data = (Optional<VnfInstancePreloadList>) readTx.read(type, preloadInstanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] " ,e);
+ log.error("Caught Exception reading MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ",
+ e);
}
if (data != null && data.isPresent()) {
VnfInstancePreloadData preloadData = (VnfInstancePreloadData) data.get().getVnfInstancePreloadData();
if (preloadData != null) {
- log.info("Read MD-SAL ("+type+") data for ["+preload_name+","+preload_type+"] VnfInstancePreloadData: " + preloadData);
+ log.info("Read MD-SAL (" + type + ") data for [" + preload_name + "," + preload_type
+ + "] VnfInstancePreloadData: " + preloadData);
preloadDataBuilder.setVnfInstanceTopologyInformation(preloadData.getVnfInstanceTopologyInformation());
preloadDataBuilder.setOperStatus(preloadData.getOperStatus());
} else {
- log.info("No vnf-instance-preload-data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+ log.info("No vnf-instance-preload-data found in MD-SAL (" + type + ") for [" + preload_name + ","
+ + preload_type + "] ");
}
} else {
- log.info("No data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+ log.info("No data found in MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ");
}
}
// 1610 preload-vf-module
- private void getVfModulePreloadData(String vnf_name, String vnf_type, VfModulePreloadDataBuilder preloadDataBuilder)
- {
+ private void getVfModulePreloadData(String vnf_name, String vnf_type,
+ VfModulePreloadDataBuilder preloadDataBuilder) {
// default to config
- getVfModulePreloadData(vnf_name, vnf_type ,preloadDataBuilder,LogicalDatastoreType.CONFIGURATION);
+ getVfModulePreloadData(vnf_name, vnf_type, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
}
- private void getVfModulePreloadData(String preload_name, String preload_type, VfModulePreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type)
- {
+ private void getVfModulePreloadData(String preload_name, String preload_type,
+ VfModulePreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type) {
// See if any data exists yet for this name/type, if so grab it.
InstanceIdentifier preloadInstanceIdentifier =
- InstanceIdentifier.<PreloadVfModules>builder(PreloadVfModules.class)
+ InstanceIdentifier.<PreloadVfModules>builder(PreloadVfModules.class)
.child(VfModulePreloadList.class, new VfModulePreloadListKey(preload_name, preload_type)).build();
ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
Optional<VfModulePreloadList> data = null;
try {
data = (Optional<VfModulePreloadList>) readTx.read(type, preloadInstanceIdentifier).get();
} catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] " ,e);
+ log.error("Caught Exception reading MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ",
+ e);
}
if (data != null && data.isPresent()) {
VfModulePreloadData preloadData = (VfModulePreloadData) data.get().getVfModulePreloadData();
if (preloadData != null) {
- log.info("Read MD-SAL ("+type+") data for ["+preload_name+","+preload_type+"] VfModulePreloadData: " + preloadData);
+ log.info("Read MD-SAL (" + type + ") data for [" + preload_name + "," + preload_type
+ + "] VfModulePreloadData: " + preloadData);
preloadDataBuilder.setVfModuleTopologyInformation(preloadData.getVfModuleTopologyInformation());
preloadDataBuilder.setOperStatus(preloadData.getOperStatus());
} else {
- log.info("No preload-data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+ log.info(
+ "No preload-data found in MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ");
}
} else {
- log.info("No data found in MD-SAL ("+type+") for ["+preload_name+","+preload_type+"] ");
+ log.info("No data found in MD-SAL (" + type + ") for [" + preload_name + "," + preload_type + "] ");
}
}
- private void SaveVnfList (final VnfList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException {
+ private void SaveVnfList(final VnfList entry, boolean merge, LogicalDatastoreType storeType)
+ throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VnfList> vnfListIdBuilder =
- InstanceIdentifier.<Vnfs>builder(Vnfs.class)
- .child(VnfList.class, entry.getKey());
+ InstanceIdentifier.<Vnfs>builder(Vnfs.class).child(VnfList.class, entry.getKey());
InstanceIdentifier<VnfList> path = vnfListIdBuilder.build();
int tries = 2;
- while(true) {
+ while (true) {
try {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
@@ -787,8 +749,8 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
log.debug("Update DataStore succeeded");
break;
} catch (final TransactionCommitFailedException e) {
- if(e instanceof OptimisticLockFailedException) {
- if(--tries <= 0) {
+ if (e instanceof OptimisticLockFailedException) {
+ if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
throw new IllegalStateException(e);
}
@@ -801,11 +763,11 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
}
- private void DeleteVnfList (final VnfList entry, LogicalDatastoreType storeType) throws IllegalStateException {
+
+ private void DeleteVnfList(final VnfList entry, LogicalDatastoreType storeType) throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VnfList> vnfListIdBuilder =
- InstanceIdentifier.<Vnfs>builder(Vnfs.class)
- .child(VnfList.class, entry.getKey());
+ InstanceIdentifier.<Vnfs>builder(Vnfs.class).child(VnfList.class, entry.getKey());
InstanceIdentifier<VnfList> path = vnfListIdBuilder.build();
int tries = 2;
@@ -832,15 +794,15 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
//1610 vnf-instance
- private void SaveVnfInstanceList (final VnfInstanceList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException {
+ private void SaveVnfInstanceList(final VnfInstanceList entry, boolean merge, LogicalDatastoreType storeType)
+ throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VnfInstanceList> vnfInstanceListIdBuilder =
- InstanceIdentifier.<VnfInstances>builder(VnfInstances.class)
- .child(VnfInstanceList.class, entry.getKey());
+ InstanceIdentifier.<VnfInstances>builder(VnfInstances.class).child(VnfInstanceList.class, entry.getKey());
InstanceIdentifier<VnfInstanceList> path = vnfInstanceListIdBuilder.build();
int tries = 2;
- while(true) {
+ while (true) {
try {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
@@ -852,8 +814,8 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
log.debug("Update DataStore succeeded");
break;
} catch (final TransactionCommitFailedException e) {
- if(e instanceof OptimisticLockFailedException) {
- if(--tries <= 0) {
+ if (e instanceof OptimisticLockFailedException) {
+ if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
throw new IllegalStateException(e);
}
@@ -867,15 +829,15 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
//1610 vf-module
- private void SaveVfModuleList (final VfModuleList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException {
+ private void SaveVfModuleList(final VfModuleList entry, boolean merge, LogicalDatastoreType storeType)
+ throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VfModuleList> vfModuleListIdBuilder =
- InstanceIdentifier.<VfModules>builder(VfModules.class)
- .child(VfModuleList.class, entry.getKey());
+ InstanceIdentifier.<VfModules>builder(VfModules.class).child(VfModuleList.class, entry.getKey());
InstanceIdentifier<VfModuleList> path = vfModuleListIdBuilder.build();
int tries = 2;
- while(true) {
+ while (true) {
try {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
@@ -887,8 +849,8 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
log.debug("Update DataStore succeeded");
break;
} catch (final TransactionCommitFailedException e) {
- if(e instanceof OptimisticLockFailedException) {
- if(--tries <= 0) {
+ if (e instanceof OptimisticLockFailedException) {
+ if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
throw new IllegalStateException(e);
}
@@ -901,15 +863,15 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
}
- private void SavePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException{
+ private void SavePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType)
+ throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VnfPreloadList> vnfListIdBuilder =
- InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class)
- .child(VnfPreloadList.class, entry.getKey());
+ InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class).child(VnfPreloadList.class, entry.getKey());
InstanceIdentifier<VnfPreloadList> path = vnfListIdBuilder.build();
int tries = 2;
- while(true) {
+ while (true) {
try {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
@@ -921,8 +883,8 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
log.debug("Update DataStore succeeded");
break;
} catch (final TransactionCommitFailedException e) {
- if(e instanceof OptimisticLockFailedException) {
- if(--tries <= 0) {
+ if (e instanceof OptimisticLockFailedException) {
+ if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
throw new IllegalStateException(e);
}
@@ -936,15 +898,16 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
//1610 preload vnf-instance
- private void SaveVnfInstancePreloadList(final VnfInstancePreloadList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException{
+ private void SaveVnfInstancePreloadList(final VnfInstancePreloadList entry, boolean merge,
+ LogicalDatastoreType storeType) throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VnfInstancePreloadList> vnfInstanceListIdBuilder =
- InstanceIdentifier.<PreloadVnfInstances>builder(PreloadVnfInstances.class)
+ InstanceIdentifier.<PreloadVnfInstances>builder(PreloadVnfInstances.class)
.child(VnfInstancePreloadList.class, entry.getKey());
InstanceIdentifier<VnfInstancePreloadList> path = vnfInstanceListIdBuilder.build();
int tries = 2;
- while(true) {
+ while (true) {
try {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
@@ -956,8 +919,8 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
log.debug("Update DataStore succeeded");
break;
} catch (final TransactionCommitFailedException e) {
- if(e instanceof OptimisticLockFailedException) {
- if(--tries <= 0) {
+ if (e instanceof OptimisticLockFailedException) {
+ if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
throw new IllegalStateException(e);
}
@@ -971,15 +934,16 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
//1610 preload vf-module
- private void SaveVfModulePreloadList(final VfModulePreloadList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException{
+ private void SaveVfModulePreloadList(final VfModulePreloadList entry, boolean merge, LogicalDatastoreType storeType)
+ throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that identifier
InstanceIdentifier.InstanceIdentifierBuilder<VfModulePreloadList> vfModuleListIdBuilder =
- InstanceIdentifier.<PreloadVfModules>builder(PreloadVfModules.class)
+ InstanceIdentifier.<PreloadVfModules>builder(PreloadVfModules.class)
.child(VfModulePreloadList.class, entry.getKey());
InstanceIdentifier<VfModulePreloadList> path = vfModuleListIdBuilder.build();
int tries = 2;
- while(true) {
+ while (true) {
try {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
@@ -991,8 +955,8 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
log.debug("Update DataStore succeeded");
break;
} catch (final TransactionCommitFailedException e) {
- if(e instanceof OptimisticLockFailedException) {
- if(--tries <= 0) {
+ if (e instanceof OptimisticLockFailedException) {
+ if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
throw new IllegalStateException(e);
}
@@ -1006,52 +970,51 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
}
//Save the requestId into MDC
- private void setRequestIdAsMDC(String requestId){
+ private void setRequestIdAsMDC(String requestId) {
MDC.put("RequestId", requestId);
}
//1610 vnf-instance-topology-operation
- @Override
- public Future<RpcResult<VnfInstanceTopologyOperationOutput>> vnfInstanceTopologyOperation(
- VnfInstanceTopologyOperationInput input) {
+ @Override public Future<RpcResult<VnfInstanceTopologyOperationOutput>> vnfInstanceTopologyOperation(
+ VnfInstanceTopologyOperationInput input) {
final String SVC_OPERATION = "vnf-instance-topology-operation";
VnfInstanceServiceData vnfInstanceServiceData = null;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
VnfInstanceTopologyOperationOutputBuilder responseBuilder = new VnfInstanceTopologyOperationOutputBuilder();
//if(input == null || input.getVnfInstanceRequestInformation().getVnfInstanceTopologyIdentifier().getVnfInstanceId() == null )
- if(input == null ||
- input.getVnfInstanceRequestInformation() == null ||
- input.getVnfInstanceRequestInformation().getVnfInstanceId() == null )
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vnf-instance-id");
+ if (input == null || input.getVnfInstanceRequestInformation() == null
+ || input.getVnfInstanceRequestInformation().getVnfInstanceId() == null) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty vnf-instance-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-instance-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfInstanceTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
// Grab the service instance ID from the input buffer
String viid = input.getVnfInstanceRequestInformation().getVnfInstanceId();
- String preload_name = input.getVnfInstanceRequestInformation().getVnfInstanceName();
+ String preload_name = input.getVnfInstanceRequestInformation().getVnfInstanceName();
String preload_type = input.getVnfInstanceRequestInformation().getVnfModelId();
// Make sure we have a valid viid
- if(viid == null || viid.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid vnf-instance-id");
+ if (viid == null || viid.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid vnf-instance-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-instance-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfInstanceTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1067,11 +1030,11 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Get service-data
VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder = new VnfInstanceServiceDataBuilder();
- getVnfInstanceServiceData(viid,vnfInstanceServiceDataBuilder);
+ getVnfInstanceServiceData(viid, vnfInstanceServiceDataBuilder);
// Get operational-data
VnfInstanceServiceDataBuilder operDataBuilder = new VnfInstanceServiceDataBuilder();
- getVnfInstanceServiceData(viid,operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getVnfInstanceServiceData(viid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
// Set the serviceStatus based on input
setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
@@ -1094,38 +1057,34 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// uses vnf-configuration-information;
// uses oper-status;
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+viid+"] input: " + input);
+ log.info("Adding INPUT data for " + SVC_OPERATION + " [" + viid + "] input: " + input);
VnfInstanceTopologyOperationInputBuilder inputBuilder = new VnfInstanceTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+viid+"] operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + viid + "] operational-data: " + operDataBuilder
+ .build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
- log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preload-data: " + vnfInstancePreloadDataBuilder.build());
+ log.info(
+ "Adding CONFIG data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] preload-data: "
+ + vnfInstancePreloadDataBuilder.build());
VnfSdnUtil.toProperties(parms, "vnf-instance-preload-data", vnfInstancePreloadDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", vnfInstanceServiceDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ respProps = svcLogicClient
+ .execute("VNF-API", SVC_OPERATION, null, "sync", vnfInstanceServiceDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -1133,27 +1092,23 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
-
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
}
- setServiceStatus(serviceStatusBuilder,errorCode, errorMessage, ackFinal);
+ setServiceStatus(serviceStatusBuilder, errorCode, errorMessage, ackFinal);
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(RpcName.VnfInstanceTopologyOperation);
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1161,13 +1116,14 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vnfInstanceListBuilder.setVnfInstanceId(viid);
vnfInstanceListBuilder.setServiceStatus(serviceStatusBuilder.build());
try {
- SaveVnfInstanceList (vnfInstanceListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+ SaveVnfInstanceList(vnfInstanceListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+viid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + viid + "] \n", e);
}
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+viid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + viid + "] " + responseBuilder.build());
RpcResult<VnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfInstanceTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1175,22 +1131,21 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Got success from SLI
try {
vnfInstanceServiceData = vnfInstanceServiceDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+viid+"] VnfInstanceServiceData: " + vnfInstanceServiceData);
+ log.info("Updating MD-SAL for " + SVC_OPERATION + " [" + viid + "] VnfInstanceServiceData: "
+ + vnfInstanceServiceData);
// svc-configuration-list
VnfInstanceListBuilder vnfInstanceListBuilder = new VnfInstanceListBuilder();
vnfInstanceListBuilder.setVnfInstanceServiceData(vnfInstanceServiceData);
vnfInstanceListBuilder.setVnfInstanceId(vnfInstanceServiceData.getVnfInstanceId());
//siid = vnfInstanceServiceData.getVnfInstanceId();
vnfInstanceListBuilder.setServiceStatus(serviceStatusBuilder.build());
- SaveVnfInstanceList (vnfInstanceListBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
- if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
- {
+ SaveVnfInstanceList(vnfInstanceListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) {
// Only update operational tree on Delete or Activate
- if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) ||
- input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
- {
+ if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) || input.getSdncRequestHeader()
+ .getSvcAction().equals(SvcAction.Activate)) {
log.info("Updating OPERATIONAL tree.");
- SaveVnfInstanceList (vnfInstanceListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ SaveVnfInstanceList(vnfInstanceListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
}
}
VnfInstanceInformationBuilder vnfInstanceInformationBuilder = new VnfInstanceInformationBuilder();
@@ -1198,13 +1153,14 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
responseBuilder.setVnfInstanceInformation(vnfInstanceInformationBuilder.build());
responseBuilder.setServiceInformation(vnfInstanceServiceData.getServiceInformation());
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+viid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + viid + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+viid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + viid + "] " + responseBuilder.build());
RpcResult<VnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfInstanceTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1212,23 +1168,22 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+viid+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+viid+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + viid + "] ");
+ log.info("Returned SUCCESS for " + SVC_OPERATION + " [" + viid + "] " + responseBuilder.build());
RpcResult<VnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfInstanceTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return success
return Futures.immediateFuture(rpcResult);
}
//1610 vf-module-topology-operation
- @Override
- public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation(
- VfModuleTopologyOperationInput input) {
+ @Override public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation(
+ VfModuleTopologyOperationInput input) {
final String SVC_OPERATION = "vf-module-topology-operation";
VfModuleServiceData vfModuleServiceData = null;
@@ -1236,38 +1191,38 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
VfModuleTopologyOperationOutputBuilder responseBuilder = new VfModuleTopologyOperationOutputBuilder();
// Validate vf-module-id from vf-module-request-information
- if(input == null ||
- input.getVfModuleRequestInformation() == null ||
- input.getVfModuleRequestInformation().getVfModuleId() == null)
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vf-module-id");
+ if (input == null || input.getVfModuleRequestInformation() == null
+ || input.getVfModuleRequestInformation().getVfModuleId() == null) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty vf-module-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vf-module-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
// Grab the vf-module-request-information.vf-module-id from the input buffer
- String vfid = input.getVfModuleRequestInformation().getVfModuleId();
- String preload_name = input.getVfModuleRequestInformation().getVfModuleName();
+ String vfid = input.getVfModuleRequestInformation().getVfModuleId();
+ String preload_name = input.getVfModuleRequestInformation().getVfModuleName();
String preload_type = input.getVfModuleRequestInformation().getVfModuleModelId();
// Make sure we have a valid siid
- if(vfid == null || vfid.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid vf-module-id");
+ if (vfid == null || vfid.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid vf-module-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vf-module-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1275,13 +1230,14 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// 1610 add vf-module-id to vnf-instance-list.vf-module-relationship-list
String viid = input.getVfModuleRequestInformation().getVnfInstanceId();
- if(viid == null || viid.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid vnf-instance-id");
+ if (viid == null || viid.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid vnf-instance-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-instance-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1297,11 +1253,11 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Get vf-module-service-data
VfModuleServiceDataBuilder vfModuleServiceDataBuilder = new VfModuleServiceDataBuilder();
- getVfModuleServiceData(vfid,vfModuleServiceDataBuilder);
+ getVfModuleServiceData(vfid, vfModuleServiceDataBuilder);
// Get vf-module operation-data
VfModuleServiceDataBuilder operDataBuilder = new VfModuleServiceDataBuilder();
- getVfModuleServiceData(vfid,operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getVfModuleServiceData(vfid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
// save service-data builder object for rollback
VfModuleServiceDataBuilder rb_vfModuleServiceDataBuilder = vfModuleServiceDataBuilder;
@@ -1313,7 +1269,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// vnf-instance operational-data
VnfInstanceServiceDataBuilder vnfInstanceOperDataBuilder = new VnfInstanceServiceDataBuilder();
- getVnfInstanceServiceData(viid, vnfInstanceOperDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getVnfInstanceServiceData(viid, vnfInstanceOperDataBuilder, LogicalDatastoreType.OPERATIONAL);
// save operational builder object for rollback
VnfInstanceServiceDataBuilder rb_vnfInstanceServiceDataBuilder = vnfInstanceServiceDataBuilder;
@@ -1340,44 +1296,42 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// uses vnf-configuration-information;
// uses oper-status;
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+vfid+"] input: " + input);
+ log.info("Adding INPUT data for " + SVC_OPERATION + " [" + vfid + "] input: " + input);
VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+vfid+"] vf-module operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + vfid + "] vf-module operational-data: "
+ + operDataBuilder.build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
- log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] vf-module-preload-data: " + vfModulePreloadDataBuilder.build());
+ log.info("Adding CONFIG data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] vf-module-preload-data: " + vfModulePreloadDataBuilder.build());
VnfSdnUtil.toProperties(parms, "vf-module-preload-data", vfModulePreloadDataBuilder);
- log.info("Adding vnf-instance CONFIG data for "+SVC_OPERATION+" ["+viid+"] vnf-instance-service-data: " + vnfInstanceServiceDataBuilder.build());
+ log.info("Adding vnf-instance CONFIG data for " + SVC_OPERATION + " [" + viid + "] vnf-instance-service-data: "
+ + vnfInstanceServiceDataBuilder.build());
VnfSdnUtil.toProperties(parms, "vnf-instance-service-data", vnfInstanceServiceDataBuilder);
- log.info("Adding vnf-instance OPERATIONAL data for "+SVC_OPERATION+" ["+viid+"] vnf-instance operational-data: " + vnfInstanceOperDataBuilder.build());
+ log.info("Adding vnf-instance OPERATIONAL data for " + SVC_OPERATION + " [" + viid
+ + "] vnf-instance operational-data: " + vnfInstanceOperDataBuilder.build());
VnfSdnUtil.toProperties(parms, "vnf-instance-operational-data", vnfInstanceOperDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", vfModuleServiceDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic on vf-module for "+ SVC_OPERATION, e);
+ try {
+ respProps = svcLogicClient
+ .execute("VNF-API", SVC_OPERATION, null, "sync", vfModuleServiceDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic on vf-module for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -1386,9 +1340,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
@@ -1401,11 +1353,11 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
ackFinal = respProps.getProperty("ack-final", "Y");
}
- setServiceStatus(serviceStatusBuilder,errorCode, errorMessage, ackFinal);
+ setServiceStatus(serviceStatusBuilder, errorCode, errorMessage, ackFinal);
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(RpcName.VfModuleTopologyOperation);
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1413,13 +1365,14 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vfModuleListBuilder.setVfModuleId(vfid);
vfModuleListBuilder.setServiceStatus(serviceStatusBuilder.build());
try {
- SaveVfModuleList (vfModuleListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+ SaveVfModuleList(vfModuleListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+vfid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + vfid + "] \n", e);
}
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+vfid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + vfid + "] " + responseBuilder.build());
RpcResult<VfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1428,22 +1381,21 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// save vf-module-service-data in MD-SAL
try {
vfModuleServiceData = vfModuleServiceDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+vfid+"] VfModuleServiceData: " + vfModuleServiceData);
+ log.info(
+ "Updating MD-SAL for " + SVC_OPERATION + " [" + vfid + "] VfModuleServiceData: " + vfModuleServiceData);
// vf-module-list
VfModuleListBuilder vfModuleListBuilder = new VfModuleListBuilder();
vfModuleListBuilder.setVfModuleServiceData(vfModuleServiceData);
vfModuleListBuilder.setVfModuleId(vfModuleServiceData.getVfModuleId());
//vfid = vfModuleServiceData.getVfModuleId();
vfModuleListBuilder.setServiceStatus(serviceStatusBuilder.build());
- SaveVfModuleList (vfModuleListBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
- if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
- {
+ SaveVfModuleList(vfModuleListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) {
// Only update operational tree on Delete or Activate
- if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) ||
- input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))
- {
+ if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) || input.getSdncRequestHeader()
+ .getSvcAction().equals(SvcAction.Activate)) {
log.info("Updating OPERATIONAL tree.");
- SaveVfModuleList (vfModuleListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ SaveVfModuleList(vfModuleListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
}
}
VfModuleInformationBuilder vfModuleInformationBuilder = new VfModuleInformationBuilder();
@@ -1451,13 +1403,14 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
responseBuilder.setVfModuleInformation(vfModuleInformationBuilder.build());
responseBuilder.setServiceInformation(vfModuleServiceData.getServiceInformation());
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+vfid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + vfid + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+vfid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + vfid + "] " + responseBuilder.build());
RpcResult<VfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1465,81 +1418,60 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated vf-module in MD-SAL for "+SVC_OPERATION+" ["+vfid+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+vfid+"] " + responseBuilder.build());
+ log.info("Updated vf-module in MD-SAL for " + SVC_OPERATION + " [" + vfid + "] ");
+ log.info("Returned SUCCESS for " + SVC_OPERATION + " [" + vfid + "] " + responseBuilder.build());
RpcResult<VfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return success
return Futures.immediateFuture(rpcResult);
}
@Override
- public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(
- VnfTopologyOperationInput input) {
-
+ public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
final String SVC_OPERATION = "vnf-topology-operation";
ServiceData serviceData = null;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder();
- if(input == null ||
- input.getServiceInformation() == null ||
- input.getServiceInformation().getServiceInstanceId() == null ||
- input.getServiceInformation().getServiceInstanceId().length() == 0)
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty service-instance-id");
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty service-instance-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
- if(input.getVnfRequestInformation() == null ||
- input.getVnfRequestInformation().getVnfId() == null ||
- input.getVnfRequestInformation().getVnfId().length() == 0)
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vf-module-id");
+ if (input.getVnfRequestInformation() == null || input.getVnfRequestInformation().getVnfId() == null
+ || input.getVnfRequestInformation().getVnfId().length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty vf-module-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vf-module-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
// Grab the service instance ID from the input buffer
String siid = input.getVnfRequestInformation().getVnfId();
- String preload_name = input.getVnfRequestInformation().getVnfName();
+ String preload_name = input.getVnfRequestInformation().getVnfName();
String preload_type = input.getVnfRequestInformation().getVnfType();
- /*
- // Make sure we have a valid siid
- if(siid == null || siid.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid siid");
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<VnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
- // return error
- return Futures.immediateFuture(rpcResult);
- }
- */
-
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
setRequestIdAsMDC(input.getSdncRequestHeader().getSvcRequestId());
@@ -1549,10 +1481,10 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
getPreloadData(preload_name, preload_type, preloadDataBuilder);
ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
- getServiceData(siid,serviceDataBuilder);
+ getServiceData(siid, serviceDataBuilder);
ServiceDataBuilder operDataBuilder = new ServiceDataBuilder();
- getServiceData(siid,operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
// Set the serviceStatus based on input
setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
@@ -1575,38 +1507,34 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// uses vnf-configuration-information;
// uses oper-status;
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+ log.info("Adding INPUT data for " + SVC_OPERATION + " [" + siid + "] input: " + input);
VnfTopologyOperationInputBuilder inputBuilder = new VnfTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+siid+"] operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + siid + "] operational-data: " + operDataBuilder
+ .build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
- log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preload-data: " + preloadDataBuilder.build());
+ log.info(
+ "Adding CONFIG data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] preload-data: "
+ + preloadDataBuilder.build());
VnfSdnUtil.toProperties(parms, "preload-data", preloadDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ respProps =
+ svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -1614,27 +1542,23 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
-
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
}
- setServiceStatus(serviceStatusBuilder,errorCode, errorMessage, ackFinal);
+ setServiceStatus(serviceStatusBuilder, errorCode, errorMessage, ackFinal);
serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
serviceStatusBuilder.setRpcName(RpcName.VnfTopologyOperation);
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -1642,13 +1566,13 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vnfListBuilder.setVnfId(siid);
vnfListBuilder.setServiceStatus(serviceStatusBuilder.build());
try {
- SaveVnfList (vnfListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+ SaveVnfList(vnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + siid + "] \n", e);
}
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + siid + "] " + responseBuilder.build());
RpcResult<VnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1656,26 +1580,24 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Got success from SLI
try {
serviceData = serviceDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] ServiceData: " + serviceData);
+ log.info("Updating MD-SAL for " + SVC_OPERATION + " [" + siid + "] ServiceData: " + serviceData);
// svc-configuration-list
VnfListBuilder vnfListBuilder = new VnfListBuilder();
vnfListBuilder.setServiceData(serviceData);
vnfListBuilder.setVnfId(serviceData.getVnfId());
siid = serviceData.getVnfId();
vnfListBuilder.setServiceStatus(serviceStatusBuilder.build());
- SaveVnfList (vnfListBuilder.build(), false,LogicalDatastoreType.CONFIGURATION);
- if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null)
- {
+ SaveVnfList(vnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) {
// Only update operational tree on Delete or Activate
if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
log.info("Updating OPERATIONAL tree.");
- SaveVnfList (vnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
- }
- else if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) ||
- input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Rollback)) {
- log.info("Delete OPERATIONAL tree.");
- DeleteVnfList (vnfListBuilder.build(), LogicalDatastoreType.CONFIGURATION);
- DeleteVnfList (vnfListBuilder.build(), LogicalDatastoreType.OPERATIONAL);
+ SaveVnfList(vnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ } else if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) || input
+ .getSdncRequestHeader().getSvcAction().equals(SvcAction.Rollback)) {
+ log.info("Delete OPERATIONAL tree.");
+ DeleteVnfList(vnfListBuilder.build(), LogicalDatastoreType.CONFIGURATION);
+ DeleteVnfList(vnfListBuilder.build(), LogicalDatastoreType.OPERATIONAL);
}
}
VnfInformationBuilder vnfInformationBuilder = new VnfInformationBuilder();
@@ -1683,13 +1605,13 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
responseBuilder.setVnfInformation(vnfInformationBuilder.build());
responseBuilder.setServiceInformation(serviceData.getServiceInformation());
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + siid + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + siid + "] " + responseBuilder.build());
RpcResult<VnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1697,55 +1619,53 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + siid + "] ");
+ log.info("Returned SUCCESS for " + SVC_OPERATION + " [" + siid + "] " + responseBuilder.build());
RpcResult<VnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<VnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return success
return Futures.immediateFuture(rpcResult);
}
-
- @Override
- public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
- NetworkTopologyOperationInput input) {
+ @Override public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
+ NetworkTopologyOperationInput input) {
final String SVC_OPERATION = "network-topology-operation";
ServiceData serviceData = null;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
NetworkTopologyOperationOutputBuilder responseBuilder = new NetworkTopologyOperationOutputBuilder();
- if(input == null ||
- input.getServiceInformation() == null ||
- input.getServiceInformation().getServiceInstanceId() == null ||
- input.getServiceInformation().getServiceInstanceId().length() == 0)
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty service-instance-id");
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty service-instance-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<NetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
- if(input.getNetworkRequestInformation() == null || input.getNetworkRequestInformation().getNetworkName() == null) {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty service-instance-id");
+ if (input.getNetworkRequestInformation() == null
+ || input.getNetworkRequestInformation().getNetworkName() == null) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty service-instance-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<NetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1754,26 +1674,12 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
String siid = null;
if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Assign)) {
siid = input.getNetworkRequestInformation().getNetworkName();
- }
- else {
+ } else {
siid = input.getNetworkRequestInformation().getNetworkId();
}
- String preload_name = input.getNetworkRequestInformation().getNetworkName();
+ String preload_name = input.getNetworkRequestInformation().getNetworkName();
String preload_type = input.getNetworkRequestInformation().getNetworkType();
- /*
- if(siid == null || siid.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid siid");
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<NetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
- // return error
- return Futures.immediateFuture(rpcResult);
- }
- */
-
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
setRequestIdAsMDC(input.getSdncRequestHeader().getSvcRequestId());
@@ -1782,41 +1688,26 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
getPreloadData(preload_name, preload_type, preloadDataBuilder);
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input);
+ log.info("Adding INPUT data for " + SVC_OPERATION + " [" + siid + "] input: " + input);
NetworkTopologyOperationInputBuilder inputBuilder = new NetworkTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
-/*
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+siid+"] operational-data: " + operDataBuilder.build());
- VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
-
- log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preload-data: " + preloadDataBuilder.build());
- VnfSdnUtil.toProperties(parms, "preload-data", preloadDataBuilder);
-*/
-
// Call SLI sync method
// Get SvcLogicService reference
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
String networkId = "error";
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", preloadDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ respProps =
+ svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", preloadDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -1824,32 +1715,29 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
-
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
- networkId = respProps.getProperty("networkId","0");
+ networkId = respProps.getProperty("networkId", "0");
}
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + siid + "] " + responseBuilder.build());
RpcResult<NetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1861,13 +1749,14 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
responseBuilder.setNetworkInformation(networkInformationBuilder.build());
responseBuilder.setServiceInformation(input.getServiceInformation());
} catch (IllegalStateException e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+siid+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + siid + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + siid + "] " + responseBuilder.build());
RpcResult<NetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
// return error
return Futures.immediateFuture(rpcResult);
}
@@ -1875,41 +1764,43 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+siid+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+siid+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + siid + "] ");
+ log.info("Returned SUCCESS for " + SVC_OPERATION + " [" + siid + "] " + responseBuilder.build());
RpcResult<NetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return success
return Futures.immediateFuture(rpcResult);
}
- @Override
- public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation(
- PreloadVnfTopologyOperationInput input) {
+ @Override public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation(
+ PreloadVnfTopologyOperationInput input) {
final String SVC_OPERATION = "preload-vnf-topology-operation";
PreloadData preloadData = null;
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder();
// Result from savePreloadData
final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
- if(input == null || input.getVnfTopologyInformation() == null || input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null || input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName() == null || input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType() == null) {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vnf-name and vnf-type");
+ if (input == null || input.getVnfTopologyInformation() == null
+ || input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null
+ || input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName() == null
+ || input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType() == null) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty vnf-name and vnf-type");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-name and vnf-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
@@ -1918,22 +1809,24 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
String preload_type = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType();
// Make sure we have a preload_name and preload_type
- if(preload_name == null || preload_name.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-name");
+ if (preload_name == null || preload_name.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-name");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, invalid preload-name");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
- if(preload_type == null || preload_type.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-type");
+ if (preload_type == null || preload_type.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-type");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, invalid preload-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
@@ -1947,7 +1840,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//preloadData = preloadDataBuilder.build();
PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
- getPreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getPreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
//
// setup a preload-data object builder
@@ -1961,36 +1854,29 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//
// container preload-data
// uses vnf-configuration-information;
-
-
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] input: " + input);
+ log.info(
+ "Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+preload_name+","+preload_type +"] operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] operational-data: " + operDataBuilder.build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", preloadDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ respProps =
+ svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", preloadDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -1998,24 +1884,20 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
-
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
// internalError = respProps.getProperty("internal-error", "false");
}
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
@@ -2025,22 +1907,29 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
preloadVnfListBuilder.setVnfName(preload_name);
preloadVnfListBuilder.setVnfType(preload_type);
preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] error code: '" + errorCode + "', Reason: '" + errorMessage + "'");
+ log.error(
+ "Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] error code: '"
+ + errorCode + "', Reason: '" + errorMessage + "'");
try {
- SavePreloadList (preloadVnfListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+ SavePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error(
+ "Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
}
log.debug("Sending Success rpc result due to external error");
RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
// Got success from SLI
try {
preloadData = preloadDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preloadData: " + preloadData);
+ log.info(
+ "Updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] preloadData: "
+ + preloadData);
// svc-configuration-list
VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
preloadVnfListBuilder.setVnfName(preload_name);
@@ -2048,86 +1937,94 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
preloadVnfListBuilder.setPreloadData(preloadData);
// SDNGC-989 set merge flag to false
- SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ SavePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
log.info("Updating OPERATIONAL tree.");
- SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ SavePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] "
+ + responseBuilder.build());
RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(false).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] ");
+ log.info(
+ "Returned SUCCESS for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] " + responseBuilder
+ .build());
RpcResult<PreloadVnfTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
//1610 preload-vnf-instance-topology-operation
- @Override
- public Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> preloadVnfInstanceTopologyOperation(
- PreloadVnfInstanceTopologyOperationInput input) {
+ @Override public Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> preloadVnfInstanceTopologyOperation(
+ PreloadVnfInstanceTopologyOperationInput input) {
final String SVC_OPERATION = "preload-vnf-instance-topology-operation";
VnfInstancePreloadData vnfInstancePreloadData = null;
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
- PreloadVnfInstanceTopologyOperationOutputBuilder responseBuilder = new PreloadVnfInstanceTopologyOperationOutputBuilder();
+ PreloadVnfInstanceTopologyOperationOutputBuilder responseBuilder =
+ new PreloadVnfInstanceTopologyOperationOutputBuilder();
// Result from savePreloadData
final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
- if(input == null ||
- input.getVnfInstanceTopologyInformation() == null ||
- input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfInstanceName() == null ||
- input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfModelId() == null)
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vnf-instance-name and vnf-model-id");
+ if (input == null || input.getVnfInstanceTopologyInformation() == null
+ || input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfInstanceName() == null
+ || input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfModelId() == null) {
+ log.debug("exiting " + SVC_OPERATION
+ + " because of invalid input, null or empty vnf-instance-name and vnf-model-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-instance-name and vnf-model-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Grab the name and type from the input buffer
- String preload_name = input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfInstanceName();
+ String preload_name =
+ input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfInstanceName();
String preload_type = input.getVnfInstanceTopologyInformation().getVnfInstanceIdentifiers().getVnfModelId();
// Make sure we have a preload_name and preload_type
- if(preload_name == null || preload_name.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-name");
+ if (preload_name == null || preload_name.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-name");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, invalid preload-name");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
- if(preload_type == null || preload_type.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-type");
+ if (preload_type == null || preload_type.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-type");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, invalid preload-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
@@ -2141,7 +2038,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//preloadData = preloadDataBuilder.build();
VnfInstancePreloadDataBuilder operDataBuilder = new VnfInstancePreloadDataBuilder();
- getVnfInstancePreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getVnfInstancePreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
//
// setup a preload-data object builder
@@ -2155,36 +2052,30 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//
// container preload-data
// uses vnf-configuration-information;
-
-
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] input: " + input);
- PreloadVnfInstanceTopologyOperationInputBuilder inputBuilder = new PreloadVnfInstanceTopologyOperationInputBuilder(input);
+ log.info(
+ "Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
+ PreloadVnfInstanceTopologyOperationInputBuilder inputBuilder =
+ new PreloadVnfInstanceTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+preload_name+","+preload_type +"] operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] operational-data: " + operDataBuilder.build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", vnfInstancePreloadDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ respProps = svcLogicClient
+ .execute("VNF-API", SVC_OPERATION, null, "sync", vnfInstancePreloadDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -2192,24 +2083,20 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
-
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
// internalError = respProps.getProperty("internal-error", "false");
}
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
@@ -2219,22 +2106,30 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vnfInstancePreloadListBuilder.setVnfInstanceName(preload_name);
vnfInstancePreloadListBuilder.setVnfModelId(preload_type);
vnfInstancePreloadListBuilder.setVnfInstancePreloadData(vnfInstancePreloadDataBuilder.build());
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] error code: '" + errorCode + "', Reason: '" + errorMessage + "'");
+ log.error(
+ "Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] error code: '"
+ + errorCode + "', Reason: '" + errorMessage + "'");
try {
- SaveVnfInstancePreloadList (vnfInstancePreloadListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+ SaveVnfInstancePreloadList(vnfInstancePreloadListBuilder.build(), true,
+ LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error(
+ "Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
}
log.debug("Sending Success rpc result due to external error");
RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Got success from SLI
try {
vnfInstancePreloadData = vnfInstancePreloadDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preloadData: " + vnfInstancePreloadData);
+ log.info(
+ "Updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] preloadData: "
+ + vnfInstancePreloadData);
// svc-configuration-list
VnfInstancePreloadListBuilder vnfInstancePreloadListBuilder = new VnfInstancePreloadListBuilder();
vnfInstancePreloadListBuilder.setVnfInstanceName(preload_name);
@@ -2242,63 +2137,69 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vnfInstancePreloadListBuilder.setVnfInstancePreloadData(vnfInstancePreloadData);
// SDNGC-989 set merge flag to false
- SaveVnfInstancePreloadList (vnfInstancePreloadListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ SaveVnfInstancePreloadList(vnfInstancePreloadListBuilder.build(), false,
+ LogicalDatastoreType.CONFIGURATION);
log.info("Updating OPERATIONAL tree.");
- SaveVnfInstancePreloadList (vnfInstancePreloadListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ SaveVnfInstancePreloadList(vnfInstancePreloadListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] "
+ + responseBuilder.build());
RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(false)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] ");
+ log.info(
+ "Returned SUCCESS for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] " + responseBuilder
+ .build());
RpcResult<PreloadVnfInstanceTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVnfInstanceTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
//1610 preload-vf-module-topology-operation
- @Override
- public Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation(
- PreloadVfModuleTopologyOperationInput input) {
+ @Override public Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation(
+ PreloadVfModuleTopologyOperationInput input) {
final String SVC_OPERATION = "preload-vf-module-topology-operation";
VfModulePreloadData vfModulePreloadData = null;
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
- PreloadVfModuleTopologyOperationOutputBuilder responseBuilder = new PreloadVfModuleTopologyOperationOutputBuilder();
+ PreloadVfModuleTopologyOperationOutputBuilder responseBuilder =
+ new PreloadVfModuleTopologyOperationOutputBuilder();
// Result from savePreloadData
final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
- if(input == null ||
- input.getVfModuleTopologyInformation() == null ||
- input.getVfModuleTopologyInformation().getVfModuleIdentifiers().getVfModuleName() == null ||
- input.getVfModuleTopologyInformation().getVfModuleIdentifiers().getVfModuleModelId() == null)
- {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vnf-instance-name and vnf-model-id");
+ if (input == null || input.getVfModuleTopologyInformation() == null
+ || input.getVfModuleTopologyInformation().getVfModuleIdentifiers().getVfModuleName() == null
+ || input.getVfModuleTopologyInformation().getVfModuleIdentifiers().getVfModuleModelId() == null) {
+ log.debug("exiting " + SVC_OPERATION
+ + " because of invalid input, null or empty vnf-instance-name and vnf-model-id");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, null or empty vnf-instance-name and vnf-model-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
@@ -2307,22 +2208,24 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
String preload_type = input.getVfModuleTopologyInformation().getVfModuleIdentifiers().getVfModuleModelId();
// Make sure we have a preload_name and preload_type
- if(preload_name == null || preload_name.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-name");
+ if (preload_name == null || preload_name.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-name");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, invalid preload-name");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
- if(preload_type == null || preload_type.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-type");
+ if (preload_type == null || preload_type.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-type");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("invalid input, invalid preload-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
@@ -2336,7 +2239,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//preloadData = preloadDataBuilder.build();
VfModulePreloadDataBuilder operDataBuilder = new VfModulePreloadDataBuilder();
- getVfModulePreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getVfModulePreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
//
// setup a preload-data object builder
@@ -2351,36 +2254,29 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
// container preload-data
// uses vnf-configuration-information;
-
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] input: " + input);
- PreloadVfModuleTopologyOperationInputBuilder inputBuilder = new PreloadVfModuleTopologyOperationInputBuilder(input);
+ log.info(
+ "Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
+ PreloadVfModuleTopologyOperationInputBuilder inputBuilder =
+ new PreloadVfModuleTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+preload_name+","+preload_type +"] operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] operational-data: " + operDataBuilder.build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
-
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
-
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", vfModulePreloadDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
+ try {
+ respProps = svcLogicClient
+ .execute("VNF-API", SVC_OPERATION, null, "sync", vfModulePreloadDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -2388,24 +2284,20 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
-
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
// internalError = respProps.getProperty("internal-error", "false");
}
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
@@ -2415,22 +2307,29 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vfModulePreloadListBuilder.setVfModuleName(preload_name);
vfModulePreloadListBuilder.setVfModuleModelId(preload_type);
vfModulePreloadListBuilder.setVfModulePreloadData(vfModulePreloadDataBuilder.build());
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] error code: '" + errorCode + "', Reason: '" + errorMessage + "'");
+ log.error(
+ "Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] error code: '"
+ + errorCode + "', Reason: '" + errorMessage + "'");
try {
- SaveVfModulePreloadList (vfModulePreloadListBuilder.build(), true,LogicalDatastoreType.CONFIGURATION);
+ SaveVfModulePreloadList(vfModulePreloadListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error(
+ "Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
}
log.debug("Sending Success rpc result due to external error");
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Got success from SLI
try {
vfModulePreloadData = vfModulePreloadDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preloadData: " + vfModulePreloadData);
+ log.info(
+ "Updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] preloadData: "
+ + vfModulePreloadData);
// svc-configuration-list
VfModulePreloadListBuilder vfModulePreloadListBuilder = new VfModulePreloadListBuilder();
vfModulePreloadListBuilder.setVfModuleName(preload_name);
@@ -2438,59 +2337,68 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
vfModulePreloadListBuilder.setVfModulePreloadData(vfModulePreloadData);
// SDNGC-989 set merge flag to false
- SaveVfModulePreloadList (vfModulePreloadListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ SaveVfModulePreloadList(vfModulePreloadListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
log.info("Updating OPERATIONAL tree.");
- SaveVfModulePreloadList (vfModulePreloadListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ SaveVfModulePreloadList(vfModulePreloadListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] "
+ + responseBuilder.build());
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(false)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] ");
+ log.info(
+ "Returned SUCCESS for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] " + responseBuilder
+ .build());
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
- @Override
- public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
- PreloadNetworkTopologyOperationInput input) {
+ @Override public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
+ PreloadNetworkTopologyOperationInput input) {
final String SVC_OPERATION = "preload-network-topology-operation";
PreloadData preloadData = null;
Properties parms = new Properties();
- log.info( SVC_OPERATION +" called." );
+ log.info(SVC_OPERATION + " called.");
// create a new response object
- PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder();
+ PreloadNetworkTopologyOperationOutputBuilder responseBuilder =
+ new PreloadNetworkTopologyOperationOutputBuilder();
// Result from savePreloadData
final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create();
- if(input == null || input.getNetworkTopologyInformation() == null || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName() == null || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType() == null) {
- log.debug("exiting " +SVC_OPERATION+ " because of invalid input, null or empty vnf-name and vnf-type");
+ if (input == null || input.getNetworkTopologyInformation() == null
+ || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null
+ || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName() == null
+ || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType() == null) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid input, null or empty vnf-name and vnf-type");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("input, null or empty vnf-name and vnf-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
+ RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
+ return Futures.immediateFuture(rpcResult);
}
// Grab the name and type from the input buffer
@@ -2498,23 +2406,26 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
String preload_type = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType();
// Make sure we have a preload_name and preload_type
- if(preload_name == null || preload_name.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-name");
+ if (preload_name == null || preload_name.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-name");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("input, invalid preload-name");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
+ RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
+ return Futures.immediateFuture(rpcResult);
}
- if(preload_type == null || preload_type.length() == 0 ) {
- log.debug("exiting "+SVC_OPERATION+" because of invalid preload-type");
+
+ if (preload_type == null || preload_type.length() == 0) {
+ log.debug("exiting " + SVC_OPERATION + " because of invalid preload-type");
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage("input, invalid preload-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
+ RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
+ return Futures.immediateFuture(rpcResult);
}
if (input.getSdncRequestHeader() != null) {
@@ -2526,7 +2437,7 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
getPreloadData(preload_name, preload_type, preloadDataBuilder);
PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
- getPreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL );
+ getPreloadData(preload_name, preload_type, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
//
// setup a preload-data object builder
@@ -2540,36 +2451,29 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
//
// container preload-data
// uses vnf-configuration-information;
-
-
- log.info("Adding INPUT data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] input: " + input);
- PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder(input);
+ log.info(
+ "Adding INPUT data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] input: " + input);
+ PreloadNetworkTopologyOperationInputBuilder inputBuilder =
+ new PreloadNetworkTopologyOperationInputBuilder(input);
VnfSdnUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for "+SVC_OPERATION+" ["+preload_name+","+preload_type +"] operational-data: " + operDataBuilder.build());
+ log.info("Adding OPERATIONAL data for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] operational-data: " + operDataBuilder.build());
VnfSdnUtil.toProperties(parms, "operational-data", operDataBuilder);
// Call SLI sync method
// Get SvcLogicService reference
-
Properties respProps = null;
-
String errorCode = "200";
String errorMessage = null;
String ackFinal = "Y";
-
- try
- {
- if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION , null, "sync"))
- {
-
- try
- {
- respProps = svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", preloadDataBuilder, parms);
- }
- catch (Exception e)
- {
- log.error("Caught exception executing service logic for "+ SVC_OPERATION, e);
+ try {
+ if (svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync")) {
+ try {
+ respProps =
+ svcLogicClient.execute("VNF-API", SVC_OPERATION, null, "sync", preloadDataBuilder, parms);
+ } catch (Exception e) {
+ log.error("Caught exception executing service logic for " + SVC_OPERATION, e);
errorMessage = e.getMessage();
errorCode = "500";
}
@@ -2577,25 +2481,21 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
errorMessage = "No service logic active for VNF-API: '" + SVC_OPERATION + "'";
errorCode = "503";
}
- }
- catch (Exception e)
- {
+ } catch (Exception e) {
errorCode = "500";
errorMessage = e.getMessage();
log.error("Caught exception looking for service logic", e);
}
- if (respProps != null)
- {
+ if (respProps != null) {
errorCode = respProps.getProperty("error-code");
errorMessage = respProps.getProperty("error-message");
ackFinal = respProps.getProperty("ack-final", "Y");
// internalError = respProps.getProperty("internal-error", "false");
}
- if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) {
-
+ if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) {
responseBuilder.setResponseCode(errorCode);
responseBuilder.setResponseMessage(errorMessage);
responseBuilder.setAckFinalIndicator(ackFinal);
@@ -2604,23 +2504,30 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
preloadVnfListBuilder.setVnfName(preload_name);
preloadVnfListBuilder.setVnfType(preload_type);
preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] error code: '" + errorCode + "', Reason: '" + errorMessage + "'");
+ log.error(
+ "Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] error code: '"
+ + errorCode + "', Reason: '" + errorMessage + "'");
try {
- SavePreloadList (preloadVnfListBuilder.build(),true,LogicalDatastoreType.CONFIGURATION);
+ SavePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error(
+ "Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
}
log.debug("Sending Success rpc result due to external error");
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
// Got success from SLI
try {
preloadData = preloadDataBuilder.build();
- log.info("Updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preloadData: " + preloadData);
+ log.info(
+ "Updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] preloadData: "
+ + preloadData);
// svc-configuration-list
VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
preloadVnfListBuilder.setVnfName(preload_name);
@@ -2628,33 +2535,37 @@ public class vnfapiProvider implements AutoCloseable, VNFAPIService, DataChangeL
preloadVnfListBuilder.setPreloadData(preloadData);
// SDNGC-989 set merge flag to false
- SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ SavePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
log.info("Updating OPERATIONAL tree.");
- SavePreloadList (preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ SavePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
} catch (Exception e) {
- log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e);
+ log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type
+ + "] \n", e);
responseBuilder.setResponseCode("500");
responseBuilder.setResponseMessage(e.toString());
responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.error("Returned FAILED for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] "
+ + responseBuilder.build());
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(false)
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Update succeeded
responseBuilder.setResponseCode(errorCode);
responseBuilder.setAckFinalIndicator(ackFinal);
- if (errorMessage != null)
- {
+ if (errorMessage != null) {
responseBuilder.setResponseMessage(errorMessage);
}
- log.info("Updated MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] ");
- log.info("Returned SUCCESS for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] " + responseBuilder.build());
+ log.info("Updated MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] ");
+ log.info(
+ "Returned SUCCESS for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + "] " + responseBuilder
+ .build());
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult =
- RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build();
+ RpcResultBuilder.<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
-
}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java
index dbfca074..3f486f62 100644
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java
+++ b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/VnfSdnUtilTest.java
@@ -1,3 +1,23 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
package org.onap.sdnc.vnfapi;
import org.junit.Assert;
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/vnfapiProviderTest.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/vnfapiProviderTest.java
new file mode 100644
index 00000000..5ea0c119
--- /dev/null
+++ b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/vnfapiProviderTest.java
@@ -0,0 +1,1509 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : SDN-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.sdnc.vnfapi;
+
+import com.google.common.base.Optional;
+import com.google.common.util.concurrent.CheckedFuture;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+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;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.NetworkTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadNetworkTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadNetworkTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVfModuleTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVfModuleTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVfModules;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfInstanceTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfInstanceTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfInstances;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.PreloadVnfs;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VNFAPIService;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModuleTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VfModules;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstanceTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfInstances;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.Vnfs;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.network.request.information.NetworkRequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.network.topology.identifier.NetworkTopologyIdentifier;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.network.topology.information.NetworkTopologyInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.data.PreloadDataBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.model.information.VnfPreloadList;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.vf.module.model.information.VfModulePreloadList;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.preload.vnf.instance.model.information.VnfInstancePreloadList;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.sdnc.request.header.SdncRequestHeader;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.information.ServiceInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.status.ServiceStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.status.ServiceStatusBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.identifiers.VfModuleIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.model.infrastructure.VfModuleList;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.preload.data.VfModulePreloadData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.preload.data.VfModulePreloadDataBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.request.information.VfModuleRequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.service.data.VfModuleServiceDataBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vf.module.topology.information.VfModuleTopologyInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.identifiers.VnfInstanceIdentifiers;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.model.infrastructure.VnfInstanceList;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.preload.data.VnfInstancePreloadData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.preload.data.VnfInstancePreloadDataBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.request.information.VnfInstanceRequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.service.data.VnfInstanceServiceDataBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.instance.topology.information.VnfInstanceTopologyInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfList;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfListKey;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.request.information.VnfRequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.topology.identifier.VnfTopologyIdentifier;
+import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.topology.information.VnfTopologyInformation;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.powermock.reflect.Whitebox;
+
+import java.util.ArrayList;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+
+public class vnfapiProviderTest {
+ @Rule public MockitoRule rule = MockitoJUnit.rule();
+
+ @Mock private DataBroker dataBroker;
+ @Mock private NotificationPublishService notificationPublishService;
+ @Mock private RpcProviderRegistry rpcProviderRegistry;
+ @Mock private VNFSDNSvcLogicServiceClient vnfsdnSvcLogicServiceClient;
+ @Mock private ReadWriteTransaction readWriteTransactionInCreateContainer;
+ @Mock private ReadWriteTransaction readWriteTransactionInDataChanged;
+ @Mock private CheckedFuture<Void, TransactionCommitFailedException> checkedFuture;
+
+ private vnfapiProvider vnfapiProvider;
+ private String vfModuleName;
+ private String vfModuleModelId;
+ private String vnfInstanceId;
+ private String vnfInstanceName;
+ private String vnfModelId;
+ private String svcRequestId;
+ private String serviceInstanceId;
+ private String vnfName;
+ private String vnfType;
+ private String vfModuleId;
+
+ @Before public void setUp() throws Exception {
+ doReturn(readWriteTransactionInCreateContainer).when(dataBroker).newReadWriteTransaction();
+ doReturn(checkedFuture).when(readWriteTransactionInCreateContainer).submit();
+ // mock readOnlyTransaction
+ ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
+ doReturn(readOnlyTransaction).when(dataBroker).newReadOnlyTransaction();
+ doReturn(checkedFuture).when(readOnlyTransaction).read(any(), any());
+ // mock writeTransaction
+ WriteTransaction writeTransaction = mock(WriteTransaction.class);
+ doReturn(writeTransaction).when(dataBroker).newWriteOnlyTransaction();
+ doReturn(checkedFuture).when(writeTransaction).submit();
+
+ vnfapiProvider = spy(new vnfapiProvider(dataBroker, notificationPublishService, rpcProviderRegistry,
+ vnfsdnSvcLogicServiceClient));
+ }
+
+ @After public void tearDown() throws Exception {
+
+ }
+
+ @Test public void close() throws Exception {
+ ExecutorService executor = Whitebox.getInternalState(vnfapiProvider, "executor");
+ BindingAwareBroker.RpcRegistration<VNFAPIService> vnfapiServiceRpcRegistration =
+ mock(BindingAwareBroker.RpcRegistration.class);
+ vnfapiProvider.rpcRegistration = vnfapiServiceRpcRegistration;
+
+ vnfapiProvider.close();
+
+ Assert.assertTrue(executor.isShutdown());
+ verify(vnfapiServiceRpcRegistration, times(1)).close();
+ }
+
+ @Test public void onDataChanged() throws Exception {
+ AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> asyncDataChangeEvent = mock(AsyncDataChangeEvent.class);
+ // instance of Vnfs
+ Vnfs vnfs = mock(Vnfs.class);
+ doReturn(vnfs).when(asyncDataChangeEvent).getUpdatedSubtree();
+ VnfList vnfList = mock(VnfList.class);
+ ServiceData serviceData = mock(ServiceData.class);
+ doReturn(serviceData).when(vnfList).getServiceData();
+ ServiceStatus serviceStatus = mock(ServiceStatus.class);
+ doReturn("N").when(serviceStatus).getFinalIndicator();
+ doReturn(ServiceStatus.RequestStatus.Synccomplete).when(serviceStatus).getRequestStatus();
+ doReturn(serviceStatus).when(vnfList).getServiceStatus();
+ ArrayList<VnfList> vnfListList = new ArrayList<>();
+ vnfListList.add(vnfList);
+ doReturn(vnfListList).when(vnfs).getVnfList();
+ doReturn(readWriteTransactionInDataChanged).when(dataBroker).newWriteOnlyTransaction();
+ doReturn(checkedFuture).when(readWriteTransactionInDataChanged).submit();
+
+ vnfapiProvider.onDataChanged(asyncDataChangeEvent);
+
+ verify(readWriteTransactionInDataChanged, times(1)).submit();
+
+ // instance of PreloadVnfs
+ PreloadVnfs preloadVnfs = mock(PreloadVnfs.class);
+ doReturn(preloadVnfs).when(asyncDataChangeEvent).getUpdatedSubtree();
+ ArrayList<VnfPreloadList> vnfPreloadLists = new ArrayList<>();
+ doReturn(vnfPreloadLists).when(preloadVnfs).getVnfPreloadList();
+ PreloadData preloadData = mock(PreloadData.class);
+ VnfPreloadList vnfPreloadList = mock(VnfPreloadList.class);
+ doReturn(preloadData).when(vnfPreloadList).getPreloadData();
+ vnfPreloadLists.add(vnfPreloadList);
+
+ vnfapiProvider.onDataChanged(asyncDataChangeEvent);
+
+ verify(readWriteTransactionInDataChanged, times(2)).submit();
+
+ // instance of PreloadVnfInstances
+ PreloadVnfInstances preloadVnfInstances = mock(PreloadVnfInstances.class);
+ doReturn(preloadVnfInstances).when(asyncDataChangeEvent).getUpdatedSubtree();
+ ArrayList<VnfInstancePreloadList> vnfInstancePreloadLists = new ArrayList<>();
+ doReturn(vnfInstancePreloadLists).when(preloadVnfInstances).getVnfInstancePreloadList();
+ VnfInstancePreloadList vnfInstancePreloadList = mock(VnfInstancePreloadList.class);
+ VnfInstancePreloadData vnfInstancePreloadData = mock(VnfInstancePreloadData.class);
+ doReturn(vnfInstancePreloadData).when(vnfInstancePreloadList).getVnfInstancePreloadData();
+ vnfInstancePreloadLists.add(vnfInstancePreloadList);
+
+ vnfapiProvider.onDataChanged(asyncDataChangeEvent);
+
+ verify(readWriteTransactionInDataChanged, times(3)).submit();
+
+ // instance of VnfInstances
+ VnfInstances vnfInstances = mock(VnfInstances.class);
+ doReturn(vnfInstances).when(asyncDataChangeEvent).getUpdatedSubtree();
+ ArrayList<VnfInstanceList> vnfInstanceLists = new ArrayList<>();
+ doReturn(vnfInstanceLists).when(vnfInstances).getVnfInstanceList();
+ VnfInstanceList vnfInstanceList = mock(VnfInstanceList.class);
+ vnfInstanceLists.add(vnfInstanceList);
+ VnfInstanceServiceData vnfInstanceServiceData = mock(VnfInstanceServiceData.class);
+ doReturn(vnfInstanceServiceData).when(vnfInstanceList).getVnfInstanceServiceData();
+ doReturn(serviceStatus).when(vnfInstanceList).getServiceStatus();
+
+ vnfapiProvider.onDataChanged(asyncDataChangeEvent);
+
+ verify(readWriteTransactionInDataChanged, times(4)).submit();
+
+ // instance of PreloadVfModules
+ PreloadVfModules preloadVfModules = mock(PreloadVfModules.class);
+ doReturn(preloadVfModules).when(asyncDataChangeEvent).getUpdatedSubtree();
+ ArrayList<VfModulePreloadList> vfModulePreloadLists = new ArrayList<>();
+ doReturn(vfModulePreloadLists).when(preloadVfModules).getVfModulePreloadList();
+ VfModulePreloadList vfModulePreloadList = mock(VfModulePreloadList.class);
+ vfModulePreloadLists.add(vfModulePreloadList);
+ VfModulePreloadData vfModulePreloadData = mock(VfModulePreloadData.class);
+ doReturn(vfModulePreloadData).when(vfModulePreloadList).getVfModulePreloadData();
+
+ vnfapiProvider.onDataChanged(asyncDataChangeEvent);
+
+ verify(readWriteTransactionInDataChanged, times(5)).submit();
+
+ // instance of VfModules
+ VfModules vfModules = mock(VfModules.class);
+ doReturn(preloadVfModules).when(asyncDataChangeEvent).getUpdatedSubtree();
+ ArrayList<VfModuleList> vfModuleLists = new ArrayList<>();
+ doReturn(vfModuleLists).when(vfModules).getVfModuleList();
+ VfModuleList vfModuleList = mock(VfModuleList.class);
+ vfModuleLists.add(vfModuleList);
+ VfModuleServiceData vfModuleServiceData = mock(VfModuleServiceData.class);
+ doReturn(vfModuleServiceData).when(vfModuleList).getVfModuleServiceData();
+ doReturn(serviceStatus).when(vfModuleList).getServiceStatus();
+
+ vnfapiProvider.onDataChanged(asyncDataChangeEvent);
+
+ verify(readWriteTransactionInDataChanged, times(6)).submit();
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getVnfInstanceRequestInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vnfInstanceTopologyOperationErrorOne() throws Exception {
+ VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
+ mock(VnfInstanceTopologyOperationInput.class);
+ doReturn(null).when(vnfInstanceTopologyOperationInput).getVnfInstanceRequestInformation();
+
+ Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vnf-instance-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>viid == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vnfInstanceTopologyOperationErrorTwo() throws Exception {
+ vnfInstanceId = "";
+ vnfInstanceName = "vnf-instance-name";
+ vnfModelId = "vnf-model-id";
+ VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
+ mock(VnfInstanceTopologyOperationInput.class);
+ VnfInstanceRequestInformation vnfInstanceRequestInformation = mock(VnfInstanceRequestInformation.class);
+ doReturn(vnfInstanceName).when(vnfInstanceRequestInformation).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceRequestInformation).getVnfModelId();
+ doReturn(vnfInstanceId).when(vnfInstanceRequestInformation).getVnfInstanceId();
+ doReturn(vnfInstanceRequestInformation).when(vnfInstanceTopologyOperationInput)
+ .getVnfInstanceRequestInformation();
+
+ Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vnf-instance-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API",SVC_OPERATION,null,"sync" = false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vnfInstanceTopologyOperationErrorThree() throws Exception {
+ vnfInstanceId = "vnf-instance-id";
+ vnfInstanceName = "vnf-instance-name";
+ vnfModelId = "vnf-model-id";
+ svcRequestId = "svc-request-id";
+
+ VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
+ mock(VnfInstanceTopologyOperationInput.class);
+ VnfInstanceRequestInformation vnfInstanceRequestInformation = mock(VnfInstanceRequestInformation.class);
+ doReturn(vnfInstanceId).when(vnfInstanceRequestInformation).getVnfInstanceId();
+ doReturn(vnfInstanceName).when(vnfInstanceRequestInformation).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceRequestInformation).getVnfModelId();
+ doReturn(vnfInstanceRequestInformation).when(vnfInstanceTopologyOperationInput)
+ .getVnfInstanceRequestInformation();
+
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(vnfInstanceTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+
+ Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void vnfInstanceTopologyOperationSuccess() throws Exception {
+ vnfInstanceId = "vnf-instance-id";
+ vnfInstanceName = "vnf-instance-name";
+ vnfModelId = "vnf-model-id";
+ svcRequestId = "svc-request-id";
+
+ VnfInstanceTopologyOperationInput vnfInstanceTopologyOperationInput =
+ mock(VnfInstanceTopologyOperationInput.class);
+ VnfInstanceRequestInformation vnfInstanceRequestInformation = mock(VnfInstanceRequestInformation.class);
+ doReturn(vnfInstanceId).when(vnfInstanceRequestInformation).getVnfInstanceId();
+ doReturn(vnfInstanceName).when(vnfInstanceRequestInformation).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceRequestInformation).getVnfModelId();
+ doReturn(vnfInstanceRequestInformation).when(vnfInstanceTopologyOperationInput)
+ .getVnfInstanceRequestInformation();
+
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(vnfInstanceTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+ doReturn(SdncRequestHeader.SvcAction.Activate).when(sdncRequestHeader).getSvcAction();
+ ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class);
+ doReturn(readOnlyTransaction).when(dataBroker).newReadOnlyTransaction();
+ doReturn(checkedFuture).when(readOnlyTransaction).read(any(), any());
+ WriteTransaction writeTransaction = mock(WriteTransaction.class);
+ doReturn(writeTransaction).when(dataBroker).newWriteOnlyTransaction();
+ doReturn(checkedFuture).when(writeTransaction).submit();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<VnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfInstanceTopologyOperation(vnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getVfModuleTopologyInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vfModuleTopologyOperationErrorOne() throws Exception {
+ VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
+ doReturn(null).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
+ Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vf-module-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>vfid = ""</code>
+ * And
+ * <p>
+ * <code>viid = ""</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vfModuleTopologyOperationErrorTwo() throws Exception {
+ // vifd = ""
+ vfModuleName = "vfModuleName";
+ vfModuleModelId = "vfModuleModelId";
+ vfModuleId = "";
+ vnfInstanceId = "";
+ VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
+ VfModuleRequestInformation vfModuleRequestInformation = mock(VfModuleRequestInformation.class);
+ doReturn(vfModuleRequestInformation).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
+ VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+ doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
+
+ Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vf-module-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+
+ // viid = ""
+ vfModuleId = "vfModuleId";
+ doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
+ doReturn(vnfInstanceId).when(vfModuleRequestInformation).getVnfInstanceId();
+ rpcResultFuture = vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vnf-instance-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vfModuleTopologyOperationErrorThree() throws Exception {
+ // vifd = ""
+ vfModuleName = "vfModuleName";
+ vfModuleModelId = "vfModuleModelId";
+ vfModuleId = "vfModuleId";
+ vnfInstanceId = "vnfInstanceId";
+ VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
+ VfModuleRequestInformation vfModuleRequestInformation = mock(VfModuleRequestInformation.class);
+ doReturn(vfModuleRequestInformation).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
+ VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+ doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
+ doReturn(vnfInstanceId).when(vfModuleRequestInformation).getVnfInstanceId();
+ // mock sdncRequestHeader
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(vfModuleTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+
+ Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void vfModuleTopologyOperationSuccess() throws Exception {
+ vfModuleName = "vfModuleName";
+ vfModuleModelId = "vfModuleModelId";
+ vfModuleId = "vfModuleId";
+ vnfInstanceId = "vnfInstanceId";
+ VfModuleTopologyOperationInput vfModuleTopologyOperationInput = mock(VfModuleTopologyOperationInput.class);
+ VfModuleRequestInformation vfModuleRequestInformation = mock(VfModuleRequestInformation.class);
+ doReturn(vfModuleRequestInformation).when(vfModuleTopologyOperationInput).getVfModuleRequestInformation();
+ VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+ doReturn(vfModuleId).when(vfModuleRequestInformation).getVfModuleId();
+ doReturn(vnfInstanceId).when(vfModuleRequestInformation).getVnfInstanceId();
+ // mock sdncRequestHeader
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(vfModuleTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<VfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vfModuleTopologyOperation(vfModuleTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getServiceInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vnfTopologyOperationErrorOne() throws Exception {
+ VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
+ doReturn(null).when(vnfTopologyOperationInput).getServiceInformation();
+
+ Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty service-instance-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getVnfRequestInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vnfTopologyOperationErrorTwo() throws Exception {
+ serviceInstanceId = "serviceInstanceId";
+ VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
+ ServiceInformation serviceInformation = mock(ServiceInformation.class);
+ doReturn(serviceInformation).when(vnfTopologyOperationInput).getServiceInformation();
+ doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
+
+ Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vf-module-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") == false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void vnfTopologyOperationErrorThree() throws Exception {
+ serviceInstanceId = "serviceInstanceId";
+ String vnfId = "vnfId";
+ VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
+ ServiceInformation serviceInformation = mock(ServiceInformation.class);
+ doReturn(serviceInformation).when(vnfTopologyOperationInput).getServiceInformation();
+ doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
+
+ VnfRequestInformation vnfRequestInformation = mock(VnfRequestInformation.class);
+ doReturn(vnfRequestInformation).when(vnfTopologyOperationInput).getVnfRequestInformation();
+ doReturn(vnfId).when(vnfRequestInformation).getVnfId();
+
+ Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void vnfTopologyOperationSuccess() throws Exception {
+ serviceInstanceId = "serviceInstanceId";
+ String vnfId = "vnfId";
+ VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
+ ServiceInformation serviceInformation = mock(ServiceInformation.class);
+ doReturn(serviceInformation).when(vnfTopologyOperationInput).getServiceInformation();
+ doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
+
+ VnfRequestInformation vnfRequestInformation = mock(VnfRequestInformation.class);
+ doReturn(vnfRequestInformation).when(vnfTopologyOperationInput).getVnfRequestInformation();
+ doReturn(vnfId).when(vnfRequestInformation).getVnfId();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getServiceInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void networkTopologyOperationErrorOne() throws Exception {
+ VnfTopologyOperationInput vnfTopologyOperationInput = mock(VnfTopologyOperationInput.class);
+ doReturn(null).when(vnfTopologyOperationInput).getServiceInformation();
+
+ Future<RpcResult<VnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.vnfTopologyOperation(vnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty service-instance-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getNetworkRequestInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void networkTopologyOperationErrorTwo() throws Exception {
+ serviceInstanceId = "serviceInstanceId";
+ NetworkTopologyOperationInput networkTopologyOperation = mock(NetworkTopologyOperationInput.class);
+ ServiceInformation serviceInformation = mock(ServiceInformation.class);
+ doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
+ doReturn(serviceInformation).when(networkTopologyOperation).getServiceInformation();
+
+ Future<RpcResult<NetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.networkTopologyOperation(networkTopologyOperation);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty service-instance-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") == false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void networkTopologyOperationErrorThree() throws Exception {
+ serviceInstanceId = "serviceInstanceId";
+ NetworkTopologyOperationInput networkTopologyOperationInput = mock(NetworkTopologyOperationInput.class);
+ ServiceInformation serviceInformation = mock(ServiceInformation.class);
+ doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
+ doReturn(serviceInformation).when(networkTopologyOperationInput).getServiceInformation();
+
+ NetworkRequestInformation networkRequestInformation = mock(NetworkRequestInformation.class);
+ doReturn(networkRequestInformation).when(networkTopologyOperationInput).getNetworkRequestInformation();
+ doReturn("NetworkName").when(networkRequestInformation).getNetworkName();
+
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(SdncRequestHeader.SvcAction.Assign).when(sdncRequestHeader).getSvcAction();
+ doReturn(sdncRequestHeader).when(networkTopologyOperationInput).getSdncRequestHeader();
+
+ Future<RpcResult<NetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.networkTopologyOperation(networkTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void networkTopologyOperationSuccess() throws Exception {
+ serviceInstanceId = "serviceInstanceId";
+ NetworkTopologyOperationInput networkTopologyOperationInput = mock(NetworkTopologyOperationInput.class);
+ ServiceInformation serviceInformation = mock(ServiceInformation.class);
+ doReturn(serviceInstanceId).when(serviceInformation).getServiceInstanceId();
+ doReturn(serviceInformation).when(networkTopologyOperationInput).getServiceInformation();
+ //mock networkRequestInformation
+ NetworkRequestInformation networkRequestInformation = mock(NetworkRequestInformation.class);
+ doReturn(networkRequestInformation).when(networkTopologyOperationInput).getNetworkRequestInformation();
+ doReturn("NetworkName").when(networkRequestInformation).getNetworkName();
+ //mock sdncRequestHeader
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(SdncRequestHeader.SvcAction.Assign).when(sdncRequestHeader).getSvcAction();
+ doReturn(sdncRequestHeader).when(networkTopologyOperationInput).getSdncRequestHeader();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<NetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.networkTopologyOperation(networkTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getVnfTopologyInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfTopologyOperationErrorOne() throws Exception {
+ PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVnfTopologyOperationInput.class);
+ doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+
+ Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vnf-name and vnf-type",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>preload_name.length() == 0</code>
+ * And
+ * <code>preload_type.length() == 0</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfTopologyOperationErrorTwo() throws Exception {
+ // preload_name.length() == 0
+ vnfName = "";
+ vnfType = "vfModuleModelId";
+ PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVnfTopologyOperationInput.class);
+ doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+
+ VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
+ doReturn(vnfTopologyInformation).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+ VnfTopologyIdentifier vnfTopologyIdentifier = mock(VnfTopologyIdentifier.class);
+ doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
+ doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
+ doReturn(vnfTopologyIdentifier).when(vnfTopologyInformation).getVnfTopologyIdentifier();
+
+ Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, invalid preload-name",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+
+ // preload_type.length() == 0
+ vnfName = "vnfName";
+ vnfType = "";
+ doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
+ doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
+
+ rpcResultFuture = vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, invalid preload-type",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfTopologyOperationErrorThree() throws Exception {
+ // preload_name.length() == 0
+ vnfName = "vnfName";
+ vnfType = "vfModuleModelId";
+ PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVnfTopologyOperationInput.class);
+ doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+
+ VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
+ doReturn(vnfTopologyInformation).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+ VnfTopologyIdentifier vnfTopologyIdentifier = mock(VnfTopologyIdentifier.class);
+ doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
+ doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
+ doReturn(vnfTopologyIdentifier).when(vnfTopologyInformation).getVnfTopologyIdentifier();
+
+ Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfTopologyOperationSuccess() throws Exception {
+ // preload_name.length() == 0
+ vnfName = "vnfName";
+ vnfType = "vfModuleModelId";
+ PreloadVnfTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVnfTopologyOperationInput.class);
+ doReturn(null).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+
+ VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
+ doReturn(vnfTopologyInformation).when(preloadVnfTopologyOperationInput).getVnfTopologyInformation();
+ VnfTopologyIdentifier vnfTopologyIdentifier = mock(VnfTopologyIdentifier.class);
+ doReturn(vnfName).when(vnfTopologyIdentifier).getVnfName();
+ doReturn(vnfType).when(vnfTopologyIdentifier).getVnfType();
+ doReturn(vnfTopologyIdentifier).when(vnfTopologyInformation).getVnfTopologyIdentifier();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<PreloadVnfTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getVnfInstanceTopologyInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfInstanceTopologyOperationErrorOne() throws Exception {
+ PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
+ mock(PreloadVnfInstanceTopologyOperationInput.class);
+ doReturn(null).when(preloadVnfInstanceTopologyOperationInput).getVnfInstanceTopologyInformation();
+ Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vnf-instance-name and vnf-model-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>preload_name = ""</code>
+ * And
+ * <code>preload_type = ""</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfInstanceTopologyOperationErrorTwo() throws Exception {
+ // preload_type = ""
+ vnfInstanceName = "vnfInstanceName";
+ vnfModelId = "";
+ PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
+ mock(PreloadVnfInstanceTopologyOperationInput.class);
+ VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
+ doReturn(vnfInstanceTopologyInformation).when(preloadVnfInstanceTopologyOperationInput)
+ .getVnfInstanceTopologyInformation();
+ VnfInstanceIdentifiers vnfInstanceIdentifiers = mock(VnfInstanceIdentifiers.class);
+ doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
+ doReturn(vnfInstanceIdentifiers).when(vnfInstanceTopologyInformation).getVnfInstanceIdentifiers();
+
+ Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, invalid preload-type",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+
+ //preload_name == ""
+ vnfInstanceName = "";
+ vnfModelId = "vnfModelId";
+ doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
+
+ rpcResultFuture = vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, invalid preload-name",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfInstanceTopologyOperationErrorThree() throws Exception {
+ // preload_type = ""
+ vnfInstanceName = "vnfInstanceName";
+ vnfModelId = "vnfModelId";
+ PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
+ mock(PreloadVnfInstanceTopologyOperationInput.class);
+ VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
+ doReturn(vnfInstanceTopologyInformation).when(preloadVnfInstanceTopologyOperationInput)
+ .getVnfInstanceTopologyInformation();
+ VnfInstanceIdentifiers vnfInstanceIdentifiers = mock(VnfInstanceIdentifiers.class);
+ doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
+ doReturn(vnfInstanceIdentifiers).when(vnfInstanceTopologyInformation).getVnfInstanceIdentifiers();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(preloadVnfInstanceTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+
+ Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVnfInstanceTopologyOperationSuccess() throws Exception {
+ // preload_type = ""
+ vnfInstanceName = "vnfInstanceName";
+ vnfModelId = "vnfModelId";
+ PreloadVnfInstanceTopologyOperationInput preloadVnfInstanceTopologyOperationInput =
+ mock(PreloadVnfInstanceTopologyOperationInput.class);
+ VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
+ doReturn(vnfInstanceTopologyInformation).when(preloadVnfInstanceTopologyOperationInput)
+ .getVnfInstanceTopologyInformation();
+ VnfInstanceIdentifiers vnfInstanceIdentifiers = mock(VnfInstanceIdentifiers.class);
+ doReturn(vnfInstanceName).when(vnfInstanceIdentifiers).getVnfInstanceName();
+ doReturn(vnfModelId).when(vnfInstanceIdentifiers).getVnfModelId();
+ doReturn(vnfInstanceIdentifiers).when(vnfInstanceTopologyInformation).getVnfInstanceIdentifiers();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(preloadVnfInstanceTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<PreloadVnfInstanceTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVnfInstanceTopologyOperation(preloadVnfInstanceTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getVfModuleTopologyInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVfModuleTopologyOperationErrorOne() throws Exception {
+ PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVfModuleTopologyOperationInput.class);
+ doReturn(null).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
+
+ Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, null or empty vnf-instance-name and vnf-model-id",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>preload_name = ""</code>
+ * And
+ * <code>preload_type = ""</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVfModuleTopologyOperationErrorTwo() throws Exception {
+ // preload_name = ""
+ vfModuleName = "";
+ vfModuleModelId = "vfModuleModelId";
+ PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVfModuleTopologyOperationInput.class);
+ VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
+ doReturn(vfModuleTopologyInformation).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
+ VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+ doReturn(vfModuleIdentifiers).when(vfModuleTopologyInformation).getVfModuleIdentifiers();
+
+ Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, invalid preload-name",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+
+ // preload_type = ""
+ vfModuleName = "vfModuleName";
+ vfModuleModelId = "";
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+
+ rpcResultFuture = vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("invalid input, invalid preload-type",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API", SVC_OPERATION, null, "sync") = false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVfModuleTopologyOperationErrorThree() throws Exception {
+ // preload_name = ""
+ vfModuleName = "vfModuleName";
+ vfModuleModelId = "vfModuleModelId";
+ PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVfModuleTopologyOperationInput.class);
+ VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
+ doReturn(vfModuleTopologyInformation).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
+ VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+ doReturn(vfModuleIdentifiers).when(vfModuleTopologyInformation).getVfModuleIdentifiers();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(preloadVnfTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+
+ Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void preloadVfModuleTopologyOperationSuccess() throws Exception {
+ // preload_name = ""
+ vfModuleName = "vfModuleName";
+ vfModuleModelId = "vfModuleModelId";
+ PreloadVfModuleTopologyOperationInput preloadVnfTopologyOperationInput =
+ mock(PreloadVfModuleTopologyOperationInput.class);
+ VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
+ doReturn(vfModuleTopologyInformation).when(preloadVnfTopologyOperationInput).getVfModuleTopologyInformation();
+ VfModuleIdentifiers vfModuleIdentifiers = mock(VfModuleIdentifiers.class);
+ doReturn(vfModuleName).when(vfModuleIdentifiers).getVfModuleName();
+ doReturn(vfModuleModelId).when(vfModuleIdentifiers).getVfModuleModelId();
+ doReturn(vfModuleIdentifiers).when(vfModuleTopologyInformation).getVfModuleIdentifiers();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(preloadVnfTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadVfModuleTopologyOperation(preloadVnfTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>input.getNetworkTopologyInformation() == null</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadNetworkTopologyOperationErrorOne() throws Exception {
+ PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
+ mock(PreloadNetworkTopologyOperationInput.class);
+ doReturn(null).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
+
+ Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("input, null or empty vnf-name and vnf-type",
+ rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>preload_name == ""</code>
+ * ANd
+ * <code>preload_type == ""ss</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadNetworkTopologyOperationErrorTwo() throws Exception {
+ String networkName = "";
+ String networkType = "NetworkType";
+ PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
+ mock(PreloadNetworkTopologyOperationInput.class);
+ NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
+ doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
+ NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
+ doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
+ doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
+ doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
+
+ Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("input, invalid preload-name", rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+
+ networkName = "NetworkName";
+ networkType = "";
+ doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
+ doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
+
+ rpcResultFuture = vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
+
+ Assert.assertEquals("403", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("input, invalid preload-type", rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Error case:
+ * <p>
+ * <code>svcLogicClient.hasGraph("VNF-API",SVC_OPERATION,null,"sync" = false</code>
+ *
+ * @throws Exception
+ */
+ @Test public void preloadNetworkTopologyOperationErrorThree() throws Exception {
+ String networkName = "NetworkName";
+ String networkType = "NetworkType";
+ PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
+ mock(PreloadNetworkTopologyOperationInput.class);
+ NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
+ doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
+ NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
+ doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
+ doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
+ doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(PreloadNetworkTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+
+ Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
+
+ Assert.assertEquals("503", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertTrue(
+ rpcResultFuture.get().getResult().getResponseMessage().contains("No service logic active for VNF-API"));
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void preloadNetworkTopologyOperationErrorFour() throws Exception {
+ String networkName = "NetworkName";
+ String networkType = "NetworkType";
+ PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
+ mock(PreloadNetworkTopologyOperationInput.class);
+ NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
+ doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
+ NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
+ doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
+ doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
+ doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(PreloadNetworkTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+ doReturn(null).when(dataBroker).newWriteOnlyTransaction();
+
+ Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
+
+ Assert.assertEquals("500", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals("java.lang.NullPointerException", rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ /**
+ * Test Success case
+ *
+ * @throws Exception
+ */
+ @Test public void preloadNetworkTopologyOperationSuccess() throws Exception {
+ String networkName = "NetworkName";
+ String networkType = "NetworkType";
+ PreloadNetworkTopologyOperationInput PreloadNetworkTopologyOperationInput =
+ mock(PreloadNetworkTopologyOperationInput.class);
+ NetworkTopologyInformation networkTopologyInformation = mock(NetworkTopologyInformation.class);
+ doReturn(networkTopologyInformation).when(PreloadNetworkTopologyOperationInput).getNetworkTopologyInformation();
+ NetworkTopologyIdentifier networkTopologyIdentifier = mock(NetworkTopologyIdentifier.class);
+ doReturn(networkTopologyIdentifier).when(networkTopologyInformation).getNetworkTopologyIdentifier();
+ doReturn(networkName).when(networkTopologyIdentifier).getNetworkName();
+ doReturn(networkType).when(networkTopologyIdentifier).getNetworkType();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(PreloadNetworkTopologyOperationInput).getSdncRequestHeader();
+ doReturn(svcRequestId).when(sdncRequestHeader).getSvcRequestId();
+ doReturn(true).when(vnfsdnSvcLogicServiceClient).hasGraph(any(), any(), any(), any());
+
+ Future<RpcResult<PreloadNetworkTopologyOperationOutput>> rpcResultFuture =
+ vnfapiProvider.preloadNetworkTopologyOperation(PreloadNetworkTopologyOperationInput);
+
+ Assert.assertEquals("200", rpcResultFuture.get().getResult().getResponseCode());
+ Assert.assertEquals(null, rpcResultFuture.get().getResult().getResponseMessage());
+ Assert.assertEquals("Y", rpcResultFuture.get().getResult().getAckFinalIndicator());
+ }
+
+ @Test public void getVfModuleServiceData() throws Exception {
+ // Three parameters: siid, vfModuleServiceDataBuilder, LogicalDatastoreType
+ String ssid = "ssid";
+ VfModuleServiceDataBuilder vfModuleServiceDataBuilder = spy(new VfModuleServiceDataBuilder());
+ Optional<VfModuleList> optional = mock(Optional.class);
+ doReturn(optional).when(checkedFuture).get();
+ doReturn(true).when(optional).isPresent();
+ VfModuleList vfModuleList = mock(VfModuleList.class);
+ doReturn(vfModuleList).when(optional).get();
+ VfModuleServiceData vfModuleServiceData = mock(VfModuleServiceData.class);
+ doReturn(vfModuleServiceData).when(vfModuleList).getVfModuleServiceData();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(vfModuleServiceData).getSdncRequestHeader();
+
+ Whitebox.invokeMethod(vnfapiProvider, "getVfModuleServiceData", ssid, vfModuleServiceDataBuilder,
+ LogicalDatastoreType.CONFIGURATION);
+
+ Assert.assertEquals(sdncRequestHeader, vfModuleServiceDataBuilder.getSdncRequestHeader());
+
+ //With Two parameters: siid, vfModuleServiceDataBuilder
+ Whitebox.invokeMethod(vnfapiProvider, "getVfModuleServiceData", ssid, vfModuleServiceDataBuilder);
+
+ Assert.assertEquals(sdncRequestHeader, vfModuleServiceDataBuilder.getSdncRequestHeader());
+ }
+
+ @Test public void getPreloadData() throws Exception {
+ // Four parameters:
+ // String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type
+ PreloadDataBuilder preloadDataBuilder = spy(new PreloadDataBuilder());
+ // mock optional
+ Optional<VnfPreloadList> optional = mock(Optional.class);
+ doReturn(optional).when(checkedFuture).get();
+ doReturn(true).when(optional).isPresent();
+
+ VnfPreloadList vnfPreloadList = mock(VnfPreloadList.class);
+ doReturn(vnfPreloadList).when(optional).get();
+ PreloadData preloadData = mock(PreloadData.class);
+ doReturn(preloadData).when(vnfPreloadList).getPreloadData();
+
+ VnfTopologyInformation vnfTopologyInformation = mock(VnfTopologyInformation.class);
+ doReturn(vnfTopologyInformation).when(preloadData).getVnfTopologyInformation();
+
+ Whitebox.invokeMethod(vnfapiProvider, "getPreloadData", "preloadName", "preloadType", preloadDataBuilder,
+ LogicalDatastoreType.CONFIGURATION);
+
+ Assert.assertEquals(vnfTopologyInformation, preloadDataBuilder.getVnfTopologyInformation());
+
+ // Three parameters:
+ // String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type
+ Whitebox.invokeMethod(vnfapiProvider, "getPreloadData", "preloadName", "preloadType", preloadDataBuilder);
+
+ Assert.assertEquals(vnfTopologyInformation, preloadDataBuilder.getVnfTopologyInformation());
+ }
+
+ @Test public void getVnfInstancePreloadData() throws Exception {
+ // Four parameters:
+ // String preload_name, String preload_type, VnfInstancePreloadDataBuilder preloadDataBuilder,
+ // LogicalDatastoreType type
+ VnfInstancePreloadDataBuilder vnfInstancePreloadDataBuilder = spy(new VnfInstancePreloadDataBuilder());
+ // mock optional
+ Optional<VnfPreloadList> optional = mock(Optional.class);
+ doReturn(optional).when(checkedFuture).get();
+ doReturn(true).when(optional).isPresent();
+ VnfInstancePreloadList vnfInstancePreloadList = mock(VnfInstancePreloadList.class);
+ doReturn(vnfInstancePreloadList).when(optional).get();
+ VnfInstancePreloadData vnfInstancePreloadData = mock(VnfInstancePreloadData.class);
+ doReturn(vnfInstancePreloadData).when(vnfInstancePreloadList).getVnfInstancePreloadData();
+ VnfInstanceTopologyInformation vnfInstanceTopologyInformation = mock(VnfInstanceTopologyInformation.class);
+ doReturn(vnfInstanceTopologyInformation).when(vnfInstancePreloadData).getVnfInstanceTopologyInformation();
+
+ Whitebox.invokeMethod(vnfapiProvider, "getVnfInstancePreloadData", "preloadName", "preloadType",
+ vnfInstancePreloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
+
+ Assert.assertEquals(vnfInstanceTopologyInformation,
+ vnfInstancePreloadDataBuilder.getVnfInstanceTopologyInformation());
+
+ // Three Parameters:
+ // String preload_name, String preload_type, VnfInstancePreloadDataBuilder preloadDataBuilder
+ Whitebox.invokeMethod(vnfapiProvider, "getVnfInstancePreloadData", "preloadName", "preloadType",
+ vnfInstancePreloadDataBuilder);
+
+ Assert.assertEquals(vnfInstanceTopologyInformation,
+ vnfInstancePreloadDataBuilder.getVnfInstanceTopologyInformation());
+ }
+
+ @Test public void getVfModulePreloadData() throws Exception {
+ // Four Parameters
+ // String preload_name, String preload_type, VfModulePreloadDataBuilder preloadDataBuilder,
+ // LogicalDatastoreType type
+ VfModulePreloadDataBuilder vfModulePreloadDataBuilder = spy(new VfModulePreloadDataBuilder());
+ // mock optional
+ Optional<VfModulePreloadList> optional = mock(Optional.class);
+ doReturn(optional).when(checkedFuture).get();
+ doReturn(true).when(optional).isPresent();
+ VfModulePreloadList vfModulePreloadList = mock(VfModulePreloadList.class);
+ doReturn(vfModulePreloadList).when(optional).get();
+ VfModulePreloadData vfModulePreloadData = mock(VfModulePreloadData.class);
+ doReturn(vfModulePreloadData).when(vfModulePreloadList).getVfModulePreloadData();
+ VfModuleTopologyInformation vfModuleTopologyInformation = mock(VfModuleTopologyInformation.class);
+ doReturn(vfModuleTopologyInformation).when(vfModulePreloadData).getVfModuleTopologyInformation();
+
+ Whitebox.invokeMethod(vnfapiProvider, "getVfModulePreloadData", "preloadName", "preloadType",
+ vfModulePreloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
+
+ Assert.assertEquals(vfModuleTopologyInformation, vfModulePreloadDataBuilder.getVfModuleTopologyInformation());
+
+ // Three Parameters:
+ // String vnf_name, String vnf_type, VfModulePreloadDataBuilder preloadDataBuilder
+ Whitebox.invokeMethod(vnfapiProvider, "getVfModulePreloadData", "preloadName", "preloadType",
+ vfModulePreloadDataBuilder);
+
+ Assert.assertEquals(vfModuleTopologyInformation, vfModulePreloadDataBuilder.getVfModuleTopologyInformation());
+ }
+
+ /**
+ * With ServiceStatusBuilder, RequestInformation
+ */
+ @Test public void setServiceStatusOne() throws Exception {
+ // VNFActivateRequest
+ RequestInformation requestInformation = mock(RequestInformation.class);
+ ServiceStatusBuilder serviceStatusBuilder = spy(new ServiceStatusBuilder());
+ doReturn(RequestInformation.RequestAction.VNFActivateRequest).when(requestInformation).getRequestAction();
+ doReturn(RequestInformation.RequestSubAction.SUPP).when(requestInformation).getRequestSubAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.VNFActivateRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //ChangeVNFActivateRequest
+ doReturn(RequestInformation.RequestAction.ChangeVNFActivateRequest).when(requestInformation).getRequestAction();
+ doReturn(RequestInformation.RequestSubAction.CANCEL).when(requestInformation).getRequestSubAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert
+ .assertEquals(ServiceStatus.VnfsdnAction.ChangeVNFActivateRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //DisconnectVNFRequest
+ doReturn(RequestInformation.RequestAction.DisconnectVNFRequest).when(requestInformation).getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.DisconnectVNFRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //PreloadVNFRequest
+ doReturn(RequestInformation.RequestAction.PreloadVNFRequest).when(requestInformation).getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.PreloadVNFRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //DeletePreloadVNFRequest
+ doReturn(RequestInformation.RequestAction.DeletePreloadVNFRequest).when(requestInformation).getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.DeletePreloadVNFRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //VnfInstanceActivateRequest
+ doReturn(RequestInformation.RequestAction.VnfInstanceActivateRequest).when(requestInformation)
+ .getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.VnfInstanceActivateRequest,
+ serviceStatusBuilder.getVnfsdnAction());
+
+ //ChangeVnfInstanceActivateRequest
+ doReturn(RequestInformation.RequestAction.ChangeVnfInstanceActivateRequest).when(requestInformation)
+ .getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.ChangeVnfInstanceActivateRequest,
+ serviceStatusBuilder.getVnfsdnAction());
+
+ //DisconnectVnfInstanceRequest
+ doReturn(RequestInformation.RequestAction.DisconnectVnfInstanceRequest).when(requestInformation)
+ .getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.DisconnectVnfInstanceRequest,
+ serviceStatusBuilder.getVnfsdnAction());
+
+ //PreloadVnfInstanceRequest
+ doReturn(RequestInformation.RequestAction.PreloadVnfInstanceRequest).when(requestInformation)
+ .getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert
+ .assertEquals(ServiceStatus.VnfsdnAction.PreloadVnfInstanceRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //VfModuleActivateRequest
+ doReturn(RequestInformation.RequestAction.VfModuleActivateRequest).when(requestInformation).getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.VfModuleActivateRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //ChangeVfModuleActivateRequest
+ doReturn(RequestInformation.RequestAction.ChangeVfModuleActivateRequest).when(requestInformation)
+ .getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.ChangeVfModuleActivateRequest,
+ serviceStatusBuilder.getVnfsdnAction());
+
+ //DisconnectVfModuleRequest
+ doReturn(RequestInformation.RequestAction.DisconnectVfModuleRequest).when(requestInformation)
+ .getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert
+ .assertEquals(ServiceStatus.VnfsdnAction.DisconnectVfModuleRequest, serviceStatusBuilder.getVnfsdnAction());
+
+ //PreloadVfModuleRequest
+ doReturn(RequestInformation.RequestAction.PreloadVfModuleRequest).when(requestInformation).getRequestAction();
+ Whitebox.invokeMethod(vnfapiProvider, "setServiceStatus", serviceStatusBuilder, requestInformation);
+ Assert.assertEquals(ServiceStatus.VnfsdnAction.PreloadVfModuleRequest, serviceStatusBuilder.getVnfsdnAction());
+ }
+
+ @Test public void getServiceData() throws Exception {
+ ServiceDataBuilder serviceDataBuilder = spy(new ServiceDataBuilder());
+ // mock optional
+ Optional<VnfList> optional = mock(Optional.class);
+ doReturn(optional).when(checkedFuture).get();
+ doReturn(true).when(optional).isPresent();
+ VnfList vnfList = mock(VnfList.class);
+ doReturn(vnfList).when(optional).get();
+ ServiceData serviceData = mock(ServiceData.class);
+ doReturn(serviceData).when(vnfList).getServiceData();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(serviceData).getSdncRequestHeader();
+
+ Whitebox.invokeMethod(vnfapiProvider, "getServiceData", "siid", serviceDataBuilder,
+ LogicalDatastoreType.CONFIGURATION);
+
+ Assert.assertEquals(sdncRequestHeader, serviceDataBuilder.getSdncRequestHeader());
+ }
+
+ @Test public void getVnfInstanceServiceData() throws Exception {
+ VnfInstanceServiceDataBuilder vnfInstanceServiceDataBuilder = spy(new VnfInstanceServiceDataBuilder());
+ // mock optional
+ Optional<VnfList> optional = mock(Optional.class);
+ doReturn(optional).when(checkedFuture).get();
+ doReturn(true).when(optional).isPresent();
+ VnfInstanceList vnfInstanceList = mock(VnfInstanceList.class);
+ doReturn(vnfInstanceList).when(optional).get();
+ VnfInstanceServiceData vnfInstanceServiceData = mock(VnfInstanceServiceData.class);
+ doReturn(vnfInstanceServiceData).when(vnfInstanceList).getVnfInstanceServiceData();
+ SdncRequestHeader sdncRequestHeader = mock(SdncRequestHeader.class);
+ doReturn(sdncRequestHeader).when(vnfInstanceServiceData).getSdncRequestHeader();
+
+ Whitebox.invokeMethod(vnfapiProvider, "getVnfInstanceServiceData", "siid", vnfInstanceServiceDataBuilder,
+ LogicalDatastoreType.CONFIGURATION);
+
+ Assert.assertEquals(sdncRequestHeader, vnfInstanceServiceDataBuilder.getSdncRequestHeader());
+ }
+
+ @Test public void DeleteVnfList() throws Exception {
+ LogicalDatastoreType configuration = LogicalDatastoreType.CONFIGURATION;
+ VnfList vnfList = mock(VnfList.class);
+ VnfListKey vnfListKey = mock(VnfListKey.class);
+ doReturn(vnfListKey).when(vnfList).getKey();
+ InstanceIdentifier<VnfList> vnfListInstanceIdentifier = mock(InstanceIdentifier.class);
+ dataBroker.newWriteOnlyTransaction().put(configuration, vnfListInstanceIdentifier, vnfList);
+
+ Whitebox.invokeMethod(vnfapiProvider, "DeleteVnfList", vnfList, configuration);
+
+ verify(dataBroker, times(2)).newWriteOnlyTransaction();
+ }
+}