aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy17
-rw-r--r--bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy43
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java103
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy62
-rw-r--r--bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy19
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java152
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java32
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java30
11 files changed, 516 insertions, 38 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
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
index c50ef3530e..df3399f1f0 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofHoming.groovy
@@ -33,6 +33,7 @@ import org.onap.so.bpmn.core.json.JsonUtils
import org.onap.so.db.catalog.beans.AuthenticationType
import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
+import org.onap.so.db.catalog.beans.HomingInstance
import org.onap.so.db.catalog.beans.ServerType
import org.onap.so.rest.APIResponse
import org.onap.so.rest.RESTClient
@@ -293,8 +294,7 @@ class OofHoming extends AbstractServiceTaskProcessor {
+ " *****", "true")
// Set cloudsite in catalog DB here
- // TODO Get cloudsite and compare, set if not present
- oofUtils.createCloudSiteCatalogDb(cloudSite, execution)
+ oofUtils.createCloudSite(cloudSite, execution)
if (oofDirectives != null && oofDirectives != "") {
resource.getHomingSolution().setOofDirectives(oofDirectives)
@@ -303,6 +303,19 @@ class OofHoming extends AbstractServiceTaskProcessor {
" *****", "true")
}
+ // Set Homing Instance
+ String serviceInstanceId = decomposition.getServiceInstance().getInstanceId()
+ HomingInstance homingInstance = new HomingInstance()
+ homingInstance.setServiceInstanceId(serviceInstanceId)
+ homingInstance.setCloudOwner(cloudOwner)
+ homingInstance.setCloudRegionId(cloudRegionId)
+ if (oofDirectives != null && oofDirectives != "") {
+ homingInstance.setOofDirectives(oofDirectives)}
+ else {
+ homingInstance.setOofDirectives("{}")
+ }
+ oofUtils.createHomingInstance(homingInstance, execution)
+
if (inventoryType.equalsIgnoreCase("service")) {
resource.getHomingSolution().setRehome(assignmentMap.get("isRehome").toBoolean())
VnfResource vnf = new VnfResource()
diff --git a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
index 19d19b8cea..f72fc47aa5 100644
--- a/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
+++ b/bpmn/MSOCommonBPMN/src/main/groovy/org/onap/so/bpmn/common/scripts/OofUtils.groovy
@@ -33,24 +33,16 @@ import org.onap.so.bpmn.core.domain.ServiceInstance
import org.onap.so.bpmn.core.domain.Subscriber
import org.onap.so.bpmn.core.domain.VnfResource
import org.onap.so.bpmn.core.json.JsonUtils
-import org.onap.so.db.catalog.beans.CloudIdentity
import org.onap.so.db.catalog.beans.CloudSite
-import org.onap.so.db.catalog.client.CatalogDbClient
-import org.onap.so.rest.APIResponse
-import org.onap.so.rest.RESTClient
-import org.onap.so.rest.RESTConfig
-import org.springframework.http.HttpEntity
-import org.springframework.http.HttpHeaders
-import org.springframework.web.util.UriComponentsBuilder
-
-import javax.ws.rs.core.MediaType
+import org.onap.so.db.catalog.beans.HomingInstance
import javax.ws.rs.core.UriBuilder
-
+import org.onap.so.bpmn.common.util.OofInfraUtils
import static org.onap.so.bpmn.common.scripts.GenericUtils.*
class OofUtils {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
private AbstractServiceTaskProcessor utils
@@ -491,6 +483,7 @@ class OofUtils {
if (candidatesJson != "") {candidatesJson = candidatesJson.substring(0, candidatesJson.length() - 1)}
return candidatesJson
}
+
/**
* This method creates a cloudsite in catalog database.
*
@@ -498,23 +491,19 @@ class OofUtils {
*
* @return void
*/
- Void createCloudSiteCatalogDb(CloudSite cloudSite, DelegateExecution execution) {
- def isDebugEnabled = execution.getVariable("isDebugLogEnabled")
- String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution)
- String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution)
- CloudSite getCloudsite = null
+ Void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+ oofInfraUtils.createCloudSite(cloudSite, execution)
+ }
- CatalogDbClient catalogDbClient = new CatalogDbClient(endpoint, auth)
- try {
- getCloudsite = catalogDbClient.getCloudSite(cloudSite.getId().toString())
- } catch (Exception e) {
- e = null
- utils.log("DEBUG", "Could not find cloudsite : " + cloudSite.getId(), isDebugEnabled)
- utils.log("DEBUG", "Creating cloudSite: " + cloudSite.toString(), isDebugEnabled)
- }
- if (getCloudsite?.getId() != cloudSite.getId()) {
- catalogDbClient.postCloudSite(cloudSite)
- }
+ /**
+ * This method creates a HomingInstance in catalog database.
+ *
+ * @param HomingInstance homingInstance
+ *
+ * @return void
+ */
+ Void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+ oofInfraUtils.createHomingInstance(homingInstance, execution)
}
String getMsbHost(DelegateExecution execution) {
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
new file mode 100644
index 0000000000..b62d8be281
--- /dev/null
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/util/OofInfraUtils.java
@@ -0,0 +1,103 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.bpmn.common.util;
+
+import org.camunda.bpm.engine.delegate.DelegateExecution;
+import org.onap.so.bpmn.core.UrnPropertiesReader;
+import org.onap.so.db.catalog.beans.CloudSite;
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.onap.so.db.catalog.client.CatalogDbClient;
+import org.onap.so.logger.MsoLogger;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.Arrays;
+import java.util.Optional;
+
+public class OofInfraUtils {
+
+ private static final MsoLogger LOGGER = MsoLogger.getMsoLogger(MsoLogger.Catalog.BPEL, OofInfraUtils.class);
+
+ /**
+ * This method creates a cloudsite in catalog database.
+ *
+ * @param cloudSite
+ *
+ * @return void
+ */
+ public void createCloudSite(CloudSite cloudSite, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+ Optional <CloudSite> optCloudsite = Optional.empty();
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ optCloudsite = Optional.ofNullable(client.getCloudSite(cloudSite.getId(), endpoint + "/cloudSite/"));
+ } catch (Exception e) {
+ LOGGER.debug("Could not find cloudsite : " + cloudSite.getId());
+ LOGGER.debug("Creating cloudSite: " + cloudSite.toString());
+ }
+ if (optCloudsite.isPresent() && (cloudSite.getId()) != optCloudsite.get().getId()) {
+ client.postCloudSite(cloudSite);
+ }
+ }
+
+ /**
+ * This method creates a HomingInstance in catalog database.
+ *
+ * @param homingInstance
+ *
+ * @return void
+ */
+ public void createHomingInstance(HomingInstance homingInstance, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ client.postHomingInstance(homingInstance);
+ } catch (Exception exception) {
+ LOGGER.debug("Could not create HomingInstance : " + homingInstance.getServiceInstanceId());
+ LOGGER.debug("HomingInstance Creation Error: " + exception);
+ }
+
+ }
+
+ /**
+ * This method gets a HomingInstance in catalog database.
+ *
+ * @param serviceInstanceId
+ *
+ * @return HomingInstance
+ */
+ public HomingInstance getHomingInstance(String serviceInstanceId, DelegateExecution execution) {
+ String endpoint = UrnPropertiesReader.getVariable("mso.catalog.db.spring.endpoint", execution);
+ String auth = UrnPropertiesReader.getVariable("mso.db.auth", execution);
+
+ CatalogDbClient client = new CatalogDbClient(endpoint, auth);
+ try {
+ return client.getHomingInstance(serviceInstanceId, endpoint + "/homingInstance/");
+ } catch (Exception exception) {
+ LOGGER.debug("Could not get HomingInstance for serviceInstanceId : " + serviceInstanceId);
+ LOGGER.debug("Get HomingInstance Error: " + exception);
+ }
+ return null;
+ }
+}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
index 58b90a1bf2..74926ce5b7 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVfModule.groovy
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.db.catalog.beans.HomingInstance
+
import javax.xml.parsers.DocumentBuilder
import javax.xml.parsers.DocumentBuilderFactory
@@ -35,6 +37,7 @@ import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.NetworkUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.VfModuleBase
+import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
@@ -75,6 +78,7 @@ public class DoCreateVfModule extends VfModuleBase {
ExceptionUtil exceptionUtil = new ExceptionUtil()
JsonUtils jsonUtil = new JsonUtils()
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
CatalogDbUtils catalog = new CatalogDbUtils()
DecomposeJsonUtil decomposeJsonUtils = new DecomposeJsonUtil()
@@ -232,12 +236,37 @@ public class DoCreateVfModule extends VfModuleBase {
String globalSubscriberId = execution.getVariable("globalSubscriberId")
execution.setVariable("DCVFM_globalSubscriberId", globalSubscriberId)
msoLogger.debug("globalSubsrciberId: " + globalSubscriberId)
- //OofDirectives
- String oofDirectives = execution.getVariable("oofDirectives")
+
+ // Set Homing Info
+ String oofDirectives = null
+ try {
+ HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+ if (homingInstance != null) {
+ execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId())
+ rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId())
+ msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+ homingInstance.getCloudRegionId())
+ execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner())
+ rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner())
+ msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " +
+ homingInstance.getCloudOwner())
+ oofDirectives = homingInstance.getOofDirectives()
+ execution.setVariable("DCVFM_oofDirectives", oofDirectives)
+ }
+ } catch (Exception exception) {
+ msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+ "... continuing")
+ msoLogger.debug("Could not find homing information for service instance error: " + exception)
+ }
+ //OofDirectives to Input Params
Map<String,String> vfModuleInputParams = execution.getVariable("vfModuleInputParams")
- if (oofDirectives != null) {
- vfModuleInputParams.put("oofDirectives", oofDirectives)
- logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled)
+ if (oofDirectives != null && vfModuleInputParams != null) {
+ vfModuleInputParams.put("oof_directives", oofDirectives)
+ vfModuleInputParams.put("sdnc_directives", "{}")
+ msoLogger.debug("OofDirectives are: " + oofDirectives)
+ } else if (vfModuleInputParams != null) {
+ vfModuleInputParams.put("oof_directives", "{}")
+ vfModuleInputParams.put("sdnc_directives", "{}")
}
if (vfModuleInputParams != null) {
execution.setVariable("DCVFM_vnfParamsMap", vfModuleInputParams)
@@ -464,11 +493,30 @@ public class DoCreateVfModule extends VfModuleBase {
}
//OofDirectives
- String oofDirectives = execution.getVariable("oofDirectives")
+ String oofDirectives = null
+ try {
+ HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+ if (homingInstance != null) {
+ execution.setVariable("DCVFM_cloudSiteId", homingInstance.getCloudRegionId())
+ rollbackData.put("VFMODULE", "aiccloudregion", homingInstance.getCloudRegionId())
+ msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+ homingInstance.getCloudRegionId())
+ execution.setVariable("DCVFM_cloudOwner", homingInstance.getCloudOwner())
+ rollbackData.put("VFMODULE", "cloudOwner", homingInstance.getCloudOwner())
+ msoLogger.debug("Overwriting cloudOwner with homing cloudOwner: " +
+ homingInstance.getCloudOwner())
+ oofDirectives = homingInstance.getOofDirectives()
+ execution.setVariable("DCVFM_oofDirectives", oofDirectives)
+ }
+ } catch (Exception exception) {
+ msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+ "... continuing")
+ msoLogger.debug("Could not find homing information for service instance error: " + exception)
+ }
if (oofDirectives != null) {
Map<String, String> paramsMap = execution.getVariable("DCVFM_vnfParamsMap")
paramsMap.put("oofDirectives", oofDirectives)
- logDebug("OofDirectives are: " + oofDirectives, isDebugLogEnabled)
+ msoLogger.debug("OofDirectives are: " + oofDirectives)
execution.setVariable("DCVFM_vnfParamsMap", paramsMap)
}
}
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
index b35aab1176..deb0bffaf9 100644
--- a/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
+++ b/bpmn/so-bpmn-infrastructure-common/src/main/groovy/org/onap/so/bpmn/infrastructure/scripts/DoCreateVnf.groovy
@@ -20,6 +20,8 @@
package org.onap.so.bpmn.infrastructure.scripts
+import org.onap.so.db.catalog.beans.HomingInstance
+
import static org.apache.commons.lang3.StringUtils.*
import org.camunda.bpm.engine.delegate.BpmnError
@@ -31,6 +33,7 @@ import org.onap.so.bpmn.common.scripts.ExceptionUtil
import org.onap.so.bpmn.common.scripts.MsoUtils
import org.onap.so.bpmn.common.scripts.SDNCAdapterUtils
import org.onap.so.bpmn.common.scripts.VidUtils
+import org.onap.so.bpmn.common.util.OofInfraUtils
import org.onap.so.bpmn.core.RollbackData
import org.onap.so.bpmn.core.UrnPropertiesReader
import org.onap.so.bpmn.core.WorkflowException
@@ -61,6 +64,7 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
JsonUtils jsonUtil = new JsonUtils()
VidUtils vidUtils = new VidUtils(this)
SDNCAdapterUtils sdncAdapterUtils = new SDNCAdapterUtils(this)
+ OofInfraUtils oofInfraUtils = new OofInfraUtils()
/**
* This method gets and validates the incoming
@@ -238,6 +242,21 @@ class DoCreateVnf extends AbstractServiceTaskProcessor {
execution.setVariable("DoCVNF_nfFunction", nfFunction)
msoLogger.debug("NF Function is: " + nfFunction)
+ // Set Homing Info
+ try {
+ HomingInstance homingInstance = oofInfraUtils.getHomingInstance(serviceInstanceId, execution)
+ if (homingInstance != null) {
+ execution.setVariable("DoCVNF_cloudSiteId", homingInstance.getCloudRegionId())
+ rollbackData.put("VNF", "cloudSiteId", homingInstance.getCloudRegionId())
+ msoLogger.debug("Overwriting cloudSiteId with homing cloudSiteId: " +
+ homingInstance.getCloudRegionId())
+ }
+ } catch (Exception exception) {
+ msoLogger.debug("Could not find homing information for service instance: " + serviceInstanceId +
+ "... continuing")
+ msoLogger.debug("Could not find homing information for service instance error: " + exception)
+ }
+
rollbackData.put("VNF", "rollbackSDNCAssign", "false")
rollbackData.put("VNF", "rollbackSDNCActivate", "false")
rollbackData.put("VNF", "rollbackVnfCreate", "false")
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java
new file mode 100644
index 0000000000..ef474be159
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/HomingInstance.java
@@ -0,0 +1,152 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.so.db.catalog.beans;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.openpojo.business.annotation.BusinessKey;
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import uk.co.blackpepper.bowman.annotation.RemoteResource;
+import uk.co.blackpepper.bowman.annotation.ResourceId;
+
+import javax.persistence.Column;
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.Table;
+import javax.persistence.Transient;
+import java.net.URI;
+
+/**
+ * EntityBean class for a HomingInstance. This bean represents a homing instance
+ * of a service, populated on successful homing
+ *
+ */
+@RemoteResource("/homingInstance")
+@Entity
+@Table(name = "homing_instances")
+public class HomingInstance {
+ @JsonProperty
+ @BusinessKey
+ @Id
+ @Column(name = "SERVICE_INSTANCE_ID")
+ private String serviceInstanceId;
+
+ @JsonProperty("cloud_region_id")
+ @BusinessKey
+ @Column(name = "CLOUD_REGION_ID")
+ private String cloudRegionId;
+
+ @JsonProperty("cloud_owner")
+ @BusinessKey
+ @Column(name = "CLOUD_OWNER")
+ private String cloudOwner;
+
+
+
+ @JsonProperty("oof_directives")
+ @BusinessKey
+ @Column(name = "OOF_DIRECTIVES", columnDefinition = "LONGTEXT")
+ private String oofDirectives;
+
+ @Transient
+ private URI uri;
+
+ public HomingInstance () {
+
+ }
+
+ public HomingInstance (HomingInstance homingInstance) {
+ this.serviceInstanceId = homingInstance.getServiceInstanceId();
+ this.cloudRegionId = homingInstance.getCloudRegionId();
+ this.cloudOwner = homingInstance.getCloudOwner();
+ this.oofDirectives = homingInstance.getOofDirectives();
+ }
+
+
+ public String getServiceInstanceId() {
+ return this.serviceInstanceId;
+ }
+
+ public void setServiceInstanceId(String serviceInstanceId) {
+
+ this.serviceInstanceId = serviceInstanceId;
+ }
+
+ public String getCloudRegionId() {
+
+ return this.cloudRegionId;
+ }
+
+ public void setCloudRegionId(String cloudRegionId) {
+
+ this.cloudRegionId = cloudRegionId;
+ }
+
+ public String getCloudOwner() {
+
+ return this.cloudOwner;
+ }
+
+ public void setCloudOwner (String cloudOwner) {
+
+ this.cloudOwner = cloudOwner;
+ }
+
+ public String getOofDirectives() {
+ return oofDirectives;
+ }
+
+ public void setOofDirectives(String oofDirectives) {
+ this.oofDirectives = oofDirectives;
+ }
+
+ @ResourceId
+ public URI getUri() {
+ return this.uri;
+ }
+
+ public void setUri(URI uri) {
+
+ this.uri = uri;
+ }
+
+ @Override
+ public String toString() {
+ return new ToStringBuilder(this).append("serviceInstanceId", serviceInstanceId)
+ .append("cloudRegionId", cloudRegionId)
+ .append("cloudOwner", cloudOwner)
+ .append("oofDirectives", oofDirectives).toString();
+ }
+
+ @Override
+ public boolean equals(final Object other) {
+ if (!(other instanceof HomingInstance)) {
+ return false;
+ }
+ HomingInstance castOther = (HomingInstance) other;
+ return new EqualsBuilder().append(serviceInstanceId, castOther.serviceInstanceId).isEquals();
+ }
+
+ @Override
+ public int hashCode() {
+ return new HashCodeBuilder().append(serviceInstanceId).toHashCode();
+ }
+}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
index 8a61102322..98addf90aa 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/client/CatalogDbClient.java
@@ -36,6 +36,7 @@ import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization
import org.onap.so.db.catalog.beans.ControllerSelectionReference;
import org.onap.so.db.catalog.beans.CvnfcCustomization;
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.NetworkCollectionResourceCustomization;
import org.onap.so.db.catalog.beans.NetworkRecipe;
@@ -125,6 +126,7 @@ public class CatalogDbClient {
private static final String WORK_STEP = "workStep";
private static final String CLLI = "clli";
private static final String CLOUD_VERSION = "cloudVersion";
+ private static final String HOMING_INSTANCE = "/homingInstance";
private static final String TARGET_ENTITY = "SO:CatalogDB";
@@ -153,6 +155,8 @@ public class CatalogDbClient {
private String findOneByActionAndRequestScopeAndIsAlacarte = "/findOneByActionAndRequestScopeAndIsAlacarte";
private String findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep = "/findOneByFlowNameAndServiceTypeAndVnfTypeAndErrorCodeAndWorkStep";
private String findByClliAndCloudVersion = "/findByClliAndCloudVersion";
+ private String findServiceByServiceInstanceId = "/findServiceByServiceInstanceId";
+
private String serviceURI;
private String vfModuleURI;
@@ -165,6 +169,7 @@ public class CatalogDbClient {
private String instanceGroupURI;
private String cloudifyManagerURI;
private String cloudSiteURI;
+ private String homingInstanceURI;
private final Client<Service> serviceClient;
@@ -210,6 +215,8 @@ public class CatalogDbClient {
private final Client<CloudSite> cloudSiteClient;
+ private final Client<HomingInstance> homingInstanceClient;
+
private final Client<CloudifyManager> cloudifyManagerClient;
private Client<CvnfcCustomization> cvnfcCustomizationClient;
@@ -262,6 +269,7 @@ public class CatalogDbClient {
instanceGroupURI = endpoint + INSTANCE_GROUP + URI_SEPARATOR;
cloudifyManagerURI = endpoint + CLOUDIFY_MANAGER + URI_SEPARATOR;
cloudSiteURI = endpoint + CLOUD_SITE + URI_SEPARATOR;
+ homingInstanceURI = endpoint + HOMING_INSTANCE + URI_SEPARATOR;
}
@@ -300,6 +308,7 @@ public class CatalogDbClient {
networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
cloudSiteClient = clientFactory.create(CloudSite.class);
+ homingInstanceClient = clientFactory.create(HomingInstance.class);
cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
@@ -342,6 +351,7 @@ public class CatalogDbClient {
networkCollectionResourceCustomizationClient = clientFactory.create(NetworkCollectionResourceCustomization.class);
collectionNetworkResourceCustomizationClient = clientFactory.create(CollectionNetworkResourceCustomization.class);
cloudSiteClient = clientFactory.create(CloudSite.class);
+ homingInstanceClient = clientFactory.create(HomingInstance.class);
cloudifyManagerClient = clientFactory.create(CloudifyManager.class);
serviceRecipeClient = clientFactory.create(ServiceRecipe.class);
cvnfcCustomizationClient = clientFactory.create(CvnfcCustomization.class);
@@ -583,7 +593,13 @@ public class CatalogDbClient {
}
public CloudSite getCloudSite(String id){
- return this.getSingleResource(cloudSiteClient, getUri(cloudSiteURI + id));
+ return this.getSingleResource(cloudSiteClient,
+ getUri(cloudSiteURI + id));
+ }
+
+ public CloudSite getCloudSite(String id, String uri){
+ return this.getSingleResource(cloudSiteClient,
+ getUri(uri + id));
}
public void postCloudSite(CloudSite cloudSite){
@@ -596,6 +612,20 @@ public class CatalogDbClient {
.queryParam(CLLI,clli).queryParam(CLOUD_VERSION,cloudVersion).build().toString()));
}
+ public HomingInstance getHomingInstance (String serviceInstanceId){
+ return this.getSingleResource(homingInstanceClient,
+ getUri(homingInstanceURI + serviceInstanceId));
+ }
+
+ public HomingInstance getHomingInstance (String serviceInstanceId, String uri){
+ return this.getSingleResource(homingInstanceClient,
+ getUri(uri + serviceInstanceId));
+ }
+
+ public void postHomingInstance(HomingInstance homingInstance){
+ this.postSingleResource(homingInstanceClient, homingInstance);
+ }
+
public Service getServiceByModelVersionAndModelInvariantUUID(String modelVersion, String modelInvariantUUID) {
return this.getSingleResource(serviceClient, getUri(UriBuilder
.fromUri(findFirstByModelVersionAndModelInvariantUUIDURI)
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java
new file mode 100644
index 0000000000..aea8d3e537
--- /dev/null
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/data/repository/HomingInstanceRepository.java
@@ -0,0 +1,30 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2018. Intel Corp. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.db.catalog.data.repository;
+
+import org.onap.so.db.catalog.beans.HomingInstance;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.rest.core.annotation.RepositoryRestResource;
+
+@RepositoryRestResource(collectionResourceRel = "homingInstance", path = "homingInstance")
+public interface HomingInstanceRepository extends JpaRepository<HomingInstance, String> {
+ HomingInstance findServiceByServiceInstanceId(String serviceInstanceId);
+}