diff options
Diffstat (limited to 'adapters')
31 files changed, 323 insertions, 262 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-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java index 0541a8f51b..9ee8a09ea6 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoYamlEditorWithEnvt.java @@ -40,6 +40,7 @@ import org.yaml.snakeyaml.Yaml; public class MsoYamlEditorWithEnvt { private static final Logger logger = LoggerFactory.getLogger(MsoYamlEditorWithEnvt.class); + public static final String EXCEPTION = "Exception:"; private Map<String, Object> yml; private Yaml yaml = new Yaml(); @@ -68,7 +69,7 @@ public class MsoYamlEditorWithEnvt { try { resourceMap = (Map<String, Object>) yml.get("parameters"); } catch (Exception e) { - logger.debug("Exception:", e); + logger.debug(EXCEPTION, e); return paramSet; } if (resourceMap == null) { @@ -89,7 +90,7 @@ public class MsoYamlEditorWithEnvt { try { value = JSON_MAPPER.writeValueAsString(obj); } catch (Exception e) { - logger.debug("Exception:", e); + logger.debug(EXCEPTION, e); value = "_BAD_JSON_MAPPING"; } } else { @@ -118,7 +119,7 @@ public class MsoYamlEditorWithEnvt { } return resourceList; } catch (Exception e) { - logger.debug("Exception:", e); + logger.debug(EXCEPTION, e); } return null; } @@ -137,7 +138,7 @@ public class MsoYamlEditorWithEnvt { try { value = resourceEntry.get("default"); } catch (ClassCastException cce) { - logger.debug("Exception:", cce); + logger.debug(EXCEPTION, cce); // This exception only - the value is an integer. For what we're doing // here - we don't care - so set value to something - and it will // get marked as not being required - which is correct. diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java index a4cdba22a1..16671bbe50 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateHeatResponse.java @@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"id", "links"}) public class MulticloudCreateHeatResponse implements Serializable { - private final static long serialVersionUID = -5215028275577848311L; + private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("id") private String id; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java index e8a5b1480e..1f55aa92a2 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateLinkResponse.java @@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"href", "rel"}) public class MulticloudCreateLinkResponse implements Serializable { - private final static long serialVersionUID = -5215028275577848311L; + private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("href") private String href; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java index bb15e58c88..fc08201bcb 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateResponse.java @@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"template_type", "workload_id", "template_response"}) public class MulticloudCreateResponse implements Serializable { - private final static long serialVersionUID = -5215028275577848311L; + private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("template_type") private String templateType; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java index 67cb73539d..67d1cbff4e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java @@ -30,7 +30,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"stack"}) public class MulticloudCreateStackResponse implements Serializable { - private final static long serialVersionUID = -5215028275577848311L; + private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("stack") private MulticloudCreateHeatResponse stack; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java index a22937aea3..ad37b39f30 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudQueryResponse.java @@ -31,7 +31,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) @JsonPropertyOrder({"template_type", "workload_id", "workload_status", "workload_status_reason"}) public class MulticloudQueryResponse implements Serializable { - private final static long serialVersionUID = -5215028275577848311L; + private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("template_type") private String templateType; diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java index b733552a2b..95dd48caa6 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudRequest.java @@ -33,7 +33,7 @@ import org.apache.commons.lang.builder.ToStringBuilder; "vf-module-model-customization-id", "oof_directives", "sdnc_directives", "user_directives", "template_type", "template_data"}) public class MulticloudRequest implements Serializable { - private final static long serialVersionUID = -5215028275577848311L; + private static final long serialVersionUID = -5215028275577848311L; @JsonProperty("generic-vnf-id") private String genericVnfId; 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(); |