summaryrefslogtreecommitdiffstats
path: root/generic-resource-api
diff options
context:
space:
mode:
authorJakub Dudycz <jakub.dudycz@nokia.com>2018-02-07 16:20:21 +0100
committerJakub Dudycz <jakub.dudycz@nokia.com>2018-02-07 16:28:17 +0100
commit1e4bccc607b7d73dee22982d1eb75520795b1eb5 (patch)
treec809102af3685f3302a259fdc375dc6df9e2ea64 /generic-resource-api
parent801091e37aebbb224ed665d5cedf204793e88c07 (diff)
GenericResourceApiProvider fixes part 5
Code reformat only Change-Id: Iee35caa38ab893f0f347a8d6d61072c88a585b9e Issue-ID: SDNC-248 Signed-off-by: Jakub Dudycz <jakub.dudycz@nokia.com>
Diffstat (limited to 'generic-resource-api')
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java3798
1 files changed, 1961 insertions, 1837 deletions
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
index fea699bf..1c437a58 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
@@ -98,14 +98,12 @@ import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
/**
- * Defines a base implementation for your provider. This class extends from a
- * helper class which provides storage for the most commonly used components of
- * the MD-SAL. Additionally the base class provides some basic logging and
+ * 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>
*
@@ -127,8 +125,8 @@ import com.google.common.util.concurrent.Futures;
* // BROKER/NOTIFICATION
* // SERVIE/RPC REGISTRY
* provider.close();
- * }
- * };
+ * }
+ * };
* }
*
* </pre>
@@ -136,27 +134,27 @@ import com.google.common.util.concurrent.Futures;
public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURCEAPIService {
- private static final String APP_NAME = "generic-resource-api";
- private static final String CALLED_STR = "{} called.";
- private static final String NULL_OR_EMPTY_ERROR_MESSAGE = "exiting {} because of null or empty service-instance-id";
- private static final String NULL_OR_EMPTY_ERROR_PARAM = "invalid input, null or empty service-instance-id";
- private static final String ADDING_INPUT_DATA_LOG = "Adding INPUT data for {} [{}] input: {}";
- private static final String ADDING_OPERATIONAL_DATA_LOG = "Adding OPERATIONAL data for {} [{}] operational-data: {}";
- private static final String OPERATIONAL_DATA_PARAM = "operational-data";
- private static final String NO_SERVICE_LOGIC_ACTIVE = "No service logic active for ";
- private static final String SERVICE_LOGIC_SEARCH_ERROR_MESSAGE = "Caught exception looking for service logic";
- private static final String ERROR_CODE_PARAM = "error-code";
- private static final String ERROR_MESSAGE_PARAM = "error-message";
- private static final String ACK_FINAL_PARAM = "ack-final";
- private static final String SERVICE_OBJECT_PATH_PARAM = "service-object-path";
- private static final String UPDATING_MDSAL_ERROR_MESSAGE = "Caught Exception updating MD-SAL for {} [{}] \n";
+ private static final String APP_NAME = "generic-resource-api";
+ private static final String CALLED_STR = "{} called.";
+ private static final String NULL_OR_EMPTY_ERROR_MESSAGE = "exiting {} because of null or empty service-instance-id";
+ private static final String NULL_OR_EMPTY_ERROR_PARAM = "invalid input, null or empty service-instance-id";
+ private static final String ADDING_INPUT_DATA_LOG = "Adding INPUT data for {} [{}] input: {}";
+ private static final String ADDING_OPERATIONAL_DATA_LOG = "Adding OPERATIONAL data for {} [{}] operational-data: {}";
+ private static final String OPERATIONAL_DATA_PARAM = "operational-data";
+ private static final String NO_SERVICE_LOGIC_ACTIVE = "No service logic active for ";
+ private static final String SERVICE_LOGIC_SEARCH_ERROR_MESSAGE = "Caught exception looking for service logic";
+ private static final String ERROR_CODE_PARAM = "error-code";
+ private static final String ERROR_MESSAGE_PARAM = "error-message";
+ private static final String ACK_FINAL_PARAM = "ack-final";
+ private static final String SERVICE_OBJECT_PATH_PARAM = "service-object-path";
+ 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 UPDATING_MDSAL_INFO_MESSAGE = "Updating MD-SAL for {} [{}] ServiceData: {}";
- private static final String UPDATED_MDSAL_INFO_MESSAGE = "Updated MD-SAL for {} [{}]";
- private static final String RETURNED_SUCCESS_MESSAGE = "Returned SUCCESS for {} [{}] {}";
- private static final String NON_NULL_PARAM = "non-null";
- private static final String NULL_PARAM = "null";
+ private static final String RETURNED_FAILED_MESSAGE = "Returned FAILED for {} [{}] {}";
+ private static final String UPDATING_MDSAL_INFO_MESSAGE = "Updating MD-SAL for {} [{}] ServiceData: {}";
+ private static final String UPDATED_MDSAL_INFO_MESSAGE = "Updated MD-SAL for {} [{}]";
+ private static final String RETURNED_SUCCESS_MESSAGE = "Returned SUCCESS for {} [{}] {}";
+ private static final String NON_NULL_PARAM = "non-null";
+ private static final String NULL_PARAM = "null";
private static final String SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE = "Caught exception executing service logic for {} ";
private static final String UPDATING_TREE_INFO_MESSAGE = "Updating OPERATIONAL tree.";
private static final String EMPTY_SERVICE_INSTANCE_MESSAGE = "exiting {} because the service-instance does not have any service data in SDNC";
@@ -164,1842 +162,1968 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
private static final String ALLOTTED_RESOURCE_ID_PARAM = "allotted-resource-id";
private static final String ERROR_NETWORK_ID = "error";
- private final Logger log = LoggerFactory.getLogger(GenericResourceApiProvider.class);
- private final ExecutorService executor;
- private final GenericResourceApiSvcLogicServiceClient svcLogicClient;
+ private final Logger log = LoggerFactory.getLogger(GenericResourceApiProvider.class);
+ private final ExecutorService executor;
+ private final GenericResourceApiSvcLogicServiceClient svcLogicClient;
protected DataBroker dataBroker;
- protected NotificationPublishService notificationService;
- protected RpcProviderRegistry rpcRegistry;
- protected BindingAwareBroker.RpcRegistration<GENERICRESOURCEAPIService> rpcRegistration;
+ protected NotificationPublishService notificationService;
+ protected RpcProviderRegistry rpcRegistry;
+ protected BindingAwareBroker.RpcRegistration<GENERICRESOURCEAPIService> rpcRegistration;
public GenericResourceApiProvider(
- DataBroker dataBroker,
- NotificationPublishService notificationPublishService,
- RpcProviderRegistry rpcProviderRegistry,
- GenericResourceApiSvcLogicServiceClient client
- ) {
- log.info("Creating provider for {}", APP_NAME);
- executor = Executors.newFixedThreadPool(1);
- setDataBroker(dataBroker);
- setNotificationService(notificationPublishService);
- setRpcRegistry(rpcProviderRegistry);
- svcLogicClient = client;
- initialize();
-
- }
-
- public void initialize() {
- log.info("Initializing provider for {}", APP_NAME);
- // Create the top level containers
- createContainers();
- try {
- GenericResourceApiUtil.loadProperties();
- } catch (Exception e) {
- log.error("Caught Exception while trying to load properties file", e);
- }
-
- log.info("Initialization complete for {}", APP_NAME);
- }
-
- protected void initializeChild() {
- // Override if you have custom initialization intelligence
- }
-
- @Override
- public void close() throws Exception {
- log.info("Closing provider for {}", APP_NAME);
- executor.shutdown();
- rpcRegistration.close();
- log.info("Successfully closed provider for {}", APP_NAME);
- }
-
- private static class Iso8601Util {
-
- private static TimeZone timeZone = TimeZone.getTimeZone("UTC");
- private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
-
- private Iso8601Util() {}
-
- static {
- dateFormat.setTimeZone(timeZone);
- }
- private static String now() {
- return dateFormat.format(new Date());
- }
- }
-
- public void setDataBroker(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- if (log.isDebugEnabled()) {
- log.debug("DataBroker set to {}", dataBroker == null ? NULL_PARAM : NON_NULL_PARAM);
- }
- }
-
- public void setNotificationService(NotificationPublishService notificationService) {
- this.notificationService = notificationService;
- if (log.isDebugEnabled()) {
- log.debug("Notification Service set to {}", notificationService == null ? NULL_PARAM : NON_NULL_PARAM);
- }
- }
-
- public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
- this.rpcRegistry = rpcRegistry;
- if (log.isDebugEnabled()) {
- log.debug("RpcRegistry set to {}", rpcRegistry == null ? NULL_PARAM : NON_NULL_PARAM);
- }
- }
-
- private void createContainers() {
-
- final WriteTransaction t = dataBroker.newReadWriteTransaction();
-
- // Create the service-instance container
- t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Services.class),
- new ServicesBuilder().build());
- t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Services.class),
- new ServicesBuilder().build());
-
- // Create the PreloadVnfs container
- t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadVnfs.class),
- new PreloadVnfsBuilder().build());
- t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadVnfs.class),
- new PreloadVnfsBuilder().build());
-
- try {
- CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
- checkedFuture.get();
- log.info("Create containers succeeded!");
-
- } catch (InterruptedException | ExecutionException e) {
- log.error("Create containers failed: ", e);
- }
- }
-
- private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, String errorCode, String errorMessage,
- String ackFinal) {
- serviceStatusBuilder.setResponseCode(errorCode);
- serviceStatusBuilder.setResponseMessage(errorMessage);
- serviceStatusBuilder.setFinalIndicator(ackFinal);
- serviceStatusBuilder.setResponseTimestamp(Iso8601Util.now());
- }
-
- private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, RequestInformation requestInformation) {
- if (requestInformation != null && requestInformation.getRequestAction() != null) {
- serviceStatusBuilder.setAction(requestInformation.getRequestAction().toString());
- }
- }
-
- 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;
- default:
- log.error("Unknown SvcAction: {}", requestHeader.getSvcAction());
- break;
- }
- }
- }
-
- private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder) {
- // default to config
- getServiceData(siid, serviceDataBuilder, LogicalDatastoreType.CONFIGURATION);
- }
-
- 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) {
- log.error("Caught Exception reading MD-SAL ({}) data for [{}] ", type, siid, e);
- }
-
- if (data != null && data.isPresent()) {
- ServiceData serviceData = data.get().getServiceData();
- if (serviceData != null) {
- log.info("Read MD-SAL ({}) data for [{}] ServiceData: {}", type, siid, serviceData);
- serviceDataBuilder.setSdncRequestHeader(serviceData.getSdncRequestHeader());
- serviceDataBuilder.setRequestInformation(serviceData.getRequestInformation());
- serviceDataBuilder.setServiceInformation(serviceData.getServiceInformation());
- serviceDataBuilder.setServiceRequestInput(serviceData.getServiceRequestInput());
- serviceDataBuilder.setServiceTopology(serviceData.getServiceTopology());
- serviceDataBuilder.setServiceLevelOperStatus(serviceData.getServiceLevelOperStatus());
- serviceDataBuilder.setNetworks(serviceData.getNetworks());
- serviceDataBuilder.setVnfs(serviceData.getVnfs());
- serviceDataBuilder.setProvidedAllottedResources(serviceData.getProvidedAllottedResources());
- serviceDataBuilder.setConsumedAllottedResources(serviceData.getConsumedAllottedResources());
- // service-instance-id needs to be set
- } else {
- log.info("No service-data found in MD-SAL ({}) for [{}]", type, siid);
- }
- } else {
- log.info("No data found in MD-SAL ({}) for [{}]", type, siid);
- }
- }
-
- private void getPreloadData(String vnfName, String vnfType, PreloadDataBuilder preloadDataBuilder) {
- // default to config
- getPreloadData(vnfName, vnfType, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
- }
-
- private void getPreloadData(String preloadName, String preloadType, PreloadDataBuilder preloadDataBuilder,
- LogicalDatastoreType type) {
- // See if any data exists yet for this name/type, if so grab it.
- InstanceIdentifier<VnfPreloadList> preloadInstanceIdentifier = InstanceIdentifier
- .builder(PreloadVnfs.class)
- .child(VnfPreloadList.class, new VnfPreloadListKey(preloadName, preloadType))
- .build();
-
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
- Optional<VnfPreloadList> data = Optional.absent();
- try {
- data = readTx.read(type, preloadInstanceIdentifier).get();
- } catch (InterruptedException | ExecutionException e) {
- log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType, e);
- }
-
- if (data != null && data.isPresent()) {
- PreloadData preloadData = data.get().getPreloadData();
- if (preloadData != null) {
- log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", type, preloadName, preloadType,
- preloadData);
- preloadDataBuilder.setVnfTopologyInformation(preloadData.getVnfTopologyInformation());
- preloadDataBuilder.setNetworkTopologyInformation(preloadData.getNetworkTopologyInformation());
- preloadDataBuilder.setOperStatus(preloadData.getOperStatus());
- } else {
- log.info("No preload-data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType);
- }
- } else {
- log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType);
- }
- }
-
- private void saveService(final Service entry, boolean merge, LogicalDatastoreType storeType) {
- // 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();
-
- trySaveEntry(entry, merge, storeType, path);
- }
-
- private void savePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) {
-
- // Each entry will be identifiable by a unique key, we have to create that
- // identifier
- InstanceIdentifier<VnfPreloadList> path = InstanceIdentifier
- .builder(PreloadVnfs.class)
- .child(VnfPreloadList.class, entry.getKey())
- .build();
-
- trySaveEntry(entry, merge, storeType, path);
- }
-
- private <T extends DataObject> void trySaveEntry(T entry, boolean merge, LogicalDatastoreType storeType,
- InstanceIdentifier<T> path) {
- int tries = 2;
- while (true) {
- try {
- save(entry, merge, storeType, path);
- break;
- } catch (OptimisticLockFailedException e) {
- if (--tries <= 0) {
- log.debug("Got OptimisticLockFailedException on last try - failing ");
- throw new IllegalStateException(e);
- }
- log.debug("Got OptimisticLockFailedException - trying again ");
- }
- catch (TransactionCommitFailedException 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 {
- WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- if (merge) {
- tx.merge(storeType, path, entry);
- } else {
- tx.put(storeType, path, entry);
- }
- tx.submit().checkedGet();
- log.debug("Update DataStore succeeded");
- }
-
- private void deleteService(final Service entry, LogicalDatastoreType storeType) {
- // 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();
-
- tryDeleteEntry(storeType, path);
- }
-
- private void tryDeleteEntry(LogicalDatastoreType storeType, InstanceIdentifier<Service> path) {
- int tries = 2;
- while (true) {
- try {
- delete(storeType, path);
- break;
- } catch (OptimisticLockFailedException e) {
- if (--tries <= 0) {
- log.debug("Got OptimisticLockFailedException on last try - failing ");
- throw new IllegalStateException(e);
- }
- log.debug("Got OptimisticLockFailedException - trying again ");
- }
- catch (TransactionCommitFailedException ex){
- log.debug("Update DataStore failed");
- throw new IllegalStateException(ex);
- }
- }
- }
-
- private void delete(LogicalDatastoreType storeType, InstanceIdentifier<Service> path)
- throws TransactionCommitFailedException {
- WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- tx.delete(storeType, path);
- tx.submit().checkedGet();
- log.debug("DataStore delete succeeded");
- }
-
- @Override
- public Future<RpcResult<ServiceTopologyOperationOutput>> serviceTopologyOperation(
- ServiceTopologyOperationInput input) {
-
- final String svcOperation = "service-topology-operation";
- ServiceData serviceData;
- ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- ServiceTopologyOperationOutputBuilder responseBuilder = new ServiceTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- responseBuilder.setResponseCode("404");
- responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Grab the service instance ID from the input buffer
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- 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());
+ DataBroker dataBroker,
+ NotificationPublishService notificationPublishService,
+ RpcProviderRegistry rpcProviderRegistry,
+ GenericResourceApiSvcLogicServiceClient client
+ ) {
+ log.info("Creating provider for {}", APP_NAME);
+ executor = Executors.newFixedThreadPool(1);
+ setDataBroker(dataBroker);
+ setNotificationService(notificationPublishService);
+ setRpcRegistry(rpcProviderRegistry);
+ svcLogicClient = client;
+ initialize();
+
+ }
+
+ public void initialize() {
+ log.info("Initializing provider for {}", APP_NAME);
+ // Create the top level containers
+ createContainers();
+ try {
+ GenericResourceApiUtil.loadProperties();
+ } catch (Exception e) {
+ log.error("Caught Exception while trying to load properties file", e);
+ }
+
+ log.info("Initialization complete for {}", APP_NAME);
+ }
+
+ protected void initializeChild() {
+ // Override if you have custom initialization intelligence
+ }
+
+ @Override
+ public void close() throws Exception {
+ log.info("Closing provider for {}", APP_NAME);
+ executor.shutdown();
+ rpcRegistration.close();
+ log.info("Successfully closed provider for {}", APP_NAME);
+ }
+
+ private static class Iso8601Util {
+
+ private static TimeZone timeZone = TimeZone.getTimeZone("UTC");
+ private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+
+ private Iso8601Util() {
+ }
+
+ static {
+ dateFormat.setTimeZone(timeZone);
+ }
+
+ private static String now() {
+ return dateFormat.format(new Date());
+ }
+ }
+
+ public void setDataBroker(DataBroker dataBroker) {
+ this.dataBroker = dataBroker;
+ if (log.isDebugEnabled()) {
+ log.debug("DataBroker set to {}", dataBroker == null ? NULL_PARAM : NON_NULL_PARAM);
+ }
+ }
+
+ public void setNotificationService(NotificationPublishService notificationService) {
+ this.notificationService = notificationService;
+ if (log.isDebugEnabled()) {
+ log.debug("Notification Service set to {}", notificationService == null ? NULL_PARAM : NON_NULL_PARAM);
+ }
+ }
+
+ public void setRpcRegistry(RpcProviderRegistry rpcRegistry) {
+ this.rpcRegistry = rpcRegistry;
+ if (log.isDebugEnabled()) {
+ log.debug("RpcRegistry set to {}", rpcRegistry == null ? NULL_PARAM : NON_NULL_PARAM);
+ }
+ }
+
+ private void createContainers() {
+
+ final WriteTransaction t = dataBroker.newReadWriteTransaction();
+
+ // Create the service-instance container
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(Services.class),
+ new ServicesBuilder().build());
+ t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(Services.class),
+ new ServicesBuilder().build());
+
+ // Create the PreloadVnfs container
+ t.merge(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.create(PreloadVnfs.class),
+ new PreloadVnfsBuilder().build());
+ t.merge(LogicalDatastoreType.OPERATIONAL, InstanceIdentifier.create(PreloadVnfs.class),
+ new PreloadVnfsBuilder().build());
+
+ try {
+ CheckedFuture<Void, TransactionCommitFailedException> checkedFuture = t.submit();
+ checkedFuture.get();
+ log.info("Create containers succeeded!");
+
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("Create containers failed: ", e);
+ }
+ }
+
+ private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, String errorCode, String errorMessage,
+ String ackFinal) {
+ serviceStatusBuilder.setResponseCode(errorCode);
+ serviceStatusBuilder.setResponseMessage(errorMessage);
+ serviceStatusBuilder.setFinalIndicator(ackFinal);
+ serviceStatusBuilder.setResponseTimestamp(Iso8601Util.now());
+ }
+
+ private void setServiceStatus(ServiceStatusBuilder serviceStatusBuilder, RequestInformation requestInformation) {
+ if (requestInformation != null && requestInformation.getRequestAction() != null) {
+ serviceStatusBuilder.setAction(requestInformation.getRequestAction().toString());
+ }
+ }
+
+ 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;
+ default:
+ log.error("Unknown SvcAction: {}", requestHeader.getSvcAction());
+ break;
+ }
+ }
+ }
+
+ private void getServiceData(String siid, ServiceDataBuilder serviceDataBuilder) {
+ // default to config
+ getServiceData(siid, serviceDataBuilder, LogicalDatastoreType.CONFIGURATION);
+ }
+
+ 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) {
+ log.error("Caught Exception reading MD-SAL ({}) data for [{}] ", type, siid, e);
+ }
+
+ if (data != null && data.isPresent()) {
+ ServiceData serviceData = data.get().getServiceData();
+ if (serviceData != null) {
+ log.info("Read MD-SAL ({}) data for [{}] ServiceData: {}", type, siid, serviceData);
+ serviceDataBuilder.setSdncRequestHeader(serviceData.getSdncRequestHeader());
+ serviceDataBuilder.setRequestInformation(serviceData.getRequestInformation());
+ serviceDataBuilder.setServiceInformation(serviceData.getServiceInformation());
+ serviceDataBuilder.setServiceRequestInput(serviceData.getServiceRequestInput());
+ serviceDataBuilder.setServiceTopology(serviceData.getServiceTopology());
+ serviceDataBuilder.setServiceLevelOperStatus(serviceData.getServiceLevelOperStatus());
+ serviceDataBuilder.setNetworks(serviceData.getNetworks());
+ serviceDataBuilder.setVnfs(serviceData.getVnfs());
+ serviceDataBuilder.setProvidedAllottedResources(serviceData.getProvidedAllottedResources());
+ serviceDataBuilder.setConsumedAllottedResources(serviceData.getConsumedAllottedResources());
+ // service-instance-id needs to be set
+ } else {
+ log.info("No service-data found in MD-SAL ({}) for [{}]", type, siid);
+ }
+ } else {
+ log.info("No data found in MD-SAL ({}) for [{}]", type, siid);
+ }
+ }
+
+ private void getPreloadData(String vnfName, String vnfType, PreloadDataBuilder preloadDataBuilder) {
+ // default to config
+ getPreloadData(vnfName, vnfType, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION);
+ }
+
+ private void getPreloadData(String preloadName, String preloadType, PreloadDataBuilder preloadDataBuilder,
+ LogicalDatastoreType type) {
+ // See if any data exists yet for this name/type, if so grab it.
+ InstanceIdentifier<VnfPreloadList> preloadInstanceIdentifier = InstanceIdentifier
+ .builder(PreloadVnfs.class)
+ .child(VnfPreloadList.class, new VnfPreloadListKey(preloadName, preloadType))
+ .build();
+
+ ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
+ Optional<VnfPreloadList> data = Optional.absent();
+ try {
+ data = readTx.read(type, preloadInstanceIdentifier).get();
+ } catch (InterruptedException | ExecutionException e) {
+ log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType, e);
+ }
+
+ if (data != null && data.isPresent()) {
+ PreloadData preloadData = data.get().getPreloadData();
+ if (preloadData != null) {
+ log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", type, preloadName, preloadType,
+ preloadData);
+ preloadDataBuilder.setVnfTopologyInformation(preloadData.getVnfTopologyInformation());
+ preloadDataBuilder.setNetworkTopologyInformation(preloadData.getNetworkTopologyInformation());
+ preloadDataBuilder.setOperStatus(preloadData.getOperStatus());
+ } else {
+ log.info("No preload-data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType);
+ }
+ } else {
+ log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preloadName, preloadType);
+ }
+ }
+
+ private void saveService(final Service entry, boolean merge, LogicalDatastoreType storeType) {
+ // 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();
+
+ trySaveEntry(entry, merge, storeType, path);
+ }
+
+ private void savePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) {
+
+ // Each entry will be identifiable by a unique key, we have to create that
+ // identifier
+ InstanceIdentifier<VnfPreloadList> path = InstanceIdentifier
+ .builder(PreloadVnfs.class)
+ .child(VnfPreloadList.class, entry.getKey())
+ .build();
+
+ trySaveEntry(entry, merge, storeType, path);
+ }
+
+ private <T extends DataObject> void trySaveEntry(T entry, boolean merge, LogicalDatastoreType storeType,
+ InstanceIdentifier<T> path) {
+ int tries = 2;
+ while (true) {
+ try {
+ save(entry, merge, storeType, path);
+ break;
+ } catch (OptimisticLockFailedException e) {
+ if (--tries <= 0) {
+ log.debug("Got OptimisticLockFailedException on last try - failing ");
+ throw new IllegalStateException(e);
+ }
+ log.debug("Got OptimisticLockFailedException - trying again ");
+ } catch (TransactionCommitFailedException 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 {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ if (merge) {
+ tx.merge(storeType, path, entry);
+ } else {
+ tx.put(storeType, path, entry);
+ }
+ tx.submit().checkedGet();
+ log.debug("Update DataStore succeeded");
+ }
+
+ private void deleteService(final Service entry, LogicalDatastoreType storeType) {
+ // 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();
+
+ tryDeleteEntry(storeType, path);
+ }
+
+ private void tryDeleteEntry(LogicalDatastoreType storeType, InstanceIdentifier<Service> path) {
+ int tries = 2;
+ while (true) {
+ try {
+ delete(storeType, path);
+ break;
+ } catch (OptimisticLockFailedException e) {
+ if (--tries <= 0) {
+ log.debug("Got OptimisticLockFailedException on last try - failing ");
+ throw new IllegalStateException(e);
+ }
+ log.debug("Got OptimisticLockFailedException - trying again ");
+ } catch (TransactionCommitFailedException ex) {
+ log.debug("Update DataStore failed");
+ throw new IllegalStateException(ex);
+ }
+ }
+ }
+
+ private void delete(LogicalDatastoreType storeType, InstanceIdentifier<Service> path)
+ throws TransactionCommitFailedException {
+ WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
+ tx.delete(storeType, path);
+ tx.submit().checkedGet();
+ log.debug("DataStore delete succeeded");
+ }
+
+ @Override
+ public Future<RpcResult<ServiceTopologyOperationOutput>> serviceTopologyOperation(
+ ServiceTopologyOperationInput input) {
+
+ final String svcOperation = "service-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ ServiceTopologyOperationOutputBuilder responseBuilder = new ServiceTopologyOperationOutputBuilder();
+
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+ RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Grab the service instance ID from the input buffer
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ 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 service-topology-operation
+ * // setup a service-data object builder // ACTION service-topology-operation
* // INPUT: // USES uses service-operation-information // OUTPUT: // uses
* topology-response-common; // uses service-response-information;
*/
- log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
- ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(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
- // Get SvcLogicService reference
-
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String serviceObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
- }
-
- setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
- serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
- serviceStatusBuilder.setRpcName(svcOperation);
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.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<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- 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.Delete)) {
- // Only update operational tree on delete
- log.info("Delete from both CONFIGURATION and OPERATIONAL tree.");
- deleteService(serviceBuilder.build(), LogicalDatastoreType.OPERATIONAL);
- deleteService(serviceBuilder.build(), LogicalDatastoreType.CONFIGURATION);
- }
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- serviceResponseInformationBuilder.setInstanceId(siid);
- serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
- responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
-
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
- responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- private Properties tryGetProperties(String svcOperation, Properties parms, ServiceDataBuilder serviceDataBuilder,
- ErrorObject error) {
- try {
- if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
- try {
- return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
- } catch (Exception e) {
- log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
- }
- } else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
- }
- } catch (Exception e) {
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
- log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
- }
-
- return null;
- }
-
- private boolean validateErrorObject(ErrorObject error) {
- return
- !error.getStatusCode().isEmpty() && !("0".equals(error.getStatusCode()) || "200".equals(error.getStatusCode()));
- }
-
- private boolean isValidRequest(ServiceTopologyOperationInput input){
- return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
- }
-
- @Override
- public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
-
- final String svcOperation = "vnf-topology-operation";
- ServiceData serviceData;
- ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- responseBuilder.setResponseCode("404");
- responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- // return error
- return Futures.immediateFuture(rpcResult);
- }
-
- // Grab the service instance ID from the input buffer
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- if (input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
- || input.getVnfInformation().getVnfId().length() == 0) {
- log.debug("exiting {} because of null or empty vnf-id", svcOperation);
- responseBuilder.setResponseCode("404");
- responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- 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
- // Get SvcLogicService reference
-
-
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String serviceObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
-
- if (respProps != null) {
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty("vnf-object-path");
- }
-
- setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
- serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
- serviceStatusBuilder.setRpcName(svcOperation);
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- ServiceBuilder serviceBuilder = new ServiceBuilder();
- serviceBuilder.setServiceInstanceId(siid);
- serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
- try {
- saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
- 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);
- }
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
- }
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>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());
-
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
- responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- // return success
- return Futures.immediateFuture(rpcResult);
- }
-
- private boolean isValidRequest(VnfTopologyOperationInput input){
- return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
- }
-
- @Override
- public Future<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 (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- 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 (input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
- || input.getVnfInformation().getVnfId().length() == 0) {
- 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 (input.getVfModuleInformation() == null || input.getVfModuleInformation().getVfModuleId() == null
- || input.getVfModuleInformation().getVfModuleId().length() == 0) {
- 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();
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- 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
- // Get SvcLogicService reference
-
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String serviceObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty("vf-module-object-path");
- }
-
- setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
- serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
- serviceStatusBuilder.setRpcName(svcOperation);
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getStatusCode());
- 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 {
- 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.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);
- }
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- serviceResponseInformationBuilder.setInstanceId(siid);
- serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
- responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
-
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
- responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
- 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(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- 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 boolean isValidRequest(VfModuleTopologyOperationInput input) {
- return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
- }
-
- @Override
- public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
- NetworkTopologyOperationInput input) {
-
- final String svcOperation = "network-topology-operation";
- ServiceData serviceData;
- ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- NetworkTopologyOperationOutputBuilder responseBuilder = new NetworkTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
- }
-
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- // Get the service-instance service data from MD-SAL
- ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
- getServiceData(siid, serviceDataBuilder);
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- ServiceData sd = serviceDataBuilder.build();
- if (sd == null || sd.getServiceLevelOperStatus() == null) {
- log.debug(EMPTY_SERVICE_INSTANCE_MESSAGE, svcOperation);
- return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
- }
-
- log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
- NetworkTopologyOperationInputBuilder inputBuilder = new NetworkTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-
- // Call SLI sync method
- // Get SvcLogicService reference
-
-
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String networkId = ERROR_NETWORK_ID;
- String serviceObjectPath = null;
- String networkObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- networkId = respProps.getProperty("networkId");
- serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
- networkObjectPath = respProps.getProperty("network-object-path");
- }
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- 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) ||
- input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Create))) {
- // Only update operational tree on Activate
- log.info(UPDATING_TREE_INFO_MESSAGE);
- saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
- }
-
- NetworkResponseInformationBuilder networkResponseInformationBuilder = new NetworkResponseInformationBuilder();
- networkResponseInformationBuilder.setInstanceId(networkId);
- networkResponseInformationBuilder.setObjectPath(networkObjectPath);
- responseBuilder.setNetworkResponseInformation(networkResponseInformationBuilder.build());
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- 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");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- private Future<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();
- return Futures.immediateFuture(rpcResult);
- }
-
- private boolean isValidRequest(NetworkTopologyOperationInput input) {
- return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
- }
-
- @Override
- public Future<RpcResult<ContrailRouteTopologyOperationOutput>> contrailRouteTopologyOperation(
- ContrailRouteTopologyOperationInput input) {
-
- final String svcOperation = "contrail-route-topology-operation";
- ServiceData serviceData;
- ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- ContrailRouteTopologyOperationOutputBuilder responseBuilder = new ContrailRouteTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
- }
-
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- // Get the service-instance service data from MD-SAL
- ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
- getServiceData(siid, serviceDataBuilder);
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- ServiceData sd = serviceDataBuilder.build();
- if (sd == null || sd.getServiceLevelOperStatus() == null) {
- log.debug(EMPTY_SERVICE_INSTANCE_MESSAGE, svcOperation);
- return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
- }
-
- log.info("Adding INPUT data for " + svcOperation + " [" + siid + "] input: " + input);
- ContrailRouteTopologyOperationInputBuilder inputBuilder = new ContrailRouteTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-
- // Call SLI sync method
- // Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String allottedResourceId = ERROR_NETWORK_ID;
- String serviceObjectPath = null;
- String contrailRouteObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
- serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
- contrailRouteObjectPath = respProps.getProperty("contrail-route-object-path");
- }
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- 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) &&
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(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
+ // Get SvcLogicService reference
+
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ }
+
+ setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.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<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ServiceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ 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.Delete)) {
+ // Only update operational tree on delete
+ log.info("Delete from both CONFIGURATION and OPERATIONAL tree.");
+ deleteService(serviceBuilder.build(), LogicalDatastoreType.OPERATIONAL);
+ deleteService(serviceBuilder.build(), LogicalDatastoreType.CONFIGURATION);
+ }
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ serviceResponseInformationBuilder.setInstanceId(siid);
+ serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
+ responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ServiceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ServiceTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private Properties tryGetProperties(String svcOperation, Properties parms, ServiceDataBuilder serviceDataBuilder,
+ ErrorObject error) {
+ try {
+ if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
+ try {
+ return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
+ error.setMessage(e.getMessage());
+ error.setStatusCode("500");
+ }
+ } else {
+ error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ error.setStatusCode("503");
+ }
+ } catch (Exception e) {
+ error.setMessage(e.getMessage());
+ error.setStatusCode("500");
+ log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
+ }
+
+ return null;
+ }
+
+ private boolean validateErrorObject(ErrorObject error) {
+ return
+ !error.getStatusCode().isEmpty() && !("0".equals(error.getStatusCode()) || "200"
+ .equals(error.getStatusCode()));
+ }
+
+ private boolean isValidRequest(ServiceTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+ @Override
+ public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) {
+
+ final String svcOperation = "vnf-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder();
+
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+ RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+ // return error
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Grab the service instance ID from the input buffer
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ if (input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
+ || input.getVnfInformation().getVnfId().length() == 0) {
+ log.debug("exiting {} because of null or empty vnf-id", svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage("invalid input, null or empty vnf-id");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ 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
+ // Get SvcLogicService reference
+
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+
+ if (respProps != null) {
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ serviceObjectPath = respProps.getProperty("vnf-object-path");
+ }
+
+ setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ ServiceBuilder serviceBuilder = new ServiceBuilder();
+ serviceBuilder.setServiceInstanceId(siid);
+ serviceBuilder.setServiceStatus(serviceStatusBuilder.build());
+ try {
+ saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ 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);
+ }
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ }
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VnfTopologyOperationOutput>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());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<VnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ // return success
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private boolean isValidRequest(VnfTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+ @Override
+ public Future<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 (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ 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 (input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null
+ || input.getVnfInformation().getVnfId().length() == 0) {
+ 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 (input.getVfModuleInformation() == null || input.getVfModuleInformation().getVfModuleId() == null
+ || input.getVfModuleInformation().getVfModuleId().length() == 0) {
+ 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();
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ 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
+ // Get SvcLogicService reference
+
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String serviceObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ serviceObjectPath = respProps.getProperty("vf-module-object-path");
+ }
+
+ setServiceStatus(serviceStatusBuilder, error.getStatusCode(), error.getMessage(), ackFinal);
+ serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete);
+ serviceStatusBuilder.setRpcName(svcOperation);
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getStatusCode());
+ 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 {
+ 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.Unassign) ||
input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
- // Only update operational tree on activate or delete
+ // Only update operational tree on activate or delete
+
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
- }
-
- ContrailRouteResponseInformationBuilder contrailRouteResponseInformationBuilder = new ContrailRouteResponseInformationBuilder();
- contrailRouteResponseInformationBuilder.setInstanceId(allottedResourceId);
- contrailRouteResponseInformationBuilder.setObjectPath(contrailRouteObjectPath);
- responseBuilder.setContrailRouteResponseInformation(contrailRouteResponseInformationBuilder.build());
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- 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");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- private Future<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();
-
- return Futures.immediateFuture(rpcResult);
- }
-
- private boolean isValidRequest(ContrailRouteTopologyOperationInput input) {
+ }
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ serviceResponseInformationBuilder.setInstanceId(siid);
+ serviceResponseInformationBuilder.setObjectPath(serviceObjectPath);
+ responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build());
+
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.toString());
+ 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(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ 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 boolean isValidRequest(VfModuleTopologyOperationInput input) {
return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
}
@Override
- public Future<RpcResult<SecurityZoneTopologyOperationOutput>> securityZoneTopologyOperation(
- SecurityZoneTopologyOperationInput input) {
-
- final String svcOperation = "security-zone-topology-operation";
- ServiceData serviceData;
- ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- SecurityZoneTopologyOperationOutputBuilder responseBuilder = new SecurityZoneTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
- }
-
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- // Get the service-instance service data from MD-SAL
- ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
- getServiceData(siid, serviceDataBuilder);
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- ServiceData sd = serviceDataBuilder.build();
- if (sd == null || sd.getServiceLevelOperStatus() == null) {
- log.debug(EMPTY_SERVICE_INSTANCE_MESSAGE, svcOperation);
- return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
- }
-
- log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
- SecurityZoneTopologyOperationInputBuilder inputBuilder = new SecurityZoneTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-
- // Call SLI sync method
- // Get SvcLogicService reference
-
- Properties respProps = null;
-
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String allottedResourceId = ERROR_NETWORK_ID;
- String serviceObjectPath = null;
- String securityZoneObjectPath = null;
-
- try {
- if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
-
- try {
- respProps = svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
- } catch (Exception e) {
- log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
- }
- } else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
- }
- } catch (Exception e) {
- error.setStatusCode("500");
- error.setMessage(e.getMessage());
- log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
- }
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
- serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
- securityZoneObjectPath = respProps.getProperty("security-zone-object-path");
- }
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- 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) &&
+ public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation(
+ NetworkTopologyOperationInput input) {
+
+ final String svcOperation = "network-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ NetworkTopologyOperationOutputBuilder responseBuilder = new NetworkTopologyOperationOutputBuilder();
+
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
+ }
+
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ // Get the service-instance service data from MD-SAL
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ ServiceData sd = serviceDataBuilder.build();
+ if (sd == null || sd.getServiceLevelOperStatus() == null) {
+ log.debug(EMPTY_SERVICE_INSTANCE_MESSAGE, svcOperation);
+ return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
+ }
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ NetworkTopologyOperationInputBuilder inputBuilder = new NetworkTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String networkId = ERROR_NETWORK_ID;
+ String serviceObjectPath = null;
+ String networkObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ networkId = respProps.getProperty("networkId");
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ networkObjectPath = respProps.getProperty("network-object-path");
+ }
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<NetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ 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) ||
+ input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Create))) {
+ // Only update operational tree on Activate
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+
+ NetworkResponseInformationBuilder networkResponseInformationBuilder = new NetworkResponseInformationBuilder();
+ networkResponseInformationBuilder.setInstanceId(networkId);
+ networkResponseInformationBuilder.setObjectPath(networkObjectPath);
+ responseBuilder.setNetworkResponseInformation(networkResponseInformationBuilder.build());
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ 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");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<NetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<NetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private Future<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();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private boolean isValidRequest(NetworkTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+ @Override
+ public Future<RpcResult<ContrailRouteTopologyOperationOutput>> contrailRouteTopologyOperation(
+ ContrailRouteTopologyOperationInput input) {
+
+ final String svcOperation = "contrail-route-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ ContrailRouteTopologyOperationOutputBuilder responseBuilder = new ContrailRouteTopologyOperationOutputBuilder();
+
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
+ }
+
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ // Get the service-instance service data from MD-SAL
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ ServiceData sd = serviceDataBuilder.build();
+ if (sd == null || sd.getServiceLevelOperStatus() == null) {
+ log.debug(EMPTY_SERVICE_INSTANCE_MESSAGE, svcOperation);
+ return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
+ }
+
+ log.info("Adding INPUT data for " + svcOperation + " [" + siid + "] input: " + input);
+ ContrailRouteTopologyOperationInputBuilder inputBuilder = new ContrailRouteTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String allottedResourceId = ERROR_NETWORK_ID;
+ String serviceObjectPath = null;
+ String contrailRouteObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, serviceDataBuilder, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ contrailRouteObjectPath = respProps.getProperty("contrail-route-object-path");
+ }
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ContrailRouteTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ 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.Unassign) ||
input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate))) {
- // Only update operational tree on activate or delete
+ // Only update operational tree on activate or delete
log.info(UPDATING_TREE_INFO_MESSAGE);
saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
- }
-
- SecurityZoneResponseInformationBuilder securityZoneResponseInformationBuilder = new SecurityZoneResponseInformationBuilder();
- securityZoneResponseInformationBuilder.setInstanceId(allottedResourceId);
- securityZoneResponseInformationBuilder.setObjectPath(securityZoneObjectPath);
- responseBuilder.setSecurityZoneResponseInformation(securityZoneResponseInformationBuilder.build());
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- 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");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- private Future<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();
-
- return Futures.immediateFuture(rpcResult);
- }
-
- private boolean isValidRequest(SecurityZoneTopologyOperationInput input) {
+ }
+
+ ContrailRouteResponseInformationBuilder contrailRouteResponseInformationBuilder = new ContrailRouteResponseInformationBuilder();
+ contrailRouteResponseInformationBuilder.setInstanceId(allottedResourceId);
+ contrailRouteResponseInformationBuilder.setObjectPath(contrailRouteObjectPath);
+ responseBuilder.setContrailRouteResponseInformation(contrailRouteResponseInformationBuilder.build());
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ 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");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ContrailRouteTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<ContrailRouteTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private Future<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();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private boolean isValidRequest(ContrailRouteTopologyOperationInput input) {
+ return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
+ }
+
+ @Override
+ public Future<RpcResult<SecurityZoneTopologyOperationOutput>> securityZoneTopologyOperation(
+ SecurityZoneTopologyOperationInput input) {
+
+ final String svcOperation = "security-zone-topology-operation";
+ ServiceData serviceData;
+ ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder();
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ SecurityZoneTopologyOperationOutputBuilder responseBuilder = new SecurityZoneTopologyOperationOutputBuilder();
+
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ return buildRpcResultFuture(responseBuilder, NULL_OR_EMPTY_ERROR_PARAM);
+ }
+
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ // Get the service-instance service data from MD-SAL
+ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder();
+ getServiceData(siid, serviceDataBuilder);
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ ServiceData sd = serviceDataBuilder.build();
+ if (sd == null || sd.getServiceLevelOperStatus() == null) {
+ log.debug(EMPTY_SERVICE_INSTANCE_MESSAGE, svcOperation);
+ return buildRpcResultFuture(responseBuilder, INVALID_INPUT_ERROR_MESSAGE);
+ }
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ SecurityZoneTopologyOperationInputBuilder inputBuilder = new SecurityZoneTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+
+ Properties respProps = null;
+
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String allottedResourceId = ERROR_NETWORK_ID;
+ String serviceObjectPath = null;
+ String securityZoneObjectPath = null;
+
+ try {
+ if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
+
+ try {
+ respProps = svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
+ error.setMessage(e.getMessage());
+ error.setStatusCode("500");
+ }
+ } else {
+ error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ error.setStatusCode("503");
+ }
+ } catch (Exception e) {
+ error.setStatusCode("500");
+ error.setMessage(e.getMessage());
+ log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
+ }
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ securityZoneObjectPath = respProps.getProperty("security-zone-object-path");
+ }
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<SecurityZoneTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ 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.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);
+ }
+
+ SecurityZoneResponseInformationBuilder securityZoneResponseInformationBuilder = new SecurityZoneResponseInformationBuilder();
+ securityZoneResponseInformationBuilder.setInstanceId(allottedResourceId);
+ securityZoneResponseInformationBuilder.setObjectPath(securityZoneObjectPath);
+ responseBuilder.setSecurityZoneResponseInformation(securityZoneResponseInformationBuilder.build());
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ 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");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<SecurityZoneTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<SecurityZoneTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private Future<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();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private boolean isValidRequest(SecurityZoneTopologyOperationInput input) {
return input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null;
}
@Override
- public Future<RpcResult<TunnelxconnTopologyOperationOutput>> tunnelxconnTopologyOperation(
- TunnelxconnTopologyOperationInput input) {
-
- final String svcOperation = "tunnelxconn-topology-operation";
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- TunnelxconnTopologyOperationOutputBuilder responseBuilder = new TunnelxconnTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- responseBuilder.setResponseCode("404");
- responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
- TunnelxconnTopologyOperationInputBuilder inputBuilder = new TunnelxconnTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-
- // Call SLI sync method
- // Get SvcLogicService reference
-
-
-
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String allottedResourceId = ERROR_NETWORK_ID;
- String serviceObjectPath = null;
- String tunnelxconnObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
- serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
- tunnelxconnObjectPath = respProps.getProperty("tunnelxconn-object-path");
- }
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Got success from SLI
- try {
-
-
-
- TunnelxconnResponseInformationBuilder tunnelxconnResponseInformationBuilder = new TunnelxconnResponseInformationBuilder();
- tunnelxconnResponseInformationBuilder.setInstanceId(allottedResourceId);
- tunnelxconnResponseInformationBuilder.setObjectPath(tunnelxconnObjectPath);
- responseBuilder.setTunnelxconnResponseInformation(tunnelxconnResponseInformationBuilder.build());
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- 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");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- private Properties tryGetProperties(String svcOperation, Properties parms, ErrorObject error) {
- try {
- if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
-
- try {
- return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", parms);
- } catch (Exception e) {
- log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
- }
- } else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
- }
- } catch (Exception e) {
+ public Future<RpcResult<TunnelxconnTopologyOperationOutput>> tunnelxconnTopologyOperation(
+ TunnelxconnTopologyOperationInput input) {
+
+ final String svcOperation = "tunnelxconn-topology-operation";
+ Properties parms = new Properties();
+ log.info(CALLED_STR, svcOperation);
+
+ // create a new response object
+ TunnelxconnTopologyOperationOutputBuilder responseBuilder = new TunnelxconnTopologyOperationOutputBuilder();
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<TunnelxconnTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+ String siid = input.getServiceInformation().getServiceInstanceId();
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ TunnelxconnTopologyOperationInputBuilder inputBuilder = new TunnelxconnTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String allottedResourceId = ERROR_NETWORK_ID;
+ String serviceObjectPath = null;
+ String tunnelxconnObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ tunnelxconnObjectPath = respProps.getProperty("tunnelxconn-object-path");
+ }
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<TunnelxconnTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+ TunnelxconnResponseInformationBuilder tunnelxconnResponseInformationBuilder = new TunnelxconnResponseInformationBuilder();
+ tunnelxconnResponseInformationBuilder.setInstanceId(allottedResourceId);
+ tunnelxconnResponseInformationBuilder.setObjectPath(tunnelxconnObjectPath);
+ responseBuilder.setTunnelxconnResponseInformation(tunnelxconnResponseInformationBuilder.build());
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ 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");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<TunnelxconnTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<TunnelxconnTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private Properties tryGetProperties(String svcOperation, Properties parms, ErrorObject error) {
+ try {
+ if (svcLogicClient.hasGraph(APP_NAME, svcOperation, null, "sync")) {
+
+ try {
+ return svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", parms);
+ } catch (Exception e) {
+ log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
+ error.setMessage(e.getMessage());
+ error.setStatusCode("500");
+ }
+ } else {
+ error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ error.setStatusCode("503");
+ }
+ } catch (Exception e) {
error.setMessage(e.getMessage());
error.setStatusCode("500");
- log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
- }
- return null;
- }
-
- @Override
- public Future<RpcResult<BrgTopologyOperationOutput>> brgTopologyOperation(BrgTopologyOperationInput input) {
- final String svcOperation = "brg-topology-operation";
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- BrgTopologyOperationOutputBuilder responseBuilder = new BrgTopologyOperationOutputBuilder();
-
- if (input == null || input.getServiceInformation() == null
- || input.getServiceInformation().getServiceInstanceId() == null
- || input.getServiceInformation().getServiceInstanceId().length() == 0) {
- log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
- responseBuilder.setResponseCode("404");
- responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- String siid = input.getServiceInformation().getServiceInstanceId();
-
- log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
- BrgTopologyOperationInputBuilder inputBuilder = new BrgTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
-
- // Call SLI sync method
- // Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- String allottedResourceId = ERROR_NETWORK_ID;
- String serviceObjectPath = null;
- String brgObjectPath = null;
- Properties respProps = tryGetProperties(svcOperation, parms, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
- serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
- brgObjectPath = respProps.getProperty("brg-object-path");
- }
-
- if (validateErrorObject(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Got success from SLI
- try {
-
-
- BrgResponseInformationBuilder brgResponseInformationBuilder = new BrgResponseInformationBuilder();
- brgResponseInformationBuilder.setInstanceId(allottedResourceId);
- brgResponseInformationBuilder.setObjectPath(brgObjectPath);
- responseBuilder.setBrgResponseInformation(brgResponseInformationBuilder.build());
-
- ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
- 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");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
- RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
- log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
-
- RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
- .withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- @Override
- public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation(
- PreloadVnfTopologyOperationInput input) {
-
- final String svcOperation = "preload-vnf-topology-operation";
- PreloadData preloadData;
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder();
-
- if (input == null || input.getVnfTopologyInformation() == null
- || input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null) {
- log.debug("exiting {} because of null input", svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("invalid input: input is null");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Grab the name and type from the input buffer
- String preloadName = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName();
- String preloadType = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType();
-
- // Make sure we have a preload_name and preload_type
- if (preloadName == null || preloadName.length() == 0 || preloadType == null || preloadType.length() == 0) {
- log.debug("exiting {} vnf-name or vnf-type is null or empty", svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("invalid input: vnf-name or vnf-type is null or empty");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
- getPreloadData(preloadName, preloadType, preloadDataBuilder);
-
- PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
- getPreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
-
- // setup a preload-data object builder
- // ACTION preload-vnf-topology-operation
- // INPUT:
- // USES sdnc-request-header;
- // USES request-information;
- // uses vnf-topology-information;
- // OUTPUT:
- // USES vnf-topology-response-body;
- //
- // container preload-data
- // uses vnf-topology-information;
- // uses network-topology-information;
- // uses oper-status;
-
- log.info("Adding INPUT data for {} [{},{}] input: {}", svcOperation, preloadName, preloadType, input);
- PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", svcOperation, preloadName,
- preloadType, operDataBuilder.build());
- GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
-
- // Call SLI sync method
- // Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- Properties respProps = tryGetProperties(svcOperation, parms, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- }
-
- if (validateErrorObject(error)) {
-
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
- preloadVnfListBuilder.setVnfName(preloadName);
- preloadVnfListBuilder.setVnfType(preloadType);
- preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
- log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName,
- preloadType, error.getStatusCode(), error.getMessage());
- try {
- savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName,
- preloadType, e);
- }
- log.debug("Sending Success rpc result due to external error");
- RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Got success from SLI
- try {
- updatePreloadData(svcOperation, preloadName, preloadType, preloadDataBuilder);
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType,
- e);
- responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType,
- responseBuilder.build());
- RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVnfTopologyOperationOutput>status(false).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType);
- log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType,
- responseBuilder.build());
-
- RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- private void updatePreloadData(String svcOperation, String preloadName, String preloadType,
- PreloadDataBuilder preloadDataBuilder) {
- PreloadData preloadData;
- preloadData = preloadDataBuilder.build();
- log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", svcOperation, preloadName, preloadType,
- preloadData);
- // svc-configuration-list
- VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
- preloadVnfListBuilder.setVnfName(preloadName);
- preloadVnfListBuilder.setVnfType(preloadType);
- preloadVnfListBuilder.setPreloadData(preloadData);
-
- // merge flag sets to false to allow it to be overwritten (not appended)
- savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
- log.info(UPDATING_TREE_INFO_MESSAGE);
- savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
- }
-
- @Override
- public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
- PreloadNetworkTopologyOperationInput input) {
-
- final String svcOperation = "preload-network-topology-operation";
- PreloadData preloadData;
- Properties parms = new Properties();
-
- log.info(CALLED_STR, svcOperation);
- // create a new response object
- PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder();
-
- if (input == null || input.getNetworkTopologyInformation() == null
- || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null) {
-
- log.debug("exiting {} because of null input", svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("input is null");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Grab the name and type from the input buffer
- String preloadName = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName();
- String preloadType = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType();
-
- // Make sure we have a preload_name and preload_type
- if (preloadName == null || preloadName.length() == 0 || preloadType == null || preloadType.length() == 0) {
- log.debug("exiting {} because of invalid preload-name", svcOperation);
- responseBuilder.setResponseCode("403");
- responseBuilder.setResponseMessage("input, invalid preload-name");
- responseBuilder.setAckFinalIndicator("Y");
- RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- if (input.getSdncRequestHeader() != null) {
- responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
- }
-
- PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
- getPreloadData(preloadName, preloadType, preloadDataBuilder);
-
- PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
- getPreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
-
- //
- // setup a preload-data object builder
- // ACTION preload-network-topology-operation
- // INPUT:
- // USES sdnc-request-header;
- // USES request-information;
- // uses network-topology-information;
- // OUTPUT:
- // USES vnf-topology-response-body;
- //
- // container preload-data
- // uses vnf-topology-information;
- // uses network-topology-information;
- // uses oper-status;
-
- log.info("Adding INPUT data for {} [{},{}] input: {}", svcOperation, preloadName, preloadType, input);
- PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder(
- input);
- GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
- log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", svcOperation, preloadName,
- preloadType, operDataBuilder.build());
- GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
-
- // Call SLI sync method
- // Get SvcLogicService reference
- ErrorObject error = new ErrorObject("200", "");
- String ackFinal = "Y";
- Properties respProps = tryGetProperties(svcOperation, parms, error);
-
- if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
- ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- }
-
- if (validateErrorObject(error)) {
-
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
- responseBuilder.setAckFinalIndicator(ackFinal);
-
- VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
- preloadVnfListBuilder.setVnfName(preloadName);
- preloadVnfListBuilder.setVnfType(preloadType);
- preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
- log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName,
- preloadType, error.getStatusCode(), error.getMessage());
- try {
- savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName,
- preloadType, e);
-
- }
- log.debug("Sending Success rpc result due to external error");
- RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Got success from SLI
- try {
- updatePreloadData(svcOperation, preloadName, preloadType, preloadDataBuilder);
- } catch (Exception e) {
- log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType, e);
- responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
- responseBuilder.setAckFinalIndicator("Y");
- log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType,
- responseBuilder.build());
- RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(false).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setAckFinalIndicator(ackFinal);
- if (!error.getMessage().isEmpty()) {
- responseBuilder.setResponseMessage(error.getMessage());
- }
- log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType);
- log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType,
- responseBuilder.build());
-
- RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
- .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
+ log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
+ }
+ return null;
+ }
+
+ @Override
+ public Future<RpcResult<BrgTopologyOperationOutput>> brgTopologyOperation(BrgTopologyOperationInput input) {
+ final String svcOperation = "brg-topology-operation";
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ BrgTopologyOperationOutputBuilder responseBuilder = new BrgTopologyOperationOutputBuilder();
+
+ if (input == null || input.getServiceInformation() == null
+ || input.getServiceInformation().getServiceInstanceId() == null
+ || input.getServiceInformation().getServiceInstanceId().length() == 0) {
+ log.debug(NULL_OR_EMPTY_ERROR_MESSAGE, svcOperation);
+ responseBuilder.setResponseCode("404");
+ responseBuilder.setResponseMessage(NULL_OR_EMPTY_ERROR_PARAM);
+ responseBuilder.setAckFinalIndicator("Y");
+ RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ String siid = input.getServiceInformation().getServiceInstanceId();
+
+ log.info(ADDING_INPUT_DATA_LOG, svcOperation, siid, input);
+ BrgTopologyOperationInputBuilder inputBuilder = new BrgTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ String allottedResourceId = ERROR_NETWORK_ID;
+ String serviceObjectPath = null;
+ String brgObjectPath = null;
+ Properties respProps = tryGetProperties(svcOperation, parms, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
+ brgObjectPath = respProps.getProperty("brg-object-path");
+ }
+
+ if (validateErrorObject(error)) {
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<BrgTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+
+ BrgResponseInformationBuilder brgResponseInformationBuilder = new BrgResponseInformationBuilder();
+ brgResponseInformationBuilder.setInstanceId(allottedResourceId);
+ brgResponseInformationBuilder.setObjectPath(brgObjectPath);
+ responseBuilder.setBrgResponseInformation(brgResponseInformationBuilder.build());
+
+ ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder();
+ 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");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<BrgTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
+ log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
+
+ RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<BrgTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ @Override
+ public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation(
+ PreloadVnfTopologyOperationInput input) {
+
+ final String svcOperation = "preload-vnf-topology-operation";
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder();
+
+ if (input == null || input.getVnfTopologyInformation() == null
+ || input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null) {
+ log.debug("exiting {} because of null input", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("invalid input: input is null");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadVnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Grab the name and type from the input buffer
+ String preloadName = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName();
+ String preloadType = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType();
+
+ // Make sure we have a preload_name and preload_type
+ if (preloadName == null || preloadName.length() == 0 || preloadType == null || preloadType.length() == 0) {
+ log.debug("exiting {} vnf-name or vnf-type is null or empty", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("invalid input: vnf-name or vnf-type is null or empty");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadVnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
+ getPreloadData(preloadName, preloadType, preloadDataBuilder);
+
+ PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
+ getPreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
+
+ // setup a preload-data object builder
+ // ACTION preload-vnf-topology-operation
+ // INPUT:
+ // USES sdnc-request-header;
+ // USES request-information;
+ // uses vnf-topology-information;
+ // OUTPUT:
+ // USES vnf-topology-response-body;
+ //
+ // container preload-data
+ // uses vnf-topology-information;
+ // uses network-topology-information;
+ // uses oper-status;
+
+ log.info("Adding INPUT data for {} [{},{}] input: {}", svcOperation, preloadName, preloadType, input);
+ PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+ log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", svcOperation, preloadName,
+ preloadType, operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ Properties respProps = tryGetProperties(svcOperation, parms, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ }
+
+ if (validateErrorObject(error)) {
+
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
+ preloadVnfListBuilder.setVnfName(preloadName);
+ preloadVnfListBuilder.setVnfType(preloadType);
+ preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
+ log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName,
+ preloadType, error.getStatusCode(), error.getMessage());
+ try {
+ savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName,
+ preloadType, e);
+ }
+ log.debug("Sending Success rpc result due to external error");
+
+ RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadVnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+ updatePreloadData(svcOperation, preloadName, preloadType, preloadDataBuilder);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType,
+ e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType,
+ responseBuilder.build());
+
+ RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadVnfTopologyOperationOutput>status(false)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType);
+ log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType,
+ responseBuilder.build());
+
+ RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadVnfTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ private void updatePreloadData(String svcOperation, String preloadName, String preloadType,
+ PreloadDataBuilder preloadDataBuilder) {
+ PreloadData preloadData;
+ preloadData = preloadDataBuilder.build();
+ log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", svcOperation, preloadName, preloadType,
+ preloadData);
+ // svc-configuration-list
+ VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
+ preloadVnfListBuilder.setVnfName(preloadName);
+ preloadVnfListBuilder.setVnfType(preloadType);
+ preloadVnfListBuilder.setPreloadData(preloadData);
+
+ // merge flag sets to false to allow it to be overwritten (not appended)
+ savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.CONFIGURATION);
+ log.info(UPDATING_TREE_INFO_MESSAGE);
+ savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL);
+ }
+
+ @Override
+ public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation(
+ PreloadNetworkTopologyOperationInput input) {
+
+ final String svcOperation = "preload-network-topology-operation";
+ Properties parms = new Properties();
+
+ log.info(CALLED_STR, svcOperation);
+ // create a new response object
+ PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder();
+
+ if (input == null || input.getNetworkTopologyInformation() == null
+ || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null) {
+
+ log.debug("exiting {} because of null input", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("input is null");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadNetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Grab the name and type from the input buffer
+ String preloadName = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName();
+ String preloadType = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType();
+
+ // Make sure we have a preload_name and preload_type
+ if (preloadName == null || preloadName.length() == 0 || preloadType == null || preloadType.length() == 0) {
+ log.debug("exiting {} because of invalid preload-name", svcOperation);
+ responseBuilder.setResponseCode("403");
+ responseBuilder.setResponseMessage("input, invalid preload-name");
+ responseBuilder.setAckFinalIndicator("Y");
+
+ RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadNetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ if (input.getSdncRequestHeader() != null) {
+ responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId());
+ }
+
+ PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder();
+ getPreloadData(preloadName, preloadType, preloadDataBuilder);
+
+ PreloadDataBuilder operDataBuilder = new PreloadDataBuilder();
+ getPreloadData(preloadName, preloadType, operDataBuilder, LogicalDatastoreType.OPERATIONAL);
+
+ //
+ // setup a preload-data object builder
+ // ACTION preload-network-topology-operation
+ // INPUT:
+ // USES sdnc-request-header;
+ // USES request-information;
+ // uses network-topology-information;
+ // OUTPUT:
+ // USES vnf-topology-response-body;
+ //
+ // container preload-data
+ // uses vnf-topology-information;
+ // uses network-topology-information;
+ // uses oper-status;
+
+ log.info("Adding INPUT data for {} [{},{}] input: {}", svcOperation, preloadName, preloadType, input);
+ PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder(
+ input);
+ GenericResourceApiUtil.toProperties(parms, inputBuilder.build());
+ log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", svcOperation, preloadName,
+ preloadType, operDataBuilder.build());
+ GenericResourceApiUtil.toProperties(parms, OPERATIONAL_DATA_PARAM, operDataBuilder);
+
+ // Call SLI sync method
+ // Get SvcLogicService reference
+ ErrorObject error = new ErrorObject("200", "");
+ String ackFinal = "Y";
+ Properties respProps = tryGetProperties(svcOperation, parms, error);
+
+ if (respProps != null) {
+ error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
+ }
+
+ if (validateErrorObject(error)) {
+
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseMessage(error.getMessage());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+
+ VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder();
+ preloadVnfListBuilder.setVnfName(preloadName);
+ preloadVnfListBuilder.setVnfType(preloadType);
+ preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build());
+ log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", svcOperation, preloadName,
+ preloadType, error.getStatusCode(), error.getMessage());
+ try {
+ savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName,
+ preloadType, e);
+
+ }
+ log.debug("Sending Success rpc result due to external error");
+
+ RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadNetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Got success from SLI
+ try {
+ updatePreloadData(svcOperation, preloadName, preloadType, preloadDataBuilder);
+ } catch (Exception e) {
+ log.error(UPDATING_MDSAL_ERROR_MESSAGE_2, svcOperation, preloadName, preloadType, e);
+ responseBuilder.setResponseCode("500");
+ responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setAckFinalIndicator("Y");
+ log.error("Returned FAILED for {} [{},{}] {}", svcOperation, preloadName, preloadType,
+ responseBuilder.build());
+
+ RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadNetworkTopologyOperationOutput>status(false)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // Update succeeded
+ responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setAckFinalIndicator(ackFinal);
+ if (!error.getMessage().isEmpty()) {
+ responseBuilder.setResponseMessage(error.getMessage());
+ }
+ log.info("Updated MD-SAL for {} [{},{}]", svcOperation, preloadName, preloadType);
+ log.info("Returned SUCCESS for {} [{},{}] {}", svcOperation, preloadName, preloadType,
+ responseBuilder.build());
+
+ RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder
+ .<PreloadNetworkTopologyOperationOutput>status(true)
+ .withResult(responseBuilder.build())
+ .build();
+
+ return Futures.immediateFuture(rpcResult);
+ }
}