diff options
author | MD IRSHAD SHEIKH <md.irshad.sheikh@huawei.com> | 2021-04-01 23:05:39 +0530 |
---|---|---|
committer | MD IRSHAD SHEIKH <md.irshad.sheikh@huawei.com> | 2021-04-01 23:08:08 +0530 |
commit | cfa8b96c1b28a7dc4f846bb74dc68d036ec431cb (patch) | |
tree | 35f3f6265926bac5e10f54221c224330ab4e2075 /plans/so/integration-etsi-testing | |
parent | 7b4a3af0a9e4a0046b303e532640bc3e4a3420e5 (diff) |
Update docker-compose for Macroflow with HEAT and small refactoring
Issue-ID: SO-3533
Signed-off-by: MD IRSHAD SHEIKH <md.irshad.sheikh@huawei.com>
Change-Id: Ic1d0f2b836ac4988fb1d8816542bce35aace3a37
Diffstat (limited to 'plans/so/integration-etsi-testing')
27 files changed, 756 insertions, 528 deletions
diff --git a/plans/so/integration-etsi-testing/config/apply-workarounds.sh b/plans/so/integration-etsi-testing/config/apply-workarounds.sh index 21a3aeb8..4ecf880f 100755 --- a/plans/so/integration-etsi-testing/config/apply-workarounds.sh +++ b/plans/so/integration-etsi-testing/config/apply-workarounds.sh @@ -109,6 +109,8 @@ mysql -h $DB_HOST -uroot -p$MYSQL_ROOT_PASSWORD $CATALOG_DB << EOF UPDATE orchestration_status_state_transition_directive SET FLOW_DIRECTIVE='CONTINUE' WHERE RESOURCE_TYPE='VNF' AND ORCHESTRATION_STATUS='CREATED' AND TARGET_ACTION='ACTIVATE' AND FLOW_DIRECTIVE='FAIL'; + insert into cloud_sites(ID, REGION_ID, IDENTITY_SERVICE_ID, CLOUD_VERSION, CLLI, ORCHESTRATOR) values("EtsiCloudRegion", "EtsiCloudRegion", "DEFAULT_KEYSTONE", "2.5", "clli2", "multicloud"); + COMMIT; EOF diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java index 27a0e79d..22209fc8 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/controller/GenericVnfsController.java @@ -241,9 +241,8 @@ public class GenericVnfsController { return getRequestErrorResponseEntity(request, VF_MODULE); } - - - + + @PutMapping(value = "/generic-vnf/{vnf-id}/vf-modules/vf-module/{vf-module-id}", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ResponseEntity<?> putVfModule(@RequestBody final VfModule vfModule, diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java index 0ee2d00c..5570381b 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProvider.java @@ -24,8 +24,6 @@ import java.util.Optional; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.VfModule; -import org.onap.aai.domain.yang.VfModules; -import org.onap.aai.domain.yang.v10.VolumeGroup; import org.springframework.http.HttpHeaders; /** @@ -52,9 +50,9 @@ public interface GenericVnfCacheServiceProvider extends Clearable { boolean deleteGenericVnf(final String vnfId, final String resourceVersion); - void putVfModule(String vnfId, String vfModuleId, VfModule vfModule); + void putVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule); - Optional<VfModule> getVfModule(final String vnfId, final String vfModuleId); + Optional<VfModule> getVfModule(final String vnfId, final String vfModuleId); - boolean patchVfModule(String vnfId, String vfModuleId, VfModule vfModule); + boolean patchVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule); } diff --git a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java index 5a0423b5..24544a6c 100644 --- a/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/aai-simulator/src/main/java/org/onap/so/aaisimulator/service/providers/GenericVnfCacheServiceProviderImpl.java @@ -24,7 +24,6 @@ import static org.onap.so.aaisimulator.utils.Constants.COMPOSED_OF; import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF; import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_ID; import static org.onap.so.aaisimulator.utils.Constants.GENERIC_VNF_VNF_NAME; -import static org.onap.so.aaisimulator.utils.Constants.X_HTTP_METHOD_OVERRIDE; import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getBiDirectionalRelationShipListRelatedLink; import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getRelationShipListRelatedLink; import static org.onap.so.aaisimulator.utils.HttpServiceUtils.getTargetUrl; @@ -39,9 +38,7 @@ import org.onap.aai.domain.yang.Relationship; import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.VfModule; -import org.onap.aai.domain.yang.v10.VfModules; -import org.onap.aai.domain.yang.VolumeGroup; -import org.onap.aai.domain.yang.v10.VolumeGroups; +import org.onap.aai.domain.yang.VfModules; import org.onap.so.aaisimulator.utils.ShallowBeanCopy; import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider; import org.slf4j.Logger; @@ -63,7 +60,6 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv private static final Logger LOGGER = LoggerFactory.getLogger(GenericVnfCacheServiceProviderImpl.class); private final HttpRestServiceProvider httpRestServiceProvider; - final org.onap.aai.domain.yang.VfModules vfModules = new org.onap.aai.domain.yang.VfModules(); @Autowired public GenericVnfCacheServiceProviderImpl(final CacheManager cacheManager, @@ -261,55 +257,58 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv clearCache(GENERIC_VNF_CACHE.getName()); } - @Override - public Optional<org.onap.aai.domain.yang.VfModule> getVfModule(final String vnfId, final String vfModuleId) { - LOGGER.info("Getting vfModule from cache for vnfId: {} and vfModuleId: {}", - vnfId, vfModuleId); - final Cache cache = getCache(GENERIC_VNF_CACHE.getName()); - final GenericVnf value = cache.get(vnfId, GenericVnf.class); + @Override + public Optional<VfModule> getVfModule(final String vnfId, final String vfModuleId) { LOGGER.info("Getting vfModule from cache for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId); - if (value.getVfModules() != null) { - for (int i=0; i<value.getVfModules().getVfModule().size(); i++) - { - if(value.getVfModules().getVfModule().get(i).getVfModuleId().equalsIgnoreCase(vfModuleId)){ - return Optional.of(value.getVfModules().getVfModule().get(i)); + final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId); + final GenericVnf value = genericVnfOptional.get(); + final VfModules vfmodules = value.getVfModules(); + if (vfmodules != null) { + for (VfModule vfModule : vfmodules.getVfModule()) { + if (vfModule.getVfModuleId().equalsIgnoreCase(vfModuleId)){ + return Optional.of(vfModule); } } } - return Optional.empty(); - } + return Optional.empty(); + } + - @Override - public void putVfModule(String vnfId, String vfModuleId, VfModule vfModule) { - LOGGER.info("Adding vfModule from cache for vnfId: {} and vfModuleId: {}", + @Override + public void putVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule) { + LOGGER.info("Adding vfModule for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId); final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId); final Cache cache = getCache(GENERIC_VNF_CACHE.getName()); if (genericVnfOptional.isPresent()) { final GenericVnf genericVnf = genericVnfOptional.get(); + VfModules vfModules = null; + if(genericVnf.getVfModules()==null){ + vfModules = new VfModules(); + genericVnf.setVfModules(vfModules); + } else { + vfModules = genericVnf.getVfModules(); + } vfModules.getVfModule().add(vfModule); - genericVnf.setVfModules(vfModules); cache.put(vfModuleId, vfModule); } - } + } - @Override - public boolean patchVfModule(String vnfId, String vfModuleId, VfModule vfModule) { - final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId); + @Override + public boolean patchVfModule(final String vnfId, final String vfModuleId, final VfModule vfModule) { + final Optional<GenericVnf> genericVnfOptional = getGenericVnf(vnfId); LOGGER.info("Create vfModule for vnfId: {} and vfModuleId: {}", vnfId, vfModuleId); if (genericVnfOptional.isPresent()) { - final GenericVnf cachedGenericVnf = genericVnfOptional.get(); + final GenericVnf cachedGenericVnf = genericVnfOptional.get(); + final VfModules vfmodules = cachedGenericVnf.getVfModules(); LOGGER.info("vfModuleId is Matched"); try { - for (int i=0; i<cachedGenericVnf.getVfModules().getVfModule().size(); i++) - { - if(cachedGenericVnf.getVfModules().getVfModule().get(i).getVfModuleId().equalsIgnoreCase(vfModuleId)){ - cachedGenericVnf.getVfModules().getVfModule().get(i).setOrchestrationStatus(vfModule.getOrchestrationStatus()); - } - } + vfmodules.getVfModule().stream().filter(tempVfModule -> + tempVfModule.getVfModuleId().equalsIgnoreCase(vfModuleId)).forEach(tempVfModule -> + tempVfModule.setOrchestrationStatus(vfModule.getOrchestrationStatus())); return true; } catch (final Exception exception) { LOGGER.error("Unable to update VfModule for vfModuleId: {}", vfModule, exception); @@ -317,5 +316,5 @@ public class GenericVnfCacheServiceProviderImpl extends AbstractCacheServiceProv } LOGGER.error("Unable to find VfModule ..."); return false; - } + } }
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/pom.xml b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/pom.xml index 926ea140..80e21746 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/pom.xml +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/pom.xml @@ -1,74 +1,67 @@ <?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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>org.onap.so.simulators</groupId> - <artifactId>so-simulators</artifactId> - <version>1.0-SNAPSHOT</version> - </parent> - <artifactId>multicloud-simulator</artifactId> - <name>${project.artifactId}</name> - <description>Demo project for Spring Boot</description> - <properties> - <java.version>11</java.version> - </properties> - <dependencies> - <dependency> +<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 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.onap.so.simulators</groupId> + <artifactId>so-simulators</artifactId> + <version>1.0-SNAPSHOT</version> + </parent> + <artifactId>multicloud-simulator</artifactId> + <name>${project.artifactId}</name> + <description>MultiCloud Simulator</description> + <properties> + <java.version>11</java.version> + <json-simple.version>1.1</json-simple.version> + <openstack4j.version>3.2.0</openstack4j.version> + <openstack4j-httpclient.version>3.2.0</openstack4j-httpclient.version> + <mso-adapters.version>1.7.1-SNAPSHOT</mso-adapters.version> + <spring-security.version>2.1.1.RELEASE</spring-security.version> + </properties> + <dependencies> + <dependency> <groupId>${project.parent.groupId}</groupId> <artifactId>common</artifactId> <version>${project.version}</version> </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter</artifactId> - </dependency> - - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-test</artifactId> - <scope>test</scope> - </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-security</artifactId> - <exclusions> - <exclusion> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-tomcat</artifactId> - </exclusion> - </exclusions> - </dependency> - <dependency> - <groupId>com.googlecode.json-simple</groupId> - <artifactId>json-simple</artifactId> - <version>1.1</version> - </dependency> - - <dependency> - <groupId>org.pacesys</groupId> - <artifactId>openstack4j-core</artifactId> - <version>3.2.0</version> - </dependency> - <dependency> - <groupId>org.pacesys.openstack4j.connectors</groupId> - <artifactId>openstack4j-httpclient</artifactId> - <version>3.2.0</version> - </dependency> - <dependency> - <groupId>org.onap.so.adapters</groupId> - <artifactId>mso-adapters-rest-interface</artifactId> - <version>1.7.1-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>org.springframework.security.oauth.boot</groupId> - <artifactId>spring-security-oauth2-autoconfigure</artifactId> - <version>2.1.1.RELEASE</version> - </dependency> - </dependencies> - - <build> - <plugins> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + <exclusions> + <exclusion> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-tomcat</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.googlecode.json-simple</groupId> + <artifactId>json-simple</artifactId> + <version>${json-simple.version}</version> + </dependency> + <dependency> + <groupId>org.onap.so.adapters</groupId> + <artifactId>mso-adapters-rest-interface</artifactId> + <version>${mso-adapters.version}</version> + </dependency> + <dependency> + <groupId>org.springframework.security.oauth.boot</groupId> + <artifactId>spring-security-oauth2-autoconfigure</artifactId> + <version>${spring-security.version}</version> + </dependency> + </dependencies> + <build> + <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> @@ -83,11 +76,11 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-maven-plugin</artifactId> - </plugin> - </plugins> - </build> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + </plugin> + </plugins> + </build> -</project> +</project>
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplication.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplication.java index 949cd9ba..479c4810 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplication.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplication.java @@ -1,13 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.multicloudsimulator; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -@SpringBootApplication(scanBasePackages = {"org.onap"}) +/** + * @author Md Irshad Sheikh (md.irshad.sheikh@huawei.com) + * + */ +@SpringBootApplication(scanBasePackages = { "org.onap" }) public class MultiCloudSimulatorApplication { - public static void main(String[] args) { - SpringApplication.run(MultiCloudSimulatorApplication.class, args); - } + public static void main(String[] args) { + SpringApplication.run(MultiCloudSimulatorApplication.class, args); -} + } + +}
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceNameOutput.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceNameOutput.java new file mode 100644 index 00000000..1bf902a2 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceNameOutput.java @@ -0,0 +1,77 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.so.multicloudsimulator.beans; + +import com.fasterxml.jackson.databind.JsonNode; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.io.InputStream; + +@Component +@PropertySource(value = "data/InstanceNameOutput.json") +@ConfigurationProperties +public class InstanceNameOutput { + private String template_type; + private String workload_id; + private String workload_status; + public JsonNode workload_status_reason; + + public String getTemplate_type() { + return template_type; + } + + public void setTemplate_type(final String template_type) { + this.template_type = template_type; + } + + public String getWorkload_id() { + return workload_id; + } + + public void setWorkload_id(final String workload_id) { + this.workload_id = workload_id; + } + + public String getWorkload_status() { + return workload_status; + } + + public void setWorkload_status(final String workload_status) { + this.workload_status = workload_status; + } + + public JsonNode getWorkload_status_reason() { + return workload_status_reason; + } + + public void setWorkload_status_reason(final JsonNode workload_status_reason) { + this.workload_status_reason = workload_status_reason; + } + + public final static InputStream getFile(final String file) throws IOException { + return new ClassPathResource(file).getInputStream(); + } + + public final static InputStream getInstanceName() throws Exception, IOException { + return getFile("data/InstanceNameOutput.json"); + } +} diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceOutput.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceOutput.java new file mode 100644 index 00000000..2cb1fcac --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceOutput.java @@ -0,0 +1,79 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.multicloudsimulator.beans; + +import com.fasterxml.jackson.databind.JsonNode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; +import org.springframework.core.io.ClassPathResource; +import org.springframework.stereotype.Component; +import java.io.IOException; +import java.io.InputStream; + +@Component +@PropertySource(value = "data/InstanceOutput.json") +@ConfigurationProperties +public class InstanceOutput { + private static final Logger LOGGER = LoggerFactory.getLogger(InstanceOutput.class); + private String template_type; + private String workload_id; + private String workload_status; + public JsonNode workload_status_reason; + + public JsonNode getWorkload_status_reason() { + return workload_status_reason; + } + + public void setWorkload_status_reason(final JsonNode workload_status_reason) { + this.workload_status_reason = workload_status_reason; + } + + public String getTemplate_type() { + return template_type; + } + + public void setTemplate_type(final String template_type) { + this.template_type = template_type; + } + + public String getWorkload_id() { + return workload_id; + } + + public void setWorkload_id(final String workload_id) { + this.workload_id = workload_id; + } + + public String getWorkload_status() { + return workload_status; + } + + public void setWorkload_status(final String workload_status) { + this.workload_status = workload_status; + } + + public static InputStream getFile(final String file) throws IOException { + return new ClassPathResource(file).getInputStream(); + } + + public static InputStream getInstance() throws Exception, IOException { + return getFile("data/InstanceOutput.json"); + } +} diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceResponse.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceResponse.java index e8f9e125..c8a58210 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceResponse.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/InstanceResponse.java @@ -1,9 +1,6 @@ - /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,14 +19,13 @@ package org.onap.so.multicloudsimulator.beans; import java.util.List; - import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"id", "request", "namespace", "resources"}) +@JsonPropertyOrder({ "id", "request", "namespace", "resources" }) @JsonIgnoreProperties(value = "true") public class InstanceResponse extends Response { @@ -42,51 +38,43 @@ public class InstanceResponse extends Response { @JsonProperty("resources") private List<Resource> resources = null; - public InstanceResponse(String errorMsg) { + public InstanceResponse(final String errorMsg) { super(errorMsg); } public InstanceResponse() { - super(""); - //new Response(""); - } - @JsonProperty("id") + super(""); + } + public String getId() { return id; } - @JsonProperty("id") - public void setId(String id) { + public void setId(final String id) { this.id = id; } - @JsonProperty("request") public MulticloudInstanceRequest getRequest() { return request; } - @JsonProperty("request") - public void setRequest(MulticloudInstanceRequest request) { + public void setRequest(final MulticloudInstanceRequest request) { this.request = request; } - @JsonProperty("namespace") public String getNamespace() { return namespace; } - @JsonProperty("namespace") - public void setNamespace(String namespace) { + public void setNamespace(final String namespace) { this.namespace = namespace; } - @JsonProperty("resources") public List<Resource> getResources() { return resources; } - @JsonProperty("resources") - public void setResources(List<Resource> resources) { + public void setResources(final List<Resource> resources) { this.resources = resources; } diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudCreateResponse.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudCreateResponse.java index f524aa97..0182fd55 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudCreateResponse.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudCreateResponse.java @@ -1,3 +1,20 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.multicloudsimulator.beans; import java.io.Serializable; @@ -11,7 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonIgnoreProperties(ignoreUnknown = true) -@JsonPropertyOrder({"template_type", "workload_id", "template_response", "workload_status_reason", "workload_status"}) +@JsonPropertyOrder({ "template_type", "workload_id", "template_response", "workload_status_reason", "workload_status" }) public class MulticloudCreateResponse implements Serializable { private static final long serialVersionUID = -5215028275577848311L; @@ -28,67 +45,57 @@ public class MulticloudCreateResponse implements Serializable { @JsonCreator public MulticloudCreateResponse(@JsonProperty("template_type") String templateType, - @JsonProperty("workload_id") String workloadId, - @JsonProperty("template_response") JsonNode templateResponse) { + @JsonProperty("workload_id") String workloadId, + @JsonProperty("template_response") JsonNode templateResponse) { this.templateType = templateType; this.workloadId = workloadId; this.templateResponse = templateResponse; } + public MulticloudCreateResponse() { } - @JsonProperty("template_type") public String getTemplateType() { return templateType; } - @JsonProperty("template_type") - public void setTemplateType(String templateType) { + public void setTemplateType(final String templateType) { this.templateType = templateType; } - @JsonProperty("workload_id") public String getWorkloadId() { return workloadId; } - @JsonProperty("workload_id") - public void setWorkloadId(String workloadId) { + public void setWorkloadId(final String workloadId) { this.workloadId = workloadId; } - @JsonProperty("template_response") - public void setTemplateResponse(JsonNode templateResponse) { + public void setTemplateResponse(final JsonNode templateResponse) { this.templateResponse = templateResponse; } - @JsonProperty("template_response") public JsonNode getTemplateResponse() { return templateResponse; } - @JsonProperty("workload_status_reason") - public void setWorkloadStatusReason(JsonNode workloadStatusReason) { + public void setWorkloadStatusReason(final JsonNode workloadStatusReason) { this.workloadStatusReason = workloadStatusReason; } - @JsonProperty("workload_status_reason") public JsonNode getWorkloadStatusReason() { return workloadStatusReason; } - @JsonProperty("workload_status") public String getWorkloadSstatus() { return workloadStatus; } - @JsonProperty("workload_status") - public void setWorkloadStatus(String workloadStatus) { + public void setWorkloadStatus(final String workloadStatus) { this.workloadStatus = workloadStatus; } - @Override public String toString() { return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId) diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudInstanceRequest.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudInstanceRequest.java index c88e7f15..b645b9bf 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudInstanceRequest.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudInstanceRequest.java @@ -1,3 +1,20 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.multicloudsimulator.beans; import java.util.Map; @@ -32,7 +49,7 @@ public class MulticloudInstanceRequest { return cloudRegion; } - public void setCloudRegion(String cloudRegion) { + public void setCloudRegion(final String cloudRegion) { this.cloudRegion = cloudRegion; } @@ -40,7 +57,7 @@ public class MulticloudInstanceRequest { return rbName; } - public void setRbName(String rbName) { + public void setRbName(final String rbName) { this.rbName = rbName; } @@ -48,7 +65,7 @@ public class MulticloudInstanceRequest { return rbVersion; } - public void setRbVersion(String rbVersion) { + public void setRbVersion(final String rbVersion) { this.rbVersion = rbVersion; } @@ -56,7 +73,7 @@ public class MulticloudInstanceRequest { return profileName; } - public void setProfileName(String profileName) { + public void setProfileName(final String profileName) { this.profileName = profileName; } @@ -80,7 +97,7 @@ public class MulticloudInstanceRequest { return vfModuleUuid; } - public void setVfModuleUuid(String vfModuleUuid) { + public void setVfModuleUuid(final String vfModuleUuid) { this.vfModuleUuid = vfModuleUuid; } diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudRequest.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudRequest.java index c2ec1910..baeebded 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudRequest.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/MulticloudRequest.java @@ -1,8 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2019 Intel Corp. All rights reserved. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,130 +27,119 @@ import com.fasterxml.jackson.databind.JsonNode; import com.woorea.openstack.heat.model.CreateStackParam; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"generic-vnf-id", "vf-module-id", "vf-module-model-invariant-id", "vf-module-model-version-id", +@JsonPropertyOrder({ "generic-vnf-id", "vf-module-id", "vf-module-model-invariant-id", "vf-module-model-version-id", "vf-module-model-customization-id", "oof_directives", "sdnc_directives", "user_directives", "template_type", - "template_data"}) + "template_data" }) public class MulticloudRequest implements Serializable { private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("generic-vnf-id") private String genericVnfId; + @JsonProperty("vf-module-id") private String vfModuleId; + @JsonProperty("vf-module-model-invariant-id") private String vfModuleModelInvariantId; + @JsonProperty("vf-module-model-version-id") private String vfModuleModelVersionId; + @JsonProperty("vf-module-model-customization-id") private String vfModuleModelCustomizationId; + @JsonProperty("oof_directives") private JsonNode oofDirectives; + @JsonProperty("sdnc_directives") private JsonNode sdncDirectives; + @JsonProperty("user_directives") private JsonNode userDirectives; + @JsonProperty("template_type") private String templateType; + @JsonProperty("template_data") private CreateStackParam templateData; - - @JsonProperty("generic-vnf-id") public String getGenericVnfId() { return genericVnfId; } - @JsonProperty("generic-vnf-id") - public void setGenericVnfId(String genericVnfId) { + public void setGenericVnfId(final String genericVnfId) { this.genericVnfId = genericVnfId; } - @JsonProperty("vf-module-id") public String getVfModuleId() { return vfModuleId; } - @JsonProperty("vf-module-id") - public void setVfModuleId(String vfModuleId) { + public void setVfModuleId(final String vfModuleId) { this.vfModuleId = vfModuleId; } - @JsonProperty("vf-module-model-invariant-id") public String getVfModuleModelInvariantId() { return vfModuleModelInvariantId; } - @JsonProperty("vf-module-model-invariant-id") - public void setVfModuleModelInvariantId(String vfModuleModelInvariantId) { + public void setVfModuleModelInvariantId(final String vfModuleModelInvariantId) { this.vfModuleModelInvariantId = vfModuleModelInvariantId; } - @JsonProperty("vf-module-model-version-id") public String getVfModuleModelVersionId() { return vfModuleModelVersionId; } - @JsonProperty("vf-module-model-version-id") - public void setVfModuleModelVersionId(String vfModuleModelVersionId) { + public void setVfModuleModelVersionId(final String vfModuleModelVersionId) { this.vfModuleModelVersionId = vfModuleModelVersionId; } - @JsonProperty("vf-module-model-customization-id") public String getVfModuleModelCustomizationId() { return vfModuleModelCustomizationId; } @JsonProperty("vf-module-model-customization-id") - public void setVfModuleModelCustomizationId(String vfModuleModelCustomizationId) { + public void setVfModuleModelCustomizationId(final String vfModuleModelCustomizationId) { this.vfModuleModelCustomizationId = vfModuleModelCustomizationId; } - @JsonProperty("oof_directives") public JsonNode getOofDirectives() { return oofDirectives; } - @JsonProperty("oof_directives") - public void setOofDirectives(JsonNode oofDirectives) { + public void setOofDirectives(final JsonNode oofDirectives) { this.oofDirectives = oofDirectives; } - @JsonProperty("sdnc_directives") public JsonNode getSdncDirectives() { return sdncDirectives; } - @JsonProperty("sdnc_directives") - public void setSdncDirectives(JsonNode sdncDirectives) { + public void setSdncDirectives(final JsonNode sdncDirectives) { this.sdncDirectives = sdncDirectives; } - @JsonProperty("user_directives") public JsonNode getUserDirectives() { return userDirectives; } - @JsonProperty("user_directives") - public void setUserDirectives(JsonNode userDirectives) { + public void setUserDirectives(final JsonNode userDirectives) { this.userDirectives = userDirectives; } - @JsonProperty("template_type") public String getTemplateType() { return templateType; } - @JsonProperty("template_type") - public void setTemplateType(String templateType) { + public void setTemplateType(final String templateType) { this.templateType = templateType; } - @JsonProperty("template_data") public CreateStackParam getTemplateData() { return templateData; } - @JsonProperty("template_data") public void setTemplateData(CreateStackParam templateData) { this.templateData = templateData; } diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Resource.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Resource.java index 368ab6d7..666cbe03 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Resource.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Resource.java @@ -1,15 +1,13 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * 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. @@ -17,7 +15,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.so.multicloudsimulator.beans; import com.fasterxml.jackson.annotation.JsonInclude; @@ -25,11 +22,12 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"resource-type", "resource-link"}) +@JsonPropertyOrder({ "resource-type", "resource-link" }) public class Resource { @JsonProperty("resource-type") private String resourceType; + @JsonProperty("resource-link") private String resourceLink; @@ -38,20 +36,16 @@ public class Resource { return resourceType; } - @JsonProperty("resource-type") - public void setResourceType(String resourceType) { + public void setResourceType(final String resourceType) { this.resourceType = resourceType; } - @JsonProperty("resource-link") public String getResourceLink() { return resourceLink; } - //@JsonProperty("resource-link") - public void setResourceLink(String resourceLink) { + public void setResourceLink(final String resourceLink) { this.resourceLink = resourceLink; } } - diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Response.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Response.java index 77a6150c..8f0713ea 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Response.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/beans/Response.java @@ -1,8 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2020 Huawei Technologies Co., Ltd. All rights reserved. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,10 +22,10 @@ public class Response { private String errorMsg; - public Response(String errorMsg) { + public Response(final String errorMsg) { this.errorMsg = errorMsg; } - + public Response() { } @@ -35,7 +33,7 @@ public class Response { return errorMsg; } - public void setErrorMsg(String errorMsg) { + public void setErrorMsg(final String errorMsg) { this.errorMsg = errorMsg; } diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configration/ApplicationConfigration.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configuration/ApplicationConfiguration.java index 34015ea1..365710e3 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configration/ApplicationConfigration.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configuration/ApplicationConfiguration.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,13 +13,11 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.multicloudsimulator.configration; +package org.onap.so.multicloudsimulator.configuration; -import static org.onap.so.multicloudsimulator.utils.Constants.SERVICE_TOPOLOGY_OPERATION_CACHE; +import static org.onap.so.multicloudsimulator.utils.Constants.MULTICLOUD_CACHE; import java.util.Arrays; import org.springframework.cache.Cache; import org.springframework.cache.CacheManager; @@ -28,17 +26,13 @@ import org.springframework.cache.support.SimpleCacheManager; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** - * @author Waqas Ikram (waqas.ikram@est.tech) - * - */ @Configuration -public class ApplicationConfigration { +public class ApplicationConfiguration { @Bean public CacheManager cacheManager() { final SimpleCacheManager manager = new SimpleCacheManager(); - manager.setCaches(Arrays.asList(getCache(SERVICE_TOPOLOGY_OPERATION_CACHE))); + manager.setCaches(Arrays.asList(getCache(MULTICLOUD_CACHE))); return manager; } diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configration/WebSecurityConfigImpl.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configuration/WebSecurityConfigImpl.java index a0c1f755..b1d0984a 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configration/WebSecurityConfigImpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/configuration/WebSecurityConfigImpl.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,11 +13,9 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ -package org.onap.so.multicloudsimulator.configration; +package org.onap.so.multicloudsimulator.configuration; import static org.onap.so.multicloudsimulator.utils.Constants.OPERATIONS_URL; import org.onap.so.simulator.configuration.SimulatorSecurityConfigurer; @@ -27,10 +25,6 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; -/** - * @author waqas.ikram@ericsson.com - * - */ @Configuration @EnableWebSecurity public class WebSecurityConfigImpl extends SimulatorSecurityConfigurer { diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/controller/MultiCloudController.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/controller/MultiCloudController.java index b0e13362..c99e246e 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/controller/MultiCloudController.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/controller/MultiCloudController.java @@ -1,171 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.multicloudsimulator.controller; import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MediaType; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.onap.so.multicloudsimulator.beans.InstanceResponse; -import org.onap.so.multicloudsimulator.beans.MulticloudInstanceRequest; +import org.apache.commons.io.IOUtils; +import org.onap.so.multicloudsimulator.beans.InstanceOutput; import org.onap.so.multicloudsimulator.beans.MulticloudCreateResponse; +import org.onap.so.multicloudsimulator.beans.MulticloudInstanceRequest; +import org.onap.so.multicloudsimulator.beans.InstanceResponse; +import org.onap.so.multicloudsimulator.beans.InstanceNameOutput; import org.onap.so.multicloudsimulator.beans.MulticloudRequest; -import org.onap.so.openstack.beans.HeatStatus; import org.springframework.http.ResponseEntity; - -import org.springframework.web.bind.annotation.*; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestHeader; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; import java.io.IOException; -import java.net.URI; +import java.io.InputStream; import static org.onap.so.multicloudsimulator.utils.Constants.BASE_URL; + @RestController @RequestMapping(path = BASE_URL) public class MultiCloudController { - public static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override"; - private static final Logger LOGGER = LoggerFactory.getLogger(MultiCloudController.class); - public MulticloudCreateResponse multicloudCreateResponse = new MulticloudCreateResponse(); - - @PostMapping(value="/v1/instance") - public ResponseEntity<?> createInstance(@RequestBody MulticloudInstanceRequest req){ - System.out.println("MultiCloud createInstance "); - InstanceResponse InstanceResponse = new InstanceResponse(); - - return ResponseEntity.ok(InstanceResponse); - } - - @GetMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload", produces = { - MediaType.APPLICATION_JSON }) - public ResponseEntity<?> getInstance( - @PathVariable("cloud-owner") String cloudOwner, @PathVariable("cloud-region-id") String cloudRegionId, - @RequestParam(value = "depth", required = false, defaultValue = "0") Integer depth, - @RequestParam(name = "format", required = false) final String name, final HttpServletRequest request) throws IOException { - - LOGGER.info("found CloudOwner {} in cache", cloudOwner); - LOGGER.info("found cloudRegionId {} in cache", cloudRegionId); - LOGGER.info("found name {} in cache", name); - JSONObject json = new JSONObject(); - - json.put("template_type", "heat"); - json.put("workload_id", ""); - json.put("workload_status", "GET_COMPLETE"); - JSONObject workload = new JSONObject(); - workload.put("stacks", HeatStatus.NOTFOUND); - json.put("workload_status_reason", workload); - - return ResponseEntity.ok(json); - } - - @PostMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload", - consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, - produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> postCreateInstance( - @RequestBody final MulticloudRequest inputRequest, @PathVariable("cloud-owner") final String cloudOwner, - @PathVariable("cloud-region-id") final String cloudRegionId, - @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride, - final HttpServletRequest request) throws IOException { - - LOGGER.info("input request {}: ",inputRequest.toString()); - String input = "{\n" + - " \"template_type\": \"heat\",\n" + - " \"workload_id\": \"sad_sammet\",\n" + - " \"template_response\": [\n" + - " {\n" + - " \"GVK\": {\n" + - " \"Group\": \"k8s.plugin.opnfv.org\",\n" + - " \"Version\": \"v1alpha1\",\n" + - " \"Kind\": \"Network\"\n" + - " },\n" + - " \"Name\": \"k8s-region-2-onap-nf-20210120t221126760z-management-network\"\n" + - " },\n" + - " {\n" + - " \"GVK\": {\n" + - " \"Group\": \"k8s.plugin.opnfv.org\",\n" + - " \"Version\": \"v1alpha1\",\n" + - " \"Kind\": \"Network\"\n" + - " },\n" + - " \"Name\": \"k8s-region-2-onap-nf-20210120t221126760z-protected-network\"\n" + - " },\n" + - " {\n" + - " \"GVK\": {\n" + - " \"Group\": \"k8s.plugin.opnfv.org\",\n" + - " \"Version\": \"v1alpha1\",\n" + - " \"Kind\": \"Network\"\n" + - " },\n" + - " \"Name\": \"k8s-region-2-onap-nf-20210120t221126760z-unprotected-network\"\n" + - " },\n" + - " {\n" + - " \"GVK\": {\n" + - " \"Group\": \"k8s.cni.cncf.io\",\n" + - " \"Version\": \"v1\",\n" + - " \"Kind\": \"NetworkAttachmentDefinition\"\n" + - " },\n" + - " \"Name\": \"k8s-region-2-onap-nf-20210120t221126760z-ovn-nat\"\n" + - " }\n" + - " ],\n" + - " \"workload_status\": \"CREATE_COMPLETE\",\n" + - " \"workload_status_reason\": \"test\"\n" + - "}"; - - ObjectMapper objectMapper = new ObjectMapper(); - JSONObject workload = new JSONObject(); - - workload.put("stack",true); - - JsonNode jsonNode = objectMapper.readTree(workload.toJSONString()); - MulticloudCreateResponse multiResponse = objectMapper.readValue(input, MulticloudCreateResponse.class); - multiResponse.setWorkloadStatusReason(null); - - LOGGER.info("workload reason: {}",multiResponse.getWorkloadStatusReason()); - multiResponse.setWorkloadId("sad_sammet"); - multiResponse.setTemplateType("heat"); - multiResponse.setWorkloadStatus("CREATE_COMPLETE"); - - return ResponseEntity.status(201).body(multiResponse); - } - - @GetMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload/{workload-id}", produces = { - MediaType.APPLICATION_JSON }) - public ResponseEntity<?> getInstanceName( - @PathVariable("cloud-owner") String cloudOwner, @PathVariable("cloud-region-id") String cloudRegionId, - @PathVariable("workload-id") String workloadId, - @RequestParam(value = "depth", required = false, defaultValue = "0") Integer depth, - @RequestParam(name = "format", required = false) final String name, final HttpServletRequest request) throws IOException { - - LOGGER.info("Calling getInstanceName"); - LOGGER.info("found CloudOwner {} in cache", cloudOwner); - LOGGER.info("found cloudRegionId {} in cache", cloudRegionId); - LOGGER.info("found name {} in cache", name); - JSONObject json = new JSONObject(); - - json.put("template_type", "heat"); - json.put("workload_id", "sad_sammet"); - json.put("workload_status", "CREATE_COMPLETE"); - JSONObject workload = new JSONObject(); - workload.put("stacks", true); - json.put("workload_status_reason", null); - - return ResponseEntity.ok(json); - } - - @PostMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload/{workload-id}", - consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, - produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) - public ResponseEntity<?> postCreateInstanceName( - @RequestBody final MulticloudRequest inputRequest, @PathVariable("cloud-owner") final String cloudOwner, - @PathVariable("workload-id") String workloadId, - @PathVariable("cloud-region-id") final String cloudRegionId, - @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride, - final HttpServletRequest request) throws IOException { - - LOGGER.info("Calling postCreateInstanceName"); - - return ResponseEntity.status(405).build(); - } -} + public static final String X_HTTP_METHOD_OVERRIDE = "X-HTTP-Method-Override"; + private static final Logger LOGGER = LoggerFactory.getLogger(MultiCloudController.class); + + @PostMapping(value = "/v1/instance") + public ResponseEntity<?> createInstance(@RequestBody MulticloudInstanceRequest req) { + System.out.println("MultiCloud createInstance "); + final InstanceResponse InstanceResponse = new InstanceResponse(); + + LOGGER.info("Calling createInstance"); + return ResponseEntity.ok(InstanceResponse); + } + + @GetMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload", produces = { MediaType.APPLICATION_JSON }) + public ResponseEntity<?> getInstance(@PathVariable("cloud-owner") String cloudOwner, + @PathVariable("cloud-region-id") String cloudRegionId, + @RequestParam(value = "depth", required = false, defaultValue = "0") Integer depth, + @RequestParam(name = "format", required = false) final String name, final HttpServletRequest request) + throws Exception { + + LOGGER.info("found CloudOwner {}", cloudOwner); + LOGGER.info("found cloudRegionId {}", cloudRegionId); + LOGGER.info("found name {}", name); + final InputStream instanceOutput = InstanceOutput.getInstance(); + final String output = IOUtils.toString(instanceOutput, "utf-8"); + + return ResponseEntity.ok(output); + } + + @PostMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload", consumes = { MediaType.APPLICATION_JSON, + MediaType.APPLICATION_XML }, produces = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public ResponseEntity<?> postCreateInstance(@RequestBody final MulticloudCreateResponse inputRequest, + @PathVariable("cloud-owner") final String cloudOwner, + @PathVariable("cloud-region-id") final String cloudRegionId, + @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride, + final HttpServletRequest request) throws IOException { + + LOGGER.info("Calling postCreateInstance"); + inputRequest.setWorkloadStatusReason(null); + + inputRequest.setWorkloadId("sad_sammet"); + inputRequest.setTemplateType("heat"); + inputRequest.setWorkloadStatus("CREATE_COMPLETE"); + + return ResponseEntity.status(201).body(inputRequest); + } + + @GetMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload/{workload-id}", produces = { + MediaType.APPLICATION_JSON }) + public ResponseEntity<?> getInstanceName(@PathVariable("cloud-owner") final String cloudOwner, + @PathVariable("cloud-region-id") final String cloudRegionId, @PathVariable("workload-id") final String workloadId, + @RequestParam(value = "depth", required = false, defaultValue = "0") final Integer depth, + @RequestParam(name = "format", required = false) final String name, final HttpServletRequest request) + throws Exception { + + LOGGER.info("Calling getInstanceName"); + LOGGER.info("found CloudOwner {}", cloudOwner); + LOGGER.info("found cloudRegionId {}", cloudRegionId); + LOGGER.info("found name {}", name); + final InputStream instanceNameOutput = InstanceNameOutput.getInstanceName(); + final String output = IOUtils.toString(instanceNameOutput, "utf-8"); + + return ResponseEntity.ok(output); + } + + @PostMapping(value = "/{cloud-owner}/{cloud-region-id}/infra_workload/{workload-id}", consumes = { + MediaType.APPLICATION_JSON, + MediaType.APPLICATION_XML }, produces = { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public ResponseEntity<?> postCreateInstanceName(@RequestBody final MulticloudRequest inputRequest, + @PathVariable("cloud-owner") final String cloudOwner, @PathVariable("workload-id") String workloadId, + @PathVariable("cloud-region-id") final String cloudRegionId, + @RequestHeader(value = X_HTTP_METHOD_OVERRIDE, required = false) final String xHttpHeaderOverride, + final HttpServletRequest request) throws IOException { + + LOGGER.info("Calling postCreateInstanceName"); + + return ResponseEntity.status(405).build(); + } +}
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/utils/Constants.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/utils/Constants.java index 5f54f5da..e104d235 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/utils/Constants.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/java/org/onap/so/multicloudsimulator/utils/Constants.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright 2021 Huawei Technologies Co., Ltd. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -13,35 +13,18 @@ * 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. - * - * SPDX-License-Identifier: Apache-2.0 * ============LICENSE_END========================================================= */ package org.onap.so.multicloudsimulator.utils; -/** - * @author Waqas Ikram (waqas.ikram@est.tech) - * - */ public class Constants { public static final String BASE_URL = "/api/multicloud/v1"; public static final String OPERATIONS_URL = BASE_URL + "/operations"; - public static final String SERVICE_TOPOLOGY_OPERATION_CACHE = "service-topology-operation-cache"; - - public static final String HEALTHY = "healthy"; - - public static final String YES = "Y"; - - public static final String SERVICE_TOPOLOGY_OPERATION = "service-topology-operation"; - - public static final String RESTCONF_CONFIG_END_POINT = "restconf/config/GENERIC-RESOURCE-API:services/service/"; - - public static final String VNF_DATA_VNF_TOPOLOGY = "/vnf-data/vnf-topology/"; - - public static final String SERVICE_DATA_VNFS_VNF = "/service-data/vnfs/vnf/"; + public static final String MULTICLOUD_CACHE = "multicloud-cache"; - private Constants() {} + private Constants() { + } } diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.properties b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.properties index 8b137891..e507a12f 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.properties +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.properties @@ -1 +1 @@ - +security.ignored=/** diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.yaml b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.yaml index 7299ff92..393d1b7b 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.yaml +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/application.yaml @@ -7,11 +7,9 @@ spring: security: users: - username: mso - #password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U password: $2a$04$f8SB6cW/VI26QvYM6z.GXu7hlEmwnFtePenD8zF18mS3Atu3QNqr2 role: VID - username: admin - #password: Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U password: $2a$04$f8SB6cW/VI26QvYM6z.GXu7hlEmwnFtePenD8zF18mS3Atu3QNqr2 role: VID main: diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/data/InstanceNameOutput.json b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/data/InstanceNameOutput.json new file mode 100644 index 00000000..8c0e88f4 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/data/InstanceNameOutput.json @@ -0,0 +1,6 @@ +{ + "workload_status_reason": null, + "template_type": "heat", + "workload_id": "sad_sammet", + "workload_status": "CREATE_COMPLETE" +}
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/data/InstanceOutput.json b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/data/InstanceOutput.json new file mode 100644 index 00000000..e47ffb43 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/main/resources/data/InstanceOutput.json @@ -0,0 +1,8 @@ +{ + "workload_status_reason": { + "stacks": "NOTFOUND" + }, + "template_type": "heat", + "workload_id": "", + "workload_status": "GET_COMPLETE" +} diff --git a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/test/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplicationTests.java b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/test/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplicationTests.java index ccce88c9..d9b10d45 100644 --- a/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/test/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplicationTests.java +++ b/plans/so/integration-etsi-testing/so-simulators/multicloud-simulator/src/test/java/org/onap/so/multicloudsimulator/MultiCloudSimulatorApplicationTests.java @@ -1,13 +1,55 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ package org.onap.so.multicloudsimulator; import org.junit.Test; +import org.junit.runner.RunWith; +import org.onap.so.multicloudsimulator.utils.Constants; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -@SpringBootTest +import static org.junit.Assert.assertEquals; + +@RunWith(SpringJUnit4ClassRunner.class) +@ActiveProfiles("test") +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@Configuration class MultiCloudSimulatorApplicationTests { + @LocalServerPort + private int port; + + @Autowired + private TestRestTemplate restTemplate; + + @Test + public void test_createInstance() { + final String url = "http://localhost:" + port + Constants.BASE_URL + "/operations"; + + final ResponseEntity<String> object = restTemplate.getForEntity(url, String.class); + + assertEquals(Constants.OPERATIONS_URL, object.getBody()); - @Test - void contextLoads() { - } + } -} +}
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/ConfigController.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/ConfigController.java new file mode 100644 index 00000000..7282e051 --- /dev/null +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/ConfigController.java @@ -0,0 +1,94 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright 2021 Huawei Technologies Co., Ltd. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.sdncsimulator.controller; + +import static org.onap.so.sdncsimulator.utils.Constants.BASE_URL; +import java.util.Optional; +import javax.ws.rs.core.MediaType; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfTopology; +import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleTopology; + +import org.onap.so.sdncsimulator.providers.ServiceOperationsCacheServiceProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; + +/** + * @author Md Irshad Sheikh (md.irshad.sheikh@huawei.com) + * + */ +@Controller +@RequestMapping(path = BASE_URL) +public class ConfigController { + private static final String HTTP_STATUS_OK = HttpStatus.OK.value() + ""; + + private static final Logger LOGGER = LoggerFactory.getLogger(OperationsController.class); + + private final ServiceOperationsCacheServiceProvider cacheServiceProvider; + + @Autowired + public ConfigController(final ServiceOperationsCacheServiceProvider cacheServiceProvider) { + this.cacheServiceProvider = cacheServiceProvider; + } + + @GetMapping(value = "/config/GENERIC-RESOURCE-API:services/service/{service-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-topology/") + public ResponseEntity<?> getVNf(@PathVariable("service-id") String serviceId, + @PathVariable("vnf-id") String vnfId) { + + LOGGER.info("Get vnf-topology with serviceId {} and vnfId {}",serviceId, vnfId); + final Optional<GenericResourceApiVnfTopology> optional = + cacheServiceProvider.getGenericResourceApiVnfTopology(vnfId); + if (optional.isPresent()) { + final GenericResourceApiVnfTopology genericVnfTopology = optional.get(); + LOGGER.info("found VnfTopology {} in cache", genericVnfTopology); + return ResponseEntity.ok(genericVnfTopology); + } + + LOGGER.error( + "Unable to find VnfTopology in cache "); + + return ResponseEntity.badRequest().build(); + } + + @GetMapping(value = "/config/GENERIC-RESOURCE-API:services/service/{service-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vf-modules/vf-module/{vf-module-id}/vf-module-data/vf-module-topology/", produces = { + MediaType.APPLICATION_JSON }) + public ResponseEntity<?> getVFmodule(@PathVariable("service-id") String serviceId, + @PathVariable("vnf-id") String vnfId, @PathVariable("vf-module-id") String vfModuleId) { + LOGGER.info("Get vfModule-topology with serviceId {}, vnfId {} and vfModuleId {}",serviceId, vnfId,vfModuleId); + + final Optional<GenericResourceApiVfModuleTopology> optional = + cacheServiceProvider.getGenericResourceApiVfModuleTopology(vfModuleId); + + if (optional.isPresent()) { + final GenericResourceApiVfModuleTopology vfModuleTopology = optional.get(); + LOGGER.info("found vfModuleTopology {} in cache", vfModuleTopology); + return ResponseEntity.ok(vfModuleTopology); + } + + LOGGER.error( + "Unable to find VfModuleTopology in cache for "); + + return ResponseEntity.badRequest().build(); + } +} diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java index 6077bddd..58f90382 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/controller/OperationsController.java @@ -23,15 +23,8 @@ import static org.onap.sdnc.northbound.client.model.GenericResourceApiRequestAct import static org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration.DELETEVNFINSTANCE; import static org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration.DELETE; import static org.onap.so.sdncsimulator.utils.Constants.OPERATIONS_URL; -import static org.onap.so.sdncsimulator.utils.Constants.BASE_URL; -import static org.onap.so.sdncsimulator.utils.Constants.RESTCONF_CONFIG_END_POINT; - -import java.util.ArrayList; -import java.util.List; - import javax.servlet.http.HttpServletRequest; import javax.ws.rs.core.MediaType; - import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader; @@ -39,8 +32,6 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationI import org.onap.sdnc.northbound.client.model.GenericResourceApiSvcActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfOperationInformation; import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleOperationInformation; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVnfTopology; -import org.onap.sdnc.northbound.client.model.GenericResourceApiVfModuleTopology; import org.onap.so.sdncsimulator.models.InputRequest; import org.onap.so.sdncsimulator.models.Output; import org.onap.so.sdncsimulator.models.OutputRequest; @@ -51,8 +42,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; @@ -62,7 +51,7 @@ import org.springframework.web.bind.annotation.RequestMapping; * */ @Controller -@RequestMapping(path = BASE_URL) +@RequestMapping(path = OPERATIONS_URL) public class OperationsController { private static final String HTTP_STATUS_OK = HttpStatus.OK.value() + ""; @@ -75,7 +64,7 @@ public class OperationsController { this.cacheServiceProvider = cacheServiceProvider; } - @PostMapping(value = "/operations/GENERIC-RESOURCE-API:service-topology-operation/", + @PostMapping(value = "/GENERIC-RESOURCE-API:service-topology-operation/", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ResponseEntity<?> postServiceOperationInformation( @@ -102,7 +91,7 @@ public class OperationsController { } - @PostMapping(value = "/operations/GENERIC-RESOURCE-API:vnf-topology-operation/", + @PostMapping(value = "/GENERIC-RESOURCE-API:vnf-topology-operation/", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ResponseEntity<?> postVnfOperationInformation( @@ -159,7 +148,7 @@ public class OperationsController { return cacheServiceProvider.putVnfOperationInformation(apiVnfOperationInformation); } - @PostMapping(value = "/operations/GENERIC-RESOURCE-API:vf-module-topology-operation/", + @PostMapping(value = "/GENERIC-RESOURCE-API:vf-module-topology-operation/", consumes = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}, produces = {MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML}) public ResponseEntity<?> postVfModuleOperationInformation( @@ -167,13 +156,13 @@ public class OperationsController { final HttpServletRequest request) { LOGGER.info("Request Received for VfModule : {} ...", inputRequest); - final GenericResourceApiVfModuleOperationInformation apiVfModuleperationInformation = inputRequest.getInput(); - if (apiVfModuleperationInformation == null) { + final GenericResourceApiVfModuleOperationInformation apiVfModuleOperationInformation = inputRequest.getInput(); + if (apiVfModuleOperationInformation == null) { LOGGER.error("Invalid input request: {}", inputRequest); return ResponseEntity.badRequest().build(); } - final Output output = getOutput(apiVfModuleperationInformation); + final Output output = getOutput(apiVfModuleOperationInformation); final OutputRequest outputRequest = new OutputRequest(output); if (output.getResponseCode().equals(HTTP_STATUS_OK)) { @@ -191,28 +180,4 @@ public class OperationsController { return cacheServiceProvider.putVfModuleOperationInformation(apiVfModuleOperationInformation); } - - @GetMapping(value = "/config/GENERIC-RESOURCE-API:services/service/{service-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vnf-topology/") - public ResponseEntity<?> getVNf(@PathVariable("service-id") String serviceId, - @PathVariable("vnf-id") String vnfId) { - - LOGGER.info("Get vnf-topology with serviceId {} and vnfId {}",serviceId, vnfId); - GenericResourceApiVnfTopology genericResourceApiVnfTopology = new GenericResourceApiVnfTopology(); - - genericResourceApiVnfTopology = cacheServiceProvider.getGenericResourceApiVnfTopology(); - return ResponseEntity.ok(genericResourceApiVnfTopology); - } - - @GetMapping(value = "/config/GENERIC-RESOURCE-API:services/service/{service-id}/service-data/vnfs/vnf/{vnf-id}/vnf-data/vf-modules/vf-module/{vf-module-id}/vf-module-data/vf-module-topology/", produces = { - MediaType.APPLICATION_JSON }) - public ResponseEntity<?> getVFmodule(@PathVariable("service-id") String serviceId, - @PathVariable("vnf-id") String vnfId, @PathVariable("vf-module-id") String vfModuleId) { - LOGGER.info("Get vfModule-topology with serviceId {}, vnfId {} and vfModuleId {}",serviceId, vnfId,vfModuleId); - - GenericResourceApiVfModuleTopology genericResourceApiVfModuleTopology = new GenericResourceApiVfModuleTopology(); - - genericResourceApiVfModuleTopology = cacheServiceProvider.getGenericResourceApiVfModuleTopology(); - return ResponseEntity.ok(genericResourceApiVfModuleTopology); - - } } diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProvider.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProvider.java index d7dbec8e..13e1d439 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProvider.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProvider.java @@ -19,7 +19,6 @@ */ package org.onap.so.sdncsimulator.providers; -import java.util.List; import java.util.Optional; import org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation; @@ -51,9 +50,10 @@ public interface ServiceOperationsCacheServiceProvider { Output putVfModuleOperationInformation(final GenericResourceApiVfModuleOperationInformation apiVfModuleOperationInformation); - public GenericResourceApiVfModuleTopology getGenericResourceApiVfModuleTopology(); + public Optional<GenericResourceApiVfModuleTopology> getGenericResourceApiVfModuleTopology(final String vfModueId); - public GenericResourceApiVnfTopology getGenericResourceApiVnfTopology(); + public Optional<GenericResourceApiVnfTopology> getGenericResourceApiVnfTopology(final String vnfId); void clearAll(); + }
\ No newline at end of file diff --git a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java index 90255de2..4c69a010 100644 --- a/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java +++ b/plans/so/integration-etsi-testing/so-simulators/sdnc-simulator/src/main/java/org/onap/so/sdncsimulator/providers/ServiceOperationsCacheServiceProviderimpl.java @@ -36,7 +36,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Optional; import javax.validation.Valid; - import org.onap.sdnc.northbound.client.model.GenericResourceApiInstanceReference; import org.onap.sdnc.northbound.client.model.GenericResourceApiLastActionEnumeration; import org.onap.sdnc.northbound.client.model.GenericResourceApiLastRpcActionEnumeration; @@ -73,6 +72,7 @@ import org.onap.sdnc.northbound.client.model.GenericResourceApiParam; import org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam; import org.onap.so.sdncsimulator.models.Output; +import org.onap.so.sdncsimulator.utils.Constants; import org.onap.so.simulator.cache.provider.AbstractCacheServiceProvider; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -94,9 +94,6 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ private static final String HTTP_STATUS_OK = Integer.toString(HttpStatus.OK.value()); private static final String EMPTY_STRING = ""; private static final Logger LOGGER = LoggerFactory.getLogger(ServiceOperationsCacheServiceProviderimpl.class); - private static List<GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData> vfModuleList; - GenericResourceApiVfModuleTopology genericResourceApiVfModuleTopology = new GenericResourceApiVfModuleTopology(); - GenericResourceApiVnfTopology genericResourceApiVnfTopology = new GenericResourceApiVnfTopology(); @Autowired public ServiceOperationsCacheServiceProviderimpl(final CacheManager cacheManager) { @@ -213,7 +210,7 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ if (ifVnfNotExists(vnfId, svcAction, vnfsList)) { vnfsList.add(getGenericResourceApiServicedataVnf(serviceInstanceId, vnfId, input)); - getVnfsList(vnfsList); + setVnfsData(vnfsList); final GenericResourceApiServicestatusServiceStatus serviceStatus = service.getServiceStatus(); return new Output().ackFinalIndicator(serviceStatus.getFinalIndicator()) @@ -522,15 +519,15 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ } - @Override - public Output putVfModuleOperationInformation( - GenericResourceApiVfModuleOperationInformation input) { + @Override + public Output putVfModuleOperationInformation( + final GenericResourceApiVfModuleOperationInformation input) { - final GenericResourceApiServiceinformationServiceInformation serviceInformation = input.getServiceInformation(); + final GenericResourceApiServiceinformationServiceInformation serviceInformation = input.getServiceInformation(); final GenericResourceApiVnfinformationVnfInformation vnfInformation = input.getVnfInformation(); final GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = input.getVfModuleInformation(); // Call getVfModule to make a vfList for get the vf-module-information while GET reqest - vfModuleList = getVfModule(input); + getVfModule(input); final GenericResourceApiSdncrequestheaderSdncRequestHeader requestHeader = input.getSdncRequestHeader(); final String svcRequestId = getSvcRequestId(requestHeader); @@ -549,18 +546,18 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ final GenericResourceApiServicemodelinfrastructureService service = optional.get(); final GenericResourceApiServicedataServiceData serviceData = service.getServiceData(); if (serviceData != null) { - - final GenericResourceApiServicestatusServiceStatus serviceStatus = service.getServiceStatus(); - return new Output().ackFinalIndicator(serviceStatus.getFinalIndicator()) - .responseCode(serviceStatus.getResponseCode()) - .responseMessage(serviceStatus.getResponseMessage()).svcRequestId(svcRequestId) - .serviceResponseInformation(new GenericResourceApiInstanceReference() - .instanceId(serviceInstanceId).objectPath(getObjectPath(serviceInstanceId))) - .vnfResponseInformation(new GenericResourceApiInstanceReference().instanceId(vnfId) - .objectPath(getObjectPath(serviceInstanceId, vnfId))) - .vfModuleResponseInformation(new GenericResourceApiInstanceReference().instanceId(vfModuleId) - .objectPath(getObjectPath(vnfId, vfModuleId))); + final GenericResourceApiServicestatusServiceStatus serviceStatus = service.getServiceStatus(); + + return new Output().ackFinalIndicator(serviceStatus.getFinalIndicator()) + .responseCode(serviceStatus.getResponseCode()) + .responseMessage(serviceStatus.getResponseMessage()).svcRequestId(svcRequestId) + .serviceResponseInformation(new GenericResourceApiInstanceReference() + .instanceId(serviceInstanceId).objectPath(getObjectPath(serviceInstanceId))) + .vnfResponseInformation(new GenericResourceApiInstanceReference().instanceId(vnfId) + .objectPath(getObjectPath(serviceInstanceId, vnfId))) + .vfModuleResponseInformation(new GenericResourceApiInstanceReference().instanceId(vfModuleId) + .objectPath(getObjectPath(vnfId, vfModuleId))); } } LOGGER.error( @@ -572,69 +569,82 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ input); return new Output().ackFinalIndicator(YES).responseCode(HTTP_STATUS_BAD_REQUEST) .responseMessage("Unable to add vfModule").svcRequestId(svcRequestId); - } + } - private List<GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData> getVfModule(GenericResourceApiVfModuleOperationInformation input) { - - final GenericResourceApiVfmoduletopologyVfModuleTopology apiVfModuletopologyVfModuleTopology = + private void getVfModule + (final GenericResourceApiVfModuleOperationInformation input) { + + final GenericResourceApiVfmoduletopologyVfModuleTopology apiVfModuletopologyVfModuleTopology = new GenericResourceApiVfmoduletopologyVfModuleTopology(); - - GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData vfModuleData = + + final GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData vfModuleData = new GenericResourceApiServicedataServicedataVnfsVnfVnfdataVfmodulesVfmoduleVfModuleData(); + + final String vfModuleId = input.getVfModuleInformation().getVfModuleId(); + vfModuleData.setVfModuleInformation(input.getVfModuleInformation()); vfModuleData.setVfModuleRequestInput(input.getVfModuleRequestInput()); - - GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = new GenericResourceApiVfmoduletopologyVfModuleTopology(); - - vfModuleTopology.setSdncGeneratedCloudResources(true); - GenericResourceApiParam vfModuleParametersData = new GenericResourceApiParam(); - List<GenericResourceApiParamParam> params = new ArrayList<GenericResourceApiParamParam>(); - GenericResourceApiParamParam param = new GenericResourceApiParamParam(); - param.setName("k8s-rb-profile-name"); - param.setValue("k8s-rb-profile-value"); - - params.add(param); - vfModuleParametersData.setParam(params); - vfModuleTopology.setVfModuleParameters(vfModuleParametersData); - + + final GenericResourceApiVfmoduletopologyVfModuleTopology vfModuleTopology = + new GenericResourceApiVfmoduletopologyVfModuleTopology(); + + vfModuleTopology.setSdncGeneratedCloudResources(true); + final GenericResourceApiParam vfModuleParametersData = new GenericResourceApiParam(); + final List<GenericResourceApiParamParam> params = new ArrayList<GenericResourceApiParamParam>(); + final GenericResourceApiParamParam param = new GenericResourceApiParamParam(); + param.setName("k8s-rb-profile-name"); + param.setValue("k8s-rb-profile-value"); + + params.add(param); + vfModuleParametersData.setParam(params); + vfModuleTopology.setVfModuleParameters(vfModuleParametersData); + vfModuleTopology.setOnapModelInformation(vfModuleData.getVfModuleInformation().getOnapModelInformation()); vfModuleTopology.setVfModuleParameters(vfModuleData.getVfModuleRequestInput().getVfModuleInputParameters()); vfModuleTopology.setAicClli(vfModuleData.getVfModuleRequestInput().getAicClli()); vfModuleTopology.setAicCloudRegion(vfModuleData.getVfModuleRequestInput().getAicCloudRegion()); vfModuleTopology.setCloudOwner(vfModuleData.getVfModuleRequestInput().getCloudOwner()); - + apiVfModuletopologyVfModuleTopology.vfModuleTopologyIdentifier(getVfModuleTopologyIdentifierStructure(input)); - + vfModuleTopology.setVfModuleTopologyIdentifier(apiVfModuletopologyVfModuleTopology.getVfModuleTopologyIdentifier()); vfModuleTopology.setTenant(vfModuleData.getVfModuleRequestInput().getTenant()); + final GenericResourceApiVfModuleTopology genericResourceApiVfModuleTopology = new GenericResourceApiVfModuleTopology(); genericResourceApiVfModuleTopology.setVfModuleTopology(vfModuleTopology); - - return null; + final Cache cache = getCache(Constants.SERVICE_TOPOLOGY_OPERATION_CACHE); + cache.put(vfModuleId, genericResourceApiVfModuleTopology); } - public GenericResourceApiVfModuleTopology getGenericResourceApiVfModuleTopology() { - return genericResourceApiVfModuleTopology; - } - - private GenericResourceApiVfmoduletopologyidentifierVfModuleTopologyIdentifier getVfModuleTopologyIdentifierStructure( + @Override + public Optional<GenericResourceApiVfModuleTopology> getGenericResourceApiVfModuleTopology(final String vfModueId) { + LOGGER.info("getting GenericResourceApiVfModuleTopology from cache using key: {}", vfModueId); + final Cache cache = getCache(Constants.SERVICE_TOPOLOGY_OPERATION_CACHE); + final GenericResourceApiVfModuleTopology value = + cache.get(vfModueId, GenericResourceApiVfModuleTopology.class); + if (value != null) { + return Optional.of(value); + } + LOGGER.error("Unable to find GenericResourceApiVfModuleTopology ..."); + return Optional.empty(); + } + + private GenericResourceApiVfmoduletopologyidentifierVfModuleTopologyIdentifier getVfModuleTopologyIdentifierStructure( @Valid final GenericResourceApiVfModuleOperationInformation input) { - - final GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = input.getVfModuleInformation(); + + final GenericResourceApiVfmoduleinformationVfModuleInformation vfModuleInformation = input.getVfModuleInformation(); return new GenericResourceApiVfmoduletopologyidentifierVfModuleTopologyIdentifier() .vfModuleId(vfModuleInformation.getVfModuleId()).vfModuleType(vfModuleInformation.getVfModuleType()).vfModuleName(input.getVfModuleRequestInput().getVfModuleName()); } - - public GenericResourceApiVnfTopology getGenericResourceApiVnfTopology() { - return genericResourceApiVnfTopology; - } - public void getVnfsList(List<GenericResourceApiServicedataServicedataVnfsVnf> vnfsList) { - - GenericResourceApiVnftopologyVnfTopology vnfTopology = new GenericResourceApiVnftopologyVnfTopology(); - LOGGER.info(String.valueOf(vnfsList)); - vnfTopology.setOnapModelInformation(vnfsList.get(0).getVnfData().getVnfInformation().getOnapModelInformation()); + + public void setVnfsData(List<GenericResourceApiServicedataServicedataVnfsVnf> vnfsList) { + + final GenericResourceApiVnftopologyVnfTopology vnfTopology = new GenericResourceApiVnftopologyVnfTopology(); + LOGGER.info(String.valueOf(vnfsList)); + final String vnfId = vnfsList.get(0).getVnfId(); + vnfTopology.setOnapModelInformation(vnfsList.get(0).getVnfData().getVnfInformation().getOnapModelInformation()); vnfTopology.setAicClli(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getAicClli())); vnfTopology.setAicCloudRegion(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getAicCloudRegion())); vnfTopology.setCloudOwner(String.valueOf(vnfsList.get(0).getVnfData().getVnfRequestInput().getCloudOwner())); @@ -643,7 +653,24 @@ public class ServiceOperationsCacheServiceProviderimpl extends AbstractCacheServ vnfTopology.setVnfTopologyIdentifierStructure(vnfsList.get(0).getVnfData().getVnfTopology().getVnfTopologyIdentifierStructure()); vnfTopology.setVnfParametersData(vnfsList.get(0).getVnfData().getVnfTopology().getVnfParametersData()); vnfTopology.setSdncGeneratedCloudResources(vnfsList.get(0).getVnfData().getVnfTopology().getSdncGeneratedCloudResources()); - + + final GenericResourceApiVnfTopology genericResourceApiVnfTopology = new GenericResourceApiVnfTopology(); genericResourceApiVnfTopology.setVnfTopology(vnfTopology); - } + + final Cache cache = getCache(Constants.SERVICE_TOPOLOGY_OPERATION_CACHE); + cache.put(vnfId, genericResourceApiVnfTopology); + } + + @Override + public Optional<GenericResourceApiVnfTopology> getGenericResourceApiVnfTopology(final String vnfId) { + LOGGER.info("getting GenericResourceApiVnfTopology from cache using key: {}", vnfId); + final Cache cache = getCache(Constants.SERVICE_TOPOLOGY_OPERATION_CACHE); + final GenericResourceApiVnfTopology value = + cache.get(vnfId, GenericResourceApiVnfTopology.class); + if (value != null) { + return Optional.of(value); + } + LOGGER.error("Unable to find GenericResourceApiVnfTopology ..."); + return Optional.empty(); + } }
\ No newline at end of file |