summaryrefslogtreecommitdiffstats
path: root/adapters
diff options
context:
space:
mode:
Diffstat (limited to 'adapters')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql5
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java15
-rw-r--r--adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java1
-rw-r--r--adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java31
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json42
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json25
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/data.sql14
7 files changed, 130 insertions, 3 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql
new file mode 100644
index 0000000000..627f7a4a61
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql
@@ -0,0 +1,5 @@
+use catalogdb;
+
+INSERT INTO `vnf_recipe` (`NF_ROLE`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `RECIPE_TIMEOUT`)
+VALUES
+('GR-API-DEFAULT', 'recreateInstance', '1', 'Gr api recipe to recreate vnf', '/mso/async/services/WorkflowActionBB', 180); \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
index ac33a5269e..4b6bd09144 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java
@@ -42,6 +42,8 @@ import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.HeatTemplate;
import org.onap.so.db.catalog.beans.NetworkResource;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
+import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization;
+import org.onap.so.db.catalog.data.repository.CollectionNetworkResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository;
import org.onap.so.db.catalog.data.repository.NetworkResourceRepository;
import org.onap.so.db.catalog.utils.MavenLikeVersioning;
@@ -108,6 +110,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
private NetworkResourceCustomizationRepository networkCustomRepo;
@Autowired
+ private CollectionNetworkResourceCustomizationRepository collectionNetworkCustomRepo;
+
+ @Autowired
private NetworkResourceRepository networkResourceRepo;
/**
* Health Check web method. Does nothing but return to show the adapter is deployed.
@@ -1124,18 +1129,26 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
NetworkResourceCustomization networkCust = null;
+ CollectionNetworkResourceCustomization collectionNetworkCust = null;
if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) {
if (!commonUtils.isNullOrEmpty(networkType)) {
- networkResource = networkResourceRepo.findOneByModelName(networkType);
+ networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType);
}
} else {
networkCust = networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
+ if (networkCust == null) {
+ collectionNetworkCust = collectionNetworkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid);
+ }
}
if(networkCust != null){
LOGGER.debug("Got Network Customization definition from Catalog: "
+ networkCust.toString());
networkResource = networkCust.getNetworkResource();
+ } else if (collectionNetworkCust != null) {
+ LOGGER.debug("Retrieved Collection Network Resource Customization from Catalog: "
+ + collectionNetworkCust.toString());
+ networkResource = collectionNetworkCust.getNetworkResource();
}
if (networkResource == null) {
String error = "Create/UpdateNetwork: Unable to get network resource with NetworkType:"
diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java
index d65cdc4638..f2238fce78 100644
--- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java
+++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java
@@ -4,7 +4,6 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
- * Modifications Copyright 2018 IBM.
* 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
diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
index 2a4564bcb2..6123415b41 100644
--- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
+++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java
@@ -142,7 +142,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange(
createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class);
-
+
CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
new File("src/test/resources/__files/CreateNetworkResponse2.json"), CreateNetworkResponse.class);
@@ -150,6 +150,8 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
assertThat(response.getBody(), sameBeanAs(expectedResponse));
}
+
+
@Test
public void testDeleteNetwork() throws IOException{
@@ -267,6 +269,33 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils {
assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
}
+ @Test
+ public void testCreateNetworkCNRC_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException {
+
+ mockOpenStackResponseAccess(wireMockPort);
+
+ mockOpenStackPostPublicUrlWithBodyFile_200();
+
+ mockOpenStackGetStackCreatedAppC_200();
+
+ mockOpenStackGetStackAppC_404();
+
+ headers.add("Content-Type", MediaType.APPLICATION_JSON);
+ headers.add("Accept", MediaType.APPLICATION_JSON);
+
+ String request = readJsonFileAsString("src/test/resources/CreateNetwork3.json");
+ HttpEntity<String> entity = new HttpEntity<String>(request, headers);
+
+ ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange(
+ createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class);
+
+ CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue(
+ new File("src/test/resources/__files/CreateNetworkResponse3.json"), CreateNetworkResponse.class);
+
+ assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value());
+ assertThat(response.getBody(), sameBeanAs(expectedResponse));
+ }
+
@Override
protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{
return new String(Files.readAllBytes(Paths.get(fileLocation)));
diff --git a/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json
new file mode 100644
index 0000000000..accd9e9a54
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json
@@ -0,0 +1,42 @@
+{
+ "createNetworkRequest": {
+ "skipAAI": true,
+ "messageId": "c4c44af4-4310-4d8b-a1eb-656fc99fe709",
+ "synchronous": true,
+ "cloudSiteId": "mtn13",
+ "tenantId": "ba38bc24a2ef4fb2ad2810c894f1938f",
+ "networkId": "da886914-efb2-4917-b335-c8381528d90b",
+ "networkName": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3",
+ "networkType": "CONTRAIL30_BASIC",
+ "modelCustomizationUuid": "3bdbb104-ffff-483e-9f8b-c095b3d30844",
+ "networkTechnology": "NEUTRON",
+ "subnets": [{
+ "subnetName": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3_subnet_1",
+ "subnetId": "da60501d-9aa8-48d2-99b7-26644fa01093",
+ "cidr": "20",
+ "gatewayIp": "",
+ "ipVersion": "4",
+ "enableDHCP": false,
+ "addrFromStart": true,
+ "hostRoutes": []
+ }],
+ "providerVlanNetwork": {
+ "physicalNetworkName": "FALSE",
+ "vlans": []
+ },
+ "contrailNetwork": {
+ "shared": "false",
+ "external": "false",
+ "routeTargets": [],
+ "policyFqdns": [],
+ "routeTableFqdns": []
+ },
+ "failIfExists": true,
+ "backout": false,
+ "msoRequest": {
+ "requestId": "5349f419-b3e9-4546-b3a1-094bd568d6b7",
+ "serviceInstanceId": "cf965caf-a003-4189-abf9-e0ed77056dd6"
+ },
+ "contrailRequest": false
+ }
+} \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json
new file mode 100644
index 0000000000..2e5517cebb
--- /dev/null
+++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json
@@ -0,0 +1,25 @@
+{
+ "createNetworkResponse": {
+ "networkId": "da886914-efb2-4917-b335-c8381528d90b",
+ "neutronNetworkId": null,
+ "networkStackId": "stackname/stackId",
+ "networkFqdn": null,
+ "networkCreated": true,
+ "subnetMap": {
+
+ },
+ "rollback": {
+ "networkStackId": "stackname/stackId",
+ "tenantId": "ba38bc24a2ef4fb2ad2810c894f1938f",
+ "cloudId": "mtn13",
+ "networkType": "CONTRAIL30_BASIC",
+ "modelCustomizationUuid": "3bdbb104-ffff-483e-9f8b-c095b3d30844",
+ "networkCreated": true,
+ "msoRequest": {
+ "requestId": "5349f419-b3e9-4546-b3a1-094bd568d6b7",
+ "serviceInstanceId": "cf965caf-a003-4189-abf9-e0ed77056dd6"
+ }
+ },
+ "messageId": "c4c44af4-4310-4d8b-a1eb-656fc99fe709"
+ }
+} \ No newline at end of file
diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql
index d16ca4528c..960f483e46 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/data.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql
@@ -71,6 +71,20 @@ insert into network_resource_customization(model_customization_uuid, model_insta
('3bdbb104-476c-483e-9f8b-c095b3d30844', 'CONTRAIL30_BASIC', '', 'CONTRAIL30_BASIC', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c4789'),
('3bdbb104-476c-483e-9f8b-c095b3d3068c', 'CONTRAIL31_BASIC', '', 'CONTRAIL31_BASIC', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c4790');
+insert into instance_group(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, role, object_type, cr_model_uuid, instance_group_type) values
+('21e43a7c-d823-4f5b-a427-5235f63035ff', 'dror_cr_network_resource_1806..NetworkCollection..0', '81c94263-c01e-4046-b0c7-51878d658eab', '1', 'org.openecomp.groups.NetworkCollection', 'SUB_INTERFACE', 'L3_NETWORK', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'L3_NETWORK');
+
+insert into collection_resource(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, description) values
+('5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'Dror_CR_Network_Resource_1806', 'fe243154-ac18-405f-94c2-ef629d26b8bb', '2.0', 'org.openecomp.resource.cr.DrorCrNetworkResource1806', 'Creation date: 07/25/18');
+
+insert into collection_resource_customization(model_customization_uuid, model_instance_name, role, object_type, function, collection_resource_type, cr_model_uuid) values
+('c51096a4-6081-41f4-a540-3ed015a8064a', 'Dror_CR_Network_Resource_1806', 'Dror2', 'NetworkCollection', 'Dror1', 'Dror3', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c');
+
+insert into collection_network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, network_resource_model_uuid, instance_group_model_uuid, crc_model_customization_uuid) values
+('3bdbb104-ffff-483e-9f8b-c095b3d30844', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c4789', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'),
+('3bdbb104-ffff-483e-9f8b-c095b3d3068c', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c4790', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a');
+
+
insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values
('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002672', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '2.0', 'vSAMP10a', 'VF', null);