aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java4
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java64
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java18
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java14
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java6
-rw-r--r--adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java6
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java98
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java12
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java119
-rw-r--r--adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql2
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java74
-rw-r--r--adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java65
-rw-r--r--adapters/mso-openstack-adapters/src/test/resources/schema.sql1
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml6
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml6
-rwxr-xr-xadapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java5
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java100
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java11
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java8
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java36
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java3
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java4
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java20
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java38
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml16
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java51
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java72
-rw-r--r--adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java47
-rw-r--r--asdc-controller/src/test/resources/schema.sql1
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java9
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java17
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java1
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java23
-rw-r--r--bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java3
-rw-r--r--bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java13
-rw-r--r--common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java2
-rw-r--r--common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java2
-rw-r--r--docs/Developer_Info.rst2
-rw-r--r--docs/architecture/SO Internal Arc.pptxbin56617 -> 58944 bytes
-rw-r--r--docs/developer_info/developer_information.rst1
-rw-r--r--docs/images/SO_1.pngbin75897 -> 58590 bytes
-rw-r--r--docs/index.rst2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql1
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java31
-rw-r--r--mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java14
-rw-r--r--mso-catalog-db/src/test/resources/schema.sql1
49 files changed, 764 insertions, 294 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
index a21db78cee..723bed17f7 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java
@@ -70,7 +70,7 @@ public class MsoHeatEnvironmentEntry {
logger.debug("Exception:", e);
this.valid = false;
this.errorString = e.getMessage();
- // e.printStackTrace();
+
}
}
@@ -173,7 +173,7 @@ public class MsoHeatEnvironmentEntry {
// Basically give back the envt - but exclude the params that aren't in the HeatTemplate
StringBuilder sb = new StringBuilder();
- ArrayList<String> paramNameList = new ArrayList<String>(params.size());
+ ArrayList<String> paramNameList = new ArrayList<>(params.size());
for (HeatTemplateParam htp : params) {
paramNameList.add(htp.getParamName());
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
index b54301509f..3dba412237 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtils.java
@@ -100,6 +100,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
protected static final String HEAT_ERROR = "HeatError";
protected static final String CREATE_STACK = "CreateStack";
+ public static final String FOUND = "Found: {}";
+ public static final String EXCEPTION_ROLLING_BACK_STACK =
+ "{} Create Stack: Nested exception rolling back stack: {} ";
+ public static final String IN_PROGRESS = "in_progress";
// Fetch cloud configuration each time (may be cached in CloudConfig class)
@Autowired
@@ -124,8 +128,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
private String deletePollIntervalProp = "org.onap.so.adapters.po.pollInterval";
private String deletePollTimeoutProp = "org.onap.so.adapters.po.pollTimeout";
- protected static final String createPollIntervalDefault = "15";
- private static final String deletePollIntervalDefault = "15";
+ protected static final String CREATE_POLL_INTERVAL_DEFAULT = "15";
+ private static final String DELETE_POLL_INTERVAL_DEFAULT = "15";
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
@@ -226,11 +230,11 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug("Found: {}", cloudSite);
+ logger.debug(FOUND, cloudSite);
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
// This could throw MsoTenantNotFound or MsoOpenstackException (both propagated)
Heat heatClient = getHeatClient(cloudSite, tenantId);
- logger.debug("Found: {}", heatClient);
+ logger.debug(FOUND, heatClient);
logger.debug("Ready to Create Stack ({}) with input params: {}", heatTemplate, stackInputs);
@@ -276,7 +280,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
boolean backout, Heat heatClient, Stack heatStack, String canonicalName)
throws MsoException, MsoOpenstackException {
int createPollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
int deletePollInterval = createPollInterval;
int deletePollTimeout = pollTimeout;
@@ -361,15 +365,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
} catch (Exception e3) {
// Just log this one. We will report the original exception.
- logger.error("{} Create Stack: Nested exception rolling back stack: {} ",
- MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(),
- e3);
+ logger.error(EXCEPTION_ROLLING_BACK_STACK, MessageEnum.RA_CREATE_STACK_ERR,
+ ErrorCode.BusinessProcesssError.getValue(), e3);
}
}
} catch (Exception e2) {
// Just log this one. We will report the original exception.
- logger.error("{} Create Stack: Nested exception rolling back stack: {} ",
- MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e2);
+ logger.error(EXCEPTION_ROLLING_BACK_STACK, MessageEnum.RA_CREATE_STACK_ERR,
+ ErrorCode.BusinessProcesssError.getValue(), e2);
}
}
@@ -465,8 +468,8 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
}
} catch (Exception e2) {
// shouldn't happen - but handle
- logger.error("{} Create Stack: Nested exception rolling back stack: {} ",
- MessageEnum.RA_CREATE_STACK_ERR, ErrorCode.BusinessProcesssError.getValue(), e2);
+ logger.error(EXCEPTION_ROLLING_BACK_STACK, MessageEnum.RA_CREATE_STACK_ERR,
+ ErrorCode.BusinessProcesssError.getValue(), e2);
}
}
MsoOpenstackException me = new MsoOpenstackException(0, "", stackErrorStatusReason.toString());
@@ -494,14 +497,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug("Found: {}", cloudSite.toString());
+ logger.debug(FOUND, cloudSite.toString());
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
Heat heatClient = null;
try {
heatClient = getHeatClient(cloudSite, tenantId);
if (heatClient != null) {
- logger.debug("Found: {}", heatClient.toString());
+ logger.debug(FOUND, heatClient.toString());
}
} catch (MsoTenantNotFound e) {
// Tenant doesn't exist, so stack doesn't either
@@ -553,14 +556,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain the cloud site information where we will create the stack
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
- logger.debug("Found: {}", cloudSite.toString());
+ logger.debug(FOUND, cloudSite.toString());
// Get a Heat client. They are cached between calls (keyed by tenantId:cloudId)
Heat heatClient = null;
try {
heatClient = getHeatClient(cloudSite, tenantId);
if (heatClient != null) {
- logger.debug("Found: {}", heatClient.toString());
+ logger.debug(FOUND, heatClient.toString());
}
} catch (MsoTenantNotFound e) {
// Tenant doesn't exist, so stack doesn't either
@@ -621,9 +624,9 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Set a timeout on polling
int pollInterval = Integer
- .parseInt(this.environment.getProperty(deletePollIntervalProp, "" + deletePollIntervalDefault));
+ .parseInt(this.environment.getProperty(deletePollIntervalProp, "" + DELETE_POLL_INTERVAL_DEFAULT));
int pollTimeout = Integer
- .parseInt(this.environment.getProperty(deletePollTimeoutProp, "" + deletePollIntervalDefault));
+ .parseInt(this.environment.getProperty(deletePollTimeoutProp, "" + DELETE_POLL_INTERVAL_DEFAULT));
// When querying by canonical name, Openstack returns DELETE_COMPLETE status
// instead of "404" (which would result from query by stack name).
@@ -805,14 +808,14 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
// Obtain an MSO token for the tenant
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- logger.debug("Found: {}", cloudIdentity.toString());
+ logger.debug(FOUND, cloudIdentity.toString());
MsoTenantUtils tenantUtils =
tenantUtilsFactory.getTenantUtilsByServerType(cloudIdentity.getIdentityServerType());
String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
logger.debug("keystoneUrl={}", keystoneUrl);
String heatUrl = null;
String tokenId = null;
- Calendar expiration = null;
+
try {
if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
@@ -849,12 +852,12 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
throw new MsoAdapterException(error, e);
}
tokenId = access.getToken().getId();
- expiration = access.getToken().getExpires();
+
} else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
try {
KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "orchestration");
tokenId = holder.getId();
- expiration = holder.getexpiration();
+
heatUrl = holder.getServiceUrl();
} catch (ServiceEndpointNotFoundException e) {
// This comes back for not found (probably an incorrect region ID)
@@ -1027,8 +1030,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
private String convertNode(final JsonNode node) {
try {
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
+ return JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
logger.debug("Error converting json to string {} ", e.getMessage(), e);
}
@@ -1321,19 +1323,19 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
* This helpful method added for Valet
*/
public String getCloudSiteKeystoneUrl(String cloudSiteId) throws MsoCloudSiteNotFound {
- String keystone_url = null;
+ String keystoneUrl = null;
try {
CloudSite cloudSite =
cloudConfig.getCloudSite(cloudSiteId).orElseThrow(() -> new MsoCloudSiteNotFound(cloudSiteId));
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- keystone_url = cloudIdentity.getIdentityUrl();
+ keystoneUrl = cloudIdentity.getIdentityUrl();
} catch (Exception e) {
throw new MsoCloudSiteNotFound(cloudSiteId);
}
- if (keystone_url == null || keystone_url.isEmpty()) {
+ if (keystoneUrl == null || keystoneUrl.isEmpty()) {
throw new MsoCloudSiteNotFound(cloudSiteId);
}
- return keystone_url;
+ return keystoneUrl;
}
/*
@@ -1550,7 +1552,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
if (heatStatus == HeatStatus.INIT || heatStatus == HeatStatus.BUILDING) {
vduStatus.setState(VduStateType.INSTANTIATING);
- vduStatus.setLastAction((new PluginAction("create", "in_progress", statusMessage)));
+ vduStatus.setLastAction((new PluginAction("create", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.NOTFOUND) {
vduStatus.setState(VduStateType.NOTFOUND);
} else if (heatStatus == HeatStatus.CREATED) {
@@ -1561,10 +1563,10 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin {
vduStatus.setLastAction((new PluginAction("update", "complete", statusMessage)));
} else if (heatStatus == HeatStatus.UPDATING) {
vduStatus.setState(VduStateType.UPDATING);
- vduStatus.setLastAction((new PluginAction("update", "in_progress", statusMessage)));
+ vduStatus.setLastAction((new PluginAction("update", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.DELETING) {
vduStatus.setState(VduStateType.DELETING);
- vduStatus.setLastAction((new PluginAction("delete", "in_progress", statusMessage)));
+ vduStatus.setLastAction((new PluginAction("delete", IN_PROGRESS, statusMessage)));
} else if (heatStatus == HeatStatus.FAILED) {
vduStatus.setState(VduStateType.FAILED);
vduStatus.setErrorMessage(stackInfo.getStatusMessage());
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
index 1bf780f6d3..a2e386adea 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatUtilsWithUpdate.java
@@ -60,6 +60,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
private static final Logger logger = LoggerFactory.getLogger(MsoHeatUtilsWithUpdate.class);
private static final ObjectMapper JSON_MAPPER = new ObjectMapper();
+ public static final String EXCEPTION = "Exception :";
@Autowired
private Environment environment;
@@ -221,8 +222,8 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
// Set a time limit on overall polling.
// Use the resource (template) timeout for Openstack (expressed in minutes)
// and add one poll interval to give Openstack a chance to fail on its own.
- int createPollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ int createPollInterval = Integer
+ .parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
boolean loopAgain = true;
@@ -335,7 +336,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
String str = JSON_MAPPER.writeValueAsString(obj);
sb.append(str).append(" (a java.util.LinkedHashMap)");
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
sb.append("(a LinkedHashMap value that would not convert nicely)");
}
} else if (obj instanceof Integer) {
@@ -343,7 +344,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (an Integer)\n";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(an Integer unable to call .toString() on)";
}
sb.append(str);
@@ -352,7 +353,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (an ArrayList)";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(an ArrayList unable to call .toString() on?)";
}
sb.append(str);
@@ -361,7 +362,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (a Boolean)";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(an Boolean unable to call .toString() on?)";
}
sb.append(str);
@@ -370,7 +371,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
try {
str = obj.toString() + " (unknown Object type)";
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
str = "(a value unable to call .toString() on?)";
}
sb.append(str);
@@ -384,8 +385,7 @@ public class MsoHeatUtilsWithUpdate extends MsoHeatUtils {
private String convertNodeWithUpdate(final JsonNode node) {
try {
final Object obj = JSON_MAPPER.treeToValue(node, Object.class);
- final String json = JSON_MAPPER.writeValueAsString(obj);
- return json;
+ return JSON_MAPPER.writeValueAsString(obj);
} catch (Exception e) {
logger.debug("Error converting json to string {} ", e.getMessage(), e);
}
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
index cfc8c23c5f..ab93a6c4c6 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoKeystoneUtils.java
@@ -58,6 +58,7 @@ import org.springframework.stereotype.Component;
@Component
public class MsoKeystoneUtils extends MsoTenantUtils {
+ public static final String DELETE_TENANT = "Delete Tenant";
private static Logger logger = LoggerFactory.getLogger(MsoKeystoneUtils.class);
@Autowired
@@ -207,7 +208,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- Map<String, String> metadata = new HashMap<String, String>();
+ Map<String, String> metadata = new HashMap<>();
if (cloudSite.getIdentityService().getTenantMetadata()) {
OpenStackRequest<Metadata> request = keystoneAdminClient.tenants().showMetadata(tenant.getId());
Metadata tenantMetadata = executeAndRecordOpenstackRequest(request);
@@ -252,7 +253,7 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
return null;
}
- Map<String, String> metadata = new HashMap<String, String>();
+ Map<String, String> metadata = new HashMap<>();
if (cloudSite.getIdentityService().getTenantMetadata()) {
OpenStackRequest<Metadata> request = keystoneAdminClient.tenants().showMetadata(tenant.getId());
Metadata tenantMetadata = executeAndRecordOpenstackRequest(request);
@@ -304,10 +305,10 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
logger.debug("Deleted Tenant {} ({})", tenant.getId(), tenant.getName());
} catch (OpenStackBaseException e) {
// Convert Keystone OpenStackResponseException to MsoOpenstackException
- throw keystoneErrorToMsoException(e, "Delete Tenant");
+ throw keystoneErrorToMsoException(e, DELETE_TENANT);
} catch (RuntimeException e) {
// Catch-all
- throw runtimeExceptionToMsoException(e, "DeleteTenant");
+ throw runtimeExceptionToMsoException(e, DELETE_TENANT);
}
return true;
@@ -354,10 +355,10 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
} catch (OpenStackBaseException e) {
// Note: It doesn't seem to matter if tenant doesn't exist, no exception is thrown.
// Convert Keystone OpenStackResponseException to MsoOpenstackException
- throw keystoneErrorToMsoException(e, "DeleteTenant");
+ throw keystoneErrorToMsoException(e, DELETE_TENANT);
} catch (RuntimeException e) {
// Catch-all
- throw runtimeExceptionToMsoException(e, "DeleteTenant");
+ throw runtimeExceptionToMsoException(e, DELETE_TENANT);
}
return true;
@@ -379,7 +380,6 @@ public class MsoKeystoneUtils extends MsoTenantUtils {
public Keystone getKeystoneAdminClient(CloudSite cloudSite) throws MsoException {
CloudIdentity cloudIdentity = cloudSite.getIdentityService();
- String cloudId = cloudIdentity.getId();
String adminTenantName = cloudIdentity.getAdminTenant();
String region = cloudSite.getRegionId();
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
index e16bf90d4d..dc5ff0dcca 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoMulticloudUtils.java
@@ -467,7 +467,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
}
int updatePollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ Integer.parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + updatePollInterval;
boolean updateTimedOut = false;
logger.debug("updatePollInterval=" + updatePollInterval + ", pollTimeout=" + pollTimeout);
@@ -535,8 +535,8 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin {
// Use the resource (template) timeout for Openstack (expressed in minutes)
// and add one poll interval to give Openstack a chance to fail on its own.s
- int createPollInterval =
- Integer.parseInt(this.environment.getProperty(createPollIntervalProp, createPollIntervalDefault));
+ int createPollInterval = Integer
+ .parseInt(this.environment.getProperty(createPollIntervalProp, CREATE_POLL_INTERVAL_DEFAULT));
int pollTimeout = (timeoutMinutes * 60) + createPollInterval;
// New 1610 - poll on delete if we rollback - use same values for now
int deletePollInterval = createPollInterval;
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
index 78db27f65e..6f08afc55f 100644
--- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
+++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoNeutronUtils.java
@@ -373,7 +373,7 @@ public class MsoNeutronUtils extends MsoCommonUtils {
final String keystoneUrl = tenantUtils.getKeystoneUrl(cloudId, cloudIdentity);
String neutronUrl = null;
String tokenId = null;
- Calendar expiration = null;
+
try {
if (ServerType.KEYSTONE.equals(cloudIdentity.getIdentityServerType())) {
Keystone keystoneTenantClient = new Keystone(keystoneUrl);
@@ -396,12 +396,12 @@ public class MsoNeutronUtils extends MsoCommonUtils {
throw new MsoAdapterException(error, e);
}
tokenId = access.getToken().getId();
- expiration = access.getToken().getExpires();
+
} else if (ServerType.KEYSTONE_V3.equals(cloudIdentity.getIdentityServerType())) {
try {
KeystoneAuthHolder holder = keystoneV3Authentication.getToken(cloudSite, tenantId, "network");
tokenId = holder.getId();
- expiration = holder.getexpiration();
+
neutronUrl = holder.getServiceUrl();
if (!neutronUrl.endsWith("/")) {
neutronUrl += "/v2.0/";
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
new file mode 100644
index 0000000000..c15b0d9df1
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroups.java
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import org.onap.so.db.catalog.beans.InstanceGroup;
+import org.onap.so.db.catalog.beans.VFCInstanceGroup;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement(name = "groups")
+public class QueryGroups extends CatalogQuery {
+
+ private List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations;
+ private static final String TEMPLATE = "\n" + "\t{ \"modelInfo\" : {\n"
+ + "\t\t\"modelName\" : <MODEL_NAME>,\n" + "\t\t\"modelUuid\" : <MODEL_UUID>,\n"
+ + "\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"
+ + "\t\t\"modelVersion\" : <MODEL_VERSION>\n" + "\t\t},\n" + "<_VNFCS_>\n" + "\t}";
+
+ public QueryGroups() {
+ super();
+ vnfcInstanceGroupCustomizations = new ArrayList<>();
+
+ }
+
+ public QueryGroups(List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations) {
+ this.vnfcInstanceGroupCustomizations = new ArrayList<>();
+ if (vnfcInstanceGroupCustomizations != null) {
+ for (VnfcInstanceGroupCustomization g : vnfcInstanceGroupCustomizations) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(g.toString());
+ }
+ this.vnfcInstanceGroupCustomizations.add(g);
+ }
+ }
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray)
+ sb.append("{ ");
+ if (isArray)
+ sb.append("\"groups\": [");
+ Map<String, String> valueMap = new HashMap<>();
+ String sep = "";
+ boolean first = true;
+
+ for (VnfcInstanceGroupCustomization o : vnfcInstanceGroupCustomizations) {
+ if (first)
+ sb.append("\n");
+ first = false;
+
+ boolean vnfcCustomizationNull = o.getVnfcCustomizations() == null;
+ InstanceGroup instanceGroup = o.getInstanceGroup();
+
+ if (instanceGroup != null) {
+ put(valueMap, "MODEL_NAME", instanceGroup.getModelName());
+ put(valueMap, "MODEL_UUID", instanceGroup.getModelInvariantUUID());
+ put(valueMap, "MODEL_INVARIANT_ID", instanceGroup.getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", instanceGroup.getModelUUID());
+ }
+
+ String subItem = new QueryVnfcs(vnfcCustomizationNull ? null : o.getVnfcCustomizations()).JSON2(true, true);
+ valueMap.put("_VNFCS_", subItem.replaceAll("(?m)^", "\t\t"));
+ sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
+ sep = ",\n";
+ }
+ if (!first)
+ sb.append("\n");
+ if (isArray)
+ sb.append("]");
+ if (!isEmbed && isArray)
+ sb.append("}");
+ return sb.toString();
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
index f786f25361..e5241a4e95 100644
--- a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryServiceVnfs.java
@@ -25,8 +25,12 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import javax.xml.bind.annotation.XmlRootElement;
+import org.onap.so.db.catalog.beans.InstanceGroup;
+import org.onap.so.db.catalog.beans.VFCInstanceGroup;
import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -45,7 +49,7 @@ public class QueryServiceVnfs extends CatalogQuery {
+ "\t\"nfFunction\" : <NF_FUNCTION>,\n" + "\t\"nfType\" : <NF_TYPE>,\n"
+ "\t\"nfRole\" : <NF_ROLE>,\n" + "\t\"nfNamingCode\" : <NF_NAMING_CODE>,\n"
+ "\t\"multiStageDesign\" : <MULTI_STEP_DESIGN>,\n"
- + "\t\"resourceInput\" : <RESOURCE_INPUT>,\n" + "<_VFMODULES_>\n" + "\t}";
+ + "\t\"resourceInput\" : <RESOURCE_INPUT>,\n" + "<_VFMODULES_>,\n" + "<_GROUPS_>\n" + "\t}";
public QueryServiceVnfs() {
super();
@@ -120,6 +124,12 @@ public class QueryServiceVnfs extends CatalogQuery {
String subitem = new QueryVfModule(vrNull ? null : o.getVfModuleCustomizations()).JSON2(true, true);
valueMap.put("_VFMODULES_", subitem.replaceAll("(?m)^", "\t\t"));
+ List<VnfcInstanceGroupCustomization> vnfcInstanceGroupCustomizations =
+ o.getVnfcInstanceGroupCustomizations();
+
+ String grpSubItem = new QueryGroups(vrNull ? null : vnfcInstanceGroupCustomizations).JSON2(true, true);
+ valueMap.put("_GROUPS_", grpSubItem.replaceAll("(?m)^", "\t\t"));
+
sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
sep = ",\n";
}
diff --git a/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java
new file mode 100644
index 0000000000..0bf82fd8b7
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcs.java
@@ -0,0 +1,119 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import org.onap.so.db.catalog.beans.VnfcCustomization;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@XmlRootElement(name = "vnfcs")
+public class QueryVnfcs extends CatalogQuery {
+ private List<VnfcCustomization> vnfcCustomizations;
+ private static final String TEMPLATE =
+ "\t{\n" + "\t\t\"modelInfo\" : { \n" + "\t\t\t\"modelName\" : <MODEL_NAME>,\n"
+ + "\t\t\t\"modelUuid\" : <MODEL_UUID>,\n"
+ + "\t\t\t\"modelInvariantUuid\" : <MODEL_INVARIANT_ID>,\n"
+ + "\t\t\t\"modelVersion\" : <MODEL_VERSION>,\n"
+ + "\t\t\t\"modelCustomizationUuid\" : <MODEL_CUSTOMIZATION_UUID>\n" + "\t\t}" + "\t}";
+
+ public QueryVnfcs() {
+ super();
+ vnfcCustomizations = new ArrayList();
+ }
+
+ public QueryVnfcs(List<VnfcCustomization> vnfcCustomizations) {
+ this.vnfcCustomizations = new ArrayList();
+ if (vnfcCustomizations != null) {
+ for (VnfcCustomization vnfcCustomization : vnfcCustomizations) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(vnfcCustomization.toString());
+ }
+ this.vnfcCustomizations.add(vnfcCustomization);
+ }
+ }
+ }
+
+ public List<VnfcCustomization> getVnfcCustomizations() {
+ return vnfcCustomizations;
+ }
+
+ public void setVnfcCustomizations(List<VnfcCustomization> vnfcCustomizations) {
+ this.vnfcCustomizations = vnfcCustomizations;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+
+ boolean first = true;
+ int i = 1;
+ for (VnfcCustomization o : vnfcCustomizations) {
+ sb.append(i).append("\t");
+ if (!first) {
+ sb.append("\n");
+ }
+ first = false;
+ sb.append(o);
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public String JSON2(boolean isArray, boolean isEmbed) {
+ StringBuilder sb = new StringBuilder();
+ if (!isEmbed && isArray) {
+ sb.append("{");
+ }
+
+ if (isArray) {
+ sb.append("\"vnfcs\": [");
+ }
+
+ Map<String, String> valueMap = new HashMap<>();
+ String sep = "";
+ boolean first = true;
+
+ for (VnfcCustomization o : vnfcCustomizations) {
+ if (first)
+ sb.append("\n");
+ first = false;
+
+ put(valueMap, "MODEL_NAME", o.getModelName());
+ put(valueMap, "MODEL_UUID", o.getModelUUID());
+ put(valueMap, "MODEL_INVARIANT_ID", o.getModelInvariantUUID());
+ put(valueMap, "MODEL_VERSION", o.getModelVersion());
+ put(valueMap, "MODEL_CUSTOMIZATION_UUID", o.getModelCustomizationUUID());
+
+ sb.append(sep).append(this.setTemplate(TEMPLATE, valueMap));
+ sep = ",\n";
+ }
+ if (!first)
+ sb.append("\n");
+ if (isArray)
+ sb.append("]");
+ if (!isEmbed && isArray)
+ sb.append("}");
+ return sb.toString();
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql
new file mode 100644
index 0000000000..95a2c25eb8
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V5.12__Add_Relation_VnfcCustomization.sql
@@ -0,0 +1,2 @@
+use catalogdb;
+ALTER TABLE vnfc_customization ADD vnfc_instance_group_customization_id INTEGER NULL; \ No newline at end of file
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java
new file mode 100644
index 0000000000..00db6d5938
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryGroupsTest.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import org.assertj.core.api.Assertions;
+import org.junit.Test;
+import org.onap.so.db.catalog.beans.Service;
+import org.onap.so.db.catalog.beans.VFCInstanceGroup;
+import org.onap.so.db.catalog.beans.VnfResource;
+import org.onap.so.db.catalog.beans.VnfResourceCustomization;
+import org.onap.so.db.catalog.beans.VnfcCustomization;
+import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization;
+import org.onap.so.db.catalog.rest.beans.ServiceMacroHolder;
+import org.onap.so.jsonpath.JsonPathUtil;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class QueryGroupsTest {
+
+ @Test
+ public void convertToJson_successful() {
+ QueryGroups queryGroups = new QueryGroups(createList());
+ String jsonResult = queryGroups.JSON2(true, false);
+
+ Assertions.assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].modelInfo.modelName"))
+ .contains("test");
+ Assertions
+ .assertThat(
+ JsonPathUtil.getInstance().locateResult(jsonResult, "$.groups[0].vnfcs[0].modelInfo.modelName"))
+ .contains("test");
+ }
+
+ private List<VnfcInstanceGroupCustomization> createList() {
+
+ VnfcCustomization vnfcCustomization = new VnfcCustomization();
+ vnfcCustomization.setModelCustomizationUUID("test");
+ vnfcCustomization.setModelVersion("test");
+ vnfcCustomization.setModelInvariantUUID("test");
+ vnfcCustomization.setModelName("test");
+
+ VFCInstanceGroup vfcInstanceGroup = new VFCInstanceGroup();
+ vfcInstanceGroup.setModelName("test");
+ vfcInstanceGroup.setModelUUID("test");
+ vfcInstanceGroup.setModelInvariantUUID("test");
+ vfcInstanceGroup.setModelVersion("test");
+
+ VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization = new VnfcInstanceGroupCustomization();
+ vnfcInstanceGroupCustomization.setVnfcCustomizations(Arrays.asList(vnfcCustomization));
+ vnfcInstanceGroupCustomization.setInstanceGroup(vfcInstanceGroup);
+
+
+ vfcInstanceGroup.setVnfcInstanceGroupCustomizations(Arrays.asList(vnfcInstanceGroupCustomization));
+ return Arrays.asList(vnfcInstanceGroupCustomization);
+ }
+}
diff --git a/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java
new file mode 100644
index 0000000000..1fd4f19e29
--- /dev/null
+++ b/adapters/mso-catalog-db-adapter/src/test/java/org/onap/so/adapters/catalogdb/catalogrest/QueryVnfcsTest.java
@@ -0,0 +1,65 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.so.adapters.catalogdb.catalogrest;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import org.junit.Test;
+import org.onap.so.db.catalog.beans.VnfcCustomization;
+import org.onap.so.jsonpath.JsonPathUtil;
+import java.util.ArrayList;
+import java.util.List;
+
+public class QueryVnfcsTest {
+
+ @Test
+ public void convertToJson_successful() {
+ QueryVnfcs queryVnfcs = new QueryVnfcs(createList());
+ String jsonResult = queryVnfcs.JSON2(true, false);
+ System.out.println(jsonResult);
+ assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[0].modelInfo.modelName"))
+ .contains("model1");
+ assertThat(JsonPathUtil.getInstance().locateResult(jsonResult, "$.vnfcs[1].modelInfo.modelName"))
+ .contains("model2");
+
+ }
+
+ private List<VnfcCustomization> createList() {
+ List<VnfcCustomization> customizations = new ArrayList();
+
+ VnfcCustomization c1 = new VnfcCustomization();
+ c1.setModelName("model1");
+ c1.setModelUUID("uuid1");
+ c1.setModelInvariantUUID("inv1");
+ c1.setModelVersion("v1");
+ c1.setModelCustomizationUUID("cust1");
+
+ VnfcCustomization c2 = new VnfcCustomization();
+ c2.setModelName("model2");
+ c2.setModelUUID("uuid2");
+ c2.setModelInvariantUUID("inv2");
+ c2.setModelVersion("v2");
+ c2.setModelCustomizationUUID("cust2");
+
+ customizations.add(c1);
+ customizations.add(c2);
+ return customizations;
+ }
+}
diff --git a/adapters/mso-openstack-adapters/src/test/resources/schema.sql b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
index 1cf28be926..c700e78868 100644
--- a/adapters/mso-openstack-adapters/src/test/resources/schema.sql
+++ b/adapters/mso-openstack-adapters/src/test/resources/schema.sql
@@ -1135,6 +1135,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
index 66a1cb1ca7..9d9e33a524 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-api/pom.xml
@@ -100,5 +100,10 @@
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
</dependency>
+ <dependency>
+ <groupId>com.squareup.okio</groupId>
+ <artifactId>okio</artifactId>
+ <version>1.13.0</version>
+ </dependency>
</dependencies>
</project>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
index da778d286e..91478e1f8e 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-adapter-ext-clients/pom.xml
@@ -62,7 +62,6 @@
<apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.api</apiPackage>
<modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.lcn.model</modelPackage>
<configOptions>
- <jackson>true</jackson>
<sourceFolder>src/gen/java/main</sourceFolder>
<withXml>true</withXml>
<useRxJava2>true</useRxJava2>
@@ -79,15 +78,16 @@
<inputSpec>${basedir}/src/main/resources/SOL003-VNFLifecycleOperationGranting-API.json
</inputSpec>
<language>java</language>
- <library>retrofit2</library>
+ <library>okhttp-gson</library>
<output>${project.build.directory}/generated-sources/sol003-vnf-grant</output>
- <generateApis>false</generateApis>
+ <apiPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.api</apiPackage>
<modelPackage>org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model</modelPackage>
<configOptions>
<generateSupportingFiles>false</generateSupportingFiles>
<sourceFolder>src/gen/java/main</sourceFolder>
<withXml>true</withXml>
<useRxJava2>true</useRxJava2>
+ <serializableModel>true</serializableModel>
</configOptions>
</configuration>
</execution>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
index c561721b3e..09c28f93f1 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/pom.xml
@@ -63,6 +63,12 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
+ <exclusions>
+ <exclusion>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ </exclusion>
+ </exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
index 30ce0c2253..62d2f7e2a9 100755
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/VnfmAdapterApplication.java
@@ -20,11 +20,13 @@
package org.onap.so.adapters.vnfmadapter;
+import static org.slf4j.LoggerFactory.getLogger;
import org.onap.so.adapters.vnfmadapter.rest.VnfmAdapterController;
import org.slf4j.Logger;
import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-import static org.slf4j.LoggerFactory.getLogger;
+import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration;
/**
* The spring boot application for the VNFM (Virtual Network Function Manager) Adapter.
@@ -36,6 +38,7 @@ import static org.slf4j.LoggerFactory.getLogger;
* SOL003 v2.5.1</a>
*/
@SpringBootApplication(scanBasePackages = {"org.onap.so"})
+@EnableAutoConfiguration(exclude = {JacksonAutoConfiguration.class})
public class VnfmAdapterApplication {
private static final Logger logger = getLogger(VnfmAdapterApplication.class);
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
index f1074bcba8..fd92910e36 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/SdcPackageProvider.java
@@ -22,20 +22,21 @@
package org.onap.so.adapters.vnfmadapter.extclients;
+import static com.google.common.base.Splitter.on;
+import static com.google.common.collect.Iterables.filter;
+import static com.google.common.io.ByteStreams.toByteArray;
+import static java.lang.String.format;
+import static org.apache.http.HttpHeaders.ACCEPT;
+import static org.apache.http.HttpHeaders.AUTHORIZATION;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.abortOperation;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
+import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
+import static org.slf4j.LoggerFactory.getLogger;
+import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
import com.google.common.io.ByteStreams;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
-import org.apache.commons.codec.binary.Base64;
-import org.apache.http.HttpEntity;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClients;
-import org.onap.so.utils.CryptoUtils;
-import org.slf4j.Logger;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
-import org.yaml.snakeyaml.Yaml;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -48,25 +49,24 @@ import java.util.NoSuchElementException;
import java.util.Set;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
-import static com.google.common.base.Splitter.on;
-import static com.google.common.collect.Iterables.filter;
-import static com.google.common.io.ByteStreams.toByteArray;
-import static java.lang.String.format;
-import static org.apache.http.HttpHeaders.ACCEPT;
-import static org.apache.http.HttpHeaders.AUTHORIZATION;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.abortOperation;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.child;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.childElement;
-import static org.onap.so.adapters.vnfmadapter.NvfmAdapterUtils.children;
-import static org.slf4j.LoggerFactory.getLogger;
-import static org.springframework.http.MediaType.APPLICATION_OCTET_STREAM_VALUE;
+import org.apache.commons.codec.binary.Base64;
+import org.apache.http.HttpEntity;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.onap.so.utils.CryptoUtils;
+import org.slf4j.Logger;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+import org.yaml.snakeyaml.Yaml;
@Component
public class SdcPackageProvider {
- private static final String GET_PACKAGE_URL = "%s/catalog/resources/%s/toscaModel";
+ private static final String GET_PACKAGE_URL = "%s/sdc/v1/catalog/resources/%s/toscaModel";
@Value("${sdc.toscametapath:TOSCA-Metadata/TOSCA.meta}")
private List<String> toscaMetaPaths;
- private final String TOSCA_VNFD_KEY = "Entry-Definitions";
+ private static final String TOSCA_VNFD_KEY = "Entry-Definitions";
private static Logger logger = getLogger(SdcPackageProvider.class);
@Value("${sdc.username}")
@@ -78,7 +78,7 @@ public class SdcPackageProvider {
@Value("${sdc.endpoint}")
private String baseUrl;
- public String getVnfdId(String csarId) {
+ public String getVnfdId(final String csarId) {
return getVnfNodeProperty(csarId, "descriptor_id");
}
@@ -96,7 +96,7 @@ public class SdcPackageProvider {
for (final JsonObject child : children(nodeTemplates)) {
final String type = childElement(child, "type").getAsString();
String propertyValue = null;
- if (type.equals("tosca.nodes.nfv.VNF")) {
+ if ("tosca.nodes.nfv.VNF".equals(type)) {
final JsonObject properties = child(child, "properties");
logger.debug("properties: " + properties.toString());
@@ -119,7 +119,7 @@ public class SdcPackageProvider {
final JsonObject nodeTypes = child(root, "node_types");
final JsonObject nodeType = child(nodeTypes, nodeTypeName);
- if (childElement(nodeType, "derived_from").getAsString().equals("tosca.nodes.nfv.VNF")) {
+ if ("tosca.nodes.nfv.VNF".equals(childElement(nodeType, "derived_from").getAsString())) {
final JsonObject properties = child(nodeType, "properties");
logger.debug("properties: " + properties.toString());
final JsonObject property = child(properties, propertyName);
@@ -130,34 +130,33 @@ public class SdcPackageProvider {
return null;
}
- private byte[] getPackage(String csarId) {
+ private byte[] getPackage(final String csarId) {
final String SERVICE_NAME = "vnfm-adapter";
try (CloseableHttpClient client = HttpClients.createDefault()) {
- HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
+ final HttpGet httpget = new HttpGet(format(GET_PACKAGE_URL, baseUrl, csarId));
httpget.setHeader(ACCEPT, APPLICATION_OCTET_STREAM_VALUE);
httpget.setHeader("X-ECOMP-InstanceID", SERVICE_NAME);
httpget.setHeader("X-FromAppId", SERVICE_NAME);
- String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey);
- byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
- String authHeader = "Basic " + new String(encodedAuth);
+ final String auth = sdcUsername + ":" + CryptoUtils.decrypt(sdcPassword, sdcKey);
+ final byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.ISO_8859_1));
+ final String authHeader = "Basic " + new String(encodedAuth);
httpget.setHeader(AUTHORIZATION, authHeader);
logger.debug("Fetching from SDC: " + httpget);
- CloseableHttpResponse response = client.execute(httpget);
- HttpEntity entity = response.getEntity();
- InputStream is = entity.getContent();
- byte[] bytes = toByteArray(is);
- return bytes;
- } catch (Exception e) {
+ final CloseableHttpResponse response = client.execute(httpget);
+ final HttpEntity entity = response.getEntity();
+ final InputStream is = entity.getContent();
+ return toByteArray(is);
+ } catch (final Exception e) {
throw abortOperation("Unable to download " + csarId + " package from SDC", e);
}
}
- private String getVnfdLocation(InputStream stream) throws IOException {
- Iterator pathIterator = toscaMetaPaths.iterator();
+ private String getVnfdLocation(final InputStream stream) throws IOException {
+ final Iterator<String> pathIterator = toscaMetaPaths.iterator();
while (pathIterator.hasNext()) {
- String toscaMetadata = new String(getFileInZip(stream, pathIterator.next().toString()).toByteArray());
+ final String toscaMetadata = new String(getFileInZip(stream, pathIterator.next()).toByteArray());
if (!toscaMetadata.isEmpty()) {
- String toscaVnfdLine =
+ final String toscaVnfdLine =
filter(on("\n").split(toscaMetadata), line -> line.contains(TOSCA_VNFD_KEY)).iterator().next();
return toscaVnfdLine.replace(TOSCA_VNFD_KEY + ":", "").trim();
}
@@ -165,20 +164,21 @@ public class SdcPackageProvider {
throw abortOperation("Unable to find valid Tosca Path");
}
- private static ByteArrayOutputStream getFileInZip(InputStream zip, String path) throws IOException {
- ZipInputStream zipInputStream = new ZipInputStream(zip);
- ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path);
+ private static ByteArrayOutputStream getFileInZip(final InputStream zip, final String path) throws IOException {
+ final ZipInputStream zipInputStream = new ZipInputStream(zip);
+ final ByteArrayOutputStream fileContent = getFileInZip(zipInputStream, path);
zipInputStream.close();
return fileContent;
}
- private static ByteArrayOutputStream getFileInZip(ZipInputStream zipInputStream, String path) throws IOException {
+ private static ByteArrayOutputStream getFileInZip(final ZipInputStream zipInputStream, final String path)
+ throws IOException {
ZipEntry zipEntry;
- Set<String> items = new HashSet<>();
+ final Set<String> items = new HashSet<>();
while ((zipEntry = zipInputStream.getNextEntry()) != null) {
items.add(zipEntry.getName());
if (zipEntry.getName().matches(path)) {
- ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+ final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
ByteStreams.copy(zipInputStream, byteArrayOutputStream);
return byteArrayOutputStream;
}
@@ -187,7 +187,7 @@ public class SdcPackageProvider {
throw new NoSuchElementException("Unable to find the " + path + " in archive found: " + items);
}
- public String getFlavourId(String csarId) {
+ public String getFlavourId(final String csarId) {
return getVnfNodeProperty(csarId, "flavour_id");
}
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
index 50fd5bcf3a..867b6522f5 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiHelper.java
@@ -20,6 +20,9 @@
package org.onap.so.adapters.vnfmadapter.extclients.aai;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
@@ -40,9 +43,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Map;
/**
* Provides helper methods for interactions with AAI.
@@ -257,7 +257,12 @@ public class AaiHelper {
relationship.setRelatedTo("tenant");
relationship.setRelatedLink("/aai/" + AAIVersion.LATEST + AAIUriFactory.createResourceUri(AAIObjectType.TENANT,
tenant.getCloudOwner(), tenant.getRegionName(), tenant.getTenantId()).build().toString());
+ relationship.getRelationshipData()
+ .add(createRelationshipData("cloud-region.cloud-owner", tenant.getCloudOwner()));
+ relationship.getRelationshipData()
+ .add(createRelationshipData("cloud-region.cloud-region-id", tenant.getRegionName()));
relationship.getRelationshipData().add(createRelationshipData("tenant.tenant-id", tenant.getTenantId()));
return relationship;
}
+
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
index f991ffafba..7021c02511 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProvider.java
@@ -24,9 +24,9 @@ import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.EsrVnfmList;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Vserver;
import org.onap.vnfmadapter.v1.model.Tenant;
-import java.util.List;
/**
* Provides methods for invoking REST calls to AAI.
@@ -47,7 +47,7 @@ public interface AaiServiceProvider {
* @param selfLink the selfLink
* @return the matching generic vnfs
*/
- List<GenericVnf> invokeQueryGenericVnf(final String selfLink);
+ GenericVnfs invokeQueryGenericVnf(final String selfLink);
/**
* Invoke a GET request for the VNFMs.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
index fa07ab5720..50e579dd83 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/aai/AaiServiceProviderImpl.java
@@ -24,6 +24,7 @@ import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.EsrVnfmList;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.client.aai.AAIObjectType;
import org.onap.so.client.aai.entities.uri.AAIUriFactory;
@@ -32,7 +33,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
-import java.util.List;
@Service
public class AaiServiceProviderImpl implements AaiServiceProvider {
@@ -56,9 +56,9 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
}
@Override
- public List<GenericVnf> invokeQueryGenericVnf(final String selfLink) {
+ public GenericVnfs invokeQueryGenericVnf(final String selfLink) {
return aaiClientProvider.getAaiClient()
- .get(List.class,
+ .get(GenericVnfs.class,
AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNFS).queryParam("selflink", selfLink))
.orElseGet(() -> {
logger.debug("No vnf found in AAI with selflink: {}", selfLink);
@@ -104,7 +104,7 @@ public class AaiServiceProviderImpl implements AaiServiceProvider {
@Override
public void invokePutVserver(final String cloudOwner, final String cloudRegion, final String tenant,
final Vserver vserver) {
- aaiClientProvider.getAaiClient().update(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
+ aaiClientProvider.getAaiClient().create(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner,
cloudRegion, tenant, vserver.getVserverId()), vserver);
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
index 31399f7720..249cf74cb2 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmHelper.java
@@ -20,10 +20,16 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
import com.google.common.reflect.TypeToken;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
+import java.security.GeneralSecurityException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vim.model.AccessInfo;
@@ -40,7 +46,7 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilte
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.SubscriptionsFilterVnfInstanceSubscriptionFilter;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateExtVirtualLinks;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.VnfInstancesvnfInstanceIdinstantiateVimConnectionInfo;
-import org.onap.so.security.WebSecurityConfig;
+import org.onap.so.utils.CryptoUtils;
import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.ExternalVirtualLink;
import org.onap.vnfmadapter.v1.model.Tenant;
@@ -49,11 +55,6 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
-import static org.onap.so.adapters.vnfmadapter.Constants.OPERATION_NOTIFICATION_ENDPOINT;
/**
* Provides helper methods for interactions with VNFM.
@@ -64,15 +65,19 @@ public class VnfmHelper {
private static final Logger logger = LoggerFactory.getLogger(VnfmHelper.class);
private static final String SEPARATOR = "_";
private final AaiServiceProvider aaiServiceProvider;
- private final WebSecurityConfig webSecurityConfig;
@Value("${vnfmadapter.endpoint}")
private String vnfmAdapterEndoint;
+ @Value("${vnfmadapter.auth:E39823AAB2739CC654C4E92B52C05BC34149342D0A46451B00CA508C8EDC62242CE4E9DA9445D3C01A3F13}")
+ private String vnfmAdapterAuth;
+
+ @Value("${mso.key}")
+ private String msoEncryptionKey;
+
@Autowired
- public VnfmHelper(final AaiServiceProvider aaiServiceProvider, final WebSecurityConfig webSecurityConfig) {
+ public VnfmHelper(final AaiServiceProvider aaiServiceProvider) {
this.aaiServiceProvider = aaiServiceProvider;
- this.webSecurityConfig = webSecurityConfig;
}
/**
@@ -171,8 +176,10 @@ public class VnfmHelper {
*
* @param the ID of the VNF notifications are required for
* @return the request
+ * @throws GeneralSecurityException
*/
- public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId) {
+ public LccnSubscriptionRequest createNotificationSubscriptionRequest(final String vnfId)
+ throws GeneralSecurityException {
final LccnSubscriptionRequest lccnSubscriptionRequest = new LccnSubscriptionRequest();
lccnSubscriptionRequest.setAuthentication(getSubscriptionsAuthentication());
lccnSubscriptionRequest.setCallbackUri(vnfmAdapterEndoint + BASE_URL + OPERATION_NOTIFICATION_ENDPOINT);
@@ -186,12 +193,11 @@ public class VnfmHelper {
return lccnSubscriptionRequest;
}
- private SubscriptionsAuthentication getSubscriptionsAuthentication() {
+ private SubscriptionsAuthentication getSubscriptionsAuthentication() throws GeneralSecurityException {
final SubscriptionsAuthenticationParamsBasic basicAuthParams = new SubscriptionsAuthenticationParamsBasic();
- basicAuthParams.setUserName("vnfm");
- basicAuthParams.setPassword(webSecurityConfig.getUsercredentials().stream()
- .filter(userCredentials -> "vnfm".equals(userCredentials.getUsername())).findFirst().get()
- .getPassword());
+ final String[] decrypedAuth = CryptoUtils.decrypt(vnfmAdapterAuth, msoEncryptionKey).split(":");
+ basicAuthParams.setUserName(decrypedAuth[0]);
+ basicAuthParams.setPassword(decrypedAuth[1]);
final SubscriptionsAuthentication authentication = new SubscriptionsAuthentication();
authentication.addAuthTypeItem(AuthTypeEnum.BASIC);
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
index 951c6f187b..645f37e72f 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmServiceProviderImpl.java
@@ -84,10 +84,12 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
@Override
public InlineResponse2001 subscribeForNotifications(final String vnfmId,
final LccnSubscriptionRequest subscriptionRequest) {
+ logger.info("Subscribing for notifications {}", subscriptionRequest);
final String url = urlProvider.getSubscriptionsUrl(vnfmId);
ResponseEntity<InlineResponse2001> response = null;
try {
response = httpServiceProvider.postHttpRequest(subscriptionRequest, url, InlineResponse2001.class);
+ logger.info("Subscribing for notifications response {}", response);
} catch (final Exception exception) {
final String errorMessage =
"Subscription to VNFM " + vnfmId + " resulted in exception" + subscriptionRequest;
@@ -146,6 +148,7 @@ public class VnfmServiceProviderImpl implements VnfmServiceProvider {
@Override
public Optional<InlineResponse201> createVnf(final String vnfmId, final CreateVnfRequest createVnfRequest) {
final String url = urlProvider.getCreationUrl(vnfmId);
+ logger.debug("Sending create request {} to : {}", createVnfRequest, url);
try {
return httpServiceProvider.post(createVnfRequest, url, InlineResponse201.class);
} catch (final Exception exception) {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
index d4aa65d159..f948f3cfac 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/extclients/vnfm/VnfmUrlProvider.java
@@ -20,6 +20,8 @@
package org.onap.so.adapters.vnfmadapter.extclients.vnfm;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.net.URI;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
@@ -28,8 +30,6 @@ import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.util.UriComponentsBuilder;
-import java.net.URI;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Provides URLs for REST calls to a VNFM.
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
index e6b787bacc..32bb9b93a4 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/lifecycle/LifecycleManager.java
@@ -21,6 +21,7 @@
package org.onap.so.adapters.vnfmadapter.lifecycle;
import com.google.common.base.Optional;
+import java.util.Map;
import org.onap.aai.domain.yang.EsrVnfm;
import org.onap.aai.domain.yang.GenericVnf;
import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
@@ -46,7 +47,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
-import java.util.Map;
/**
* Manages lifecycle operations towards the VNFMs.
@@ -64,7 +64,7 @@ public class LifecycleManager {
@Autowired
LifecycleManager(final AaiServiceProvider aaiServiceProvider, final AaiHelper aaiHelper,
final VnfmHelper vnfmHelper, final VnfmServiceProvider vnfmServiceProvider, final JobManager jobManager,
- SdcPackageProvider packageProvider) {
+ final SdcPackageProvider packageProvider) {
this.aaiServiceProvider = aaiServiceProvider;
this.vnfmServiceProvider = vnfmServiceProvider;
this.aaiHelper = aaiHelper;
@@ -90,7 +90,11 @@ public class LifecycleManager {
aaiHelper.addRelationshipFromGenericVnfToVnfm(genericVnf, vnfm.getVnfmId());
}
aaiHelper.addRelationshipFromGenericVnfToTenant(genericVnf, request.getTenant());
- InlineResponse201 vnfmResponse = sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+ final InlineResponse201 vnfmResponse =
+ sendCreateRequestToVnfm(request, genericVnf, vnfIdInAai, vnfm.getVnfmId());
+
+ logger.info("Create response: {}", vnfmResponse);
+
genericVnf.setSelflink(vnfmResponse.getLinks().getSelf().getHref());
aaiServiceProvider.invokePutGenericVnf(genericVnf);
final String vnfIdInVnfm = vnfmResponse.getId();
@@ -135,18 +139,18 @@ public class LifecycleManager {
}
}
- private InlineResponse201 sendCreateRequestToVnfm(CreateVnfRequest aaiRequest, GenericVnf genericVnf,
- String vnfIdInAai, String vnfmId) {
+ private InlineResponse201 sendCreateRequestToVnfm(final CreateVnfRequest aaiRequest, final GenericVnf genericVnf,
+ final String vnfIdInAai, final String vnfmId) {
logger.debug("Sending a create request to SVNFM " + aaiRequest);
- org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
+ final org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest vnfmRequest =
new org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.CreateVnfRequest();
- String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId());
+ final String vnfdId = packageProvider.getVnfdId(genericVnf.getModelVersionId());
vnfmRequest.setVnfdId(vnfdId);
vnfmRequest.setVnfInstanceName(aaiRequest.getName().replaceAll(" ", "_"));
vnfmRequest.setVnfInstanceDescription(vnfIdInAai);
- Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
+ final Optional<InlineResponse201> optionalResponse = vnfmServiceProvider.createVnf(vnfmId, vnfmRequest);
try {
return optionalResponse.get();
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
index a339b9be70..d39a2cb761 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/notificationhandling/NotificationHandler.java
@@ -20,6 +20,10 @@
package org.onap.so.adapters.vnfmadapter.notificationhandling;
+import static org.slf4j.LoggerFactory.getLogger;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.json.JSONException;
import org.json.JSONObject;
import org.onap.aai.domain.yang.GenericVnf;
@@ -36,10 +40,6 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201VimConnectionInfo;
import org.onap.so.adapters.vnfmadapter.jobmanagement.JobManager;
import org.slf4j.Logger;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import static org.slf4j.LoggerFactory.getLogger;
/**
* Performs updates to AAI based on a received notification. The updates are executed in a separate thread so as the
@@ -93,8 +93,8 @@ public class NotificationHandler implements Runnable {
}
private void handleVnfInstantiateCompleted() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
setOamIpAddress(genericVnf, vnfInstance);
genericVnf.setOrchestrationStatus("Created");
@@ -141,16 +141,16 @@ public class NotificationHandler implements Runnable {
}
private void handleVnfTerminateFailed() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
vnfInstance.getVimConnectionInfo());
jobManager.notificationProcessedForOperation(vnfLcmOperationOccurrenceNotification.getId(), false);
}
private void handleVnfTerminateCompleted() {
- final GenericVnf genericVnf =
- aaiServiceProvider.invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).get(0);
+ final GenericVnf genericVnf = aaiServiceProvider
+ .invokeQueryGenericVnf(vnfInstance.getLinks().getSelf().getHref()).getGenericVnf().get(0);
updateVservers(vnfLcmOperationOccurrenceNotification, genericVnf.getVnfId(),
vnfInstance.getVimConnectionInfo());
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
index 6b8802eed2..e241d0de7e 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantController.java
@@ -20,6 +20,11 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.UUID;
+import javax.ws.rs.core.MediaType;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiHelper;
import org.onap.so.adapters.vnfmadapter.extclients.aai.AaiServiceProvider;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.VnfmHelper;
@@ -36,15 +41,10 @@ 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.RequestMapping;
-import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import javax.ws.rs.core.MediaType;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.UUID;
-import static org.onap.so.adapters.vnfmadapter.Constants.BASE_URL;
+import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping(value = BASE_URL, produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@@ -52,9 +52,6 @@ public class Sol003GrantController {
private static final String SEPARATOR = "_";
private static final String VIM_TYPE = "OPENSTACK";
- private static final String CLOUD_OWNER = "myTestCloudOwner";
- private static final String REGION = "myTestRegion";
- private static final String TENANT_ID = "myTestTenantId";
private static final Logger logger = LoggerFactory.getLogger(Sol003GrantController.class);
public final AaiServiceProvider aaiServiceProvider;
public final AaiHelper aaiHelper;
@@ -71,7 +68,7 @@ public class Sol003GrantController {
@GetMapping(value = "/grants/{grantId}")
public ResponseEntity<InlineResponse201> grantsGrantIdGet(@PathVariable("grantId") final String grantId) {
logger.info("Get grant received from VNFM, grant id: " + grantId);
- return new ResponseEntity<InlineResponse201>(HttpStatus.NOT_IMPLEMENTED);
+ return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
@PostMapping(value = "/grants")
@@ -80,7 +77,7 @@ public class Sol003GrantController {
final InlineResponse201 grantResponse = createGrantResponse(grantRequest);
logger.info("Grant request returning to VNFM: " + grantResponse);
- return new ResponseEntity<InlineResponse201>(grantResponse, HttpStatus.CREATED);
+ return new ResponseEntity<>(grantResponse, HttpStatus.CREATED);
}
private InlineResponse201 createGrantResponse(final GrantRequest grantRequest) {
@@ -88,8 +85,9 @@ public class Sol003GrantController {
grantResponse.setId(UUID.randomUUID().toString());
grantResponse.setVnfInstanceId(grantRequest.getVnfInstanceId());
grantResponse.setVnfLcmOpOccId(grantRequest.getVnfLcmOpOccId());
- final Tenant tenant =
- aaiHelper.getAssignedTenant(aaiServiceProvider.invokeGetGenericVnf((grantRequest.getVnfInstanceId())));
+ final String vnfSelfLink = grantRequest.getLinks().getVnfInstance().getHref();
+ final Tenant tenant = aaiHelper
+ .getAssignedTenant(aaiServiceProvider.invokeQueryGenericVnf(vnfSelfLink).getGenericVnf().get(0));
String vimConnectionId = "";
final InlineResponse201VimConnections vimConnection = vnfmHelper.getVimConnections(tenant);
@@ -104,14 +102,6 @@ public class Sol003GrantController {
return grantResponse;
}
- private InlineResponse201VimConnections getVimConnectionsItem(final Tenant tenant) {
- final InlineResponse201VimConnections vimConnection = new InlineResponse201VimConnections();
- vimConnection.setId(createVimConnectionId(tenant.getCloudOwner(), tenant.getRegionName()));
- vimConnection.setVimId(vimConnection.getId());
- vimConnection.setVimType(VIM_TYPE);
- return vimConnection;
- }
-
private List<InlineResponse201AddResources> getResources(final List<GrantsAddResources> requestResources,
final String vimId) {
final List<InlineResponse201AddResources> resources = new ArrayList<>();
@@ -123,8 +113,4 @@ public class Sol003GrantController {
}
return resources;
}
-
- private String createVimConnectionId(String cloudOwner, String cloudRegionId) {
- return cloudOwner + SEPARATOR + cloudRegionId;
- }
}
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
index 4fb110349d..951d4a3bb9 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/main/resources/application.yaml
@@ -11,6 +11,19 @@
# 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.
+spring:
+ security:
+ usercredentials:
+ - username: test
+ password: '$2a$12$Zi3AuYcZoZO/gBQyUtST2.F5N6HqcTtaNci2Et.ufsQhski56srIu'
+ role: BPEL-Client
+ - username: vnfm
+ password: '$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke'
+ role: BPEL-Client
+ http:
+ converters:
+ preferred-json-mapper: gson
+
server:
port: 9092
tomcat:
@@ -29,6 +42,9 @@ sdc:
password: sdcPassword
key: adadadadad
endpoint: http://sdc.onap/1234A
+
+vnfmadapter:
+ endpoint: http://so-vnfm-adapter.onap:9092
#Actuator
management:
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
index b7f5e96eab..4af0da1485 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003GrantControllerTest.java
@@ -20,7 +20,14 @@
package org.onap.so.adapters.vnfmadapter.rest;
-import com.google.gson.Gson;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -30,6 +37,7 @@ import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.aai.domain.yang.EsrSystemInfo;
import org.onap.aai.domain.yang.EsrSystemInfoList;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
@@ -38,6 +46,8 @@ import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantRequest.OperationEnum;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsAddResources.TypeEnum;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinks;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.GrantsLinksVnfLcmOpOcc;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.grant.model.InlineResponse201VimConnections;
import org.onap.so.client.aai.AAIResourcesClient;
@@ -54,12 +64,6 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -84,7 +88,6 @@ public class Sol003GrantControllerTest {
@Autowired
private Sol003GrantController controller;
- private final Gson gson = new Gson();
@Before
public void setUp() throws Exception {
@@ -94,17 +97,17 @@ public class Sol003GrantControllerTest {
@Test
public void grantRequest_ValidRequestInstantiate_GrantApproved() {
- GrantRequest grantRequest = createGrantRequest("INSTANTIATE");
+ final GrantRequest grantRequest = createGrantRequest("INSTANTIATE");
setUpGenericVnfWithVnfmRelationshipInMockAai("vnfmType", "vnfm1");
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertEquals(1, response.getBody().getAddResources().size());
assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
- assertEquals("myTestVnfId", response.getBody().getVnfInstanceId());
+ assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
assertEquals("123456", response.getBody().getVnfLcmOpOccId());
- InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
+ final InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
assertEquals(vimConnectionId, vimConnections.getVimId());
assertEquals("OPENSTACK", vimConnections.getVimType());
assertNotNull(vimConnections.getAccessInfo());
@@ -120,17 +123,17 @@ public class Sol003GrantControllerTest {
@Test
public void grantRequest_ValidRequestTerminate_GrantApproved() {
- GrantRequest grantRequest = createGrantRequest("TERMINATE");
+ final GrantRequest grantRequest = createGrantRequest("TERMINATE");
setUpGenericVnfWithVnfmRelationshipInMockAai("vnfmType", "vnfm1");
final ResponseEntity<InlineResponse201> response = controller.grantsPost(grantRequest);
assertEquals(HttpStatus.CREATED, response.getStatusCode());
assertEquals(1, response.getBody().getAddResources().size());
assertEquals(vimConnectionId, response.getBody().getAddResources().get(0).getVimConnectionId());
- assertEquals("myTestVnfId", response.getBody().getVnfInstanceId());
+ assertEquals("myTestVnfIdOnVnfm", response.getBody().getVnfInstanceId());
assertEquals("123456", response.getBody().getVnfLcmOpOccId());
- InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
+ final InlineResponse201VimConnections vimConnections = response.getBody().getVimConnections().get(0);
assertEquals(vimConnectionId, vimConnections.getVimId());
assertEquals("OPENSTACK", vimConnections.getVimType());
assertNotNull(vimConnections.getAccessInfo());
@@ -139,19 +142,21 @@ public class Sol003GrantControllerTest {
}
- private GrantRequest createGrantRequest(String operation) {
- GrantRequest grantRequest = new GrantRequest();
- grantRequest.setVnfInstanceId("myTestVnfId");
+ private GrantRequest createGrantRequest(final String operation) {
+ final GrantRequest grantRequest = new GrantRequest();
+ grantRequest.setVnfInstanceId("myTestVnfIdOnVnfm");
grantRequest.setVnfLcmOpOccId("123456");
+ grantRequest.links(new GrantsLinks()
+ .vnfInstance(new GrantsLinksVnfLcmOpOcc().href("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm")));
if (operation == "INSTANTIATE") {
grantRequest.setOperation(OperationEnum.INSTANTIATE);
- GrantsAddResources resource = new GrantsAddResources();
+ final GrantsAddResources resource = new GrantsAddResources();
resource.setId("123");
resource.setType(TypeEnum.COMPUTE);
grantRequest.addAddResourcesItem(resource);
} else if (operation == "TERMINATE") {
grantRequest.setOperation(OperationEnum.TERMINATE);
- GrantsAddResources resource = new GrantsAddResources();
+ final GrantsAddResources resource = new GrantsAddResources();
resource.setId("123");
resource.setType(TypeEnum.COMPUTE);
grantRequest.addRemoveResourcesItem(resource);
@@ -210,6 +215,14 @@ public class Sol003GrantControllerTest {
doReturn(Optional.of(genericVnf)).when(aaiResourcesClient).get(eq(GenericVnf.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher("/network/generic-vnfs/generic-vnf/myTestVnfId")));
+
+ final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
+ listOfGenericVnfs.add(genericVnf);
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
+ MockitoHamcrest.argThat(new AaiResourceUriMatcher(
+ "/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
}
private class AaiResourceUriMatcher extends BaseMatcher<AAIResourceUri> {
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
index 66e8e99f72..822201ea1c 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/Sol003LcnControllerTest.java
@@ -20,7 +20,25 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.junit.Assert.assertEquals;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.timeout;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyZeroInteractions;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import com.google.gson.Gson;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import javax.inject.Inject;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -29,6 +47,7 @@ import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
import org.mockito.hamcrest.MockitoHamcrest;
import org.onap.aai.domain.yang.GenericVnf;
+import org.onap.aai.domain.yang.GenericVnfs;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.Vserver;
import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
@@ -64,24 +83,6 @@ import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.client.MockRestServiceServer;
import org.springframework.web.client.RestTemplate;
-import javax.inject.Inject;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.timeout;
-import static org.mockito.Mockito.verifyZeroInteractions;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -166,9 +167,11 @@ public class Sol003LcnControllerTest {
.andRespond(withSuccess(gson.toJson(vnfInstance), MediaType.APPLICATION_JSON));
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
- final List<GenericVnf> genericVnfs = new ArrayList<>();
- genericVnfs.add(genericVnf);
- doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(List.class),
+ final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
+ listOfGenericVnfs.add(genericVnf);
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+ doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
"/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
@@ -176,23 +179,27 @@ public class Sol003LcnControllerTest {
controller.lcnVnfLcmOperationOccurrenceNotificationPost(vnfLcmOperationOccurrenceNotification);
assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
- final ArgumentCaptor<Object> bodyArgument = ArgumentCaptor.forClass(Object.class);
- final ArgumentCaptor<AAIResourceUri> uriArgument = ArgumentCaptor.forClass(AAIResourceUri.class);
+ final ArgumentCaptor<Object> bodyArgument1 = ArgumentCaptor.forClass(Object.class);
+ final ArgumentCaptor<AAIResourceUri> uriArgument1 = ArgumentCaptor.forClass(AAIResourceUri.class);
- verify(aaiResourcesClient, timeout(1000).times(2)).update(uriArgument.capture(), bodyArgument.capture());
+ verify(aaiResourcesClient, timeout(1000)).update(uriArgument1.capture(), bodyArgument1.capture());
assertEquals("/network/generic-vnfs/generic-vnf/myTestVnfId",
- uriArgument.getAllValues().get(0).build().toString());
- final GenericVnf updatedGenericVnf = (GenericVnf) bodyArgument.getAllValues().get(0);
+ uriArgument1.getAllValues().get(0).build().toString());
+ final GenericVnf updatedGenericVnf = (GenericVnf) bodyArgument1.getAllValues().get(0);
assertEquals("10.10.10.10", updatedGenericVnf.getIpv4OamAddress());
assertEquals("Created", updatedGenericVnf.getOrchestrationStatus());
+ final ArgumentCaptor<Object> bodyArgument2 = ArgumentCaptor.forClass(Object.class);
+ final ArgumentCaptor<AAIResourceUri> uriArgument2 = ArgumentCaptor.forClass(AAIResourceUri.class);
+ verify(aaiResourcesClient, timeout(1000)).create(uriArgument2.capture(), bodyArgument2.capture());
+
assertEquals(
"/cloud-infrastructure/cloud-regions/cloud-region/" + CLOUD_OWNER + "/" + REGION + "/tenants/tenant/"
+ TENANT_ID + "/vservers/vserver/myVnfc1",
- uriArgument.getAllValues().get(1).build().toString());
+ uriArgument2.getAllValues().get(0).build().toString());
- final Vserver vserver = (Vserver) bodyArgument.getAllValues().get(1);
+ final Vserver vserver = (Vserver) bodyArgument2.getAllValues().get(0);
assertEquals("myVnfc1", vserver.getVserverId());
final Relationship relationship = vserver.getRelationshipList().getRelationship().get(0);
assertEquals("generic-vnf", relationship.getRelatedTo());
@@ -218,9 +225,12 @@ public class Sol003LcnControllerTest {
final GenericVnf genericVnf = createGenericVnf("vnfmType1");
genericVnf.setSelflink("http://vnfm:8080/vnfs/myTestVnfIdOnVnfm");
- final List<GenericVnf> genericVnfs = new ArrayList<>();
- genericVnfs.add(genericVnf);
- doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(List.class),
+ final List<GenericVnf> listOfGenericVnfs = new ArrayList<>();
+ listOfGenericVnfs.add(genericVnf);
+ final GenericVnfs genericVnfs = new GenericVnfs();
+ genericVnfs.getGenericVnf().addAll(listOfGenericVnfs);
+
+ doReturn(Optional.of(genericVnfs)).when(aaiResourcesClient).get(eq(GenericVnfs.class),
MockitoHamcrest.argThat(new AaiResourceUriMatcher(
"/network/generic-vnfs?selflink=http%3A%2F%2Fvnfm%3A8080%2Fvnfs%2FmyTestVnfIdOnVnfm")));
diff --git a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
index 20a074b2ba..73a49e9c40 100644
--- a/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
+++ b/adapters/mso-vnfm-adapter/mso-vnfm-etsi-adapter/src/test/java/org/onap/so/adapters/vnfmadapter/rest/VnfmAdapterControllerTest.java
@@ -20,7 +20,21 @@
package org.onap.so.adapters.vnfmadapter.rest;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.verify;
+import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
+import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withBadRequest;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withStatus;
+import static org.springframework.test.web.client.response.MockRestResponseCreators.withSuccess;
import com.google.gson.Gson;
+import java.net.URI;
+import java.util.Optional;
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.junit.Before;
@@ -36,24 +50,23 @@ import org.onap.aai.domain.yang.GenericVnf;
import org.onap.aai.domain.yang.Relationship;
import org.onap.aai.domain.yang.RelationshipData;
import org.onap.aai.domain.yang.RelationshipList;
+import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
+import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
+import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201Links;
import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201LinksSelf;
+import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
+import org.onap.so.client.aai.AAIResourcesClient;
+import org.onap.so.client.aai.entities.uri.AAIResourceUri;
+import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.CreateVnfResponse;
import org.onap.vnfmadapter.v1.model.DeleteVnfResponse;
import org.onap.vnfmadapter.v1.model.OperationEnum;
import org.onap.vnfmadapter.v1.model.OperationStateEnum;
import org.onap.vnfmadapter.v1.model.QueryJobResponse;
-import org.onap.so.adapters.vnfmadapter.VnfmAdapterApplication;
-import org.onap.so.adapters.vnfmadapter.extclients.SdcPackageProvider;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.*;
-import org.onap.so.adapters.vnfmadapter.rest.exceptions.VnfmNotFoundException;
-import org.onap.so.client.aai.AAIResourcesClient;
-import org.onap.so.client.aai.entities.uri.AAIResourceUri;
-import org.onap.vnfmadapter.v1.model.CreateVnfRequest;
import org.onap.vnfmadapter.v1.model.Tenant;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse200;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse2001;
-import org.onap.so.adapters.vnfmadapter.extclients.vnfm.model.InlineResponse201;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.test.context.SpringBootTest;
@@ -72,18 +85,6 @@ import org.springframework.web.client.RestTemplate;
import org.threeten.bp.LocalDateTime;
import org.threeten.bp.OffsetDateTime;
import org.threeten.bp.ZoneOffset;
-import java.net.URI;
-import java.util.Optional;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.verify;
-import static org.onap.so.client.RestTemplateConfig.CONFIGURABLE_REST_TEMPLATE;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
-import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
-import static org.springframework.test.web.client.response.MockRestResponseCreators.*;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = VnfmAdapterApplication.class, webEnvironment = WebEnvironment.RANDOM_PORT)
@@ -131,7 +132,7 @@ public class VnfmAdapterControllerTest {
setUpVimInMockAai();
final String expectedsubscriptionRequest =
- "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"$2a$10$Fh9ffgPw2vnmsghsRD3ZauBL1aKXebigbq3BB1RPWtE62UDILsjke\"}}}";
+ "{\"filter\":{\"vnfInstanceSubscriptionFilter\":{\"vnfInstanceIds\":[\"vnfId\"]},\"notificationTypes\":[\"VnfLcmOperationOccurrenceNotification\"]},\"callbackUri\":\"https://so-vnfm-adapter.onap:30406/so/vnfm-adapter/v1/lcn/VnfLcmOperationOccurrenceNotification\",\"authentication\":{\"authType\":[\"BASIC\"],\"paramsBasic\":{\"userName\":\"vnfm\",\"password\":\"password1$\"}}}";
final InlineResponse2001 subscriptionResponse = new InlineResponse2001();
final InlineResponse201 createResponse = createCreateResponse();
diff --git a/asdc-controller/src/test/resources/schema.sql b/asdc-controller/src/test/resources/schema.sql
index d143b52fe1..bdd906d870 100644
--- a/asdc-controller/src/test/resources/schema.sql
+++ b/asdc-controller/src/test/resources/schema.sql
@@ -1137,6 +1137,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java
index a3f5253765..6f8d34e760 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/ResponseBuilder.java
@@ -40,6 +40,7 @@ import org.slf4j.LoggerFactory;
*/
public class ResponseBuilder implements java.io.Serializable {
private static final long serialVersionUID = 1L;
+ private static final String WORKFLOWEXCEPTION = "WorkflowException";
private static final Logger logger = LoggerFactory.getLogger(ResponseBuilder.class);
/**
@@ -61,7 +62,7 @@ public class ResponseBuilder implements java.io.Serializable {
logger.debug("processKey=" + processKey);
// See if there"s already a WorkflowException object in the execution.
- WorkflowException theException = (WorkflowException) execution.getVariable("WorkflowException");
+ WorkflowException theException = (WorkflowException) execution.getVariable(WORKFLOWEXCEPTION);
if (theException != null) {
logger.debug("Exited " + method + " - propagated " + theException);
@@ -138,7 +139,7 @@ public class ResponseBuilder implements java.io.Serializable {
// Create a new WorkflowException object
theException = new WorkflowException(processKey, intResponseCode, errorResponse);
- execution.setVariable("WorkflowException", theException);
+ execution.setVariable(WORKFLOWEXCEPTION, theException);
logger.debug("Exited " + method + " - created " + theException);
return theException;
}
@@ -163,7 +164,7 @@ public class ResponseBuilder implements java.io.Serializable {
Object theResponse = null;
- WorkflowException theException = (WorkflowException) execution.getVariable("WorkflowException");
+ WorkflowException theException = (WorkflowException) execution.getVariable(WORKFLOWEXCEPTION);
String errorResponse = trimString(execution.getVariable(prefix + "ErrorResponse"), null);
String responseCode = trimString(execution.getVariable(prefix + "ResponseCode"), null);
@@ -222,7 +223,7 @@ public class ResponseBuilder implements java.io.Serializable {
}
String s = String.valueOf(object).trim();
- return s.equals("") ? emptyStringValue : s;
+ return "".equals(s) ? emptyStringValue : s;
}
/**
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java
index 841eaee675..c37b77d332 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/AllottedResource.java
@@ -22,7 +22,6 @@ package org.onap.so.bpmn.core.domain;
import java.util.UUID;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonRootName;
/**
@@ -35,14 +34,6 @@ public class AllottedResource extends Resource {
private static final long serialVersionUID = 1L;
/*
- * set resourceType for this object
- */
- public AllottedResource() {
- resourceType = ResourceType.ALLOTTED_RESOURCE;
- setResourceId(UUID.randomUUID().toString());
- }
-
- /*
* fields specific to Allotted Resource resource type
*/
private String allottedResourceType;
@@ -60,6 +51,14 @@ public class AllottedResource extends Resource {
private String resourceInput;
/*
+ * set resourceType for this object
+ */
+ public AllottedResource() {
+ resourceType = ResourceType.ALLOTTED_RESOURCE;
+ setResourceId(UUID.randomUUID().toString());
+ }
+
+ /*
* GET and SET
*/
public String getAllottedResourceType() {
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
index 897cbe3573..309b053589 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/HomingSolution.java
@@ -21,7 +21,6 @@
package org.onap.so.bpmn.core.domain;
import java.io.Serializable;
-import java.util.List;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonRootName;
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
index 602172f8a4..bf53c880e9 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/JsonWrapper.java
@@ -45,6 +45,7 @@ import org.slf4j.LoggerFactory;
*/
@JsonInclude(Include.NON_NULL)
public abstract class JsonWrapper implements Serializable {
+ private static final String EXCEPTION = "Exception :";
private static final Logger logger = LoggerFactory.getLogger(JsonWrapper.class);
@@ -63,7 +64,7 @@ public abstract class JsonWrapper implements Serializable {
jsonString = ow.writeValueAsString(this);
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return jsonString;
}
@@ -76,14 +77,10 @@ public abstract class JsonWrapper implements Serializable {
JSONObject json = new JSONObject();
try {
json = new JSONObject(mapper.writeValueAsString(this));
- } catch (JsonGenerationException e) {
- logger.debug("Exception :", e);
- } catch (JsonMappingException e) {
- logger.debug("Exception :", e);
- } catch (JSONException e) {
- logger.debug("Exception :", e);
+ } catch (JsonGenerationException | JsonMappingException | JSONException e) {
+ logger.debug(EXCEPTION, e);
} catch (IOException e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return json;
}
@@ -95,12 +92,10 @@ public abstract class JsonWrapper implements Serializable {
String jsonString = "";
try {
jsonString = mapper.writeValueAsString(list);
- } catch (JsonGenerationException e) {
- logger.debug("Exception :", e);
- } catch (JsonMappingException e) {
- logger.debug("Exception :", e);
+ } catch (JsonGenerationException | JsonMappingException e) {
+ logger.debug(EXCEPTION, e);
} catch (IOException e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return jsonString;
}
@@ -118,7 +113,7 @@ public abstract class JsonWrapper implements Serializable {
jsonString = ow.writeValueAsString(this);
} catch (Exception e) {
- logger.debug("Exception :", e);
+ logger.debug(EXCEPTION, e);
}
return jsonString;
}
diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
index f66ad36058..a69a49b89a 100644
--- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
+++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/domain/VnfResource.java
@@ -32,6 +32,7 @@ import com.fasterxml.jackson.annotation.JsonRootName;
* Encapsulates VNF resource data set
*
*/
+@JsonIgnoreProperties(ignoreUnknown = true)
@JsonRootName("vnfResource")
public class VnfResource extends Resource {
@@ -59,7 +60,7 @@ public class VnfResource extends Resource {
private String multiStageDesign;
private String orchestrationStatus;
- @JsonIgnore
+ @JsonProperty("resourceInput")
private String resourceInput;
/*
diff --git a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
index 09bcfe8470..b23633b4d8 100644
--- a/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
+++ b/bpmn/MSOCoreBPMN/src/test/java/org/onap/so/bpmn/core/domain/VnfResourceTest.java
@@ -58,6 +58,19 @@ public class VnfResourceTest {
VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class);
assertTrue(vnfResource != null);
+ assertEquals("sample", vnfResource.getResourceInput());
+ assertEquals("home", vnfResource.getVnfHostname());
+ }
+
+ @Test
+ public void vnfResourceMapperTestNoResourceInput() throws IOException {
+ String jsonStr = "{\"vnfHostname\": \"home\"}";
+ ObjectMapper objectMapper = new ObjectMapper();
+ VnfResource vnfResource = objectMapper.readValue(jsonStr, VnfResource.class);
+
+ assertTrue(vnfResource != null);
+ assertEquals(null, vnfResource.getResourceInput());
+ assertEquals("home", vnfResource.getVnfHostname());
}
@Test
diff --git a/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java
index 5b99fe1a05..6e7baa37e6 100644
--- a/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java
+++ b/common/src/main/java/org/onap/so/client/policy/entities/DictionaryJson.java
@@ -31,7 +31,7 @@ import com.fasterxml.jackson.annotation.JsonPropertyOrder;
public class DictionaryJson {
@JsonProperty("DictionaryDatas")
- private List<DictionaryData> dictionaryDatas = new ArrayList<DictionaryData>();
+ private List<DictionaryData> dictionaryDatas = new ArrayList<>();
@JsonProperty("DictionaryDatas")
public List<DictionaryData> getDictionaryDatas() {
diff --git a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
index 8e6ebab43a..a627e82802 100644
--- a/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
+++ b/common/src/main/java/org/onap/so/rest/service/HttpRestServiceProviderImpl.java
@@ -96,7 +96,7 @@ public class HttpRestServiceProviderImpl implements HttpRestServiceProvider {
private <T> Optional<T> createOptional(final ResponseEntity<T> response, final String url,
final HttpMethod httpMethod) {
- if (!response.getStatusCode().equals(HttpStatus.OK)) {
+ if (!response.getStatusCode().equals(HttpStatus.OK) && !response.getStatusCode().equals(HttpStatus.CREATED)) {
final String message = "Unable to invoke HTTP " + httpMethod + " using URL: " + url + ", Response Code: "
+ response.getStatusCode();
LOGGER.error(message);
diff --git a/docs/Developer_Info.rst b/docs/Developer_Info.rst
index 59dc9d6f1c..46c114f193 100644
--- a/docs/Developer_Info.rst
+++ b/docs/Developer_Info.rst
@@ -10,5 +10,5 @@ Developer Information
Install_Configure_SO.rst
architecture.rst
- FAQs.rst
+
\ No newline at end of file
diff --git a/docs/architecture/SO Internal Arc.pptx b/docs/architecture/SO Internal Arc.pptx
index bff3e352e0..ee4b112b3b 100644
--- a/docs/architecture/SO Internal Arc.pptx
+++ b/docs/architecture/SO Internal Arc.pptx
Binary files differ
diff --git a/docs/developer_info/developer_information.rst b/docs/developer_info/developer_information.rst
index f6d66b913d..bae1e2e348 100644
--- a/docs/developer_info/developer_information.rst
+++ b/docs/developer_info/developer_information.rst
@@ -13,6 +13,7 @@ SO Developer Information
Working_with_SO_Docker.rst
Camunda_Cockpit_Community_Edition.rst
Camunda_Cockpit_Enterprise_Edition.rst
+ FAQs.rst
.. developer_info_Project_Structure.rst
.. developer_info_Main_Process_Flows.rst
.. developer_info_Subprocess_Process_Flows.rst
diff --git a/docs/images/SO_1.png b/docs/images/SO_1.png
index 715801330b..5bdc14644f 100644
--- a/docs/images/SO_1.png
+++ b/docs/images/SO_1.png
Binary files differ
diff --git a/docs/index.rst b/docs/index.rst
index ebb8b0b552..fd5f1241e6 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -12,4 +12,4 @@ ONAP SO
architecture/architecture.rst
api/offered_consumed_apis.rst
developer_info/developer_information.rst
- release_notes/release-notes.rst \ No newline at end of file
+ release-notes.rst \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
index 4cbb5de4ca..765740e864 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/schema.sql
@@ -1136,6 +1136,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
index a7a31dcf89..413efaf12c 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcCustomization.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,23 +21,25 @@
package org.onap.so.db.catalog.beans;
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
+import com.fasterxml.jackson.annotation.JsonFormat;
+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 javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
+import javax.persistence.JoinColumn;
+import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.openpojo.business.annotation.BusinessKey;
-import org.apache.commons.lang3.builder.HashCodeBuilder;
-import org.apache.commons.lang3.builder.EqualsBuilder;
-import org.apache.commons.lang3.builder.ToStringBuilder;
+import java.io.Serializable;
+import java.util.Date;
+import java.util.List;
@Entity
@Table(name = "vnfc_customization")
@@ -81,6 +84,10 @@ public class VnfcCustomization implements Serializable {
@OneToMany(cascade = CascadeType.ALL, mappedBy = "vnfcCustomization")
private List<CvnfcCustomization> cvnfcCustomization;
+ @ManyToOne(cascade = CascadeType.ALL)
+ @JoinColumn(name = "VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID")
+ private VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization;
+
@Override
public boolean equals(final Object other) {
if (!(other instanceof VnfcCustomization)) {
@@ -190,6 +197,14 @@ public class VnfcCustomization implements Serializable {
this.cvnfcCustomization = cvnfcCustomization;
}
+ public VnfcInstanceGroupCustomization getVnfcInstanceGroupCustomization() {
+ return vnfcInstanceGroupCustomization;
+ }
+
+ public void setVnfcInstanceGroupCustomization(VnfcInstanceGroupCustomization vnfcInstanceGroupCustomization) {
+ this.vnfcInstanceGroupCustomization = vnfcInstanceGroupCustomization;
+ }
+
public String getResourceInput() {
return resourceInput;
}
diff --git a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
index 695e5bbbb9..8a00ccd261 100644
--- a/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
+++ b/mso-catalog-db/src/main/java/org/onap/so/db/catalog/beans/VnfcInstanceGroupCustomization.java
@@ -3,6 +3,7 @@
* ONAP - SO
* ================================================================================
* Copyright (C) 2017 - 2018 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2019 Huawei Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +23,7 @@ package org.onap.so.db.catalog.beans;
import java.io.Serializable;
import java.util.Date;
+import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -32,6 +34,7 @@ import javax.persistence.Id;
import javax.persistence.IdClass;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
+import javax.persistence.OneToMany;
import javax.persistence.PrePersist;
import javax.persistence.Table;
import javax.persistence.Temporal;
@@ -66,6 +69,9 @@ public class VnfcInstanceGroupCustomization implements Serializable {
@JoinColumn(name = "INSTANCE_GROUP_MODEL_UUID")
private InstanceGroup instanceGroup;
+ @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "vnfcInstanceGroupCustomization")
+ private List<VnfcCustomization> vnfcCustomizations;
+
@Column(name = "FUNCTION")
private String function;
@@ -150,4 +156,12 @@ public class VnfcInstanceGroupCustomization implements Serializable {
public void setInstanceGroup(InstanceGroup instanceGroup) {
this.instanceGroup = instanceGroup;
}
+
+ public List<VnfcCustomization> getVnfcCustomizations() {
+ return vnfcCustomizations;
+ }
+
+ public void setVnfcCustomizations(List<VnfcCustomization> vnfcCustomizations) {
+ this.vnfcCustomizations = vnfcCustomizations;
+ }
}
diff --git a/mso-catalog-db/src/test/resources/schema.sql b/mso-catalog-db/src/test/resources/schema.sql
index 97afcc04be..34340f1357 100644
--- a/mso-catalog-db/src/test/resources/schema.sql
+++ b/mso-catalog-db/src/test/resources/schema.sql
@@ -1134,6 +1134,7 @@ CREATE TABLE `vnfc_customization` (
`TOSCA_NODE_TYPE` varchar(200) NOT NULL,
`DESCRIPTION` varchar(1200) DEFAULT NULL,
`RESOURCE_INPUT` varchar(20000) DEFAULT NULL,
+ `VNFC_INSTANCE_GROUP_CUSTOMIZATION_ID` integer DEFAULT NULL,
`CREATION_TIMESTAMP` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`MODEL_CUSTOMIZATION_UUID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;