diff options
14 files changed, 1382 insertions, 1742 deletions
diff --git a/generic-resource-api/features/pom.xml b/generic-resource-api/features/pom.xml index 7c2e8907..041307fc 100644 --- a/generic-resource-api/features/pom.xml +++ b/generic-resource-api/features/pom.xml @@ -1,42 +1,37 @@ <?xml version='1.0' encoding='UTF-8'?> -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api</artifactId> - <version>1.2.0-SNAPSHOT</version> - </parent> + <parent> + <groupId>org.onap.sdnc.northbound</groupId> + <artifactId>generic-resource-api</artifactId> + <version>1.2.0-SNAPSHOT</version> + </parent> - <artifactId>generic-resource-api.features</artifactId> - <packaging>jar</packaging> + <artifactId>generic-resource-api-features</artifactId> + <packaging>jar</packaging> - <dependencies> - <dependency> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.model</artifactId> - </dependency> - <dependency> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.provider</artifactId> - <type>xml</type> - <classifier>config</classifier> - </dependency> - <dependency> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.provider</artifactId> - </dependency> + <dependencies> + <dependency> + <groupId>org.onap.sdnc.northbound</groupId> + <artifactId>generic-resource-api-model</artifactId> + </dependency> + <dependency> + <groupId>org.onap.sdnc.northbound</groupId> + <artifactId>generic-resource-api-provider</artifactId> + </dependency> <dependency> <groupId>org.opendaylight.mdsal</groupId> <artifactId>features-mdsal</artifactId> - <version>${odl.mdsal.features.version}</version> + <version>${odl.mdsal.features.version}</version> <type>xml</type> <classifier>features</classifier> <scope>runtime</scope> </dependency> - <dependency><!-- Required for launching the feature tests--> + <dependency><!-- Required for launching the feature tests --> <groupId>org.opendaylight.odlparent</groupId> <artifactId>features-test</artifactId> <version>${odl.commons.opendaylight.version}</version> @@ -46,56 +41,56 @@ <dependency> <groupId>org.opendaylight.yangtools</groupId> <artifactId>features-yangtools</artifactId> - <version>${odl.yangtools.version}</version> + <version>${odl.yangtools.version}</version> <type>xml</type> <classifier>features</classifier> <scope>runtime</scope> </dependency> - </dependencies> + </dependencies> - <build> - <resources> - <resource> - <filtering>true</filtering> - <directory>src/main/resources</directory> - </resource> - </resources> - <plugins> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-resources-plugin</artifactId> - <executions> - <execution> - <id>filter</id> - <goals> - <goal>resources</goal> - </goals> - <phase>generate-resources</phase> - </execution> - </executions> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>attach-artifacts</id> - <goals> - <goal>attach-artifact</goal> - </goals> - <phase>package</phase> - <configuration> - <artifacts> - <artifact> - <file>${project.build.directory}/classes/${features.file}</file> - <type>xml</type> - <classifier>features</classifier> - </artifact> - </artifacts> - </configuration> - </execution> - </executions> - </plugin> - </plugins> - </build> + <build> + <resources> + <resource> + <filtering>true</filtering> + <directory>src/main/resources</directory> + </resource> + </resources> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>filter</id> + <goals> + <goal>resources</goal> + </goals> + <phase>generate-resources</phase> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> + <execution> + <id>attach-artifacts</id> + <goals> + <goal>attach-artifact</goal> + </goals> + <phase>package</phase> + <configuration> + <artifacts> + <artifact> + <file>${project.build.directory}/classes/${features.file}</file> + <type>xml</type> + <classifier>features</classifier> + </artifact> + </artifacts> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> </project> diff --git a/generic-resource-api/features/src/main/resources/features.xml b/generic-resource-api/features/src/main/resources/features.xml index ccf60324..219c7215 100644 --- a/generic-resource-api/features/src/main/resources/features.xml +++ b/generic-resource-api/features/src/main/resources/features.xml @@ -4,15 +4,14 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> - <feature name='GENERIC-RESOURCE-API' description="generic-resource-api.GENERIC-RESOURCE-API" version='${project.version}'> - <feature version="${odl.controller.mdsal.version}">odl-mdsal-broker</feature> + <feature name='sdnc-generic-resource-api' description="sdnc-generic-resource-api" version='${project.version}'> + <feature>odl-mdsal-broker</feature> <feature>sdnc-sli</feature> <!-- It is assumed that applications are installed on BVC, which installs bvc-core including MD-SAL etc. Do not list those features out here as that will tie your implementation to a specific version of MD-SAL / BVC and force updates to your application for every upgrade of BVC core platform.--> - <bundle>mvn:org.onap.sdnc.northbound/generic-resource-api.model/${project.version}</bundle> - <bundle>mvn:org.onap.sdnc.northbound/generic-resource-api.provider/${project.version}</bundle> - <configfile finalname="etc/opendaylight/karaf/200-generic-resource-api-provider.xml">mvn:org.onap.sdnc.northbound/generic-resource-api.provider/${project.version}/xml/config</configfile> + <bundle>mvn:org.onap.sdnc.northbound/generic-resource-api-model/${project.version}</bundle> + <bundle>mvn:org.onap.sdnc.northbound/generic-resource-api-provider/${project.version}</bundle> </feature> </features> diff --git a/generic-resource-api/installer/pom.xml b/generic-resource-api/installer/pom.xml index b190ff7b..e1f2d513 100755 --- a/generic-resource-api/installer/pom.xml +++ b/generic-resource-api/installer/pom.xml @@ -12,9 +12,9 @@ <packaging>pom</packaging> <properties> - <application.name>sdnc-generic-resources-api</application.name> - <features.boot>sdnc-generic-resources-api</features.boot> - <features.repositories>mvn:org.onap.sdnc.northbound/generic-resources-api-features/${project.version}/xml/features</features.repositories> + <application.name>sdnc-generic-resource-api</application.name> + <features.boot>sdnc-generic-resource-api</features.boot> + <features.repositories>mvn:org.onap.sdnc.northbound/generic-resource-api-features/${project.version}/xml/features</features.repositories> <include.transitive.dependencies>false</include.transitive.dependencies> </properties> @@ -22,7 +22,7 @@ <dependency> <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.features</artifactId> + <artifactId>generic-resource-api-features</artifactId> <version>${project.version}</version> <classifier>features</classifier> <type>xml</type> @@ -36,7 +36,7 @@ <dependency> <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.provider</artifactId> + <artifactId>generic-resource-api-provider</artifactId> <version>${project.version}</version> </dependency> diff --git a/generic-resource-api/installer/src/assembly/assemble_mvnrepo_zip.xml b/generic-resource-api/installer/src/assembly/assemble_mvnrepo_zip.xml index c1b6357f..89d9c14f 100644 --- a/generic-resource-api/installer/src/assembly/assemble_mvnrepo_zip.xml +++ b/generic-resource-api/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -1,21 +1,13 @@ -<!-- - ============LICENSE_START======================================================= - openECOMP : SDN-C - ================================================================================ - Copyright (C) 2017 AT&T Intellectual Property. All rights - reserved. - ================================================================================ - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - http://www.apache.org/licenses/LICENSE-2.0 - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - ============LICENSE_END========================================================= - --> +<!-- ============LICENSE_START======================================================= + openECOMP : SDN-C ================================================================================ + Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. ================================================================================ + Licensed under the Apache License, Version 2.0 (the "License"); you may not + use this file except in compliance with the License. You may obtain a copy + of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required + by applicable law or agreed to in writing, software distributed under the + License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS + OF ANY KIND, either express or implied. See the License for the specific + language governing permissions and limitations under the License. ============LICENSE_END========================================================= --> <!-- Defines how we build the .zip file which is our distribution. --> @@ -28,9 +20,8 @@ <format>zip</format> </formats> - <!-- we want "system" and related files right at the root level - as this file is suppose to be unzip on top of a karaf - distro. --> + <!-- we want "system" and related files right at the root level as this + file is suppose to be unzip on top of a karaf distro. --> <includeBaseDirectory>false</includeBaseDirectory> <fileSets> @@ -44,14 +35,10 @@ <files> <file> - <source>../provider/src/main/resources/initial/${feature-name}-provider.xml</source> - <destName>./etc/opendaylight/karaf/200-${feature-name}-provider.xml</destName> - </file> - <file> - <source>../model/target/generic-resource-api.properties</source> - <destName>./configuration/generic-resource-api.properties</destName> + <source>../model/target/generic-resource-api.properties</source> + <destName>./configuration/generic-resource-api.properties</destName> - </file> + </file> </files> </assembly> diff --git a/generic-resource-api/model/pom.xml b/generic-resource-api/model/pom.xml index 97f1b060..f0bf6b9e 100644 --- a/generic-resource-api/model/pom.xml +++ b/generic-resource-api/model/pom.xml @@ -8,7 +8,7 @@ <version>1.2.0-SNAPSHOT</version> </parent> - <artifactId>generic-resource-api.model</artifactId> + <artifactId>generic-resource-api-model</artifactId> <packaging>bundle</packaging> <dependencies> diff --git a/generic-resource-api/pom.xml b/generic-resource-api/pom.xml index 2d761019..f3c2e937 100644 --- a/generic-resource-api/pom.xml +++ b/generic-resource-api/pom.xml @@ -18,9 +18,9 @@ </properties> <modules> <module>model</module> + <module>provider</module> <module>features</module> <module>installer</module> - <module>provider</module> </modules> @@ -28,26 +28,19 @@ <dependencies> <dependency> <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.features</artifactId> + <artifactId>generic-resource-api-features</artifactId> <version>${project.version}</version> <type>xml</type> <classifier>features</classifier> </dependency> <dependency> <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.model</artifactId> + <artifactId>generic-resource-api-model</artifactId> <version>${project.version}</version> </dependency> <dependency> <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.provider</artifactId> - <version>${project.version}</version> - <type>xml</type> - <classifier>config</classifier> - </dependency> - <dependency> - <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.provider</artifactId> + <artifactId>generic-resource-api-provider</artifactId> <version>${project.version}</version> </dependency> </dependencies> diff --git a/generic-resource-api/provider/pom.xml b/generic-resource-api/provider/pom.xml index 2f4a25fb..23375b54 100644 --- a/generic-resource-api/provider/pom.xml +++ b/generic-resource-api/provider/pom.xml @@ -8,13 +8,13 @@ <version>1.2.0-SNAPSHOT</version> </parent> - <artifactId>generic-resource-api.provider</artifactId> + <artifactId>generic-resource-api-provider</artifactId> <packaging>bundle</packaging> <dependencies> <dependency> <groupId>org.onap.sdnc.northbound</groupId> - <artifactId>generic-resource-api.model</artifactId> + <artifactId>generic-resource-api-model</artifactId> </dependency> <dependency> <groupId>org.opendaylight.controller</groupId> @@ -97,25 +97,7 @@ <build> <plugins> - <!-- - <plugin> - <groupId>com.brocade.tools</groupId> - <artifactId>providermodule-plugin</artifactId> - <version>1.0.0-SNAPSHOT</version> - <configuration> - <packageId>org.onap.sdnc.northbound</packageId> - <appName>generic-resource-api</appName> - </configuration> - <executions> - <execution> - <phase>process-sources</phase> - <goals> - <goal>process</goal> - </goals> - </execution> - </executions> - </plugin> - --> + <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> @@ -127,69 +109,8 @@ </instructions> </configuration> </plugin> - <plugin> - <groupId>org.opendaylight.yangtools</groupId> - <artifactId>yang-maven-plugin</artifactId> - <executions> - <execution> - <id>config</id> - <goals> - <goal>generate-sources</goal> - </goals> - <configuration> - <codeGenerators> - <generator> - <codeGeneratorClass>org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator</codeGeneratorClass> - <outputBaseDir>${jmxGeneratorPath}</outputBaseDir> - <additionalConfiguration> - <namespaceToPackage1>urn:opendaylight:params:xml:ns:yang:controller==org.opendaylight.controller.config.yang</namespaceToPackage1> - </additionalConfiguration> - </generator> - <generator> - <codeGeneratorClass>org.opendaylight.mdsal.binding.maven.api.gen.plugin.CodeGeneratorImpl</codeGeneratorClass> - <outputBaseDir>${salGeneratorPath}</outputBaseDir> - </generator> - </codeGenerators> - <inspectDependencies>true</inspectDependencies> - </configuration> - </execution> - </executions> - <dependencies> - <dependency> - <groupId>org.opendaylight.mdsal</groupId> - <artifactId>maven-sal-api-gen-plugin</artifactId> - <version>${odl.sal.api.gen.plugin.version}</version> - <type>jar</type> - </dependency> - <dependency> - <groupId>org.opendaylight.controller</groupId> - <artifactId>yang-jmx-generator-plugin</artifactId> - <version>${odl.yang.jmx.generator.version}</version> - </dependency> - </dependencies> - </plugin> - <plugin> - <groupId>org.codehaus.mojo</groupId> - <artifactId>build-helper-maven-plugin</artifactId> - <executions> - <execution> - <id>attach-artifacts</id> - <goals> - <goal>attach-artifact</goal> - </goals> - <phase>package</phase> - <configuration> - <artifacts> - <artifact> - <file>${project.build.directory}/classes/initial/generic-resource-api-provider.xml</file> - <type>xml</type> - <classifier>config</classifier> - </artifact> - </artifacts> - </configuration> - </execution> - </executions> - </plugin> + + </plugins> </build> </project> 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 a0b08621..7d8f4b3a 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 @@ -97,388 +97,375 @@ import com.google.common.util.concurrent.CheckedFuture; import com.google.common.util.concurrent.Futures; import com.google.common.util.concurrent.SettableFuture; - /** - * 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. + * 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> + * + * @Override + * public java.lang.AutoCloseable createInstance() { + * + * // final GENERIC-RESOURCE-APIProvider provider = new + * // GENERIC-RESOURCE-APIProvider(); + * final GenericResourceApiProvider provider = new GenericResourceApiProvider(); + * provider.setDataBroker(getDataBrokerDependency()); + * provider.setNotificationService(getNotificationServiceDependency()); + * provider.setRpcRegistry(getRpcRegistryDependency()); + * provider.initialize(); + * return new AutoCloseable() { + * + * @Override + * public void close() throws Exception { + * // TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE + * // BROKER/NOTIFICATION + * // SERVIE/RPC REGISTRY + * provider.close(); + * } + * }; + * } + * + * </pre> + */ - @Override - public java.lang.AutoCloseable createInstance() { +public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURCEAPIService { - //final GENERIC-RESOURCE-APIProvider provider = new GENERIC-RESOURCE-APIProvider(); - final GenericResourceApiProvider provider = new GenericResourceApiProvider(); - provider.setDataBroker( getDataBrokerDependency() ); - provider.setNotificationService( getNotificationServiceDependency() ); - provider.setRpcRegistry( getRpcRegistryDependency() ); - provider.initialize(); - return new AutoCloseable() { + private final Logger log = LoggerFactory.getLogger(GenericResourceApiProvider.class); + private final String appName = "generic-resource-api"; - @Override - public void close() throws Exception { - //TODO: CLOSE ANY REGISTRATION OBJECTS CREATED USING ABOVE BROKER/NOTIFICATION - //SERVIE/RPC REGISTRY - provider.close(); - } - }; - } + private final ExecutorService executor; + protected DataBroker dataBroker; + protected NotificationPublishService notificationService; + protected RpcProviderRegistry rpcRegistry; + protected BindingAwareBroker.RpcRegistration<GENERICRESOURCEAPIService> rpcRegistration; - </pre> - */ + private GenericResourceApiSvcLogicServiceClient svcLogicClient; + + public GenericResourceApiProvider(DataBroker dataBroker2, NotificationPublishService notificationPublishService, + RpcProviderRegistry rpcProviderRegistry, GenericResourceApiSvcLogicServiceClient client) { + log.info("Creating provider for {}", appName); + executor = Executors.newFixedThreadPool(1); + dataBroker = dataBroker2; + notificationService = notificationPublishService; + rpcRegistry = rpcProviderRegistry; + svcLogicClient = client; + initialize(); -public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURCEAPIService{ - - private final Logger log = LoggerFactory.getLogger( GenericResourceApiProvider.class ); - private final String appName = "generic-resource-api"; - - private final ExecutorService executor; - - protected DataBroker dataBroker; - protected NotificationPublishService notificationService; - protected RpcProviderRegistry rpcRegistry; - protected BindingAwareBroker.RpcRegistration<GENERICRESOURCEAPIService> rpcRegistration; - - public GenericResourceApiProvider(DataBroker dataBroker2, - NotificationPublishService notificationPublishService, - RpcProviderRegistry rpcProviderRegistry) { - log.info( "Creating provider for {}", appName); - executor = Executors.newFixedThreadPool(1); - dataBroker = dataBroker2; - notificationService = notificationPublishService; - rpcRegistry = rpcProviderRegistry; - initialize(); - - } - - public void initialize(){ - log.info("Initializing provider for {}", appName); - // Create the top level containers - createContainers(); - try { - GenericResourceApiUtil.loadProperties(); - } catch (Exception e) { - log.error("Caught Exception while trying to load properties file"); - } - rpcRegistration = rpcRegistry.addRpcImplementation(GENERICRESOURCEAPIService.class, this); - - log.info("Initialization complete for {}", appName); - } - - - protected void initializeChild() { - //Override if you have custom initialization intelligence - } - - - @Override - public void close() throws Exception { - log.info("Closing provider for {}", appName); - executor.shutdown(); - rpcRegistration.close(); - log.info("Successfully closed provider for {}", appName); - } - - private static class Iso8601Util - { - private static TimeZone tz = TimeZone.getTimeZone("UTC"); - private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); - - static { df.setTimeZone(tz); } - - private static String now() { - return df.format(new Date()); - } - } - - - public void setDataBroker(DataBroker dataBroker) { - this.dataBroker = dataBroker; - if( log.isDebugEnabled() ){ - log.debug("DataBroker set to {}", (dataBroker==null?"null":"non-null")); - } - } - - public void setNotificationService(NotificationPublishService notificationService) { - this.notificationService = notificationService; - if( log.isDebugEnabled() ){ - log.debug("Notification Service set to {}", (notificationService==null?"null":"non-null")); - } - } - - public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { - this.rpcRegistry = rpcRegistry; - if( log.isDebugEnabled() ){ - log.debug("RpcRegistry set to {}", (rpcRegistry==null?"null":"non-null")); - } - } - - 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()); - } - - /* - if (requestInformation != null && requestInformation.getRequestSubAction() != null) { - switch (requestInformation.getRequestSubAction()) - { - case SUPP: - serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.SUPP); - break; - case CANCEL: - serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.CANCEL); - break; - default: - log.error("Unknown RequestSubAction: " + requestInformation.getRequestSubAction() ); - break; - }; - } - */ - } - - 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 serviceInstanceIdentifier = - InstanceIdentifier.<Services>builder(Services.class) - .child(Service.class, new ServiceKey(siid)).build(); - ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); - Optional<Service> data = null; - try { - data = (Optional<Service>) 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 vnf_name, String vnf_type, PreloadDataBuilder preloadDataBuilder) - { - // default to config - getPreloadData(vnf_name, vnf_type ,preloadDataBuilder, LogicalDatastoreType.CONFIGURATION); - } - - private void getPreloadData(String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, LogicalDatastoreType type) - { - // See if any data exists yet for this name/type, if so grab it. - InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class) - .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).build(); - ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); - Optional<VnfPreloadList> data = null; - try { - data = (Optional<VnfPreloadList>) readTx.read(type, preloadInstanceIdentifier).get(); - } catch (InterruptedException | ExecutionException e) { - log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type, e); - } - - if (data != null && data.isPresent()) { - PreloadData preloadData = data.get().getPreloadData(); - if (preloadData != null) { - log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", - type, preload_name, preload_type, 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, preload_name, preload_type); - } - } else { - log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type); - } - } - - private void saveService(final Service entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException { - // Each entry will be identifiable by a unique key, we have to create that identifier - InstanceIdentifier.InstanceIdentifierBuilder<Service> serviceBuilder = - InstanceIdentifier.<Services>builder(Services.class) - .child(Service.class, entry.getKey()); - InstanceIdentifier<Service> path = serviceBuilder.build(); - - int tries = 2; - while(true) { - try { - 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"); - break; - } catch (final TransactionCommitFailedException e) { - if(e instanceof OptimisticLockFailedException) { - if(--tries <= 0) { - log.debug("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - log.debug("Got OptimisticLockFailedException - trying again "); - } else { - log.debug("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - } - - private void deleteService(final Service entry, LogicalDatastoreType storeType) throws IllegalStateException { - // Each entry will be identifiable by a unique key, we have to create - // that identifier - InstanceIdentifier.InstanceIdentifierBuilder<Service> serviceListIdBuilder = InstanceIdentifier.<Services> builder(Services.class).child(Service.class, entry.getKey()); - InstanceIdentifier<Service> path = serviceListIdBuilder.build(); - - int tries = 2; - while (true) { - try { - WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); - tx.delete(storeType, path); - tx.submit().checkedGet(); - log.debug("DataStore delete succeeded"); - break; - } catch (final TransactionCommitFailedException e) { - if (e instanceof OptimisticLockFailedException) { - if (--tries <= 0) { - log.debug("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - log.debug("Got OptimisticLockFailedException - trying again "); - } else { - log.debug("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - } - - private void savePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) throws IllegalStateException{ - - // Each entry will be identifiable by a unique key, we have to create that identifier - InstanceIdentifier.InstanceIdentifierBuilder<VnfPreloadList> vnfPreloadListBuilder = - InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class) - .child(VnfPreloadList.class, entry.getKey()); - InstanceIdentifier<VnfPreloadList> path = vnfPreloadListBuilder.build(); - int tries = 2; - while(true) { - try { - 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"); - break; - } catch (final TransactionCommitFailedException e) { - if(e instanceof OptimisticLockFailedException) { - if(--tries <= 0) { - log.debug("Got OptimisticLockFailedException on last try - failing "); - throw new IllegalStateException(e); - } - log.debug("Got OptimisticLockFailedException - trying again "); - } else { - log.debug("Update DataStore failed"); - throw new IllegalStateException(e); - } - } - } - } + } + + public void initialize() { + log.info("Initializing provider for {}", appName); + // Create the top level containers + createContainers(); + try { + GenericResourceApiUtil.loadProperties(); + } catch (Exception e) { + log.error("Caught Exception while trying to load properties file"); + } + + log.info("Initialization complete for {}", appName); + } + + protected void initializeChild() { + // Override if you have custom initialization intelligence + } + + @Override + public void close() throws Exception { + log.info("Closing provider for {}", appName); + executor.shutdown(); + rpcRegistration.close(); + log.info("Successfully closed provider for {}", appName); + } + + private static class Iso8601Util { + private static TimeZone tz = TimeZone.getTimeZone("UTC"); + private static DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"); + + static { + df.setTimeZone(tz); + } + + private static String now() { + return df.format(new Date()); + } + } + + public void setDataBroker(DataBroker dataBroker) { + this.dataBroker = dataBroker; + if (log.isDebugEnabled()) { + log.debug("DataBroker set to {}", (dataBroker == null ? "null" : "non-null")); + } + } + + public void setNotificationService(NotificationPublishService notificationService) { + this.notificationService = notificationService; + if (log.isDebugEnabled()) { + log.debug("Notification Service set to {}", (notificationService == null ? "null" : "non-null")); + } + } + + public void setRpcRegistry(RpcProviderRegistry rpcRegistry) { + this.rpcRegistry = rpcRegistry; + if (log.isDebugEnabled()) { + log.debug("RpcRegistry set to {}", (rpcRegistry == null ? "null" : "non-null")); + } + } + + 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()); + } + + /* + * if (requestInformation != null && requestInformation.getRequestSubAction() != + * null) { switch (requestInformation.getRequestSubAction()) { case SUPP: + * serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.SUPP); break; case + * CANCEL: serviceStatusBuilder.setVnfsdnSubaction(VnfsdnSubaction.CANCEL); + * break; default: log.error("Unknown RequestSubAction: " + + * requestInformation.getRequestSubAction() ); break; }; } + */ + } + + 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 serviceInstanceIdentifier = InstanceIdentifier.<Services>builder(Services.class) + .child(Service.class, new ServiceKey(siid)).build(); + ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); + Optional<Service> data = null; + try { + data = (Optional<Service>) 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 vnf_name, String vnf_type, PreloadDataBuilder preloadDataBuilder) { + // default to config + getPreloadData(vnf_name, vnf_type, preloadDataBuilder, LogicalDatastoreType.CONFIGURATION); + } + + private void getPreloadData(String preload_name, String preload_type, PreloadDataBuilder preloadDataBuilder, + LogicalDatastoreType type) { + // See if any data exists yet for this name/type, if so grab it. + InstanceIdentifier preloadInstanceIdentifier = InstanceIdentifier.<PreloadVnfs>builder(PreloadVnfs.class) + .child(VnfPreloadList.class, new VnfPreloadListKey(preload_name, preload_type)).build(); + ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction(); + Optional<VnfPreloadList> data = null; + try { + data = (Optional<VnfPreloadList>) readTx.read(type, preloadInstanceIdentifier).get(); + } catch (InterruptedException | ExecutionException e) { + log.error("Caught Exception reading MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type, e); + } + + if (data != null && data.isPresent()) { + PreloadData preloadData = data.get().getPreloadData(); + if (preloadData != null) { + log.info("Read MD-SAL ({}) data for [{},{}] PreloadData: {}", type, preload_name, preload_type, + 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, preload_name, preload_type); + } + } else { + log.info("No data found in MD-SAL ({}) for [{},{}] ", type, preload_name, preload_type); + } + } + + private void saveService(final Service entry, boolean merge, LogicalDatastoreType storeType) + throws IllegalStateException { + // Each entry will be identifiable by a unique key, we have to create that + // identifier + InstanceIdentifier.InstanceIdentifierBuilder<Service> serviceBuilder = InstanceIdentifier + .<Services>builder(Services.class).child(Service.class, entry.getKey()); + InstanceIdentifier<Service> path = serviceBuilder.build(); + + int tries = 2; + while (true) { + try { + 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"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + log.debug("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + log.debug("Got OptimisticLockFailedException - trying again "); + } else { + log.debug("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } + + private void deleteService(final Service entry, LogicalDatastoreType storeType) throws IllegalStateException { + // Each entry will be identifiable by a unique key, we have to create + // that identifier + InstanceIdentifier.InstanceIdentifierBuilder<Service> serviceListIdBuilder = InstanceIdentifier + .<Services>builder(Services.class).child(Service.class, entry.getKey()); + InstanceIdentifier<Service> path = serviceListIdBuilder.build(); + + int tries = 2; + while (true) { + try { + WriteTransaction tx = dataBroker.newWriteOnlyTransaction(); + tx.delete(storeType, path); + tx.submit().checkedGet(); + log.debug("DataStore delete succeeded"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + log.debug("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + log.debug("Got OptimisticLockFailedException - trying again "); + } else { + log.debug("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } + + private void savePreloadList(final VnfPreloadList entry, boolean merge, LogicalDatastoreType storeType) + throws IllegalStateException { + + // Each entry will be identifiable by a unique key, we have to create that + // identifier + InstanceIdentifier.InstanceIdentifierBuilder<VnfPreloadList> vnfPreloadListBuilder = InstanceIdentifier + .<PreloadVnfs>builder(PreloadVnfs.class).child(VnfPreloadList.class, entry.getKey()); + InstanceIdentifier<VnfPreloadList> path = vnfPreloadListBuilder.build(); + int tries = 2; + while (true) { + try { + 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"); + break; + } catch (final TransactionCommitFailedException e) { + if (e instanceof OptimisticLockFailedException) { + if (--tries <= 0) { + log.debug("Got OptimisticLockFailedException on last try - failing "); + throw new IllegalStateException(e); + } + log.debug("Got OptimisticLockFailedException - trying again "); + } else { + log.debug("Update DataStore failed"); + throw new IllegalStateException(e); + } + } + } + } @Override public Future<RpcResult<ServiceTopologyOperationOutput>> serviceTopologyOperation( @@ -489,21 +476,19 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); Properties parms = new Properties(); - log.info("{} called.",SVC_OPERATION); + log.info("{} called.", SVC_OPERATION); // create a new response object ServiceTopologyOperationOutputBuilder responseBuilder = new ServiceTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<ServiceTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -515,85 +500,72 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC } ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + getServiceData(siid, serviceDataBuilder); ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,operDataBuilder, LogicalDatastoreType.OPERATIONAL ); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); // Set the serviceStatus based on input setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); setServiceStatus(serviceStatusBuilder, input.getRequestInformation()); /* - // 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; - */ + * // 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 for {} [{}] input: {}", SVC_OPERATION, siid, input); ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(input); GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, operDataBuilder.build()); + log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, + operDataBuilder.build()); GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; - String serviceObjectPath = null; + String serviceObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {} ", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); - serviceObjectPath = respProps.getProperty("service-object-path"); + serviceObjectPath = respProps.getProperty("service-object-path"); } - setServiceStatus(serviceStatusBuilder,errorCode, errorMessage, ackFinal); + setServiceStatus(serviceStatusBuilder, errorCode, errorMessage, ackFinal); serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); - //serviceStatusBuilder.setRpcName(RpcName.ServiceTopologyOperation); + // serviceStatusBuilder.setRpcName(RpcName.ServiceTopologyOperation); serviceStatusBuilder.setRpcName(SVC_OPERATION); - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); @@ -607,8 +579,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); } log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<ServiceTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -624,51 +596,47 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete)) { log.info("Delete from both CONFIGURATION and OPERATIONAL tree."); - deleteService(serviceBuilder.build(), LogicalDatastoreType.OPERATIONAL); - deleteService(serviceBuilder.build(), LogicalDatastoreType.CONFIGURATION); + deleteService(serviceBuilder.build(), LogicalDatastoreType.OPERATIONAL); + deleteService(serviceBuilder.build(), LogicalDatastoreType.CONFIGURATION); } } - ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); - serviceResponseInformationBuilder.setInstanceId(siid); - serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); - responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); } catch (Exception e) { - log.error("Caught Exception updating MD-SAL for {} [{}] \n",SVC_OPERATION, siid, e); + log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); responseBuilder.setResponseCode("500"); responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<ServiceTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<ServiceTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ServiceTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ServiceTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ServiceTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @Override - public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation( - VnfTopologyOperationInput input) { + public Future<RpcResult<VnfTopologyOperationOutput>> vnfTopologyOperation(VnfTopologyOperationInput input) { final String SVC_OPERATION = "vnf-topology-operation"; ServiceData serviceData; @@ -679,17 +647,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // create a new response object VnfTopologyOperationOutputBuilder responseBuilder = new VnfTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<VnfTopologyOperationOutput> rpcResult = - RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); // return error return Futures.immediateFuture(rpcResult); } @@ -701,46 +667,40 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId()); } - if(input.getVnfInformation() == null || - input.getVnfInformation().getVnfId() == null || - input.getVnfInformation().getVnfId().length() == 0) - { + if (input.getVnfInformation() == null || input.getVnfInformation().getVnfId() == null + || input.getVnfInformation().getVnfId().length() == 0) { log.debug("exiting {} because of null or empty vnf-id", SVC_OPERATION); 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(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - /* Mobility wont use vipr intf in 1707 - - String preload_name = null; - String preload_type = null; - if (input.getVnfRequestInput() != null && - input.getVnfRequestInput().getVnfName() != null && input.getVnfRequestInput().getVnfName().length() != 0) { - preload_name = input.getVnfRequestInput().getVnfName(); - } - if (input.getVnfInformation().getVnfType() != null && - input.getVnfInformation().getVnfType().length() != 0) { - preload_type = input.getVnfInformation().getVnfType(); - } - - PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); - if (preload_name != null && preload_type != null) { - getPreloadData(preload_name, preload_type, preloadDataBuilder); - } - else { - log.info("vnf-name and vnf-type not present in the request"); - } - */ + /* + * Mobility wont use vipr intf in 1707 + * + * String preload_name = null; String preload_type = null; if + * (input.getVnfRequestInput() != null && + * input.getVnfRequestInput().getVnfName() != null && + * input.getVnfRequestInput().getVnfName().length() != 0) { preload_name = + * input.getVnfRequestInput().getVnfName(); } if + * (input.getVnfInformation().getVnfType() != null && + * input.getVnfInformation().getVnfType().length() != 0) { preload_type = + * input.getVnfInformation().getVnfType(); } + * + * PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); if + * (preload_name != null && preload_type != null) { getPreloadData(preload_name, + * preload_type, preloadDataBuilder); } else { + * log.info("vnf-name and vnf-type not present in the request"); } + */ ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + getServiceData(siid, serviceDataBuilder); ServiceDataBuilder operDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,operDataBuilder, LogicalDatastoreType.OPERATIONAL ); + getServiceData(siid, operDataBuilder, LogicalDatastoreType.OPERATIONAL); // Set the serviceStatus based on input setServiceStatus(serviceStatusBuilder, input.getSdncRequestHeader()); @@ -750,83 +710,77 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // 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 + // 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 + // USES vnf-topology-response-body; + // USES vnf-information + // USES service-information // // container service-data - // uses vnf-configuration-information; - // uses oper-status; + // uses vnf-configuration-information; + // uses oper-status; log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input); VnfTopologyOperationInputBuilder inputBuilder = new VnfTopologyOperationInputBuilder(input); GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, operDataBuilder.build()); + log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, + operDataBuilder.build()); GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); - /* - log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preload-data: " + preloadDataBuilder.build()); - GenericResourceApiUtil.toProperties(parms, "preload-data", preloadDataBuilder); - */ + /* + * log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+ + * preload_type+"] preload-data: " + preloadDataBuilder.build()); + * GenericResourceApiUtil.toProperties(parms, "preload-data", + * preloadDataBuilder); + */ // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; - String serviceObjectPath = null; + String serviceObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {} ", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); - serviceObjectPath = respProps.getProperty("vnf-object-path"); + serviceObjectPath = respProps.getProperty("vnf-object-path"); } - setServiceStatus(serviceStatusBuilder,errorCode, errorMessage, ackFinal); + setServiceStatus(serviceStatusBuilder, errorCode, errorMessage, ackFinal); serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); - //serviceStatusBuilder.setRpcName(RpcName.VnfTopologyOperation); + // serviceStatusBuilder.setRpcName(RpcName.VnfTopologyOperation); serviceStatusBuilder.setRpcName(SVC_OPERATION); - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); @@ -836,12 +790,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); try { saveService(serviceBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on activate or delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Delete) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -850,8 +802,8 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); } log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<VnfTopologyOperationOutput> rpcResult = - RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); // return error return Futures.immediateFuture(rpcResult); } @@ -868,20 +820,18 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on Assign - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } } - ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); - serviceResponseInformationBuilder.setInstanceId(siid); - serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); - responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); } catch (Exception e) { log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); @@ -889,272 +839,251 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<VnfTopologyOperationOutput> rpcResult = - RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<VnfTopologyOperationOutput> rpcResult = - RpcResultBuilder.<VnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<VnfTopologyOperationOutput> rpcResult = RpcResultBuilder.<VnfTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); // return success return Futures.immediateFuture(rpcResult); } - @Override - public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation( - VfModuleTopologyOperationInput input) { - - final String SVC_OPERATION = "vf-module-topology-operation"; - ServiceData serviceData; - ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); - Properties parms = new Properties(); - - log.info("{} called.", SVC_OPERATION); - // 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("exiting {} because of null or empty service-instance-id", SVC_OPERATION); - responseBuilder.setResponseCode("403"); - responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); - 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", SVC_OPERATION); - 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", SVC_OPERATION); - 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()); - } - - /* - String preload_name = null; - String preload_type = null; - - preload_name = input.getVfModuleRequestInput().getVfModuleName(); - - if(input.getVfModuleInformation().getVfModuleType() != null && - input.getVfModuleInformation().getVfModuleType().length() != 0) { - preload_type = input.getVfModuleInformation().getVfModuleType(); - } - - PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); - if (preload_name != null && preload_type != null) { - getPreloadData(preload_name, preload_type, preloadDataBuilder); - } - else { - log.debug("vf-module-name and vf-module-type not present in the request."); - } - */ - - 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 for {} [{}] input: {}", SVC_OPERATION, siid, input); - VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input); - GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - - log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, operDataBuilder.build()); - GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); - - /* - log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] preload-data: " +preloadDataBuilder.build()); - GenericResourceApiUtil.toProperties(parms, "preload-data", preloadDataBuilder); - */ - - // Call SLI sync method - // Get SvcLogicService reference - - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); - Properties respProps = null; - - String errorCode = "200"; - String errorMessage = null; - String ackFinal = "Y"; - String serviceObjectPath = null; - - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { - - try - { - respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { - log.error("Caught exception executing service logic for "+ SVC_OPERATION, e); - errorMessage = e.getMessage(); - errorCode = "500"; - } - } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; - errorCode = "503"; - } - } - catch (Exception e) - { - errorCode = "500"; - errorMessage = e.getMessage(); - log.error("Caught exception looking for service logic", e); - } - - if (respProps != null) - { - errorCode = respProps.getProperty("error-code"); - errorMessage = respProps.getProperty("error-message"); - ackFinal = respProps.getProperty("ack-final", "Y"); - serviceObjectPath = respProps.getProperty("vf-module-object-path"); - } - - setServiceStatus(serviceStatusBuilder,errorCode, errorMessage, ackFinal); - serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); - serviceStatusBuilder.setRpcName(SVC_OPERATION); - - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { - responseBuilder.setResponseCode(errorCode); - responseBuilder.setResponseMessage(errorMessage); - 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("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); - } - log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, 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 MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData); - - // service object - ServiceBuilder serviceBuilder = new ServiceBuilder(); - serviceBuilder.setServiceData(serviceData); - //serviceBuilder.setServiceInstanceId(serviceData.getServiceTopology().getServiceTopologyIdentifier().getServiceInstanceId()); - serviceBuilder.setServiceInstanceId(siid); - serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); - saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + @Override + public Future<RpcResult<VfModuleTopologyOperationOutput>> vfModuleTopologyOperation( + VfModuleTopologyOperationInput input) { + + final String SVC_OPERATION = "vf-module-topology-operation"; + ServiceData serviceData; + ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); + Properties parms = new Properties(); + + log.info("{} called.", SVC_OPERATION); + // 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("exiting {} because of null or empty service-instance-id", SVC_OPERATION); + responseBuilder.setResponseCode("403"); + responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); + 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", SVC_OPERATION); + 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", SVC_OPERATION); + 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()); + } + + /* + * String preload_name = null; String preload_type = null; + * + * preload_name = input.getVfModuleRequestInput().getVfModuleName(); + * + * if(input.getVfModuleInformation().getVfModuleType() != null && + * input.getVfModuleInformation().getVfModuleType().length() != 0) { + * preload_type = input.getVfModuleInformation().getVfModuleType(); } + * + * PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); if + * (preload_name != null && preload_type != null) { getPreloadData(preload_name, + * preload_type, preloadDataBuilder); } else { + * log.debug("vf-module-name and vf-module-type not present in the request."); } + */ + + 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 for {} [{}] input: {}", SVC_OPERATION, siid, input); + VfModuleTopologyOperationInputBuilder inputBuilder = new VfModuleTopologyOperationInputBuilder(input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + + log.info("Adding OPERATIONAL data for {} [{}] operational-data: {}", SVC_OPERATION, siid, + operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); + + /* + * log.info("Adding CONFIG data for "+SVC_OPERATION+" ["+preload_name+","+ + * preload_type+"] preload-data: " +preloadDataBuilder.build()); + * GenericResourceApiUtil.toProperties(parms, "preload-data", + * preloadDataBuilder); + */ + + // Call SLI sync method + // Get SvcLogicService reference + + Properties respProps = null; + + String errorCode = "200"; + String errorMessage = null; + String ackFinal = "Y"; + String serviceObjectPath = null; + + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { + + try { + respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); + } catch (Exception e) { + log.error("Caught exception executing service logic for " + SVC_OPERATION, e); + errorMessage = e.getMessage(); + errorCode = "500"; + } + } else { + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; + errorCode = "503"; + } + } catch (Exception e) { + errorCode = "500"; + errorMessage = e.getMessage(); + log.error("Caught exception looking for service logic", e); + } + + if (respProps != null) { + errorCode = respProps.getProperty("error-code"); + errorMessage = respProps.getProperty("error-message"); + ackFinal = respProps.getProperty("ack-final", "Y"); + serviceObjectPath = respProps.getProperty("vf-module-object-path"); + } + + setServiceStatus(serviceStatusBuilder, errorCode, errorMessage, ackFinal); + serviceStatusBuilder.setRequestStatus(RequestStatus.Synccomplete); + serviceStatusBuilder.setRpcName(SVC_OPERATION); + + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { + responseBuilder.setResponseCode(errorCode); + responseBuilder.setResponseMessage(errorMessage); + 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("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); + } + log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, 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 MD-SAL for {} [{}] ServiceData: {}", SVC_OPERATION, siid, serviceData); + + // service object + ServiceBuilder serviceBuilder = new ServiceBuilder(); + serviceBuilder.setServiceData(serviceData); + // serviceBuilder.setServiceInstanceId(serviceData.getServiceTopology().getServiceTopologyIdentifier().getServiceInstanceId()); + serviceBuilder.setServiceInstanceId(siid); + serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); + saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); + + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on activate or delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); 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("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); - responseBuilder.setResponseCode("500"); - responseBuilder.setResponseMessage(e.toString()); - responseBuilder.setAckFinalIndicator("Y"); - log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<VfModuleTopologyOperationOutput> rpcResult = - RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // Update succeeded - responseBuilder.setResponseCode(errorCode); - responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { - responseBuilder.setResponseMessage(errorMessage); - } - log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); - log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - - RpcResult<VfModuleTopologyOperationOutput> rpcResult = - RpcResultBuilder.<VfModuleTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); - // return success - return Futures.immediateFuture(rpcResult); - } + ServiceResponseInformationBuilder serviceResponseInformationBuilder = new ServiceResponseInformationBuilder(); + serviceResponseInformationBuilder.setInstanceId(siid); + serviceResponseInformationBuilder.setObjectPath(serviceObjectPath); + responseBuilder.setServiceResponseInformation(serviceResponseInformationBuilder.build()); + + } catch (Exception e) { + log.error("Caught Exception updating MD-SAL for {} [{}] \n", SVC_OPERATION, siid, e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.toString()); + responseBuilder.setAckFinalIndicator("Y"); + log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); + RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(errorCode); + responseBuilder.setAckFinalIndicator(ackFinal); + if (errorMessage != null) { + responseBuilder.setResponseMessage(errorMessage); + } + log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); + log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); + + RpcResult<VfModuleTopologyOperationOutput> rpcResult = RpcResultBuilder + .<VfModuleTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + // return success + return Futures.immediateFuture(rpcResult); + } @Override public Future<RpcResult<NetworkTopologyOperationOutput>> networkTopologyOperation( @@ -1165,70 +1094,61 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC ServiceStatusBuilder serviceStatusBuilder = new ServiceStatusBuilder(); Properties parms = new Properties(); - log.info("{} called.", SVC_OPERATION ); + log.info("{} called.", SVC_OPERATION); // create a new response object NetworkTopologyOperationOutputBuilder responseBuilder = new NetworkTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<NetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - String siid = input.getServiceInformation().getServiceInstanceId(); + String siid = input.getServiceInformation().getServiceInstanceId(); - // Get the service-instance service data from MD-SAL - ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + // 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) - { + ServiceData sd = serviceDataBuilder.build(); + if (sd == null || sd.getServiceLevelOperStatus() == null) { log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION); responseBuilder.setResponseCode("404"); - responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); + responseBuilder + .setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<NetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - - /* - //String preload_name = null; - //String preload_type = null; - // If both network-name and network-type are present in request, get the preload network from MD-SAL - if (input.getNetworkRequestInput() != null && - input.getNetworkRequestInput().getNetworkName() != null && - input.getNetworkRequestInput().getNetworkName().length() != 0) { - preload_name = input.getNetworkRequestInput().getNetworkName(); - } - if (input.getNetworkInformation() != null && - input.getNetworkInformation().getNetworkType() != null && - input.getNetworkInformation().getNetworkType().length() != 0) { - preload_type = input.getNetworkInformation().getNetworkType(); - } - - PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); - if (preload_name != null && preload_type != null) { - getPreloadData(preload_name, preload_type, preloadDataBuilder); - } - else { - log.debug("network-name and network-type not present in request"); - } - */ + /* + * //String preload_name = null; //String preload_type = null; // If both + * network-name and network-type are present in request, get the preload network + * from MD-SAL if (input.getNetworkRequestInput() != null && + * input.getNetworkRequestInput().getNetworkName() != null && + * input.getNetworkRequestInput().getNetworkName().length() != 0) { preload_name + * = input.getNetworkRequestInput().getNetworkName(); } if + * (input.getNetworkInformation() != null && + * input.getNetworkInformation().getNetworkType() != null && + * input.getNetworkInformation().getNetworkType().length() != 0) { preload_type + * = input.getNetworkInformation().getNetworkType(); } + * + * PreloadDataBuilder preloadDataBuilder = new PreloadDataBuilder(); if + * (preload_name != null && preload_type != null) { getPreloadData(preload_name, + * preload_type, preloadDataBuilder); } else { + * log.debug("network-name and network-type not present in request"); } + */ log.info("Adding INPUT data for {} [{}] input: {}", SVC_OPERATION, siid, input); NetworkTopologyOperationInputBuilder inputBuilder = new NetworkTopologyOperationInputBuilder(input); @@ -1237,46 +1157,36 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; String networkId = "error"; - String serviceObjectPath = null; - String networkObjectPath = null; + String serviceObjectPath = null; + String networkObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); @@ -1285,15 +1195,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC networkObjectPath = respProps.getProperty("network-object-path"); } - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<NetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1310,11 +1220,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on Activate - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -1336,23 +1244,22 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<NetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<NetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<NetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<NetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<NetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1369,89 +1276,77 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // create a new response object ContrailRouteTopologyOperationOutputBuilder responseBuilder = new ContrailRouteTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - String siid = input.getServiceInformation().getServiceInstanceId(); + String siid = input.getServiceInformation().getServiceInstanceId(); - // Get the service-instance service data from MD-SAL - ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + // 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) - { + ServiceData sd = serviceDataBuilder.build(); + if (sd == null || sd.getServiceLevelOperStatus() == null) { log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION); responseBuilder.setResponseCode("404"); - responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); + responseBuilder + .setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - log.info("Adding INPUT data for "+SVC_OPERATION+" ["+siid+"] input: " + input); + log.info("Adding INPUT data for " + SVC_OPERATION + " [" + siid + "] input: " + input); ContrailRouteTopologyOperationInputBuilder inputBuilder = new ContrailRouteTopologyOperationInputBuilder(input); GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; String allottedResourceId = "error"; - String serviceObjectPath = null; - String contrailRouteObjectPath = null; + String serviceObjectPath = null; + String contrailRouteObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); @@ -1460,15 +1355,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC contrailRouteObjectPath = respProps.getProperty("contrail-route-object-path"); } - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1485,12 +1380,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on activate or delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -1512,23 +1405,22 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = - RpcResultBuilder.<ContrailRouteTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<ContrailRouteTopologyOperationOutput> rpcResult = RpcResultBuilder + .<ContrailRouteTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1545,39 +1437,37 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // create a new response object SecurityZoneTopologyOperationOutputBuilder responseBuilder = new SecurityZoneTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = - RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - String siid = input.getServiceInformation().getServiceInstanceId(); + String siid = input.getServiceInformation().getServiceInstanceId(); - // Get the service-instance service data from MD-SAL - ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + // 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) - { + ServiceData sd = serviceDataBuilder.build(); + if (sd == null || sd.getServiceLevelOperStatus() == null) { log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION); responseBuilder.setResponseCode("404"); - responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); + responseBuilder + .setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = - RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1588,46 +1478,36 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; String allottedResourceId = "error"; - String serviceObjectPath = null; - String securityZoneObjectPath = null; + String serviceObjectPath = null; + String securityZoneObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); @@ -1636,15 +1516,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC securityZoneObjectPath = respProps.getProperty("security-zone-object-path"); } - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = - RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1661,12 +1541,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on activate or delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -1688,23 +1566,22 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = - RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = - RpcResultBuilder.<SecurityZoneTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<SecurityZoneTopologyOperationOutput> rpcResult = RpcResultBuilder + .<SecurityZoneTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1721,39 +1598,37 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // create a new response object TunnelxconnTopologyOperationOutputBuilder responseBuilder = new TunnelxconnTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = - RpcResultBuilder.<TunnelxconnTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - String siid = input.getServiceInformation().getServiceInstanceId(); + String siid = input.getServiceInformation().getServiceInstanceId(); - // Get the service-instance service data from MD-SAL - ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + // 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) - { + ServiceData sd = serviceDataBuilder.build(); + if (sd == null || sd.getServiceLevelOperStatus() == null) { log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION); responseBuilder.setResponseCode("404"); - responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); + responseBuilder + .setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = - RpcResultBuilder.<TunnelxconnTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1764,46 +1639,36 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; String allottedResourceId = "error"; - String serviceObjectPath = null; - String tunnelxconnObjectPath = null; + String serviceObjectPath = null; + String tunnelxconnObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); @@ -1812,15 +1677,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC tunnelxconnObjectPath = respProps.getProperty("tunnelxconn-object-path"); } - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = - RpcResultBuilder.<TunnelxconnTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1837,12 +1702,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on activate or delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -1864,23 +1727,22 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = - RpcResultBuilder.<TunnelxconnTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = - RpcResultBuilder.<TunnelxconnTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<TunnelxconnTopologyOperationOutput> rpcResult = RpcResultBuilder + .<TunnelxconnTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1895,39 +1757,37 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // create a new response object BrgTopologyOperationOutputBuilder responseBuilder = new BrgTopologyOperationOutputBuilder(); - if(input == null || - input.getServiceInformation() == null || - input.getServiceInformation().getServiceInstanceId() == null || - input.getServiceInformation().getServiceInstanceId().length() == 0) - { + if (input == null || input.getServiceInformation() == null + || input.getServiceInformation().getServiceInstanceId() == null + || input.getServiceInformation().getServiceInstanceId().length() == 0) { log.debug("exiting {} because of null or empty service-instance-id", SVC_OPERATION); responseBuilder.setResponseCode("404"); responseBuilder.setResponseMessage("invalid input, null or empty service-instance-id"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<BrgTopologyOperationOutput> rpcResult = - RpcResultBuilder.<BrgTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } - String siid = input.getServiceInformation().getServiceInstanceId(); + String siid = input.getServiceInformation().getServiceInstanceId(); - // Get the service-instance service data from MD-SAL - ServiceDataBuilder serviceDataBuilder = new ServiceDataBuilder(); - getServiceData(siid,serviceDataBuilder); + // 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) - { + ServiceData sd = serviceDataBuilder.build(); + if (sd == null || sd.getServiceLevelOperStatus() == null) { log.debug("exiting {} because the service-instance does not have any service data in SDNC", SVC_OPERATION); responseBuilder.setResponseCode("404"); - responseBuilder.setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); + responseBuilder + .setResponseMessage("invalid input: the service-instance does not have any service data in SDNC"); responseBuilder.setAckFinalIndicator("Y"); - RpcResult<BrgTopologyOperationOutput> rpcResult = - RpcResultBuilder.<BrgTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -1938,46 +1798,36 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC // Call SLI sync method // Get SvcLogicService reference - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); Properties respProps = null; String errorCode = "200"; String errorMessage = null; String ackFinal = "Y"; String allottedResourceId = "error"; - String serviceObjectPath = null; - String brgObjectPath = null; + String serviceObjectPath = null; + String brgObjectPath = null; - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { - try - { + try { respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", serviceDataBuilder, parms); - } - catch (Exception e) - { + } catch (Exception e) { log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); errorMessage = e.getMessage(); errorCode = "500"; } } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; errorCode = "503"; } - } - catch (Exception e) - { + } catch (Exception e) { errorCode = "500"; errorMessage = e.getMessage(); log.error("Caught exception looking for service logic", e); } - - if (respProps != null) - { + if (respProps != null) { errorCode = respProps.getProperty("error-code"); errorMessage = respProps.getProperty("error-message"); ackFinal = respProps.getProperty("ack-final", "Y"); @@ -1986,15 +1836,15 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC brgObjectPath = respProps.getProperty("brg-object-path"); } - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { responseBuilder.setResponseCode(errorCode); responseBuilder.setResponseMessage(errorMessage); responseBuilder.setAckFinalIndicator(ackFinal); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<BrgTopologyOperationOutput> rpcResult = - RpcResultBuilder.<BrgTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } @@ -2011,12 +1861,10 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC serviceBuilder.setServiceStatus(serviceStatusBuilder.build()); saveService(serviceBuilder.build(), false, LogicalDatastoreType.CONFIGURATION); - if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) - { + if (input.getSdncRequestHeader() != null && input.getSdncRequestHeader().getSvcAction() != null) { // Only update operational tree on activate or delete - if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) || - input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) - { + if (input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Unassign) + || input.getSdncRequestHeader().getSvcAction().equals(SvcAction.Activate)) { log.info("Updating OPERATIONAL tree."); saveService(serviceBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); } @@ -2038,402 +1886,377 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC responseBuilder.setResponseMessage(e.toString()); responseBuilder.setAckFinalIndicator("Y"); log.error("Returned FAILED for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<BrgTopologyOperationOutput> rpcResult = - RpcResultBuilder.<BrgTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); + RpcResult<BrgTopologyOperationOutput> rpcResult = RpcResultBuilder.<BrgTopologyOperationOutput>status(true) + .withResult(responseBuilder.build()).build(); return Futures.immediateFuture(rpcResult); } // Update succeeded responseBuilder.setResponseCode(errorCode); responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { + if (errorMessage != null) { responseBuilder.setResponseMessage(errorMessage); } log.info("Updated MD-SAL for {} [{}]", SVC_OPERATION, siid); log.info("Returned SUCCESS for {} [{}] {}", SVC_OPERATION, siid, responseBuilder.build()); - RpcResult<BrgTopologyOperationOutput> rpcResult = - RpcResultBuilder.<BrgTopologyOperationOutput> status(true).withResult(responseBuilder.build()).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 SVC_OPERATION = "preload-vnf-topology-operation"; - PreloadData preloadData; - Properties parms = new Properties(); - - log.info("{} called.", SVC_OPERATION); - // create a new response object - PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder(); - - // Result from savePreloadData - final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create(); - - if(input == null || input.getVnfTopologyInformation() == null || - input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null) { - log.debug("exiting {} because of null input", SVC_OPERATION); - 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 preload_name = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName(); - String preload_type = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType(); - - // Make sure we have a preload_name and preload_type - if(preload_name == null || preload_name.length() == 0 || preload_type == null || preload_type.length() == 0 ) { - log.debug("exiting {} vnf-name or vnf-type is null or empty", SVC_OPERATION); - 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(preload_name, preload_type, preloadDataBuilder); - - PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); - getPreloadData(preload_name, preload_type, 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: {}", SVC_OPERATION, preload_name, preload_type, input); - PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input); - GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", - SVC_OPERATION, preload_name, preload_type, operDataBuilder.build()); - GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); - - // Call SLI sync method - // Get SvcLogicService reference - - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); - Properties respProps = null; - - String errorCode = "200"; - String errorMessage = null; - String ackFinal = "Y"; - - - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { - - try - { - respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", preloadDataBuilder, parms); - } - catch (Exception e) - { - log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); - errorMessage = e.getMessage(); - errorCode = "500"; - } - } else { - errorMessage = "No service logic active for "+ appName + ": '" + SVC_OPERATION + "'"; - errorCode = "503"; - } - } - catch (Exception e) - { - errorCode = "500"; - errorMessage = e.getMessage(); - log.error("Caught exception looking for service logic", e); - } - - - if (respProps != null) - { - errorCode = respProps.getProperty("error-code"); - errorMessage = respProps.getProperty("error-message"); - ackFinal = respProps.getProperty("ack-final", "Y"); - // internalError = respProps.getProperty("internal-error", "false"); - } - - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { - - responseBuilder.setResponseCode(errorCode); - responseBuilder.setResponseMessage(errorMessage); - responseBuilder.setAckFinalIndicator(ackFinal); - - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preload_name); - preloadVnfListBuilder.setVnfType(preload_type); - preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build()); - log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", - SVC_OPERATION, preload_name, preload_type, errorCode, errorMessage); - try { - savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); - } catch (Exception e) { - log.error("Caught Exception updating MD-SAL for {} [{},{}] \n", - SVC_OPERATION, preload_name, preload_type, 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 { - preloadData = preloadDataBuilder.build(); - log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", - SVC_OPERATION, preload_name, preload_type, preloadData); - // svc-configuration-list - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preload_name); - preloadVnfListBuilder.setVnfType(preload_type); - 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 OPERATIONAL tree."); - savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); - } catch (Exception e) { - log.error("Caught Exception updating MD-SAL for {} [{},{}] \n", - SVC_OPERATION, preload_name, preload_type, e); - responseBuilder.setResponseCode("500"); - responseBuilder.setResponseMessage(e.toString()); - responseBuilder.setAckFinalIndicator("Y"); - log.error("Returned FAILED for {} [{},{}] {}", - SVC_OPERATION, preload_name, preload_type, responseBuilder.build()); - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = - RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // Update succeeded - responseBuilder.setResponseCode(errorCode); - responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { - responseBuilder.setResponseMessage(errorMessage); - } - log.info("Updated MD-SAL for {} [{},{}]", SVC_OPERATION, preload_name, preload_type); - log.info("Returned SUCCESS for {} [{},{}] {}", SVC_OPERATION, preload_name, preload_type, responseBuilder.build()); - - RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = - RpcResultBuilder.<PreloadVnfTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - - @Override - public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation( - PreloadNetworkTopologyOperationInput input) { - - final String SVC_OPERATION = "preload-network-topology-operation"; - PreloadData preloadData; - Properties parms = new Properties(); - - log.info("{} called.", SVC_OPERATION); - // create a new response object - PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder(); - - // Result from savePreloadData - final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create(); - - if(input == null || input.getNetworkTopologyInformation() == null || - input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null) { - - log.debug("exiting {} because of null input", SVC_OPERATION); - 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 preload_name = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName(); - String preload_type = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType(); - - // Make sure we have a preload_name and preload_type - if(preload_name == null || preload_name.length() == 0 || preload_type == null || preload_type.length() == 0 ) { - log.debug("exiting {} because of invalid preload-name", SVC_OPERATION); - 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(preload_name, preload_type, preloadDataBuilder); - - PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); - getPreloadData(preload_name, preload_type, 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: {}", SVC_OPERATION, preload_name, preload_type, input); - PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder(input); - GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); - log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", - SVC_OPERATION, preload_name, preload_type, operDataBuilder.build()); - GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); - - // Call SLI sync method - // Get SvcLogicService reference - - GenericResourceApiSvcLogicServiceClient svcLogicClient = new GenericResourceApiSvcLogicServiceClient(); - Properties respProps = null; - - String errorCode = "200"; - String errorMessage = null; - String ackFinal = "Y"; - - - try - { - if (svcLogicClient.hasGraph(appName, SVC_OPERATION , null, "sync")) - { - - try - { - respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", preloadDataBuilder, parms); - } - catch (Exception e) - { - log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); - errorMessage = e.getMessage(); - errorCode = "500"; - } - } else { - errorMessage = "No service logic active for "+ appName +": '" + SVC_OPERATION + "'"; - errorCode = "503"; - } - } - catch (Exception e) - { - errorCode = "500"; - errorMessage = e.getMessage(); - log.error("Caught exception looking for service logic", e); - } - - - if (respProps != null) - { - errorCode = respProps.getProperty("error-code"); - errorMessage = respProps.getProperty("error-message"); - ackFinal = respProps.getProperty("ack-final", "Y"); - // internalError = respProps.getProperty("internal-error", "false"); - } - - if ( errorCode != null && errorCode.length() != 0 && !( errorCode.equals("0")|| errorCode.equals("200"))) { - - responseBuilder.setResponseCode(errorCode); - responseBuilder.setResponseMessage(errorMessage); - responseBuilder.setAckFinalIndicator(ackFinal); - - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preload_name); - preloadVnfListBuilder.setVnfType(preload_type); - preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build()); - log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", - SVC_OPERATION, preload_name, preload_type, errorCode, errorMessage); - try { - savePreloadList(preloadVnfListBuilder.build(),true, LogicalDatastoreType.CONFIGURATION); - } catch (Exception e) { - log.error("Caught Exception updating MD-SAL for {} [{},{}] \n", - SVC_OPERATION, preload_name, preload_type, 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 { - preloadData = preloadDataBuilder.build(); - log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", - SVC_OPERATION, preload_name, preload_type, preloadData); - // svc-configuration-list - VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); - preloadVnfListBuilder.setVnfName(preload_name); - preloadVnfListBuilder.setVnfType(preload_type); - 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 OPERATIONAL tree."); - savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); - } catch (Exception e) { - log.error("Caught Exception updating MD-SAL for "+SVC_OPERATION+" ["+preload_name+","+preload_type+"] \n",e); - responseBuilder.setResponseCode("500"); - responseBuilder.setResponseMessage(e.toString()); - responseBuilder.setAckFinalIndicator("Y"); - log.error("Returned FAILED for {} [{},{}] {}", - SVC_OPERATION, preload_name, preload_type, responseBuilder.build()); - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(false).withResult(responseBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } - - // Update succeeded - responseBuilder.setResponseCode(errorCode); - responseBuilder.setAckFinalIndicator(ackFinal); - if (errorMessage != null) - { - responseBuilder.setResponseMessage(errorMessage); - } - log.info("Updated MD-SAL for {} [{},{}]", SVC_OPERATION, preload_name, preload_type); - log.info("Returned SUCCESS for {} [{},{}] {}", - SVC_OPERATION, preload_name, preload_type, responseBuilder.build()); - - RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = - RpcResultBuilder.<PreloadNetworkTopologyOperationOutput> status(true).withResult(responseBuilder.build()).build(); - return Futures.immediateFuture(rpcResult); - } + @Override + public Future<RpcResult<PreloadVnfTopologyOperationOutput>> preloadVnfTopologyOperation( + PreloadVnfTopologyOperationInput input) { + + final String SVC_OPERATION = "preload-vnf-topology-operation"; + PreloadData preloadData; + Properties parms = new Properties(); + + log.info("{} called.", SVC_OPERATION); + // create a new response object + PreloadVnfTopologyOperationOutputBuilder responseBuilder = new PreloadVnfTopologyOperationOutputBuilder(); + + // Result from savePreloadData + final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create(); + + if (input == null || input.getVnfTopologyInformation() == null + || input.getVnfTopologyInformation().getVnfTopologyIdentifier() == null) { + log.debug("exiting {} because of null input", SVC_OPERATION); + 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 preload_name = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfName(); + String preload_type = input.getVnfTopologyInformation().getVnfTopologyIdentifier().getVnfType(); + + // Make sure we have a preload_name and preload_type + if (preload_name == null || preload_name.length() == 0 || preload_type == null || preload_type.length() == 0) { + log.debug("exiting {} vnf-name or vnf-type is null or empty", SVC_OPERATION); + 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(preload_name, preload_type, preloadDataBuilder); + + PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); + getPreloadData(preload_name, preload_type, 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: {}", SVC_OPERATION, preload_name, preload_type, input); + PreloadVnfTopologyOperationInputBuilder inputBuilder = new PreloadVnfTopologyOperationInputBuilder(input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", SVC_OPERATION, preload_name, + preload_type, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); + + // Call SLI sync method + // Get SvcLogicService reference + + Properties respProps = null; + + String errorCode = "200"; + String errorMessage = null; + String ackFinal = "Y"; + + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { + + try { + respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", preloadDataBuilder, parms); + } catch (Exception e) { + log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); + errorMessage = e.getMessage(); + errorCode = "500"; + } + } else { + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; + errorCode = "503"; + } + } catch (Exception e) { + errorCode = "500"; + errorMessage = e.getMessage(); + log.error("Caught exception looking for service logic", e); + } + + if (respProps != null) { + errorCode = respProps.getProperty("error-code"); + errorMessage = respProps.getProperty("error-message"); + ackFinal = respProps.getProperty("ack-final", "Y"); + // internalError = respProps.getProperty("internal-error", "false"); + } + + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { + + responseBuilder.setResponseCode(errorCode); + responseBuilder.setResponseMessage(errorMessage); + responseBuilder.setAckFinalIndicator(ackFinal); + + VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); + preloadVnfListBuilder.setVnfName(preload_name); + preloadVnfListBuilder.setVnfType(preload_type); + preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build()); + log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", SVC_OPERATION, preload_name, + preload_type, errorCode, errorMessage); + try { + savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + } catch (Exception e) { + log.error("Caught Exception updating MD-SAL for {} [{},{}] \n", SVC_OPERATION, preload_name, + preload_type, 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 { + preloadData = preloadDataBuilder.build(); + log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", SVC_OPERATION, preload_name, preload_type, + preloadData); + // svc-configuration-list + VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); + preloadVnfListBuilder.setVnfName(preload_name); + preloadVnfListBuilder.setVnfType(preload_type); + 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 OPERATIONAL tree."); + savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + } catch (Exception e) { + log.error("Caught Exception updating MD-SAL for {} [{},{}] \n", SVC_OPERATION, preload_name, preload_type, + e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.toString()); + responseBuilder.setAckFinalIndicator("Y"); + log.error("Returned FAILED for {} [{},{}] {}", SVC_OPERATION, preload_name, preload_type, + responseBuilder.build()); + RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadVnfTopologyOperationOutput>status(false).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(errorCode); + responseBuilder.setAckFinalIndicator(ackFinal); + if (errorMessage != null) { + responseBuilder.setResponseMessage(errorMessage); + } + log.info("Updated MD-SAL for {} [{},{}]", SVC_OPERATION, preload_name, preload_type); + log.info("Returned SUCCESS for {} [{},{}] {}", SVC_OPERATION, preload_name, preload_type, + responseBuilder.build()); + + RpcResult<PreloadVnfTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadVnfTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + @Override + public Future<RpcResult<PreloadNetworkTopologyOperationOutput>> preloadNetworkTopologyOperation( + PreloadNetworkTopologyOperationInput input) { + + final String SVC_OPERATION = "preload-network-topology-operation"; + PreloadData preloadData; + Properties parms = new Properties(); + + log.info("{} called.", SVC_OPERATION); + // create a new response object + PreloadNetworkTopologyOperationOutputBuilder responseBuilder = new PreloadNetworkTopologyOperationOutputBuilder(); + + // Result from savePreloadData + final SettableFuture<RpcResult<Void>> futureResult = SettableFuture.create(); + + if (input == null || input.getNetworkTopologyInformation() == null + || input.getNetworkTopologyInformation().getNetworkTopologyIdentifier() == null) { + + log.debug("exiting {} because of null input", SVC_OPERATION); + 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 preload_name = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkName(); + String preload_type = input.getNetworkTopologyInformation().getNetworkTopologyIdentifier().getNetworkType(); + + // Make sure we have a preload_name and preload_type + if (preload_name == null || preload_name.length() == 0 || preload_type == null || preload_type.length() == 0) { + log.debug("exiting {} because of invalid preload-name", SVC_OPERATION); + 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(preload_name, preload_type, preloadDataBuilder); + + PreloadDataBuilder operDataBuilder = new PreloadDataBuilder(); + getPreloadData(preload_name, preload_type, 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: {}", SVC_OPERATION, preload_name, preload_type, input); + PreloadNetworkTopologyOperationInputBuilder inputBuilder = new PreloadNetworkTopologyOperationInputBuilder( + input); + GenericResourceApiUtil.toProperties(parms, inputBuilder.build()); + log.info("Adding OPERATIONAL data for {} [{},{}] operational-data: {}", SVC_OPERATION, preload_name, + preload_type, operDataBuilder.build()); + GenericResourceApiUtil.toProperties(parms, "operational-data", operDataBuilder); + + // Call SLI sync method + // Get SvcLogicService reference + + Properties respProps = null; + + String errorCode = "200"; + String errorMessage = null; + String ackFinal = "Y"; + + try { + if (svcLogicClient.hasGraph(appName, SVC_OPERATION, null, "sync")) { + + try { + respProps = svcLogicClient.execute(appName, SVC_OPERATION, null, "sync", preloadDataBuilder, parms); + } catch (Exception e) { + log.error("Caught exception executing service logic for {}", SVC_OPERATION, e); + errorMessage = e.getMessage(); + errorCode = "500"; + } + } else { + errorMessage = "No service logic active for " + appName + ": '" + SVC_OPERATION + "'"; + errorCode = "503"; + } + } catch (Exception e) { + errorCode = "500"; + errorMessage = e.getMessage(); + log.error("Caught exception looking for service logic", e); + } + + if (respProps != null) { + errorCode = respProps.getProperty("error-code"); + errorMessage = respProps.getProperty("error-message"); + ackFinal = respProps.getProperty("ack-final", "Y"); + // internalError = respProps.getProperty("internal-error", "false"); + } + + if (errorCode != null && errorCode.length() != 0 && !(errorCode.equals("0") || errorCode.equals("200"))) { + + responseBuilder.setResponseCode(errorCode); + responseBuilder.setResponseMessage(errorMessage); + responseBuilder.setAckFinalIndicator(ackFinal); + + VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); + preloadVnfListBuilder.setVnfName(preload_name); + preloadVnfListBuilder.setVnfType(preload_type); + preloadVnfListBuilder.setPreloadData(preloadDataBuilder.build()); + log.error("Returned FAILED for {} [{},{}] error code: '{}', Reason: '{}'", SVC_OPERATION, preload_name, + preload_type, errorCode, errorMessage); + try { + savePreloadList(preloadVnfListBuilder.build(), true, LogicalDatastoreType.CONFIGURATION); + } catch (Exception e) { + log.error("Caught Exception updating MD-SAL for {} [{},{}] \n", SVC_OPERATION, preload_name, + preload_type, 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 { + preloadData = preloadDataBuilder.build(); + log.info("Updating MD-SAL for {} [{},{}] preloadData: {}", SVC_OPERATION, preload_name, preload_type, + preloadData); + // svc-configuration-list + VnfPreloadListBuilder preloadVnfListBuilder = new VnfPreloadListBuilder(); + preloadVnfListBuilder.setVnfName(preload_name); + preloadVnfListBuilder.setVnfType(preload_type); + 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 OPERATIONAL tree."); + savePreloadList(preloadVnfListBuilder.build(), false, LogicalDatastoreType.OPERATIONAL); + } catch (Exception e) { + log.error("Caught Exception updating MD-SAL for " + SVC_OPERATION + " [" + preload_name + "," + preload_type + + "] \n", e); + responseBuilder.setResponseCode("500"); + responseBuilder.setResponseMessage(e.toString()); + responseBuilder.setAckFinalIndicator("Y"); + log.error("Returned FAILED for {} [{},{}] {}", SVC_OPERATION, preload_name, preload_type, + responseBuilder.build()); + RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadNetworkTopologyOperationOutput>status(false).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } + + // Update succeeded + responseBuilder.setResponseCode(errorCode); + responseBuilder.setAckFinalIndicator(ackFinal); + if (errorMessage != null) { + responseBuilder.setResponseMessage(errorMessage); + } + log.info("Updated MD-SAL for {} [{},{}]", SVC_OPERATION, preload_name, preload_type); + log.info("Returned SUCCESS for {} [{},{}] {}", SVC_OPERATION, preload_name, preload_type, + responseBuilder.build()); + + RpcResult<PreloadNetworkTopologyOperationOutput> rpcResult = RpcResultBuilder + .<PreloadNetworkTopologyOperationOutput>status(true).withResult(responseBuilder.build()).build(); + return Futures.immediateFuture(rpcResult); + } } diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiSvcLogicServiceClient.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiSvcLogicServiceClient.java index 04b71e79..e5be5e3a 100644 --- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiSvcLogicServiceClient.java +++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiSvcLogicServiceClient.java @@ -19,22 +19,9 @@ public class GenericResourceApiSvcLogicServiceClient { private SvcLogicService svcLogic = null; - public GenericResourceApiSvcLogicServiceClient() + public GenericResourceApiSvcLogicServiceClient(SvcLogicService svcLogic) { - BundleContext bctx = FrameworkUtil.getBundle(SvcLogicService.class).getBundleContext(); - - // Get SvcLogicService reference - ServiceReference sref = bctx.getServiceReference(SvcLogicService.NAME); - if (sref != null) - { - svcLogic = (SvcLogicService) bctx.getService(sref); - - } - else - { - LOG.warn("Cannot find service reference for "+SvcLogicService.NAME); - - } + this.svcLogic = svcLogic; } public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException @@ -77,8 +64,10 @@ public class GenericResourceApiSvcLogicServiceClient { } } + Properties respProps = svcLogic.execute(module, rpc, version, mode, parms); + if (LOG.isDebugEnabled()) { LOG.debug("Parameters returned by SLI"); diff --git a/generic-resource-api/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/northbound/generic/resource/api/provider/impl/rev170824/GENERICRESOURCEAPIProviderModule.java b/generic-resource-api/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/northbound/generic/resource/api/provider/impl/rev170824/GENERICRESOURCEAPIProviderModule.java deleted file mode 100644 index 2314c260..00000000 --- a/generic-resource-api/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/northbound/generic/resource/api/provider/impl/rev170824/GENERICRESOURCEAPIProviderModule.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.api.provider.impl.rev170824; - -import org.onap.sdnc.northbound.GenericResourceApiProvider; -import org.opendaylight.controller.config.api.DependencyResolver; -import org.opendaylight.controller.config.api.ModuleIdentifier; - -public class GENERICRESOURCEAPIProviderModule extends AbstractGENERICRESOURCEAPIProviderModule { - public GENERICRESOURCEAPIProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver) { - super(identifier, dependencyResolver); - } - - public GENERICRESOURCEAPIProviderModule(ModuleIdentifier identifier, DependencyResolver dependencyResolver, GENERICRESOURCEAPIProviderModule oldModule, AutoCloseable oldInstance) { - super(identifier, dependencyResolver, oldModule, oldInstance); - } - - @Override - public void customValidation() { - // add custom validation form module attributes here. - } - - @Override - public AutoCloseable createInstance() { - final GenericResourceApiProvider provider = new GenericResourceApiProvider(getDataBrokerDependency() - , getNotificationPublishAdapterDependency() - , getRpcRegistryDependency()); - - return new AutoCloseable() { - - @Override - public void close() throws Exception { - provider.close(); - } - }; - } - - -} diff --git a/generic-resource-api/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/northbound/generic/resource/api/provider/impl/rev170824/GENERICRESOURCEAPIProviderModuleFactory.java b/generic-resource-api/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/northbound/generic/resource/api/provider/impl/rev170824/GENERICRESOURCEAPIProviderModuleFactory.java deleted file mode 100644 index ca96122d..00000000 --- a/generic-resource-api/provider/src/main/java/org/opendaylight/yang/gen/v1/org/onap/sdnc/northbound/generic/resource/api/provider/impl/rev170824/GENERICRESOURCEAPIProviderModuleFactory.java +++ /dev/null @@ -1,13 +0,0 @@ -/* -* Generated file -* -* Generated from: yang module name: GENERIC-RESOURCE-API-provider-impl yang module local name: GENERIC-RESOURCE-API-provider-impl -* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator -* Generated at: Tue Sep 05 14:01:41 EDT 2017 -* -* Do not modify this file unless it is present under src/main directory -*/ -package org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.api.provider.impl.rev170824; -public class GENERICRESOURCEAPIProviderModuleFactory extends AbstractGENERICRESOURCEAPIProviderModuleFactory { - -} diff --git a/generic-resource-api/provider/src/main/resources/initial/generic-resource-api-provider.xml b/generic-resource-api/provider/src/main/resources/initial/generic-resource-api-provider.xml deleted file mode 100644 index a9d3e639..00000000 --- a/generic-resource-api/provider/src/main/resources/initial/generic-resource-api-provider.xml +++ /dev/null @@ -1,51 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- vi: set et smarttab sw=4 tabstop=4: --> -<snapshot> - <configuration> - <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"> - <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config"> - <module> - - <!-- This xmlns:prefix should match the namespace in the *-provider-impl.yang file - The prefix: inside type should match the prefix of the yang file. --> - <type xmlns:prefix="org:onap:sdnc:northbound:GENERIC-RESOURCE-API:provider:impl"> - prefix:GENERIC-RESOURCE-API-provider-impl - </type> - <name>GENERIC-RESOURCE-API-provider-impl</name> - - <!-- The following sections contain bindings to services defined in the - *-provider-impl yang file. For example the rpc-registry is required - because we have a dependency (or augmentation) named "rpc-registry" - and which binds to the md-sa-binding-registry. If you remove those - dependencies from the yang file then you can remove them from here. --> - <rpc-registry> - <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type> - <name>binding-rpc-broker</name> - </rpc-registry> - - <data-broker> - <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-async-data-broker</type> - <name>binding-data-broker</name> - </data-broker> - - <notification-service> - <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl"> - binding:binding-new-notification-publish-service - </type> - <name>binding-notification-broker</name> - </notification-service> - </module> - - </modules> - </data> - - </configuration> - - <!-- Required capabilities are basically a listing of all modules that need to be imported before - our service can be resolved. Capabilities for dependencies defined above are implied which is - why we do not have define a required capability for the data broker, for example. --> - <required-capabilities> - <capability>org:onap:sdnc:northbound:GENERIC-RESOURCE-API:provider:impl?module=GENERIC-RESOURCE-API-provider-impl&revision=2017-08-24</capability> - </required-capabilities> - -</snapshot> diff --git a/generic-resource-api/provider/src/main/resources/org/opendaylight/blueprint/generic-resource-api-blueprint.xml b/generic-resource-api/provider/src/main/resources/org/opendaylight/blueprint/generic-resource-api-blueprint.xml new file mode 100644 index 00000000..80d35574 --- /dev/null +++ b/generic-resource-api/provider/src/main/resources/org/opendaylight/blueprint/generic-resource-api-blueprint.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" + xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0" + odl:use-default-for-reference-types="true"> + + <reference id="svcLogicService" + interface="org.onap.ccsdk.sli.core.sli.provider.SvcLogicService" /> + + <bean id="client" class="org.onap.sdnc.northbound.GenericResourceApiSvcLogicServiceClient"> + <argument ref="svcLogicService" /> + </bean> + + <reference id="dataBroker" + interface="org.opendaylight.controller.md.sal.binding.api.DataBroker" + odl:type="default" /> + + <reference id="notificationService" + interface="org.opendaylight.controller.md.sal.binding.api.NotificationPublishService" + odl:type="default" /> + + <reference id="rpcRegistry" + interface="org.opendaylight.controller.sal.binding.api.RpcProviderRegistry" + odl:type="default" /> + + <bean id="provider" class="org.onap.sdnc.northbound.GenericResourceApiProvider"> + <argument ref="dataBroker" /> + <argument ref="notificationService" /> + <argument ref="rpcRegistry" /> + <argument ref="client" /> + </bean> + + <odl:rpc-implementation ref="provider"/> + +</blueprint>
\ No newline at end of file diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java index dd1523d0..939ada80 100644 --- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java +++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/TestGenericResourceApi.java @@ -57,9 +57,9 @@ public class TestGenericResourceApi extends AbstractConcurrentDataBrokerTest { DataBroker dataBroker = getDataBroker(); NotificationPublishService mockNotification = mock(NotificationPublishService.class); RpcProviderRegistry mockRpcRegistry = mock(RpcProviderRegistry.class); - + GenericResourceApiSvcLogicServiceClient client = mock(GenericResourceApiSvcLogicServiceClient.class); try { - genericResourceApiProvider = new GenericResourceApiProvider(dataBroker, mockNotification, mockRpcRegistry); + genericResourceApiProvider = new GenericResourceApiProvider(dataBroker, mockNotification, mockRpcRegistry, client); } catch (Exception e) { LOG.error("Caught exception on setUp", e); throw e; @@ -67,7 +67,7 @@ public class TestGenericResourceApi extends AbstractConcurrentDataBrokerTest { } } - @Test(expected = NullPointerException.class) + @Test public void testServiceTopologyOperation() { ServiceTopologyOperationInputBuilder inputBuilder = new ServiceTopologyOperationInputBuilder(); |