diff options
Diffstat (limited to 'adapters')
15 files changed, 180 insertions, 54 deletions
diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/HeatStack.json b/adapters/mso-adapter-utils/src/test/resources/__files/HeatStack.json index 411a3e0bd7..679e8e1832 100644 --- a/adapters/mso-adapter-utils/src/test/resources/__files/HeatStack.json +++ b/adapters/mso-adapter-utils/src/test/resources/__files/HeatStack.json @@ -1,11 +1,11 @@ { "description" : "description", "links" : [], - "stackStatusReason" : "stackStatusReason", - "stackName" : "stackName", - "updatedTime" : null, - "creationTime" : null, - "stackStatus" : "stackStatus", + "stack_status_reason" : "stackStatusReason", + "stack_name" : "stackName", + "updated_time" : null, + "creation_time" : null, + "stack_status" : "stackStatus", "id" : "id", "files" : {} }
\ No newline at end of file diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json index f1c08cc093..cd516ad082 100644 --- a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json +++ b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Access.json @@ -18,7 +18,7 @@ "adminURL": null } ], - "endpointsLinks": null + "endpoints_links": null }, { "type": "network", @@ -31,7 +31,7 @@ "adminURL": null } ], - "endpointsLinks": null + "endpoints_links": null }, { "type": "identity", @@ -44,7 +44,7 @@ "adminURL": null } ], - "endpointsLinks": null + "endpoints_links": null } ], "user": null, diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Stack_DeleteComplete.json b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Stack_DeleteComplete.json index 8612258eee..a26a551f7d 100644 --- a/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Stack_DeleteComplete.json +++ b/adapters/mso-adapter-utils/src/test/resources/__files/OpenstackResponse_Stack_DeleteComplete.json @@ -2,10 +2,10 @@ "stack": { "description": null, "links": null, - "stackStatusReason": null, - "stackName": null, - "updatedTime": null, - "creationTime": null, + "stack_status_reason": null, + "stack_name": null, + "updated_time": null, + "creation_time": null, "stack_status": "DELETE_COMPLETE", "id": "stackId", "files": null, diff --git a/adapters/mso-adapter-utils/src/test/resources/__files/UpdateStack.json b/adapters/mso-adapter-utils/src/test/resources/__files/UpdateStack.json index 0a09d599ba..bf61cc8c8b 100644 --- a/adapters/mso-adapter-utils/src/test/resources/__files/UpdateStack.json +++ b/adapters/mso-adapter-utils/src/test/resources/__files/UpdateStack.json @@ -1,11 +1,11 @@ { "description" : "description", "links" : [], - "stackStatusReason" : "stackStatusReason", - "stackName" : "stackName", - "updatedTime" : null, - "creationTime" : null, - "stackStatus" : "UPDATE_COMPLETE", + "stack_status_reason" : "stackStatusReason", + "stack_name" : "stackName", + "updated_time" : null, + "creation_time" : null, + "stack_status" : "UPDATE_COMPLETE", "id" : "id", "files" : {} }
\ No newline at end of file diff --git a/adapters/mso-adapters-rest-interface/src/test/resources/stack-example.json b/adapters/mso-adapters-rest-interface/src/test/resources/stack-example.json index c0f08f8bd7..968f6179b0 100644 --- a/adapters/mso-adapters-rest-interface/src/test/resources/stack-example.json +++ b/adapters/mso-adapters-rest-interface/src/test/resources/stack-example.json @@ -1,13 +1,12 @@ { "outputs" : [{ - "outputKey": "key1", - "outputValue": "value1" + "output_key": "key1", + "output_value": "value1" },{ - "outputKey": "key2", - "outputValue": "value2" + "output_key": "key2", + "output_value": "value2" },{ - "outputKey": "key3", - "outputValue": "value3" + "output_key": "key3", + "output_value": "value3" }] - }
\ No newline at end of file diff --git a/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql new file mode 100644 index 0000000000..627f7a4a61 --- /dev/null +++ b/adapters/mso-catalog-db-adapter/src/main/resources/db/migration/V4.11__RecreateRecipe.sql @@ -0,0 +1,5 @@ +use catalogdb; + +INSERT INTO `vnf_recipe` (`NF_ROLE`, `ACTION`, `VERSION_STR`, `DESCRIPTION`, `ORCHESTRATION_URI`, `RECIPE_TIMEOUT`) +VALUES +('GR-API-DEFAULT', 'recreateInstance', '1', 'Gr api recipe to recreate vnf', '/mso/async/services/WorkflowActionBB', 180);
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java index 2eeed777de..b47905d134 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImpl.java @@ -294,7 +294,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { } catch (Exception e1) { error = "Error sending updateNetwork notification " + e1.getMessage (); LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNetwork notification", e1); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -311,7 +311,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { } catch (Exception e) { error = "Error sending updateNotification request" + e.getMessage (); LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending updateNotification request", e); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -376,9 +376,9 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.queryNetworkNotification (messageId, false, exCat, eMsg, null, null, null, null, null, null); } catch (Exception e1) { - error = "Error sending createNetwork notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + error = CREATE_NETWORK_ERROR_MSG + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e1); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -398,9 +398,9 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { vlans.value, copyQuerySubnetIdMap (subnetIdMap)); } catch (Exception e) { - error = "Error sending createNetwork notification " + e.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + error = CREATE_NETWORK_ERROR_MSG + e.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -463,9 +463,9 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.deleteNetworkNotification (messageId, false, exCat, eMsg, null); } catch (Exception e1) { - error = "Error sending createNetwork notification " + e1.getMessage (); - LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending createNetwork notification", e1); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + error = CREATE_NETWORK_ERROR_MSG + e1.getMessage (); + LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, CREATE_NETWORK_EXCEPTON_MSG, e1); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -477,7 +477,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { } catch (Exception e) { error = "Error sending deleteNetwork notification " + e.getMessage (); LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception sending deleteNetwork notification", e); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -527,9 +527,9 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { NetworkAdapterNotify notifyPort = getNotifyEP (notificationUrl); notifyPort.rollbackNetworkNotification (rollback.getMsoRequest ().getRequestId (), false, exCat, eMsg); } catch (Exception e1) { - error = "Error sending createNetwork notification " + e1.getMessage (); + error = CREATE_NETWORK_ERROR_MSG + e1.getMessage (); LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending createNetwork notification ", e1); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -541,7 +541,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { } catch (Exception e) { error = "Error sending rollbackNetwork notification " + e.getMessage (); LOGGER.error (MessageEnum.RA_CREATE_NETWORK_NOTIF_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception in sending rollbackNetwork notification", e); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error); } return; } @@ -627,7 +627,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { } catch (Exception e) { String error1 = "Unable to set authorization in callback request" + e.getMessage (); LOGGER.error (MessageEnum.RA_SET_CALLBACK_AUTH_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception - Unable to set authorization in callback request", e); - alarmLogger.sendAlarm ("MsoInternalError", MsoAlarmLogger.CRITICAL, error1); + alarmLogger.sendAlarm (MSO_INTERNAL_ERROR_MSG, MsoAlarmLogger.CRITICAL, error1); } return notifyPort; 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 ac33a5269e..4b6bd09144 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 @@ -42,6 +42,8 @@ import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.HeatTemplate; import org.onap.so.db.catalog.beans.NetworkResource; import org.onap.so.db.catalog.beans.NetworkResourceCustomization; +import org.onap.so.db.catalog.beans.CollectionNetworkResourceCustomization; +import org.onap.so.db.catalog.data.repository.CollectionNetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceCustomizationRepository; import org.onap.so.db.catalog.data.repository.NetworkResourceRepository; import org.onap.so.db.catalog.utils.MavenLikeVersioning; @@ -108,6 +110,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { private NetworkResourceCustomizationRepository networkCustomRepo; @Autowired + private CollectionNetworkResourceCustomizationRepository collectionNetworkCustomRepo; + + @Autowired private NetworkResourceRepository networkResourceRepo; /** * Health Check web method. Does nothing but return to show the adapter is deployed. @@ -1124,18 +1129,26 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { // Retrieve the Network Resource definition NetworkResource networkResource = null; NetworkResourceCustomization networkCust = null; + CollectionNetworkResourceCustomization collectionNetworkCust = null; if (commonUtils.isNullOrEmpty(modelCustomizationUuid)) { if (!commonUtils.isNullOrEmpty(networkType)) { - networkResource = networkResourceRepo.findOneByModelName(networkType); + networkResource = networkResourceRepo.findFirstByModelNameOrderByModelVersionDesc(networkType); } } else { networkCust = networkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid); + if (networkCust == null) { + collectionNetworkCust = collectionNetworkCustomRepo.findOneByModelCustomizationUUID(modelCustomizationUuid); + } } if(networkCust != null){ LOGGER.debug("Got Network Customization definition from Catalog: " + networkCust.toString()); networkResource = networkCust.getNetworkResource(); + } else if (collectionNetworkCust != null) { + LOGGER.debug("Retrieved Collection Network Resource Customization from Catalog: " + + collectionNetworkCust.toString()); + networkResource = collectionNetworkCust.getNetworkResource(); } if (networkResource == null) { String error = "Create/UpdateNetwork: Unable to get network resource with NetworkType:" diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java index 465fb6d866..effe7a8c61 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/NetworkAdapterRest.java @@ -84,8 +84,8 @@ import io.swagger.annotations.ApiResponses; public class NetworkAdapterRest { private static final MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA,NetworkAdapterRest.class); private static final String TESTING_KEYWORD = "___TESTING___"; - - + private String APPEND_RESPONSE = ", resp="; + private String EXCEPTION = "Exception:"; @Autowired private MsoNetworkAdapterImpl adapter; @@ -239,7 +239,7 @@ public class NetworkAdapterRest { rollback.value, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug ("Exception:", e); + LOGGER.debug (EXCEPTION, e); eresp = new CreateNetworkError( e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } @@ -248,7 +248,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug ("CreateNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + LOGGER.debug ("CreateNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); } } @@ -345,7 +345,7 @@ public class NetworkAdapterRest { } response = new DeleteNetworkResponse(req.getNetworkId(), networkDeleted.value, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug ("Exception:", e); + LOGGER.debug (EXCEPTION, e); eresp = new DeleteNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -353,7 +353,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("DeleteNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + LOGGER.debug("DeleteNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); } } @@ -501,7 +501,7 @@ public class NetworkAdapterRest { adapter.rollbackNetwork(nwr); response = new RollbackNetworkResponse(true, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug ("Exception:", e); + LOGGER.debug (EXCEPTION, e); eresp = new RollbackNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -509,7 +509,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("RollbackNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + LOGGER.debug("RollbackNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); } } @@ -649,7 +649,7 @@ public class NetworkAdapterRest { subnetIdMap.value, req.getMessageId()); } catch (NetworkException e) { - LOGGER.debug ("Exception:", e); + LOGGER.debug (EXCEPTION, e); eresp = new UpdateNetworkError(e.getMessage(), MsoExceptionCategory.INTERNAL, true, req.getMessageId()); } if (!req.isSynchronous()) { @@ -657,7 +657,7 @@ public class NetworkAdapterRest { BpelRestClient bpelClient = bpelRestClientProvider.get(); bpelClient.bpelPost(getResponse(), req.getNotificationUrl(), sendxml); } - LOGGER.debug("UpdateNetworkTask exit: code=" + getStatusCode() + ", resp="+ getResponse()); + LOGGER.debug("UpdateNetworkTask exit: code=" + getStatusCode() + APPEND_RESPONSE+ getResponse()); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java index d65cdc4638..f2238fce78 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/async/client/ObjectFactory.java @@ -4,7 +4,6 @@ * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ - * Modifications Copyright 2018 IBM. * 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 diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java index 996e2c2712..72c74ccaf9 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/openstack/CXFConfiguration.java @@ -47,7 +47,7 @@ import org.onap.so.adapters.vnf.VnfAdapterRestV2; import org.onap.so.adapters.vnf.VolumeAdapterRest; import org.onap.so.adapters.vnf.VolumeAdapterRestV2; import org.onap.so.client.policy.JettisonStyleMapperProvider; -import org.onap.so.logger.MsoLogger; + import org.onap.so.logging.cxf.interceptor.SOAPLoggingInInterceptor; import org.onap.so.logging.cxf.interceptor.SOAPLoggingOutInterceptor; import org.springframework.beans.factory.annotation.Autowired; diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java index 2a4564bcb2..6123415b41 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/NetworkAdapterRestTest.java @@ -142,7 +142,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange( createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); - + CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( new File("src/test/resources/__files/CreateNetworkResponse2.json"), CreateNetworkResponse.class); @@ -150,6 +150,8 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { assertThat(response.getBody(), sameBeanAs(expectedResponse)); } + + @Test public void testDeleteNetwork() throws IOException{ @@ -267,6 +269,33 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); } + @Test + public void testCreateNetworkCNRC_JSON() throws JSONException, JsonParseException, JsonMappingException, IOException { + + mockOpenStackResponseAccess(wireMockPort); + + mockOpenStackPostPublicUrlWithBodyFile_200(); + + mockOpenStackGetStackCreatedAppC_200(); + + mockOpenStackGetStackAppC_404(); + + headers.add("Content-Type", MediaType.APPLICATION_JSON); + headers.add("Accept", MediaType.APPLICATION_JSON); + + String request = readJsonFileAsString("src/test/resources/CreateNetwork3.json"); + HttpEntity<String> entity = new HttpEntity<String>(request, headers); + + ResponseEntity<CreateNetworkResponse> response = restTemplate.exchange( + createURLWithPort("/services/rest/v1/networks"), HttpMethod.POST, entity, CreateNetworkResponse.class); + + CreateNetworkResponse expectedResponse = jettisonTypeObjectMapper.getMapper().readValue( + new File("src/test/resources/__files/CreateNetworkResponse3.json"), CreateNetworkResponse.class); + + assertEquals(Response.Status.OK.getStatusCode(), response.getStatusCode().value()); + assertThat(response.getBody(), sameBeanAs(expectedResponse)); + } + @Override protected String readJsonFileAsString(String fileLocation) throws JsonParseException, JsonMappingException, IOException{ return new String(Files.readAllBytes(Paths.get(fileLocation))); diff --git a/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json new file mode 100644 index 0000000000..accd9e9a54 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork3.json @@ -0,0 +1,42 @@ +{ + "createNetworkRequest": { + "skipAAI": true, + "messageId": "c4c44af4-4310-4d8b-a1eb-656fc99fe709", + "synchronous": true, + "cloudSiteId": "mtn13", + "tenantId": "ba38bc24a2ef4fb2ad2810c894f1938f", + "networkId": "da886914-efb2-4917-b335-c8381528d90b", + "networkName": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3", + "networkType": "CONTRAIL30_BASIC", + "modelCustomizationUuid": "3bdbb104-ffff-483e-9f8b-c095b3d30844", + "networkTechnology": "NEUTRON", + "subnets": [{ + "subnetName": "APP-C-24595-T-IST-04AShared_untrusted_vDBE_net_3_subnet_1", + "subnetId": "da60501d-9aa8-48d2-99b7-26644fa01093", + "cidr": "20", + "gatewayIp": "", + "ipVersion": "4", + "enableDHCP": false, + "addrFromStart": true, + "hostRoutes": [] + }], + "providerVlanNetwork": { + "physicalNetworkName": "FALSE", + "vlans": [] + }, + "contrailNetwork": { + "shared": "false", + "external": "false", + "routeTargets": [], + "policyFqdns": [], + "routeTableFqdns": [] + }, + "failIfExists": true, + "backout": false, + "msoRequest": { + "requestId": "5349f419-b3e9-4546-b3a1-094bd568d6b7", + "serviceInstanceId": "cf965caf-a003-4189-abf9-e0ed77056dd6" + }, + "contrailRequest": false + } +}
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json new file mode 100644 index 0000000000..2e5517cebb --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse3.json @@ -0,0 +1,25 @@ +{ + "createNetworkResponse": { + "networkId": "da886914-efb2-4917-b335-c8381528d90b", + "neutronNetworkId": null, + "networkStackId": "stackname/stackId", + "networkFqdn": null, + "networkCreated": true, + "subnetMap": { + + }, + "rollback": { + "networkStackId": "stackname/stackId", + "tenantId": "ba38bc24a2ef4fb2ad2810c894f1938f", + "cloudId": "mtn13", + "networkType": "CONTRAIL30_BASIC", + "modelCustomizationUuid": "3bdbb104-ffff-483e-9f8b-c095b3d30844", + "networkCreated": true, + "msoRequest": { + "requestId": "5349f419-b3e9-4546-b3a1-094bd568d6b7", + "serviceInstanceId": "cf965caf-a003-4189-abf9-e0ed77056dd6" + } + }, + "messageId": "c4c44af4-4310-4d8b-a1eb-656fc99fe709" + } +}
\ No newline at end of file diff --git a/adapters/mso-openstack-adapters/src/test/resources/data.sql b/adapters/mso-openstack-adapters/src/test/resources/data.sql index d16ca4528c..960f483e46 100644 --- a/adapters/mso-openstack-adapters/src/test/resources/data.sql +++ b/adapters/mso-openstack-adapters/src/test/resources/data.sql @@ -71,6 +71,20 @@ insert into network_resource_customization(model_customization_uuid, model_insta ('3bdbb104-476c-483e-9f8b-c095b3d30844', 'CONTRAIL30_BASIC', '', 'CONTRAIL30_BASIC', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c4789'), ('3bdbb104-476c-483e-9f8b-c095b3d3068c', 'CONTRAIL31_BASIC', '', 'CONTRAIL31_BASIC', '', '', '2017-04-19 14:28:32', '10b36f65-f4e6-4be6-ae49-9596dc1c4790'); +insert into instance_group(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, role, object_type, cr_model_uuid, instance_group_type) values +('21e43a7c-d823-4f5b-a427-5235f63035ff', 'dror_cr_network_resource_1806..NetworkCollection..0', '81c94263-c01e-4046-b0c7-51878d658eab', '1', 'org.openecomp.groups.NetworkCollection', 'SUB_INTERFACE', 'L3_NETWORK', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'L3_NETWORK'); + +insert into collection_resource(model_uuid, model_name, model_invariant_uuid, model_version, tosca_node_type, description) values +('5e3fca45-e2d8-4987-bef1-016d9bda1a8c', 'Dror_CR_Network_Resource_1806', 'fe243154-ac18-405f-94c2-ef629d26b8bb', '2.0', 'org.openecomp.resource.cr.DrorCrNetworkResource1806', 'Creation date: 07/25/18'); + +insert into collection_resource_customization(model_customization_uuid, model_instance_name, role, object_type, function, collection_resource_type, cr_model_uuid) values +('c51096a4-6081-41f4-a540-3ed015a8064a', 'Dror_CR_Network_Resource_1806', 'Dror2', 'NetworkCollection', 'Dror1', 'Dror3', '5e3fca45-e2d8-4987-bef1-016d9bda1a8c'); + +insert into collection_network_resource_customization(model_customization_uuid, model_instance_name, network_technology, network_type, network_role, network_scope, network_resource_model_uuid, instance_group_model_uuid, crc_model_customization_uuid) values +('3bdbb104-ffff-483e-9f8b-c095b3d30844', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c4789', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'), +('3bdbb104-ffff-483e-9f8b-c095b3d3068c', 'ExtVL 0', 'CONTRAIL', 'L3-NETWORK', '', '', '10b36f65-f4e6-4be6-ae49-9596dc1c4790', '21e43a7c-d823-4f5b-a427-5235f63035ff', 'c51096a4-6081-41f4-a540-3ed015a8064a'); + + insert into vnf_resource(orchestration_mode, description, creation_timestamp, model_uuid, aic_version_min, aic_version_max, model_invariant_uuid, model_version, model_name, tosca_node_type, heat_template_artifact_uuid) values ('HEAT', '1607 vSAMP10a - inherent network', '2017-04-14 21:46:28', 'ff2ae348-214a-11e7-93ae-92361f002672', '', '', '2fff5b20-214b-11e7-93ae-92361f002671', '2.0', 'vSAMP10a', 'VF', null); |