diff options
Diffstat (limited to 'adapters')
4 files changed, 96 insertions, 65 deletions
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..732f9b5196 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 @@ -22,13 +22,16 @@ package org.onap.so.openstack.utils; import java.io.Serializable; import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import com.fasterxml.jackson.databind.JsonNode; import org.apache.commons.lang.builder.ToStringBuilder; @JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"template_type", "workload_id", "template_response"}) +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonPropertyOrder({"template_type", "workload_id", "template_response", "workload_status_reason", "workload_status"}) public class MulticloudCreateResponse implements Serializable { private final static long serialVersionUID = -5215028275577848311L; @@ -37,12 +40,16 @@ public class MulticloudCreateResponse implements Serializable { @JsonProperty("workload_id") private String workloadId; @JsonProperty("template_response") - private MulticloudCreateStackResponse templateResponse; + private JsonNode templateResponse; + @JsonProperty("workload_status_reason") + private JsonNode workloadStatusReason; + @JsonProperty("workload_status") + private String workloadStatus; @JsonCreator public MulticloudCreateResponse(@JsonProperty("template_type") String templateType, @JsonProperty("workload_id") String workloadId, - @JsonProperty("template_response") MulticloudCreateStackResponse templateResponse) { + @JsonProperty("template_response") JsonNode templateResponse) { this.templateType = templateType; this.workloadId = workloadId; this.templateResponse = templateResponse; @@ -69,18 +76,41 @@ public class MulticloudCreateResponse implements Serializable { } @JsonProperty("template_response") - public void setTemplateResponse(MulticloudCreateStackResponse templateResponse) { + public void setTemplateResponse(JsonNode templateResponse) { this.templateResponse = templateResponse; } @JsonProperty("template_response") - public MulticloudCreateStackResponse getTemplateResponse() { + public JsonNode getTemplateResponse() { return templateResponse; } + @JsonProperty("workload_status_reason") + public void setWorkloadStatusReason(JsonNode workloadStatusReason) { + this.workloadStatusReason = workloadStatusReason; + } + + @JsonProperty("workload_status_reason") + public JsonNode getWorkloadStatusReason() { + return workloadStatusReason; + } + + @JsonProperty("workload_status") + public String getWorkloadSstatus() { + return workloadStatus; + } + + @JsonProperty("workload_status") + public void setWorkloadStatus(String workloadStatus) { + this.workloadStatus = workloadStatus; + } + + @Override public String toString() { return new ToStringBuilder(this).append("templateType", templateType).append("workloadId", workloadId) - .append("templateResponse", templateResponse).toString(); + .append("templateResponse", templateResponse) + .append("workload_status_reason", workloadStatusReason.toString()) + .append("workload_status", workloadStatus).toString(); } } 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 deleted file mode 100644 index 67cb73539d..0000000000 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MulticloudCreateStackResponse.java +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2018 Intel Corp. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.so.openstack.utils; - -import java.io.Serializable; -import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -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; - - @JsonProperty("stack") - private MulticloudCreateHeatResponse stack; - - @JsonCreator - public MulticloudCreateStackResponse(@JsonProperty("stack") MulticloudCreateHeatResponse stack) { - this.stack = stack; - } - - @JsonProperty("stack") - public MulticloudCreateHeatResponse getStack() { - return stack; - } - - @JsonProperty("stack") - public void setStack(MulticloudCreateHeatResponse stack) { - this.stack = stack; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("stack", stack).toString(); - } -} diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java index 5f2057524f..48ca0fd79c 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/vnf/MsoVnfMulticloudAdapterImplTest.java @@ -55,8 +55,6 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { @Autowired private CloudConfig cloudConfig; - private static final String CREATE_STACK_RESPONSE = "{\"template_type\": \"TEST-template\", \"workload_id\": " - + "\"workload-id\", \"template_response\": {\"stack\": {\"id\": \"TEST-stack\", \"links\": []}}}"; private static final String UPDATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": " + "\"workload-id\"}"; private static final String GET_CREATE_STACK_RESPONSE = "{\"template_type\": \"heat\", \"workload_id\": " @@ -125,6 +123,51 @@ public class MsoVnfMulticloudAdapterImplTest extends BaseRestTestUtils { } @Test + public void createVfModule2() throws Exception { + + Map<String, Object> stackInputs = new HashMap<>(); + stackInputs.put("oof_directives", "{}"); + stackInputs.put("sdnc_directives", "{}"); + stackInputs.put("user_directives", "{}"); + stackInputs.put("generic_vnf_id", "genVNFID"); + stackInputs.put("vf_module_id", "vfMODULEID"); + + MsoRequest msoRequest = new MsoRequest(); + msoRequest.setRequestId("12345"); + msoRequest.setServiceInstanceId("12345"); + + wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_NAME)).willReturn( + aResponse().withHeader("Content-Type", "application/json").withStatus(HttpStatus.SC_NOT_FOUND))); + + wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE") + .whenScenarioStateIs("CREATING").willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBody(GET_CREATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK))); + + wireMockServer.stubFor(get(urlPathEqualTo(MULTICLOUD_GET_PATH_BY_ID)).inScenario("CREATE") + .whenScenarioStateIs("UPDATING").willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBody(GET_UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_OK))); + + wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_CREATE_PATH)).inScenario("CREATE") + .willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBodyFile("MulticloudResponse_Stack_Create2.json").withStatus(HttpStatus.SC_CREATED)) + .willSetStateTo("CREATING")); + + wireMockServer.stubFor(post(urlPathEqualTo(MULTICLOUD_UPDATE_PATH)) + .inScenario("CREATE").willReturn(aResponse().withHeader("Content-Type", "application/json") + .withBody(UPDATE_STACK_RESPONSE).withStatus(HttpStatus.SC_ACCEPTED)) + .willSetStateTo("UPDATING")); + + try { + instance.createVfModule("MTN13", "CloudOwner", "123", "vf", "v1", "genericVnfId", "vfname", "vfModuleId", + "create", null, "234", "9b339a61-69ca-465f-86b8-1c72c582b8e8", stackInputs, true, true, true, + msoRequest, new Holder<>(), new Holder<>(), new Holder<>()); + } catch (VnfException e) { + fail("createVfModule success expected, failed with exception: " + e.toString()); + } + wireMockServer.resetScenarios(); + } + + @Test public void createVfModuleAlreadyExists() throws Exception { Map<String, Object> stackInputs = new HashMap<>(); diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json new file mode 100644 index 0000000000..8532fae97c --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/MulticloudResponse_Stack_Create2.json @@ -0,0 +1,15 @@ +{ + "template_type": "HEAT", + "workload_id": "workload-id", + "workload_status_reason": + { + "id": "workload-id", + "links": [ + { + "href": "http://localhost:1234/v1/id12345678/stacks/workload-id/abcdef00-1234-abcd-5678-ef9123456789", + "rel": "self" + } + ] + }, + "workload_status": "CREATE_IN_PROGRESS" +} |