aboutsummaryrefslogtreecommitdiffstats
path: root/adapters/mso-catalog-db-adapter/src
diff options
context:
space:
mode:
authorMarcus G K Williams <marcus.williams@intel.com>2018-11-28 12:37:54 -0800
committerMarcus Williams <marcus.williams@intel.com>2018-11-30 02:08:50 +0000
commit17078f031da59e4a3b7a4e18cf5b23daf9ddac56 (patch)
tree6080dc352f7b2203ca141cf4abaf1ac26cb666c5 /adapters/mso-catalog-db-adapter/src
parentf8e7af7517c6a825ec252ec38475a7e08bdeb41f (diff)
Fix alacarte homing flows
This fix adds homingInstance bean and stores homing info in the database. It then retreves that info when homing ala carte and populates homingSiteId and oofDirectives. SO-1254 Issue-ID: SO-1258 Change-Id: I6f8d5d3aff9ebeb669064a02926c779886dc59dd Signed-off-by: Marcus G K Williams <marcus.williams@intel.com>
Diffstat (limited to 'adapters/mso-catalog-db-adapter/src')
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql7
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java75
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql14
3 files changed, 95 insertions, 1 deletions
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql
new file mode 100644
index 0000000000..a2ebe04ed8
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/v4.21_AddHomingTables.sql
@@ -0,0 +1,7 @@
+CREATE TABLE IF NOT EXISTS `homing_instances` (
+`SERVICE_INSTANCE_ID` varchar(50) NOT NULL,
+`CLOUD_OWNER` VARCHAR(200) NOT NULL,
+`CLOUD_REGION_ID` VARCHAR(200) NOT NULL,
+`OOF_DIRECTIVES` longtext NULL DEFAULT NULL,
+PRIMARY KEY (`SERVICE_INSTANCE_ID`)
+) ; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
index c85a4c28f5..8c990a1a65 100644
--- a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/db/catalog/client/CatalogDbClientTest.java
@@ -33,6 +33,7 @@ import org.onap.so.db.catalog.beans.CloudIdentity;
import org.onap.so.db.catalog.beans.CloudSite;
import org.onap.so.db.catalog.beans.CloudifyManager;
import org.onap.so.db.catalog.beans.ExternalServiceToInternalService;
+import org.onap.so.db.catalog.beans.HomingInstance;
import org.onap.so.db.catalog.beans.InstanceGroup;
import org.onap.so.db.catalog.beans.NetworkResourceCustomization;
import org.onap.so.db.catalog.beans.ServerType;
@@ -414,6 +415,80 @@ public class CatalogDbClientTest {
Assert.assertEquals("RANDOMID", getCloudSite.getIdentityServiceId());
}
+ @Test
+ public void testGetHomingInstance() {
+ HomingInstance homingInstance = client.getHomingInstance("5df8b6de-2083-11e7-93ae-92361f232671");
+ Assert.assertNotNull(homingInstance);
+ Assert.assertNotNull(homingInstance.getCloudOwner());
+ Assert.assertNotNull(homingInstance.getCloudRegionId());
+ Assert.assertNotNull(homingInstance.getOofDirectives());
+ }
+
+ @Test
+ public void testPostHomingInstance() {
+ CatalogDbClientPortChanger localClient = new CatalogDbClientPortChanger("http://localhost:" + client.wiremockPort, msoAdaptersAuth, client.wiremockPort);
+ HomingInstance homingInstance = new HomingInstance();
+ homingInstance.setServiceInstanceId("5df8d6be-2083-11e7-93ae-92361f232671");
+ homingInstance.setCloudOwner("CloudOwner-1");
+ homingInstance.setCloudRegionId("CloudRegionOne");
+ homingInstance.setOofDirectives("{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"attributes\": [\n" +
+ "{\n" +
+ "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
+ "\"attribute_name\": \"firewall_flavor_name\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"flavor_directives\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"vnfc\",\n" +
+ "\"id\": \"vfw\"\n" +
+ "},\n" +
+ "{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"attributes\": [\n" +
+ "{\n" +
+ "\"attribute_value\": \"onap.hpa.flavor32\",\n" +
+ "\"attribute_name\": \"packetgen_flavor_name\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"flavor_directives\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"vnfc\",\n" +
+ "\"id\": \"vgenerator\"\n" +
+ "},\n" +
+ "{\n" +
+ "\"directives\": [\n" +
+ "{\n" +
+ "\"attributes\": [\n" +
+ "{\n" +
+ "\"attribute_value\": \"onap.hpa.flavor31\",\n" +
+ "\"attribute_name\": \"sink_flavor_name\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"flavor_directives\"\n" +
+ "}\n" +
+ "],\n" +
+ "\"type\": \"vnfc\",\n" +
+ "\"id\": \"vsink\"\n" +
+ "}\n" +
+ "]\n" +
+ "}");
+ localClient.postHomingInstance(homingInstance);
+ HomingInstance getHomingInstance = this.client.getHomingInstance("5df8d6be-2083-11e7-93ae-92361f232671");
+ Assert.assertNotNull(getHomingInstance);
+ Assert.assertNotNull(getHomingInstance.getCloudRegionId());
+ Assert.assertNotNull(getHomingInstance.getCloudOwner());
+ Assert.assertEquals("CloudOwner-1", getHomingInstance.getCloudOwner());
+ Assert.assertEquals("CloudRegionOne", getHomingInstance.getCloudRegionId());
+ }
+
@Test
public void testGetServiceByModelName() {
Service service = client.getServiceByModelName("MSOTADevInfra_Test_Service");
diff --git a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
index c8475564a4..7ac3c53420 100644
--- a/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
+++ b/adapters/mso-catalog-db-adapter/src/test/resources/db/migration/afterMigrate.sql
@@ -49,6 +49,14 @@ CREATE TABLE IF NOT EXISTS `cloud_sites` (
CONSTRAINT `FK_cloud_sites_identity_services` FOREIGN KEY (`IDENTITY_SERVICE_ID`) REFERENCES `identity_services` (`ID`)
) ;
+CREATE TABLE IF NOT EXISTS `homing_instances` (
+`SERVICE_INSTANCE_ID` varchar(50) NOT NULL,
+`CLOUD_OWNER` VARCHAR(200) NOT NULL,
+`CLOUD_REGION_ID` VARCHAR(200) NOT NULL,
+`OOF_DIRECTIVES` longtext NULL DEFAULT NULL,
+PRIMARY KEY (`SERVICE_INSTANCE_ID`)
+) ;
+
insert into heat_files(artifact_uuid, name, version, description, body, artifact_checksum, creation_timestamp) values
('00535bdd-0878-4478-b95a-c575c742bfb0', 'nimbus-ethernet-gw', '1', 'created from csar', 'DEVICE=$dev\nBOOTPROTO=none\nNM_CONTROLLED=no\nIPADDR=$ip\nNETMASK=$netmask\nGATEWAY=$gateway\n', 'MANUAL RECORD', '2017-01-21 23:56:43');
@@ -203,4 +211,8 @@ VALUES
INSERT INTO vnf_components_recipe (VNF_COMPONENT_TYPE, ACTION, VERSION, DESCRIPTION, ORCHESTRATION_URI, RECIPE_TIMEOUT, VF_MODULE_MODEL_UUID)
VALUES
-('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671'); \ No newline at end of file
+('volumeGroup', 'createInstance', '1', 'Gr api recipe to create volume-group', '/mso/async/services/WorkflowActionBB', 180, '20c4431c-246d-11e7-93ae-92361f002671');
+
+insert into homing_instances (service_instance_id, cloud_owner, cloud_region_id, oof_directives) values
+('5df8b6de-2083-11e7-93ae-92361f232671', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'),
+('5df8b6de-2083-11e7-93ae-92361f562672', 'CloudOwner', 'CloudRegionId', '{"directives": [{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "firewall_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vfw"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor33","attribute_name": "packetgen_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vgenerator"},{"directives": [{"attributes": [{"attribute_value": "onap.hpa.flavor32","attribute_name": "sink_flavor_name"}],"type": "flavor_directives"}],"type": "vnfc","id": "vsink"}]}'); \ No newline at end of file