diff options
author | Eric Multanen <eric.w.multanen@intel.com> | 2019-03-21 20:32:55 -0700 |
---|---|---|
committer | Eric Multanen <eric.w.multanen@intel.com> | 2019-03-22 01:16:08 -0700 |
commit | eea8c1d2c9a830b20aacbacf9bbd0e36f664ee0f (patch) | |
tree | 3d00829bc32f773bc8087d05b1523a852f0be867 | |
parent | 2061d60c2d380af5b9276ff4f86b3c95fbb7a5c1 (diff) |
Multicloud VNF adapter use updated multicloud API
Update the Multicloud plugin adapter to use the
the enhanced multicloud infra_workload API.
Mainly involves adding the user_directives and
the vf-module model IDs to the call.
Change-Id: I7ab78a8a304dbd61a5743ec67bb839037861ef9d
Issue-ID: SO-1446
Signed-off-by: Eric Multanen <eric.w.multanen@intel.com>
9 files changed, 132 insertions, 32 deletions
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 b6c98ad996..e8ef86a3b4 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 @@ -147,6 +147,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ cloudOwner, tenantId, stackName, + null, heatTemplate, stackInputs, pollForCompletion, @@ -172,6 +173,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ cloudOwner, tenantId, stackName, + null, heatTemplate, stackInputs, pollForCompletion, @@ -197,6 +199,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ cloudOwner, tenantId, stackName, + null, heatTemplate, stackInputs, pollForCompletion, @@ -223,6 +226,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ cloudOwner, tenantId, stackName, + null, heatTemplate, stackInputs, pollForCompletion, @@ -262,6 +266,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ * @param cloudOwner the cloud owner of the cloud site in which to create the stack * @param tenantId The Openstack ID of the tenant in which to create the Stack * @param stackName The name of the stack to create + * @param vduModelInfo contains information about the vdu model (added for plugin adapter) * @param heatTemplate The Heat template * @param stackInputs A map of key/value inputs * @param pollForCompletion Indicator that polling should be handled in Java vs. in the client @@ -279,6 +284,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ String cloudOwner, String tenantId, String stackName, + VduModelInfo vduModel, String heatTemplate, Map <String, ?> stackInputs, boolean pollForCompletion, @@ -1551,6 +1557,7 @@ public class MsoHeatUtils extends MsoCommonUtils implements VduPlugin{ cloudOwner, tenantId, instanceName, + vduModel, heatTemplate, inputs, true, // poll for completion 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 01120d51a3..fec4a1d16c 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 @@ -67,11 +67,12 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ public static final String OOF_DIRECTIVES = "oof_directives"; public static final String SDNC_DIRECTIVES = "sdnc_directives"; + public static final String USER_DIRECTIVES = "user_directives"; public static final String VNF_ID = "vnf_id"; public static final String VF_MODULE_ID = "vf_module_id"; public static final String TEMPLATE_TYPE = "template_type"; public static final List<String> MULTICLOUD_INPUTS = - Arrays.asList(OOF_DIRECTIVES, SDNC_DIRECTIVES, TEMPLATE_TYPE); + Arrays.asList(OOF_DIRECTIVES, SDNC_DIRECTIVES, USER_DIRECTIVES, TEMPLATE_TYPE); private static final Logger logger = LoggerFactory.getLogger(MsoMulticloudUtils.class); @@ -134,6 +135,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ String cloudOwner, String tenantId, String stackName, + VduModelInfo vduModel, String heatTemplate, Map <String, ?> stackInputs, boolean pollForCompletion, @@ -148,6 +150,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ // Get the directives, if present. String oofDirectives = "{}"; String sdncDirectives = "{}"; + String userDirectives = "{}"; String genericVnfId = ""; String vfModuleId = ""; String templateType = ""; @@ -160,6 +163,9 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ if (key == SDNC_DIRECTIVES) { sdncDirectives = (String) stackInputs.get(key); } + if (key == USER_DIRECTIVES) { + sdncDirectives = (String) stackInputs.get(key); + } if (key == TEMPLATE_TYPE) { templateType = (String) stackInputs.get(key); } @@ -184,10 +190,14 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ multicloudRequest.setGenericVnfId(genericVnfId); multicloudRequest.setVfModuleId(vfModuleId); + multicloudRequest.setVfModuleModelInvariantId(vduModel.getModelInvariantUUID()); + multicloudRequest.setVfModuleModelVersionId(vduModel.getModelUUID()); + multicloudRequest.setVfModuleModelCustomizationId(vduModel.getModelCustomizationUUID()); multicloudRequest.setTemplateType(templateType); multicloudRequest.setTemplateData(stack); multicloudRequest.setOofDirectives(getDirectiveNode(oofDirectives)); multicloudRequest.setSdncDirectives(getDirectiveNode(sdncDirectives)); + multicloudRequest.setUserDirectives(getDirectiveNode(userDirectives)); if (logger.isDebugEnabled()) { logger.debug(String.format("Multicloud Request is: %s", multicloudRequest.toString())); } @@ -677,6 +687,7 @@ public class MsoMulticloudUtils extends MsoHeatUtils implements VduPlugin{ cloudOwner, tenantId, instanceName, + vduModel, heatTemplate, inputs, true, // poll for completion 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 4204813cec..3689d34204 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 @@ -2,7 +2,7 @@ * ============LICENSE_START======================================================= * ONAP - SO * ================================================================================ - * Copyright (C) 2018 Intel Corp. All rights reserved. + * Copyright (C) 2019 Intel Corp. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,8 +33,12 @@ import org.apache.commons.lang.builder.ToStringBuilder; @JsonPropertyOrder({ "generic-vnf-id", "vf-module-id", + "vf-module-model-invariant-id", + "vf-module-model-version-id", + "vf-module-model-customization-id", "oof_directives", "sdnc_directives", + "user_directives", "template_type", "template_data" }) @@ -45,10 +49,18 @@ public class MulticloudRequest implements Serializable { private String genericVnfId; @JsonProperty("vf-module-id") private String vfModuleId; + @JsonProperty("vf-module-model-invariant-id") + private String vfModuleModelInvariantId; + @JsonProperty("vf-module-model-version-id") + private String vfModuleModelVersionId; + @JsonProperty("vf-module-model-customization-id") + private String vfModuleModelCustomizationId; @JsonProperty("oof_directives") private JsonNode oofDirectives; @JsonProperty("sdnc_directives") private JsonNode sdncDirectives; + @JsonProperty("user_directives") + private JsonNode userDirectives; @JsonProperty("template_type") private String templateType; @JsonProperty("template_data") @@ -75,6 +87,36 @@ public class MulticloudRequest implements Serializable { this.vfModuleId = vfModuleId; } + @JsonProperty("vf-module-model-invariant-id") + public String getVfModuleModelInvariantId() { + return vfModuleModelInvariantId; + } + + @JsonProperty("vf-module-model-invariant-id") + public void setVfModuleModelInvariantId(String vfModuleModelInvariantId) { + this.vfModuleModelInvariantId = vfModuleModelInvariantId; + } + + @JsonProperty("vf-module-model-version-id") + public String getVfModuleModelVersionId() { + return vfModuleModelVersionId; + } + + @JsonProperty("vf-module-model-version-id") + public void setVfModuleModelVersionId(String vfModuleModelVersionId) { + this.vfModuleModelVersionId = vfModuleModelVersionId; + } + + @JsonProperty("vf-module-model-customization-id") + public String getVfModuleModelCustomizationId() { + return vfModuleModelCustomizationId; + } + + @JsonProperty("vf-module-model-customization-id") + public void setVfModuleModelCustomizationId(String vfModuleModelCustomizationId) { + this.vfModuleModelCustomizationId = vfModuleModelCustomizationId; + } + @JsonProperty("oof_directives") public JsonNode getOofDirectives() { return oofDirectives; @@ -95,6 +137,16 @@ public class MulticloudRequest implements Serializable { this.sdncDirectives = sdncDirectives; } + @JsonProperty("user_directives") + public JsonNode getUserDirectives() { + return userDirectives; + } + + @JsonProperty("user_directives") + public void setUserDirectives(JsonNode userDirectives) { + this.userDirectives = userDirectives; + } + @JsonProperty("template_type") public String getTemplateType() { return templateType; @@ -117,7 +169,16 @@ public class MulticloudRequest implements Serializable { @Override public String toString() { - return new ToStringBuilder(this).append("genericVnfId", genericVnfId).append("vfModuleId", vfModuleId).append("oofDirectives", oofDirectives).append("sdncDirectives", sdncDirectives).append("templateType", templateType).append("templateData", templateData).toString(); + return new ToStringBuilder(this).append("genericVnfId", genericVnfId) + .append("vfModuleId", vfModuleId) + .append("vfModuleModelInvariantId", vfModuleModelInvariantId) + .append("vfModuleModelVersionId", vfModuleModelVersionId) + .append("vfModuleModelCustomizationId", vfModuleModelCustomizationId) + .append("oofDirectives", oofDirectives) + .append("sdncDirectives", sdncDirectives) + .append("userDirectives", userDirectives) + .append("templateType", templateType) + .append("templateData", templateData).toString(); } } diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java index 888d376d37..c771a75976 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoHeatUtilsTest.java @@ -229,7 +229,7 @@ public class MsoHeatUtilsTest extends BaseTest{ StubOpenStack.mockOpenStackResponseAccess(wireMockPort); StubOpenStack.mockOpenStackPostStack_200("OpenstackResponse_Stack_Created.json"); StubOpenStack.mockOpenStackGet("TEST-stack/stackId"); - StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack", + StackInfo stackInfo = heatUtils.createStack(cloudSite.getId(), "CloudOwner", "tenantId", "TEST-stack", null, "TEST-heat", new HashMap<>(), false, 1, "TEST-env", new HashMap<>(), new HashMap<>(), false); assertNotNull(stackInfo); diff --git a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java index b999b49ab1..b2a69ded46 100644 --- a/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java +++ b/adapters/mso-adapter-utils/src/test/java/org/onap/so/openstack/utils/MsoMulticloudUtilsTest.java @@ -37,6 +37,7 @@ import org.junit.Test; import org.mockito.InjectMocks; import org.mockito.Mock; import org.onap.so.BaseTest; +import org.onap.so.adapters.vdu.VduModelInfo; import org.onap.so.cloud.CloudConfig; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.CloudSite; @@ -64,9 +65,9 @@ public class MsoMulticloudUtilsTest extends BaseTest { .willReturn(aResponse().withHeader("Content-Type", "application/json") .withBody(CREATE_STACK_RESPONSE) .withStatus(HttpStatus.SC_CREATED))); - StackInfo result = multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", + StackInfo result = multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", - new HashMap<>(), new HashMap<>()); + new HashMap<>(), new HashMap<>(), false); assertNotNull(result); assertEquals("TEST-stack", result.getName()); } @@ -79,9 +80,9 @@ public class MsoMulticloudUtilsTest extends BaseTest { cloudSite.setIdentityService(new CloudIdentity()); when(cloudConfigMock.getCloudSite("MTN13")). thenReturn(Optional.of(cloudSite)); - multicloudUtilsMock.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", + multicloudUtilsMock.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", - new HashMap<>(), new HashMap<>()); + new HashMap<>(), new HashMap<>(), false); } catch (MsoException e) { assertEquals("0 : Multicloud client could not be initialized", e.toString()); return; @@ -95,9 +96,9 @@ public class MsoMulticloudUtilsTest extends BaseTest { stubFor(post(urlPathEqualTo("/v2.0")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(HttpStatus.SC_BAD_REQUEST))); - multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", + multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", - new HashMap<>(), new HashMap<>()); + new HashMap<>(), new HashMap<>(), false); } catch (MsoException e) { assertEquals("0 : Bad Request", e.toString()); return; @@ -110,9 +111,9 @@ public class MsoMulticloudUtilsTest extends BaseTest { stubFor(post(urlPathEqualTo("/v2.0")) .willReturn(aResponse().withHeader("Content-Type", "application/json") .withStatus(HttpStatus.SC_CREATED))); - StackInfo result = multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", + StackInfo result = multicloudUtils.createStack("MTN13", "CloudOwner", "TEST-tenant", "TEST-stack", new VduModelInfo(), "TEST-heat", new HashMap<>(), false, 200, "TEST-env", - new HashMap<>(), new HashMap<>()); + new HashMap<>(), new HashMap<>(), false); assertNotNull(result); assertEquals("TEST-stack/", result.getName()); } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vdu/VduModelInfo.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vdu/VduModelInfo.java index 47f4c74aae..a3ce1b5a6c 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vdu/VduModelInfo.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/vdu/VduModelInfo.java @@ -7,9 +7,9 @@ * 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. @@ -23,17 +23,31 @@ package org.onap.so.adapters.vdu; import java.util.ArrayList; import java.util.List; -public class VduModelInfo { +public class VduModelInfo { private String modelCustomizationUUID; + private String modelUUID; + private String modelInvariantUUID; private int timeoutMinutes; private List<VduArtifact> artifacts = new ArrayList<>(); - + public String getModelCustomizationUUID() { return modelCustomizationUUID; } public void setModelCustomizationUUID(String modelCustomizationUUID) { this.modelCustomizationUUID = modelCustomizationUUID; } + public String getModelUUID() { + return modelUUID; + } + public void setModelUUID(String modelUUID) { + this.modelUUID = modelUUID; + } + public String getModelInvariantUUID() { + return modelInvariantUUID; + } + public void setModelInvariantUUID(String modelInvariantUUID) { + this.modelInvariantUUID = modelInvariantUUID; + } public int getTimeoutMinutes() { return timeoutMinutes; } @@ -46,5 +60,5 @@ public class VduModelInfo { public void setArtifacts(List<VduArtifact> artifacts) { this.artifacts = artifacts; } - + }
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 8053cd6f9e..2e8c7990db 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -537,6 +537,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { "CloudOwner", tenantId, networkName, + null, template, stackParams, true, diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java index f6442b6252..b418368170 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vdu/mapper/VfModuleCustomizationToVduMapper.java @@ -33,25 +33,29 @@ import org.springframework.stereotype.Component; @Component public class VfModuleCustomizationToVduMapper { - + public VduModelInfo mapVfModuleCustomizationToVdu(VfModuleCustomization vfModuleCustom) - { + { VduModelInfo vduModel = new VduModelInfo(); vduModel.setModelCustomizationUUID(vfModuleCustom.getModelCustomizationUUID()); - + vduModel.setModelUUID(vfModuleCustom.getVfModule().getModelUUID()); + vduModel.setModelInvariantUUID(vfModuleCustom.getVfModule().getModelInvariantUUID()); + // Map the cloud templates, attached files, and environment file mapCloudTemplates(vfModuleCustom.getVfModule().getModuleHeatTemplate(), vduModel); mapCloudFiles(vfModuleCustom,vduModel); mapEnvironment(vfModuleCustom.getHeatEnvironment(), vduModel); - + return vduModel; } - + public VduModelInfo mapVfModuleCustVolumeToVdu(VfModuleCustomization vfModuleCustom) - { + { VduModelInfo vduModel = new VduModelInfo(); vduModel.setModelCustomizationUUID(vfModuleCustom.getModelCustomizationUUID()); - + vduModel.setModelUUID(vfModuleCustom.getVfModule().getModelUUID()); + vduModel.setModelInvariantUUID(vfModuleCustom.getVfModule().getModelInvariantUUID()); + // Map the cloud templates, attached files, and environment file mapCloudTemplates(vfModuleCustom.getVfModule().getVolumeHeatTemplate(), vduModel); mapCloudFiles(vfModuleCustom,vduModel); @@ -62,20 +66,20 @@ public class VfModuleCustomizationToVduMapper { private void mapCloudTemplates(HeatTemplate heatTemplate, VduModelInfo vduModel) { // TODO: These catalog objects will be refactored to be non-Heat-specific - + List<VduArtifact> vduArtifacts = vduModel.getArtifacts(); - + // Main template. Also set the VDU timeout based on the main template. vduArtifacts.add(mapHeatTemplateToVduArtifact(heatTemplate, ArtifactType.MAIN_TEMPLATE)); vduModel.setTimeoutMinutes(heatTemplate.getTimeoutMinutes()); - + // Nested templates List<HeatTemplate> childTemplates = heatTemplate.getChildTemplates(); if (childTemplates != null) { for(HeatTemplate childTemplate : childTemplates){ vduArtifacts.add(mapHeatTemplateToVduArtifact(childTemplate, ArtifactType.NESTED_TEMPLATE)); } - } + } } private VduArtifact mapHeatTemplateToVduArtifact(HeatTemplate heatTemplate, ArtifactType artifactType) { @@ -85,12 +89,12 @@ public class VfModuleCustomizationToVduMapper { vduArtifact.setType(artifactType); return vduArtifact; } - + private void mapCloudFiles(VfModuleCustomization vfModuleCustom, VduModelInfo vduModel) { // TODO: These catalog objects will be refactored to be non-Heat-specific - + List<VduArtifact> vduArtifacts = vduModel.getArtifacts(); - + // Attached Files List<HeatFiles> heatFiles = vfModuleCustom.getVfModule().getHeatFiles(); if (heatFiles != null) { @@ -115,7 +119,7 @@ public class VfModuleCustomizationToVduMapper { vduArtifacts.add(mapEnvironmentFileToVduArtifact(heatEnvironment)); } } - + private VduArtifact mapEnvironmentFileToVduArtifact(HeatEnvironment heatEnv) { VduArtifact vduArtifact = new VduArtifact(); vduArtifact.setName(heatEnv.getName()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java index 0563d6c242..3913d7f758 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/vnf/MsoVnfAdapterImpl.java @@ -1206,6 +1206,7 @@ public class MsoVnfAdapterImpl implements MsoVnfAdapter { cloudOwner, tenantId, vfModuleName, + null, template, goldenInputs, true, |