package org.onap.sdnc.northbound;
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.Futures;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.Optional;
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 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.WriteTransaction;
-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.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.BrgTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ConnectionAttachmentTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ConnectionAttachmentTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ConnectionAttachmentTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ConnectionAttachmentTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GENERICRESOURCEAPIService;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationNotificationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationNotificationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GenericConfigurationTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.GetpathsegmentTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PolicyUpdateNotifyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PortMirrorTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadInformation;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadNetworkTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.PreloadVfModuleTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.Services;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServicesBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.TunnelxconnTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfGetResourceRequestOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder;
+
+import com.google.common.util.concurrent.FluentFuture;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
+import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.mdsal.binding.api.WriteTransaction;
+import org.opendaylight.mdsal.common.api.CommitInfo;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
+import org.opendaylight.mdsal.common.api.OptimisticLockFailedException;
+import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.*;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.brg.response.information.BrgResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.connection.attachment.response.information.ConnectionAttachmentResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.gc.response.information.GcResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.pnf.response.information.PnfResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.port.mirror.response.information.PortMirrorResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadData;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.preload.data.PreloadDataBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.tunnelxconn.response.information.TunnelxconnResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.response.information.VfModuleResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder;
+import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.DataObject;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.slf4j.LoggerFactory;
/**
- * 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
+ * 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.
*
- * To use this, copy and paste (overwrite) the following method into the
- * TestApplicationProviderModule class which is auto generated under
- * src/main/java in this project (created only once during first compilation):
+ * To use this, copy and paste (overwrite) the following method into the TestApplicationProviderModule class which is
+ * auto generated under src/main/java in this project (created only once during first compilation):
*
* <pre>
*
* final GenericResourceApiProvider provider = new GenericResourceApiProvider();
* provider.setDataBroker(getDataBrokerDependency());
* provider.setNotificationService(getNotificationServiceDependency());
- * provider.setRpcRegistry(getRpcRegistryDependency());
+ * provider.setRpcService(getRpcServiceDependency());
* provider.initialize();
* return new AutoCloseable() {
*
private static final String SERVICE_OBJECT_PATH_PARAM = "service-object-path";
private static final String NETWORK_OBJECT_PATH_PARAM = "network-object-path";
private static final String VNF_OBJECT_PATH_PARAM = "vnf-object-path";
+ private static final String PNF_OBJECT_PATH_PARAM = "pnf-object-path";
private static final String VF_MODULE_OBJECT_PATH_PARAM = "vf-module-object-path";
+ private static final String VF_MODULE_ID_PARAM = "vf-module-id";
private static final String UPDATING_MDSAL_ERROR_MESSAGE = "Caught Exception updating MD-SAL for {} [{}] \n";
private static final String UPDATING_MDSAL_ERROR_MESSAGE_2 = "Caught Exception updating MD-SAL for {} [{},{}] \n";
private static final String RETURNED_FAILED_MESSAGE = "Returned FAILED for {} [{}] {}";
private static final String ERROR_NETWORK_ID = "error";
private static final String BACKGROUND_THREAD_STARTED_MESSAGE = "Start background thread";
private static final String BACKGROUND_THREAD_INFO = "Background thread: input conf_id is {}";
+ private static final String SKIP_MDSAL_UPDATE_PROP = "skip-mdsal-update";
private final Logger log = LoggerFactory.getLogger(GenericResourceApiProvider.class);
private final ExecutorService executor;
protected DataBroker dataBroker;
protected NotificationPublishService notificationService;
- protected RpcProviderRegistry rpcRegistry;
- protected BindingAwareBroker.RpcRegistration<GENERICRESOURCEAPIService> rpcRegistration;
+ protected RpcProviderService rpcService;
+ protected ObjectRegistration<GENERICRESOURCEAPIService> rpcRegistration;
public GenericResourceApiProvider(DataBroker dataBroker, NotificationPublishService notificationPublishService,
- RpcProviderRegistry rpcProviderRegistry, GenericResourceApiSvcLogicServiceClient client) {
+ RpcProviderService rpcProviderService, GenericResourceApiSvcLogicServiceClient client) {
log.info("Creating provider for {}", APP_NAME);
executor = Executors.newFixedThreadPool(1);
setDataBroker(dataBroker);
setNotificationService(notificationPublishService);
- setRpcRegistry(rpcProviderRegistry);
+ setRpcService(rpcProviderService);
svcLogicClient = client;
initialize();
log.error("Caught Exception while trying to load properties file", e);
}
+ if (rpcRegistration == null) {
+ if (rpcService != null) {
+ rpcRegistration = rpcService.registerRpcImplementation(GENERICRESOURCEAPIService.class, this);
+ }
+ }
+
log.info("Initialization complete for {}", APP_NAME);
}
}
}
- public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
- this.rpcRegistry = rpcRegistry;
+ public void setRpcService(RpcProviderService rpcService) {
+ this.rpcService = rpcService;
if (log.isDebugEnabled()) {
- log.debug("RpcRegistry set to {}", rpcRegistry == null ? NULL_PARAM : NON_NULL_PARAM);
+ log.debug("rpcService set to {}", rpcService == null ? NULL_PARAM : NON_NULL_PARAM);
}
}
// Create the service-instance container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Services.class),
- new ServicesBuilder().build());
+ new ServicesBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Services.class),
- new ServicesBuilder().build());
+ new ServicesBuilder().build());
// Create the PreloadInformation container
t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadInformation.class),
- new PreloadInformationBuilder().build());
+ new PreloadInformationBuilder().build());
t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadInformation.class),
- new PreloadInformationBuilder().build());
+ new PreloadInformationBuilder().build());
try {
- CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
+ FluentFuture<? extends @NonNull CommitInfo> checkedFuture = t.commit();
checkedFuture.get();
log.info("Create containers succeeded!");
}
private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, String errorCode, String errorMessage,
- String ackFinal) {
+ String ackFinal) {
serviceStatusBuilder.setResponseCode(errorCode);
serviceStatusBuilder.setResponseMessage(errorMessage);
serviceStatusBuilder.setFinalIndicator(ackFinal);
private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, SdncRequestHeader requestHeader) {
if (requestHeader != null && requestHeader.getSvcAction() != null) {
switch (requestHeader.getSvcAction()) {
- case Assign:
- serviceStatusBuilder.setRpcAction(RpcAction.Assign);
- break;
- case Unassign:
- serviceStatusBuilder.setRpcAction(RpcAction.Unassign);
- break;
- case Activate:
- serviceStatusBuilder.setRpcAction(RpcAction.Activate);
- break;
- case Deactivate:
- serviceStatusBuilder.setRpcAction(RpcAction.Deactivate);
- break;
- case Delete:
- serviceStatusBuilder.setRpcAction(RpcAction.Delete);
- break;
- case Create:
- serviceStatusBuilder.setRpcAction(RpcAction.Create);
- break;
- default:
- log.error("Unknown SvcAction: {}", requestHeader.getSvcAction());
- break;
+ case Assign:
+ serviceStatusBuilder.setRpcAction(RpcAction.Assign);
+ break;
+ case Unassign:
+ serviceStatusBuilder.setRpcAction(RpcAction.Unassign);
+ break;
+ case Activate:
+ serviceStatusBuilder.setRpcAction(RpcAction.Activate);
+ break;
+ case Deactivate:
+ serviceStatusBuilder.setRpcAction(RpcAction.Deactivate);
+ break;
+ case Delete:
+ serviceStatusBuilder.setRpcAction(RpcAction.Delete);
+ break;
+ case Create:
+ serviceStatusBuilder.setRpcAction(RpcAction.Create);
+ break;
+ default:
+ log.error("Unknown SvcAction: {}", requestHeader.getSvcAction());
+ break;
}
}
}
private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder, LogicalDatastoreType type) {
// See if any data exists yet for this siid, if so grab it.
- InstanceIdentifier<Service> serviceInstanceIdentifier = InstanceIdentifier.builder(Services.class)
- .child(Service.class, new ServiceKey(siid)).build();
-
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
- Optional<Service> data = Optional.absent();
- try {
- data = readTx.read(type, serviceInstanceIdentifier).get();
- } catch (InterruptedException | ExecutionException e) {
+ InstanceIdentifier<Service> serviceInstanceIdentifier = InstanceIdentifier.<Services>builder(Services.class)
+ .child(Service.class, new ServiceKey(siid)).build();
+
+ Optional<Service> data = null;
+
+ try (final ReadTransaction readTx = dataBroker.newReadOnlyTransaction()) {
+ data = (Optional<Service>) readTx.read(type, serviceInstanceIdentifier).get();
+ } catch (final InterruptedException | ExecutionException e) {
log.error("Caught Exception reading MD-SAL ({}) data for [{}] ", type, siid, e);
}
// Each entry will be identifiable by a unique key, we have to create that
// identifier
InstanceIdentifier<Service> path = InstanceIdentifier.builder(Services.class)
- .child(Service.class, entry.getKey()).build();
+ .child(Service.class, entry.key()).build();
trySaveEntry(entry, merge, storeType, path);
}
private <T extends DataObject> void trySaveEntry(T entry, boolean merge, LogicalDatastoreType storeType,
- InstanceIdentifier<T> path) {
+ InstanceIdentifier<T> path) {
int tries = 2;
while (true) {
try {
throw new IllegalStateException(e);
}
log.debug("Got OptimisticLockFailedException - trying again ");
- } catch (TransactionCommitFailedException ex) {
+ } catch (TransactionCommitFailedException|InterruptedException|ExecutionException ex) {
log.debug("Update DataStore failed");
throw new IllegalStateException(ex);
}
}
private <T extends DataObject> void save(T entry, boolean merge, LogicalDatastoreType storeType,
- InstanceIdentifier<T> path) throws TransactionCommitFailedException {
+ InstanceIdentifier<T> path) throws TransactionCommitFailedException, InterruptedException,
+ ExecutionException {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
if (merge) {
tx.merge(storeType, path, entry);
} else {
tx.put(storeType, path, entry);
}
- tx.submit().checkedGet();
+ tx.commit().get();
log.debug("Update DataStore succeeded");
}
// Each entry will be identifiable by a unique key, we have to create
// that identifier
InstanceIdentifier<Service> path = InstanceIdentifier.builder(Services.class)
- .child(Service.class, entry.getKey()).build();
+ .child(Service.class, entry.key()).build();
tryDeleteEntry(storeType, path);
}
throw new IllegalStateException(e);
}
log.debug("Got OptimisticLockFailedException - trying again ");
- } catch (TransactionCommitFailedException ex) {
+ } catch (TransactionCommitFailedException|InterruptedException|ExecutionException ex) {
log.debug("Update DataStore failed");
throw new IllegalStateException(ex);
}
}
private void delete(LogicalDatastoreType storeType, InstanceIdentifier<Service> path)
- throws TransactionCommitFailedException {
+ throws TransactionCommitFailedException, InterruptedException, ExecutionException {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.delete(storeType, path);
- tx.submit().checkedGet();
+ tx.commit().get();
log.debug("DataStore delete succeeded");
}
}
private void getPreloadData(String preloadName, String preloadType, PreloadDataBuilder preloadDataBuilder,
- LogicalDatastoreType type) {
+ LogicalDatastoreType type) {
// See if any data exists yet for this name/type, if so grab it.
InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier
- .<PreloadInformation>builder(PreloadInformation.class)
- .child(PreloadList.class, new PreloadListKey(preloadName, preloadType)).build();
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ .<PreloadInformation>builder(PreloadInformation.class)
+ .child(PreloadList.class, new PreloadListKey(preloadName, preloadType)).build();
+
Optional<PreloadList> data = null;
- try {
+ try (final ReadTransaction readTx = dataBroker.newReadOnlyTransaction()) {
data = (Optional<PreloadList>) readTx.read(type, preloadInstanceIdentifier).get();
- } catch (InterruptedException | ExecutionException e) {
+ } catch (final InterruptedException | ExecutionException e) {
log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType, e);
}
PreloadData preloadData = data.get().getPreloadData();
if (preloadData != null) {
log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", type, preloadName, preloadType,
- preloadData);
+ preloadData);
preloadDataBuilder
- .setPreloadVfModuleTopologyInformation(preloadData.getPreloadVfModuleTopologyInformation());
+ .setPreloadVfModuleTopologyInformation(preloadData.getPreloadVfModuleTopologyInformation());
preloadDataBuilder
- .setPreloadNetworkTopologyInformation(preloadData.getPreloadNetworkTopologyInformation());
+ .setPreloadNetworkTopologyInformation(preloadData.getPreloadNetworkTopologyInformation());
preloadDataBuilder.setPreloadOperStatus(preloadData.getPreloadOperStatus());
} else {
log.info("No preload-data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType);
}
private void savePreloadList(final PreloadList entry, boolean merge, LogicalDatastoreType storeType)
- throws IllegalStateException {
+ throws IllegalStateException {
// Each entry will be identifiable by a unique key, we have to create that
// identifier
InstanceIdentifier.InstanceIdentifierBuilder<PreloadList> preloadListBuilder = InstanceIdentifier
- .<PreloadInformation>builder(PreloadInformation.class).child(PreloadList.class, entry.getKey());
+ .<PreloadInformation>builder(PreloadInformation.class).child(PreloadList.class, entry.key());
InstanceIdentifier<PreloadList> path = preloadListBuilder.build();
int tries = 2;
while (true) {
} else {
tx.put(storeType, path, entry);
}
- tx.submit().checkedGet();
+ tx.commit().get();
log.debug("Update DataStore succeeded");
break;
- } catch (final TransactionCommitFailedException e) {
+ } catch (final InterruptedException | ExecutionException e) {
if (e instanceof OptimisticLockFailedException) {
if (--tries <= 0) {
log.debug("Got OptimisticLockFailedException on last try - failing ");
// Each entry will be identifiable by a unique key, we have to create
// that identifier
InstanceIdentifier<PreloadList> path = InstanceIdentifier.builder(PreloadInformation.class)
- .child(PreloadList.class, entry.getKey()).build();
+ .child(PreloadList.class, entry.key()).build();
tryDeletePreloadListEntry(storeType, path);
}
throw new IllegalStateException(e);
}
log.debug("Got OptimisticLockFailedException - trying again ");
- } catch (TransactionCommitFailedException ex) {
+ } catch (TransactionCommitFailedException|InterruptedException|ExecutionException ex) {
log.debug("Update DataStore failed");
throw new IllegalStateException(ex);
}
}
private void deletePreloadList(LogicalDatastoreType storeType, InstanceIdentifier<PreloadList> path)
- throws TransactionCommitFailedException {
+ throws TransactionCommitFailedException, InterruptedException, ExecutionException {
WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
tx.delete(storeType, path);
- tx.submit().checkedGet();
+ tx.commit().get();
log.debug("DataStore delete succeeded");
}
@Override
- public Future<RpcResult<ServiceTopologyOperationOutput>> serviceTopologyOperation(
- ServiceTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<ServiceTopologyOperationOutput>> serviceTopologyOperation(
+ ServiceTopologyOperationInput input) {
final String svcOperation = "service-topology-operation";
ServiceData serviceData;
responseBuilder.setAckFinalIndicator("Y");
RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(ServiceTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
private boolean hasInvalidServiceId(ServiceTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private void trySetSvcRequestId(ServiceTopologyOperationInput input,
- ServiceTopologyOperationOutputBuilder responseBuilder) {
+ ServiceTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
}
private Properties tryGetProperties(String svcOperation, Properties parms, ServiceDataBuilder serviceDataBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
try {
if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
try {
private boolean failed(ResponseObject error) {
return !error.getStatusCode().isEmpty()
- && !("0".equals(error.getStatusCode()) || "200".equals(error.getStatusCode()));
+ && !("0".equals(error.getStatusCode()) || "200".equals(error.getStatusCode()));
}
private boolean isValidRequest(ServiceTopologyOperationInput input) {
return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
}
+
+ @Override
+ public ListenableFuture<RpcResult<PnfTopologyOperationOutput>> pnfTopologyOperation(
+ PnfTopologyOperationInput input) {
+
+ final String svcOperation = "pnf-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties properties = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ PnfTopologyOperationOutputBuilder responseBuilder = new PnfTopologyOperationOutputBuilder();
+
+ if (hasInvalidServiceId(input)) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Grab the service instance ID from the input buffer
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ trySetSvcRequestId(input, responseBuilder);
+
+ /* Comment out mandatory check for pnf id for scenario wherein for assign/create request pnf-id is generated by
+ SDNC itself.
+ if (hasInvalidPnfId(input)) {
+ log.debug("exiting {} because of null or empty pnf-id", svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage("invalid input, null or empty pnf-id");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+ */
+
+ String pnfId = input.getPnfDetails().getPnfId();
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ ServiceDataBuilder operDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
+
+ // Set the serviceStatus based on input
+ setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
+ setServiceStatus(serviceStatusBuilder, input.getRequestInformation());
+
+ //
+ // setup a service-data object builder
+ // ACTION pnf-topology-operation
+ // INPUT:
+ // USES sdnc-request-header;
+ // USES request-information;
+ // USES service-information;
+ // USES pnf-details
+ // OUTPUT:
+ // USES pnf-topology-response-body;
+ // USES pnf-details
+ // USES service-information
+ //
+ // uses oper-status;
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ PnfTopologyOperationInputBuilder inputBuilder = new PnfTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(properties, inputBuilder.build());
+
+ log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+
+ ResponseObject responseObject = new ResponseObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ String pnfObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject);
+
+ if (respProps != null) {
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ if (pnfId == null) {
+ pnfId = respProps.getProperty("pnfId");
+ }
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ pnfObjectPath = respProps.getProperty(PNF_OBJECT_PATH_PARAM);
+ }
+
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ try {
+ saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ trySaveService(input, serviceBuilder);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ }
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
+
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+
+ if (isValidRequest(input) && input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
+ // Only update operational tree on Assign
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ serviceResponseInformationBuilder.setInstanceId(siid);
+ serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
+ responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
+
+ PnfResponseInformationBuilder pnfResponseInformationBuilder = new PnfResponseInformationBuilder();
+ pnfResponseInformationBuilder.setInstanceId(pnfId);
+ pnfResponseInformationBuilder.setObjectPath(pnfObjectPath);
+ responseBuilder.setPnfResponseInformation(pnfResponseInformationBuilder.build());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.getMessage());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ trySetResponseMessage(responseBuilder, responseObject);
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<PnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<PnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ // return success
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private void trySetResponseMessage(PnfTopologyOperationOutputBuilder responseBuilder,
+ ResponseObject responseObject) {
+ if (responseObject.getMessage() != null) {
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ }
+ }
+
+ private void trySaveService(PnfTopologyOperationInput input, ServiceBuilder serviceBuilder) {
+ if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
+
+ // Only update operational tree on activate or delete
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+ }
+
+ private boolean hasInvalidPnfId(PnfTopologyOperationInput input) {
+ return input.getPnfDetails() == null || input.getPnfDetails().getPnfId() == null
+ || input.getPnfDetails().getPnfId().length() == 0;
+ }
+
+ private boolean hasInvalidServiceId(PnfTopologyOperationInput input) {
+ return input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ }
+
+ private void trySetSvcRequestId(PnfTopologyOperationInput input,
+ PnfTopologyOperationOutputBuilder responseBuilder) {
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+ }
+
+ private boolean isValidRequest(PnfTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+
@Override
- public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(
+ VnfTopologyOperationInput input) {
final String svcOperation = "vnf-topology-operation";
ServiceData serviceData;
responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
responseBuilder.setAckFinalIndicator("Y");
RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
String ackFinal = "Y";
String serviceObjectPath = null;
String vnfObjectPath = null;
+ String skipMdsalUpdate = null;
Properties respProps = tryGetProperties(svcOperation, properties, serviceDataBuilder, responseObject);
if (respProps != null) {
}
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
vnfObjectPath = respProps.getProperty(VNF_OBJECT_PATH_PARAM);
+ skipMdsalUpdate = respProps.getProperty(SKIP_MDSAL_UPDATE_PROP);
+ if (skipMdsalUpdate == null) {
+ skipMdsalUpdate = "N";
+ }
}
setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
// Got success from SLI
try {
- serviceData = serviceDataBuilder.build();
- log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
-
- // service object
- ServiceBuilder serviceBuilder = new ServiceBuilder();
- serviceBuilder.setServiceData(serviceData);
- serviceBuilder.setServiceInstanceId(siid);
- serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
- saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
-
- if (isValidRequest(input) && input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
- // Only update operational tree on Assign
- log.info(UPDATING_TREE_INFO_MESSAGE);
- saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ if (skipMdsalUpdate.equals("N")) {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
+
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+
+ if (isValidRequest(input) && input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
+ // Only update operational tree on Assign
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+ } else {
+ // Even if we are skipping the MD-SAL update, update the service status object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ Service service = serviceBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, service);
+ saveService(service, true, LogicalDatastoreType.CONFIGURATION);
}
ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
+
+ if (ackFinal.equals("N")) {
+ // Spawn background thread to invoke the Async DG
+ Runnable backgroundThread = new Runnable() {
+ public void run() {
+ log.info(BACKGROUND_THREAD_STARTED_MESSAGE);
+ processAsyncVnfTopologyOperation(input);
+ }
+ };
+ new Thread(backgroundThread).start();
+ }
// return success
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(VnfTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
private void trySaveService(VnfTopologyOperationInput input, ServiceBuilder serviceBuilder) {
if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
// Only update operational tree on activate or delete
log.info(UPDATING_TREE_INFO_MESSAGE);
private boolean hasInvalidVnfId(VnfTopologyOperationInput input) {
return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
- || input.getVnfInformation().getVnfId().length() == 0;
+ || input.getVnfInformation().getVnfId().length() == 0;
}
private boolean hasInvalidServiceId(VnfTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ }
+
+ private void trySetSvcRequestId(VnfTopologyOperationInput input,
+ VnfTopologyOperationOutputBuilder responseBuilder) {
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+ }
+
+ private boolean isValidRequest(VnfTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+ public void processAsyncVnfTopologyOperation(VnfTopologyOperationInput input) {
+ log.info(BACKGROUND_THREAD_INFO, input.getVnfInformation().getVnfId());
+
+ final String svcOperation = "vnf-topology-operation-async";
+ ServiceData serviceData = null;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+
+ // create a new response object (for logging purposes only)
+ VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder();
+
+ // Grab the service instance ID from the input buffer
+ String siid = input.getServiceInformation().getServiceInstanceId();
+ String vnfId = input.getVnfInformation().getVnfId();
+
+ trySetSvcRequestId(input, responseBuilder);
+
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ ServiceDataBuilder operDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
+
+ // Set the serviceStatus based on input
+ setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
+ setServiceStatus(serviceStatusBuilder, input.getRequestInformation());
+
+ //
+ // setup a service-data object builder
+ // ACTION vnf-topology-operation
+ // INPUT:
+ // USES sdnc-request-header;
+ // USES request-information;
+ // USES service-information;
+ // USES vnf-request-information
+ // OUTPUT:
+ // USES vnf-topology-response-body;
+ // USES vnf-information
+ // USES service-information
+ //
+ // container service-data
+ // uses vnf-configuration-information;
+ // uses oper-status;
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ VnfTopologyOperationInputBuilder inputBuilder = new VnfTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+
+ ResponseObject responseObject = new ResponseObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ String vnfObjectPath = null;
+ String skipMdsalUpdate = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
+
+ if (respProps != null) {
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ vnfObjectPath = respProps.getProperty(VNF_OBJECT_PATH_PARAM);
+ skipMdsalUpdate = respProps.getProperty(SKIP_MDSAL_UPDATE_PROP);
+ if (skipMdsalUpdate == null) {
+ skipMdsalUpdate = "N";
+ }
+ }
+
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ try {
+ saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ }
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+ return;
+ }
+
+ // Got success from SLI
+ try {
+ if (skipMdsalUpdate.equals("N")) {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
+
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+
+ trySaveService(input, serviceBuilder);
+ } else {
+ // Even if we are skipping the MD-SAL update, update the service status object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ Service service = serviceBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, service);
+ saveService(service, true, LogicalDatastoreType.CONFIGURATION);
+ }
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ serviceResponseInformationBuilder.setInstanceId(siid);
+ serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
+ responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
+
+ VnfResponseInformationBuilder vnfResponseInformationBuilder = new VnfResponseInformationBuilder();
+ vnfResponseInformationBuilder.setInstanceId(vnfId);
+ vnfResponseInformationBuilder.setObjectPath(vnfObjectPath);
+ responseBuilder.setVnfResponseInformation(vnfResponseInformationBuilder.build());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.getMessage());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ return;
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ trySetResponseMessage(responseBuilder, responseObject);
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+ return;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation(
+ VfModuleTopologyOperationInput input) {
+
+ final String svcOperation = "vf-module-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ VfModuleTopologyOperationOutputBuilder responseBuilder = new VfModuleTopologyOperationOutputBuilder();
+
+ if (hasInvalidServiceId(input)) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ if (hasInvalidVnfId(input)) {
+ log.debug("exiting {} because of null or empty vnf-id", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
+ responseBuilder.setAckFinalIndicator("Y");
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ /*if (hasInvalidVfModuleId(input)) {
+ log.debug("exiting {} because of null or empty vf-module-id", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("invalid input, vf-module-id is null or empty");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }*/
+
+ // Grab the service instance ID from the input buffer
+ String siid = input.getServiceInformation().getServiceInstanceId();
+ String vnfId = input.getVnfInformation().getVnfId();
+ String vfModuleId = input.getVfModuleInformation().getVfModuleId();
+
+ trySetSvcRequestId(input, responseBuilder);
+
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ ServiceDataBuilder operDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
+
+ // Set the serviceStatus based on input
+ setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader());
+ setServiceStatus(serviceStatusBuilder, input.getRequestInformation());
+
+ //
+ // setup a service-data object builder
+ // ACTION vnf-topology-operation
+ // INPUT:
+ // USES sdnc-request-header;
+ // USES request-information;
+ // USES service-information;
+ // USES vnf-request-information
+ // OUTPUT:
+ // USES vnf-topology-response-body;
+ // USES vnf-information
+ // USES service-information
+ //
+ // container service-data
+ // uses vnf-configuration-information;
+ // uses oper-status;
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+
+ ResponseObject responseObject = new ResponseObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ String vnfObjectPath = null;
+ String vfModuleObjectPath = null;
+ String skipMdsalUpdate = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
+
+ if (respProps != null) {
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ if (vfModuleId == null) {
+ vfModuleId = respProps.getProperty(VF_MODULE_ID_PARAM);
+ if (vfModuleId == null) {
+ log.debug("exiting {} because vf-module-id not found in response", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("failed to generate vf-module-id");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+ }
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ vnfObjectPath = respProps.getProperty(VNF_OBJECT_PATH_PARAM);
+ vfModuleObjectPath = respProps.getProperty(VF_MODULE_OBJECT_PATH_PARAM);
+ skipMdsalUpdate = respProps.getProperty(SKIP_MDSAL_UPDATE_PROP);
+ if (skipMdsalUpdate == null) {
+ skipMdsalUpdate = "N";
+ }
+ }
+
+ setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ try {
+ saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ }
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+ if (skipMdsalUpdate.equals("N")) {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
+
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+
+ trySaveService(input, serviceBuilder);
+ } else {
+ // Even if we are skipping the MD-SAL update, update the service status object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ Service service = serviceBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, service);
+ saveService(service, true, LogicalDatastoreType.CONFIGURATION);
+ }
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ serviceResponseInformationBuilder.setInstanceId(siid);
+ serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
+ responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
+
+ VnfResponseInformationBuilder vnfResponseInformationBuilder = new VnfResponseInformationBuilder();
+ vnfResponseInformationBuilder.setInstanceId(vnfId);
+ vnfResponseInformationBuilder.setObjectPath(vnfObjectPath);
+ responseBuilder.setVnfResponseInformation(vnfResponseInformationBuilder.build());
+
+ VfModuleResponseInformationBuilder vfModuleResponseInformationBuilder = new VfModuleResponseInformationBuilder();
+ vfModuleResponseInformationBuilder.setInstanceId(vfModuleId);
+ vfModuleResponseInformationBuilder.setObjectPath(vfModuleObjectPath);
+ responseBuilder.setVfModuleResponseInformation(vfModuleResponseInformationBuilder.build());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.getMessage());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ trySetResponseMessage(responseBuilder, responseObject);
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+
+ if (ackFinal.equals("N")) {
+ // Spawn background thread to invoke the Async DG
+ Runnable backgroundThread = new Runnable() {
+ public void run() {
+ log.info(BACKGROUND_THREAD_STARTED_MESSAGE);
+ processAsyncVfModuleTopologyOperation(input);
+ }
+ };
+ new Thread(backgroundThread).start();
+ }
+
+ // return success
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private void trySetResponseMessage(VfModuleTopologyOperationOutputBuilder responseBuilder,
+ ResponseObject responseObject) {
+ if (responseObject.getMessage() != null) {
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ }
+ }
+
+ private void trySaveService(VfModuleTopologyOperationInput input, ServiceBuilder serviceBuilder) {
+ if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign)
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
+ // Only update operational tree on activate or delete
+
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+ }
+
+ private void trySetSvcRequestId(VfModuleTopologyOperationInput input,
+ VfModuleTopologyOperationOutputBuilder responseBuilder) {
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+ }
+
+ private boolean hasInvalidVfModuleId(VfModuleTopologyOperationInput input) {
+ return input.getVfModuleInformation() == null || input.getVfModuleInformation().getVfModuleId() == null
+ || input.getVfModuleInformation().getVfModuleId().length() == 0;
+ }
+
+ private boolean hasInvalidVnfId(VfModuleTopologyOperationInput input) {
+ return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
+ || input.getVnfInformation().getVnfId().length() == 0;
}
- private void trySetSvcRequestId(VnfTopologyOperationInput input,
- VnfTopologyOperationOutputBuilder responseBuilder) {
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
+ private boolean hasInvalidServiceId(VfModuleTopologyOperationInput input) {
+ return input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
- private boolean isValidRequest(VnfTopologyOperationInput input) {
+ private boolean isValidRequest(VfModuleTopologyOperationInput input) {
return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
}
- @Override
- public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation(
- VfModuleTopologyOperationInput input) {
+ public void processAsyncVfModuleTopologyOperation(VfModuleTopologyOperationInput input) {
+ log.info(BACKGROUND_THREAD_INFO, input.getVfModuleInformation().getVfModuleId());
- final String svcOperation = "vf-module-topology-operation";
- ServiceData serviceData;
+ final String svcOperation = "vf-module-topology-operation-async";
+ ServiceData serviceData = null;
ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
Properties parms = new Properties();
log.info(CALLED_STR, svcOperation);
- // create a new response object
- VfModuleTopologyOperationOutputBuilder responseBuilder = new VfModuleTopologyOperationOutputBuilder();
-
- if (hasInvalidServiceId(input)) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
- responseBuilder.setAckFinalIndicator("Y");
-
- RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
-
- // return error
- return Futures.immediateFuture(rpcResult);
- }
-
- if (hasInvalidVnfId(input)) {
- log.debug("exiting {} because of null or empty vnf-id", svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- if (hasInvalidVfModuleId(input)) {
- log.debug("exiting {} because of null or empty vf-module-id", svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("invalid input, vf-module-id is null or empty");
- responseBuilder.setAckFinalIndicator("Y");
-
- RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
+ // create a new response object (for logging purposes only)
+ VfModuleTopologyOperationOutputBuilder responseBuilder = new VfModuleTopologyOperationOutputBuilder();
// Grab the service instance ID from the input buffer
String siid = input.getServiceInformation().getServiceInstanceId();
String serviceObjectPath = null;
String vnfObjectPath = null;
String vfModuleObjectPath = null;
+ String skipMdsalUpdate = null;
Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
if (respProps != null) {
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
vnfObjectPath = respProps.getProperty(VNF_OBJECT_PATH_PARAM);
vfModuleObjectPath = respProps.getProperty(VF_MODULE_OBJECT_PATH_PARAM);
+ skipMdsalUpdate = respProps.getProperty(SKIP_MDSAL_UPDATE_PROP);
+ if (skipMdsalUpdate == null) {
+ skipMdsalUpdate = "N";
+ }
}
setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
-
- // return error
- return Futures.immediateFuture(rpcResult);
+ return;
}
// Got success from SLI
try {
- serviceData = serviceDataBuilder.build();
- log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
+ if (skipMdsalUpdate.equals("N")) {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
- // service object
- ServiceBuilder serviceBuilder = new ServiceBuilder();
- serviceBuilder.setServiceData(serviceData);
- serviceBuilder.setServiceInstanceId(siid);
- serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
- saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
- trySaveService(input, serviceBuilder);
+ trySaveService(input, serviceBuilder);
+ } else {
+ // Even if we are skipping the MD-SAL update, update the service status object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ Service service = serviceBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, service);
+ saveService(service, true, LogicalDatastoreType.CONFIGURATION);
+ }
ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
serviceResponseInformationBuilder.setInstanceId(siid);
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
-
- return Futures.immediateFuture(rpcResult);
+ return;
}
// Update succeeded
trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
-
- // return success
- return Futures.immediateFuture(rpcResult);
- }
-
- private void trySetResponseMessage(VfModuleTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
- if (responseObject.getMessage() != null) {
- responseBuilder.setResponseMessage(responseObject.getMessage());
- }
- }
-
- private void trySaveService(VfModuleTopologyOperationInput input, ServiceBuilder serviceBuilder) {
- if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
- // Only update operational tree on activate or delete
-
- log.info(UPDATING_TREE_INFO_MESSAGE);
- saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
- }
- }
-
- private void trySetSvcRequestId(VfModuleTopologyOperationInput input,
- VfModuleTopologyOperationOutputBuilder responseBuilder) {
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
- }
-
- private boolean hasInvalidVfModuleId(VfModuleTopologyOperationInput input) {
- return input.getVfModuleInformation() == null || input.getVfModuleInformation().getVfModuleId() == null
- || input.getVfModuleInformation().getVfModuleId().length() == 0;
- }
-
- private boolean hasInvalidVnfId(VfModuleTopologyOperationInput input) {
- return input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
- || input.getVnfInformation().getVnfId().length() == 0;
- }
-
- private boolean hasInvalidServiceId(VfModuleTopologyOperationInput input) {
- return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
- }
-
- private boolean isValidRequest(VfModuleTopologyOperationInput input) {
- return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ return;
}
@Override
- public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
- NetworkTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
+ NetworkTopologyOperationInput input) {
final String svcOperation = "network-topology-operation";
ServiceData serviceData;
String networkId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
String networkObjectPath = null;
+ String skipMdsalUpdate = null;
Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
if (respProps != null) {
networkId = respProps.getProperty("networkId");
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
networkObjectPath = respProps.getProperty(NETWORK_OBJECT_PATH_PARAM);
+ skipMdsalUpdate = respProps.getProperty(SKIP_MDSAL_UPDATE_PROP);
+ if (skipMdsalUpdate == null) {
+ skipMdsalUpdate = "N";
+ }
}
if (failed(responseObject)) {
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Got success from SLI
try {
+ if (skipMdsalUpdate.equals("N")) {
+ serviceData = serviceDataBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
- serviceData = serviceDataBuilder.build();
- log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, serviceData);
-
- // service object
- ServiceBuilder serviceBuilder = new ServiceBuilder();
- serviceBuilder.setServiceData(serviceData);
- serviceBuilder.setServiceInstanceId(siid);
- serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
- saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ // service object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceData(serviceData);
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
- trySaveService(input, serviceBuilder);
+ trySaveService(input, serviceBuilder);
+ } else {
+ // Even if we are skipping the MD-SAL update, update the service status object
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ Service service = serviceBuilder.build();
+ log.info(UPDATING_MDSAL_INFO_MESSAGE, svcOperation, siid, service);
+ saveService(service, true, LogicalDatastoreType.CONFIGURATION);
+ }
NetworkResponseInformationBuilder networkResponseInformationBuilder = new NetworkResponseInformationBuilder();
networkResponseInformationBuilder.setInstanceId(networkId);
serviceResponseInformationBuilder.setInstanceId(siid);
serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
-
} catch (IllegalStateException e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(NetworkTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
}
private void trySetSvcRequestId(NetworkTopologyOperationInput input,
- NetworkTopologyOperationOutputBuilder responseBuilder) {
+ NetworkTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
private void trySaveService(NetworkTopologyOperationInput input, ServiceBuilder serviceBuilder) {
if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Create))) {
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Create))) {
// Only update operational tree on Activate
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
private boolean hasInvalidServiceId(NetworkTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
- private Future<RpcResult<NetworkTopologyOperationOutput>> buildRpcResultFuture(
- NetworkTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
+ private ListenableFuture<RpcResult<NetworkTopologyOperationOutput>> buildRpcResultFuture(
+ NetworkTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(responseMessage);
responseBuilder.setAckFinalIndicator("Y");
RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
}
@Override
- public Future<RpcResult<ContrailRouteTopologyOperationOutput>> contrailRouteTopologyOperation(
- ContrailRouteTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<ContrailRouteTopologyOperationOutput>> contrailRouteTopologyOperation(
+ ContrailRouteTopologyOperationInput input) {
final String svcOperation = "contrail-route-topology-operation";
ServiceData serviceData;
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(ContrailRouteTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
private void trySaveService(ContrailRouteTopologyOperationInput input, ServiceBuilder serviceBuilder) {
if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
// Only update operational tree on activate or delete
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
}
private void trySetSvcRequestId(ContrailRouteTopologyOperationInput input,
- ContrailRouteTopologyOperationOutputBuilder responseBuilder) {
+ ContrailRouteTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
private boolean hasInvalidServiceId(ContrailRouteTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
- private Future<RpcResult<ContrailRouteTopologyOperationOutput>> buildRpcResultFuture(
- ContrailRouteTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
+ private ListenableFuture<RpcResult<ContrailRouteTopologyOperationOutput>> buildRpcResultFuture(
+ ContrailRouteTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(responseMessage);
responseBuilder.setAckFinalIndicator("Y");
RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
}
@Override
- public Future<RpcResult<SecurityZoneTopologyOperationOutput>> securityZoneTopologyOperation(
- SecurityZoneTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<SecurityZoneTopologyOperationOutput>> securityZoneTopologyOperation(
+ SecurityZoneTopologyOperationInput input) {
final String svcOperation = "security-zone-topology-operation";
ServiceData serviceData;
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(SecurityZoneTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
private void trySaveService(SecurityZoneTopologyOperationInput input, ServiceBuilder serviceBuilder) {
if (isValidRequest(input) && (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
// Only update operational tree on activate or delete
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
}
private void trySetSvcRequestId(SecurityZoneTopologyOperationInput input,
- SecurityZoneTopologyOperationOutputBuilder responseBuilder) {
+ SecurityZoneTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
private boolean hasInvalidServiceId(SecurityZoneTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
- private Future<RpcResult<SecurityZoneTopologyOperationOutput>> buildRpcResultFuture(
- SecurityZoneTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
+ private ListenableFuture<RpcResult<SecurityZoneTopologyOperationOutput>> buildRpcResultFuture(
+ SecurityZoneTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
responseBuilder.setResponseCode("404");
responseBuilder.setResponseMessage(responseMessage);
responseBuilder.setAckFinalIndicator("Y");
RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
}
}
- private Future<RpcResult<ConnectionAttachmentTopologyOperationOutput>>
+ private ListenableFuture<RpcResult<ConnectionAttachmentTopologyOperationOutput>>
buildRpcResultFuture(ConnectionAttachmentTopologyOperationOutputBuilder responseBuilder, String responseMessage) {
responseBuilder.setResponseCode("404");
}
@Override
- public Future<RpcResult<ConnectionAttachmentTopologyOperationOutput>> connectionAttachmentTopologyOperation(ConnectionAttachmentTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<ConnectionAttachmentTopologyOperationOutput>> connectionAttachmentTopologyOperation(
+ ConnectionAttachmentTopologyOperationInput input) {
final String svcOperation = "connection-attachment-topology-operation";
Properties parms = new Properties();
log.info(CALLED_STR, svcOperation);
return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
}
- ConnectionAttachmentTopologyOperationInputBuilder inputBuilder = new ConnectionAttachmentTopologyOperationInputBuilder(input);
+ ConnectionAttachmentTopologyOperationInputBuilder inputBuilder = new ConnectionAttachmentTopologyOperationInputBuilder(
+ input);
GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
// Call SLI sync method
ConnectionAttachmentResponseInformationBuilder connectionAttachmentResponseInformationBuilder = new ConnectionAttachmentResponseInformationBuilder();
connectionAttachmentResponseInformationBuilder.setInstanceId(allottedResourceId);
connectionAttachmentResponseInformationBuilder.setObjectPath(connectionAttachmentObjectPath);
- responseBuilder.setConnectionAttachmentResponseInformation(connectionAttachmentResponseInformationBuilder.build());
+ responseBuilder
+ .setConnectionAttachmentResponseInformation(connectionAttachmentResponseInformationBuilder.build());
ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
serviceResponseInformationBuilder.setInstanceId(siid);
}
@Override
- public Future<RpcResult<TunnelxconnTopologyOperationOutput>> tunnelxconnTopologyOperation(
- TunnelxconnTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<TunnelxconnTopologyOperationOutput>> tunnelxconnTopologyOperation(
+ TunnelxconnTopologyOperationInput input) {
final String svcOperation = "tunnelxconn-topology-operation";
Properties parms = new Properties();
responseBuilder.setAckFinalIndicator("Y");
RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(TunnelxconnTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
private boolean hasInvalidServiceId(TunnelxconnTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private Properties tryGetProperties(String svcOperation, Properties parms, ResponseObject responseObject) {
}
@Override
- public Future<RpcResult<BrgTopologyOperationOutput>> brgTopologyOperation(BrgTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<BrgTopologyOperationOutput>> brgTopologyOperation(
+ BrgTopologyOperationInput input) {
final String svcOperation = "brg-topology-operation";
Properties parms = new Properties();
responseBuilder.setAckFinalIndicator("Y");
RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private void trySetResponseMessage(BrgTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
private boolean hasInvalidServiceId(BrgTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private String resolveAckFinal(ResponseObject responseObject, Properties respProps) {
}
@Override
- public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
- PreloadNetworkTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
+ PreloadNetworkTopologyOperationInput input) {
final String svcOperation = "preload-network-topology-operation";
PreloadData preloadData;
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Grab the preload ID from the input buffer
String preloadId = input.getPreloadNetworkTopologyInformation().getNetworkTopologyIdentifierStructure()
- .getNetworkName();
+ .getNetworkName();
String preloadType = "network";
trySetSvcRequestId(input, responseBuilder);
log.info(ADDING_INPUT_DATA_LOG, svcOperation, preloadId, input);
PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder(
- input);
+ input);
GenericResourceApiUtil.toProperties(properties, inputBuilder.build());
log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, preloadId, input);
GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder);
responseBuilder.setAckFinalIndicator(ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build());
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build());
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, preloadId, responseBuilder.build());
RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private boolean hasInvalidPreloadNetwork(PreloadNetworkTopologyOperationInput input) {
return input == null || input.getPreloadNetworkTopologyInformation() == null
- || input.getPreloadNetworkTopologyInformation().getNetworkTopologyIdentifierStructure() == null;
+ || input.getPreloadNetworkTopologyInformation().getNetworkTopologyIdentifierStructure() == null;
}
private boolean hasInvalidPreloadId(String preloadId) {
}
private void trySetSvcRequestId(PreloadNetworkTopologyOperationInput input,
- PreloadNetworkTopologyOperationOutputBuilder responseBuilder) {
+ PreloadNetworkTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
}
private Properties tryGetProperties(String svcOperation, Properties parms, PreloadDataBuilder preloadDataBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
try {
if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
try {
}
private void trySetResponseMessage(PreloadNetworkTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
if (!responseObject.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
@Override
- public Future<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation(
- PreloadVfModuleTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<PreloadVfModuleTopologyOperationOutput>> preloadVfModuleTopologyOperation(
+ PreloadVfModuleTopologyOperationInput input) {
final String svcOperation = "preload-vf-module-topology-operation";
PreloadData preloadData;
if (hasInvalidPreloadVfModule(input)) {
log.debug(
- "exiting {} because of null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name",
- svcOperation);
+ "exiting {} because of null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name",
+ svcOperation);
responseBuilder.setResponseCode("403");
responseBuilder.setResponseMessage(
- "invalid input, null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name");
+ "invalid input, null or empty preload-vf-module-topology-information.vf-module-topology.vf-module-topology-identifier.vf-module-name");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
// Grab the preload ID from the input buffer
String preloadId = input.getPreloadVfModuleTopologyInformation().getVfModuleTopology()
- .getVfModuleTopologyIdentifier().getVfModuleName();
+ .getVfModuleTopologyIdentifier().getVfModuleName();
String preloadType = "vf-module";
trySetSvcRequestId(input, responseBuilder);
log.info(ADDING_INPUT_DATA_LOG, svcOperation, preloadId, input);
PreloadVfModuleTopologyOperationInputBuilder inputBuilder = new PreloadVfModuleTopologyOperationInputBuilder(
- input);
+ input);
GenericResourceApiUtil.toProperties(properties, inputBuilder.build());
log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, preloadId, input);
GenericResourceApiUtil.toProperties(properties, OPERATIONAL_DATA_PARAM, operDataBuilder);
responseBuilder.setAckFinalIndicator(ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build());
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, preloadId, responseBuilder.build());
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, preloadId, responseBuilder.build());
RpcResult<PreloadVfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PreloadVfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private boolean hasInvalidPreloadVfModule(PreloadVfModuleTopologyOperationInput input) {
return input == null || input.getPreloadVfModuleTopologyInformation() == null
- || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology() == null
- || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology()
- .getVfModuleTopologyIdentifier() == null
- || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology().getVfModuleTopologyIdentifier()
- .getVfModuleName() == null;
+ || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology() == null
+ || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology()
+ .getVfModuleTopologyIdentifier() == null
+ || input.getPreloadVfModuleTopologyInformation().getVfModuleTopology().getVfModuleTopologyIdentifier()
+ .getVfModuleName() == null;
}
private void trySetSvcRequestId(PreloadVfModuleTopologyOperationInput input,
- PreloadVfModuleTopologyOperationOutputBuilder responseBuilder) {
+ PreloadVfModuleTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
}
private void trySetResponseMessage(PreloadVfModuleTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
if (!responseObject.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
@Override
- public Future<RpcResult<GenericConfigurationTopologyOperationOutput>> genericConfigurationTopologyOperation(
- GenericConfigurationTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<GenericConfigurationTopologyOperationOutput>> genericConfigurationTopologyOperation(
+ GenericConfigurationTopologyOperationInput input) {
final String svcOperation = "generic-configuration-topology-operation";
ServiceData serviceData;
responseBuilder.setAckFinalIndicator("Y");
RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
- .build();
+ .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setResponseMessage("invalid input, null or empty configuration-id or configuration-type");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
- .build();
+ .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
GenericConfigurationTopologyOperationInputBuilder inputBuilder = new GenericConfigurationTopologyOperationInputBuilder(
- input);
+ input);
GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
- .build();
+ .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
- .build();
+ .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build())
+ .build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<GenericConfigurationTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<GenericConfigurationTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private boolean hasInvalidService(GenericConfigurationTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private void trySetSvcRequestId(GenericConfigurationTopologyOperationInput input,
- GenericConfigurationTopologyOperationOutputBuilder responseBuilder) {
+ GenericConfigurationTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
private boolean hasInvalidConfigurationIdOrType(GenericConfigurationTopologyOperationInput input) {
return input.getConfigurationInformation() == null
- || input.getConfigurationInformation().getConfigurationId() == null
- || input.getConfigurationInformation().getConfigurationType() == null;
+ || input.getConfigurationInformation().getConfigurationId() == null
+ || input.getConfigurationInformation().getConfigurationType() == null;
}
private void trySetResponseMessage(GenericConfigurationTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
if (!responseObject.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
@Override
- public Future<RpcResult<Void>> genericConfigurationNotification(GenericConfigurationNotificationInput input) {
+ public ListenableFuture<RpcResult<GenericConfigurationNotificationOutput>> genericConfigurationNotification(
+ GenericConfigurationNotificationInput input) {
final String svcOperation = "generic-configuration-notification";
ServiceData serviceData;
log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
GenericConfigurationNotificationInputBuilder inputBuilder = new GenericConfigurationNotificationInputBuilder(
- input);
+ input);
GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
}
- RpcResult<Void> rpcResult = RpcResultBuilder.<Void>status(true).build();
+ RpcResult<GenericConfigurationNotificationOutput> rpcResult = RpcResultBuilder.<GenericConfigurationNotificationOutput>status(
+ true).build();
return Futures.immediateFuture(rpcResult);
}
} catch (Exception e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
- RpcResult<Void> rpcResult = RpcResultBuilder.<Void>status(true).build();
+ RpcResult<GenericConfigurationNotificationOutput> rpcResult = RpcResultBuilder.<GenericConfigurationNotificationOutput>status(
+ true).build();
return Futures.immediateFuture(rpcResult);
}
// Update succeeded
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- RpcResult<Void> rpcResult = RpcResultBuilder.<Void>status(true).build();
+ RpcResult<GenericConfigurationNotificationOutput> rpcResult = RpcResultBuilder.<GenericConfigurationNotificationOutput>status(
+ true).build();
return Futures.immediateFuture(rpcResult);
}
@Override
- public Future<RpcResult<GetpathsegmentTopologyOperationOutput>> getpathsegmentTopologyOperation(
- GetpathsegmentTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<GetpathsegmentTopologyOperationOutput>> getpathsegmentTopologyOperation(
+ GetpathsegmentTopologyOperationInput input) {
final String svcOperation = "getpathsegment-topology-operation";
ServiceData serviceData;
responseBuilder.setAckFinalIndicator("Y");
RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setResponseMessage("invalid input, no model-uuid provided");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
GetpathsegmentTopologyOperationInputBuilder inputBuilder = new GetpathsegmentTopologyOperationInputBuilder(
- input);
+ input);
GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, siid, operDataBuilder.build());
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<GetpathsegmentTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<GetpathsegmentTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
private boolean hasInvalidService(GetpathsegmentTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private void trySetSvcRequestId(GetpathsegmentTopologyOperationInput input,
- GetpathsegmentTopologyOperationOutputBuilder responseBuilder) {
+ GetpathsegmentTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
private boolean hasInvalidOnapModelInformation(GetpathsegmentTopologyOperationInput input) {
return input.getServiceInformation() == null || input.getServiceInformation().getOnapModelInformation() == null
- || input.getServiceInformation().getOnapModelInformation().getModelUuid() == null;
+ || input.getServiceInformation().getOnapModelInformation().getModelUuid() == null;
}
private void trySetResponseMessage(GetpathsegmentTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
if (!responseObject.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(responseObject.getMessage());
}
@Override
- public Future<RpcResult<PolicyUpdateNotifyOperationOutput>> policyUpdateNotifyOperation(
- PolicyUpdateNotifyOperationInput input) {
+ public ListenableFuture<RpcResult<PolicyUpdateNotifyOperationOutput>> policyUpdateNotifyOperation(
+ PolicyUpdateNotifyOperationInput input) {
final String svcOperation = "policy-update-notify-operation";
Properties parms = new Properties();
responseBuilder.setErrorCode("404");
responseBuilder.setErrorMsg("Invalid input, missing input data");
RpcResult<PolicyUpdateNotifyOperationOutput> rpcResult = RpcResultBuilder
- .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, "policy update", responseBuilder.build());
RpcResult<PolicyUpdateNotifyOperationOutput> rpcResult = RpcResultBuilder
- .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
}
log.info("Returned SUCCESS for " + svcOperation + responseBuilder.build());
RpcResult<PolicyUpdateNotifyOperationOutput> rpcResult = RpcResultBuilder
- .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PolicyUpdateNotifyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return success
return Futures.immediateFuture(rpcResult);
}
}
@Override
- public Future<RpcResult<PortMirrorTopologyOperationOutput>> portMirrorTopologyOperation(
- final PortMirrorTopologyOperationInput input) {
+ public ListenableFuture<RpcResult<PortMirrorTopologyOperationOutput>> portMirrorTopologyOperation(
+ final PortMirrorTopologyOperationInput input) {
final String svcOperation = "port-mirror-topology-operation";
ServiceData serviceData = null;
responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
responseBuilder.setResponseMessage("invalid input, null or empty configuration-id");
responseBuilder.setAckFinalIndicator("Y");
RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) {
// Only update operational tree on activate or delete
if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
}
responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
PortMirrorResponseInformationBuilder portMirrorResponseInformationBuilder = new PortMirrorResponseInformationBuilder();
portMirrorResponseInformationBuilder
- .setInstanceId(input.getConfigurationInformation().getConfigurationId());
+ .setInstanceId(input.getConfigurationInformation().getConfigurationId());
portMirrorResponseInformationBuilder.setObjectPath(portMirrorObjectPath);
responseBuilder.setPortMirrorResponseInformation(portMirrorResponseInformationBuilder.build());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
return Futures.immediateFuture(rpcResult);
}
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<PortMirrorTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ .<PortMirrorTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
if (ackFinal.equals("N")) {
// Spawn background thread to invoke the Async DG
private boolean hasInvalidService(PortMirrorTopologyOperationInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
}
private boolean hasInvalidConfigurationId(PortMirrorTopologyOperationInput input) {
return input.getConfigurationInformation() == null
- || input.getConfigurationInformation().getConfigurationId() == null
- || input.getConfigurationInformation().getConfigurationId().length() == 0;
+ || input.getConfigurationInformation().getConfigurationId() == null
+ || input.getConfigurationInformation().getConfigurationId().length() == 0;
}
private void trySetSvcRequestId(PortMirrorTopologyOperationInput input,
- PortMirrorTopologyOperationOutputBuilder responseBuilder) {
+ PortMirrorTopologyOperationOutputBuilder responseBuilder) {
if (input.getSdncRequestHeader() != null) {
responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
}
}
private void trySetResponseMessage(PortMirrorTopologyOperationOutputBuilder responseBuilder,
- ResponseObject responseObject) {
+ ResponseObject responseObject) {
if (responseObject.getMessage() != null) {
if (!responseObject.getMessage().isEmpty()) {
responseBuilder.setResponseMessage(responseObject.getMessage());
if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) {
// Only update operational tree on activate or delete
if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign)
- || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
+ || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) {
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
}
}
@Override
- public Future<RpcResult<VnfGetResourceRequestOutput>> vnfGetResourceRequest(VnfGetResourceRequestInput input) {
+ public ListenableFuture<RpcResult<VnfGetResourceRequestOutput>> vnfGetResourceRequest(
+ VnfGetResourceRequestInput input) {
final String svcOperation = "vnf-get-resource-request";
ServiceData serviceData;
if (hasInvalidService(input)) {
log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
RpcResult<VnfGetResourceRequestOutput> rpcResult = RpcResultBuilder
- .<VnfGetResourceRequestOutput>status(true).withResult(responseBuilder.build()).build();
+ .<VnfGetResourceRequestOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
if (failed(responseObject)) {
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
RpcResult<VnfGetResourceRequestOutput> rpcResult = RpcResultBuilder
- .<VnfGetResourceRequestOutput>status(true).withResult(responseBuilder.build()).build();
+ .<VnfGetResourceRequestOutput>status(true).withResult(responseBuilder.build()).build();
// return error
return Futures.immediateFuture(rpcResult);
}
}
RpcResult<VnfGetResourceRequestOutput> rpcResult = RpcResultBuilder.<VnfGetResourceRequestOutput>status(true)
- .withResult(responseBuilder.build()).build();
+ .withResult(responseBuilder.build()).build();
// return success
return Futures.immediateFuture(rpcResult);
private boolean hasInvalidService(VnfGetResourceRequestInput input) {
return input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0;
+ }
+
+ @Override
+ public ListenableFuture<RpcResult<CollectPerformanceDataOutput>> collectPerformanceData(CollectPerformanceDataInput input) {
+ final String svcOperation = "performance-data-collector";
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ CollectPerformanceDataOutputBuilder responseBuilder = new CollectPerformanceDataOutputBuilder();
+
+ if (hasInvalidService(input)) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ RpcResult<CollectPerformanceDataOutput> rpcResult = RpcResultBuilder
+ .<CollectPerformanceDataOutput>status(true).withResult(responseBuilder.build()).build();
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ serviceDataBuilder.setControllerIpv4Address(input.getControllerIpv4Address());
+
+ ServiceDataBuilder operDataBuilder = new ServiceDataBuilder();
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, input.getControllerIpv4Address(), input);
+ CollectPerformanceDataInputBuilder inputBuilder = new CollectPerformanceDataInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ log.info(ADDING_OPERATIONAL_DATA_LOG, svcOperation, input.getControllerIpv4Address(), operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+ ResponseObject responseObject = new ResponseObject("200", "");
+ String ackFinal = "Y";
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, responseObject);
+
+ if (respProps != null) {
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ }
+
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, input.getControllerIpv4Address(), responseBuilder.build());
+ RpcResult<CollectPerformanceDataOutput> rpcResult = RpcResultBuilder
+ .<CollectPerformanceDataOutput>status(true).withResult(responseBuilder.build()).build();
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, input.getControllerIpv4Address(), responseBuilder.build());
+
+ if (respProps != null) {
+ GenericResourceApiUtil.toBuilder(respProps, responseBuilder);
+ }
+
+ RpcResult<CollectPerformanceDataOutput> rpcResult = RpcResultBuilder.<CollectPerformanceDataOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+
+ // return success
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private boolean hasInvalidService(CollectPerformanceDataInput input) {
+ return input == null || input.getControllerIpv4Address() == null;
}
}