diff options
author | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-24 17:06:39 -0500 |
---|---|---|
committer | Benjamin, Max (mb388a) <mb388a@us.att.com> | 2019-01-24 17:13:01 -0500 |
commit | 7ab8e99936aa0dd72c8b0f54620bbfef8d7ec455 (patch) | |
tree | 7018cb258315e327f4817a7f01abe344426f4426 /adapters | |
parent | 147e9ee814448c8bbec4aa3aeac4b7118b7c1bc7 (diff) |
bugfixes jan 24th
Fix null pointer exception when no requestParameters are specified
Add configurable timer in ActivateVfModuleBB to delay call to SDNC
activate - Use raw slf4j logger - use {} formatting
Add configurable timer in ActivateVfModuleBB to delay call to SDNC
activate - Use raw slf4j logger
Add configurable timer in ActivateVfModuleBB to delay call to SDNC
activate - removed unused references in test class
Add configurable timer in ActivateVfModuleBB to delay call to SDNC
activate
Update PortGroup objects separately from the parent VCE object -
restore setVariable calls back into vce object - they might be needed
later.
Update PortGroup objects separately from the parent VCE object -
updated test class
extra call to get PortGroups
Update PortGroup objects separately from the parent VCE object - use
PortGroup.getInterfaceRole() getter method instead of accessing field
directly.
Update PortGroup objects separately from the parent VCE object
Added back required headers for tenant isolation.
removed workflow exception from outmapping in execute
Fix possible null ptr exception, fix to add braces.
Default networkTechnology in Update as done in Create
Fix failing junits, mapper force upper case nwtech
update exception builder to properly throw exception error message
supporting assign service instance a la carte as well
adding in proper exception handling in network rest v1
add the unassign action to R macro data file
Change-Id: Ide420514f81b8083b4c76c762c064de199624cf7
Issue-ID: SO-1424
Signed-off-by: Benjamin, Max (mb388a) <mb388a@us.att.com>
Diffstat (limited to 'adapters')
12 files changed, 239 insertions, 44 deletions
diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/CreateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/CreateNetworkRequest.java index 3e4d18cb1b..153ee78cb0 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/CreateNetworkRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/CreateNetworkRequest.java @@ -54,7 +54,7 @@ public class CreateNetworkRequest extends NetworkRequestCommon { private String networkType; private String networkTypeVersion; private String modelCustomizationUuid; - private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; + private String networkTechnology = "NEUTRON"; private List<Subnet> subnets; private ProviderVlanNetwork providerVlanNetwork; private ContrailNetwork contrailNetwork; @@ -62,7 +62,6 @@ public class CreateNetworkRequest extends NetworkRequestCommon { private Boolean backout = true; private Map<String,String> networkParams = new HashMap<>(); private MsoRequest msoRequest = new MsoRequest(); - @JsonProperty private boolean contrailRequest; public CreateNetworkRequest() { @@ -125,13 +124,12 @@ public class CreateNetworkRequest extends NetworkRequestCommon { this.networkTypeVersion = networkTypeVersion; } - public NetworkTechnology getNetworkTechnology() { + public String getNetworkTechnology() { return networkTechnology; } - public void setNetworkTechnology(NetworkTechnology networkTechnology) { + public void setNetworkTechnology(String networkTechnology) { this.networkTechnology = networkTechnology; - this.contrailRequest = determineContrail(); } public List<Subnet> getSubnets() { @@ -156,7 +154,6 @@ public class CreateNetworkRequest extends NetworkRequestCommon { public void setContrailNetwork(ContrailNetwork contrailNetwork) { this.contrailNetwork = contrailNetwork; - this.contrailRequest = determineContrail(); } public Boolean getFailIfExists() { @@ -195,12 +192,8 @@ public class CreateNetworkRequest extends NetworkRequestCommon { return this.contrailRequest; } - @JsonIgnore - protected void setContrailRequest(boolean contrailRequest) { + public void setContrailRequest(boolean contrailRequest) { this.contrailRequest = contrailRequest; } - private boolean determineContrail() { - return (networkTechnology == NetworkTechnology.CONTRAIL && (contrailNetwork != null)); - } } diff --git a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/UpdateNetworkRequest.java b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/UpdateNetworkRequest.java index a7976840b7..595662251f 100644 --- a/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/UpdateNetworkRequest.java +++ b/adapters/mso-adapters-rest-interface/src/main/java/org/onap/so/adapters/nwrest/UpdateNetworkRequest.java @@ -52,7 +52,7 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { private String networkType; private String networkTypeVersion; private String modelCustomizationUuid; - private NetworkTechnology networkTechnology = NetworkTechnology.NEUTRON; + private String networkTechnology = "NEUTRON"; private List<Subnet> subnets; private ProviderVlanNetwork providerVlanNetwork; private ContrailNetwork contrailNetwork; @@ -130,13 +130,12 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { this.networkTypeVersion = networkTypeVersion; } - public NetworkTechnology getNetworkTechnology() { + public String getNetworkTechnology() { return networkTechnology; } - public void setNetworkTechnology(NetworkTechnology networkTechnology) { + public void setNetworkTechnology(String networkTechnology) { this.networkTechnology = networkTechnology; - this.contrailRequest = determineContrail(); } public List<Subnet> getSubnets() { @@ -161,7 +160,6 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { public void setContrailNetwork(ContrailNetwork contrailNetwork) { this.contrailNetwork = contrailNetwork; - this.contrailRequest = determineContrail(); } public Boolean getBackout() { @@ -195,8 +193,4 @@ public class UpdateNetworkRequest extends NetworkRequestCommon { return contrailRequest; } - private boolean determineContrail() { - return (networkTechnology == NetworkTechnology.CONTRAIL && (contrailNetwork != null)); - } - } diff --git a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java index 08851c2ce9..5e04fc49ee 100644 --- a/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java +++ b/adapters/mso-adapters-rest-interface/src/test/java/org/onap/so/adapters/nwrest/NetworkRequestTest.java @@ -38,13 +38,4 @@ public class NetworkRequestTest { assertEquals(true, networkResponse.isSynchronous()); } - @Test - public void isContrailRequest() { - CreateNetworkRequest networkResponse = new CreateNetworkRequest(); - assertEquals(false, networkResponse.isContrailRequest()); - networkResponse.setNetworkTechnology(NetworkTechnology.CONTRAIL); - assertEquals(false, networkResponse.isContrailRequest()); - networkResponse.setContrailNetwork(new ContrailNetwork()); - assertEquals(true, networkResponse.isContrailRequest()); - } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java index 27829a6156..6e2fcb02c9 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapter.java @@ -55,9 +55,12 @@ public interface MsoNetworkAdapter @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") String physicalNetworkName, @WebParam(name="vlans") List<Integer> vlans, + @WebParam(name="shared") String shared, + @WebParam(name="external") String external, @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="networkParams") Map<String, String> networkParams, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId, @WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId, @@ -77,6 +80,7 @@ public interface MsoNetworkAdapter @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="networkParams") Map<String, String> networkParams, @WebParam(name="policyFqdns") List<String> policyFqdns, @WebParam(name="routeTableFqdns") List<String> routeTableFqdns, @WebParam(name="request") MsoRequest msoRequest, @@ -100,7 +104,10 @@ public interface MsoNetworkAdapter @WebParam(name="networkName") @XmlElement(required=true) String networkName, @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, @WebParam(name="vlans") @XmlElement(required=true) List<Integer> vlans, + @WebParam(name="shared") String shared, + @WebParam(name="external") String external, @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="networkParams") Map<String,String> networkParams, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap, @WebParam(name="rollback", mode=Mode.OUT) Holder<NetworkRollback> rollback ) @@ -117,6 +124,7 @@ public interface MsoNetworkAdapter @WebParam(name="shared") String shared, @WebParam(name="external") String external, @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="networkParams") Map<String,String> networkParams, @WebParam(name="policyFqdns") List<String> policyFqdns, @WebParam(name="routeTableFqdns") List<String> routeTableFqdns, @WebParam(name="request") MsoRequest msoRequest, diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java index 99f590b773..a85da58536 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterAsync.java @@ -22,6 +22,7 @@ package org.onap.so.adapters.network; import java.util.List; +import java.util.Map; import javax.jws.Oneway; import javax.jws.WebMethod; @@ -56,6 +57,7 @@ public interface MsoNetworkAdapterAsync @WebParam(name="failIfExists") Boolean failIfExists, @WebParam(name="backout") Boolean backout, @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="networkParams") Map<String, String> networkParams, @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); @@ -71,6 +73,7 @@ public interface MsoNetworkAdapterAsync @WebParam(name="physicalNetworkName") @XmlElement(required=true) String physicalNetworkName, @WebParam(name="vlans") @XmlElement(required=true) List<Integer> vlans, @WebParam(name="subnets") List<Subnet> subnets, + @WebParam(name="networkParams") Map<String, String> networkParams, @WebParam(name="messageId") @XmlElement(required=true) String messageId, @WebParam(name="request") MsoRequest msoRequest, @WebParam(name="notificationUrl") @XmlElement(required=true) String notificationUrl ); 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 608f39adb4..8181714c0a 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 @@ -122,6 +122,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { Boolean failIfExists, Boolean backout, List <Subnet> subnets, + Map<String,String> networkParams, String messageId, MsoRequest msoRequest, String notificationUrl) { @@ -145,6 +146,16 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { Holder <String> neutronNetworkId = new Holder <> (); Holder <NetworkRollback> networkRollback = new Holder <> (); Holder <Map <String, String>> subnetIdMap = new Holder <> (); + + HashMap<String, String> params = (HashMap<String,String>) networkParams; + if (params == null) + params = new HashMap<String,String>(); + String shared = null; + String external = null; + if (params.containsKey("shared")) + shared = params.get("shared"); + if (params.containsKey("external")) + external = params.get("external"); try { networkAdapter.createNetwork (cloudSiteId, @@ -154,9 +165,12 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { networkName, physicalNetworkName, vlans, + shared, + external, failIfExists, backout, subnets, + params, msoRequest, networkId, neutronNetworkId, @@ -239,6 +253,7 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { String physicalNetworkName, List <Integer> vlans, List <Subnet> subnets, + Map <String,String> networkParams, String messageId, MsoRequest msoRequest, String notificationUrl) { @@ -261,6 +276,16 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { // Synchronous Web Service Outputs Holder <NetworkRollback> networkRollback = new Holder <> (); Holder <Map <String, String>> subnetIdMap = new Holder <> (); + + HashMap<String, String> params = (HashMap<String,String>) networkParams; + if (params == null) + params = new HashMap<String,String>(); + String shared = null; + String external = null; + if (params.containsKey("shared")) + shared = params.get("shared"); + if (params.containsKey("external")) + external = params.get("external"); try { networkAdapter.updateNetwork (cloudSiteId, @@ -271,7 +296,10 @@ public class MsoNetworkAdapterAsyncImpl implements MsoNetworkAdapterAsync { networkName, physicalNetworkName, vlans, + shared, + external, subnets, + params, msoRequest, subnetIdMap, networkRollback); 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 45285d0e51..d250561f16 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 @@ -138,9 +138,12 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String networkName, String physicalNetworkName, List <Integer> vlans, + String shared, + String external, Boolean failIfExists, Boolean backout, List <Subnet> subnets, + Map<String, String> networkParams, MsoRequest msoRequest, Holder <String> networkId, Holder <String> neutronNetworkId, @@ -155,8 +158,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { physicalNetworkName, vlans, null, - null, - null, + shared, + external, failIfExists, backout, subnets, @@ -182,6 +185,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { Boolean failIfExists, Boolean backout, List <Subnet> subnets, + Map<String, String> networkParams, List <String> policyFqdns, List<String> routeTableFqdns, MsoRequest msoRequest, @@ -660,7 +664,10 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String networkName, String physicalNetworkName, List <Integer> vlans, + String shared, + String external, List <Subnet> subnets, + Map<String,String> networkParams, MsoRequest msoRequest, Holder <Map <String, String>> subnetIdMap, Holder <NetworkRollback> rollback) throws NetworkException { @@ -673,8 +680,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { physicalNetworkName, vlans, null, - null, - null, + shared, + external, subnets, null, null, @@ -695,6 +702,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { String shared, String external, List <Subnet> subnets, + Map<String, String> networkParams, List <String> policyFqdns, List<String> routeTableFqdns, MsoRequest msoRequest, 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 effe7a8c61..8d08b3b52c 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 @@ -168,6 +168,13 @@ public class NetworkAdapterRest { Holder<String> networkFqdn = new Holder<>(); Holder<Map<String, String>> subnetIdMap = new Holder<>(); Holder<NetworkRollback> rollback = new Holder<>(); + + HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams(); + if (params == null) { + params = new HashMap<String,String>(); + } + String shared = null; + String external = null; String cloudsite = req.getCloudSiteId(); if (cloudsite != null && cloudsite.equals(TESTING_KEYWORD)) { @@ -186,6 +193,20 @@ public class NetworkAdapterRest { ctn = new ContrailNetwork(); req.setContrailNetwork(ctn); } + if (params.containsKey("shared")) { + shared = params.get("shared"); + } else { + if (ctn.getShared() != null) { + shared = ctn.getShared(); + } + } + if (params.containsKey("external")) { + external = params.get("external"); + } else { + if (ctn.getExternal() != null) { + external = ctn.getExternal(); + } + } adapter.createNetworkContrail( req.getCloudSiteId(), req.getTenantId(), @@ -193,11 +214,12 @@ public class NetworkAdapterRest { req.getModelCustomizationUuid(), req.getNetworkName(), req.getContrailNetwork().getRouteTargets(), - req.getContrailNetwork().getShared(), - req.getContrailNetwork().getExternal(), + shared, + external, req.getFailIfExists(), req.getBackout(), req.getSubnets(), + params, req.getContrailNetwork().getPolicyFqdns(), req.getContrailNetwork().getRouteTableFqdns(), req.getMsoRequest(), @@ -212,6 +234,10 @@ public class NetworkAdapterRest { pvn = new ProviderVlanNetwork(); req.setProviderVlanNetwork(pvn); } + if (params.containsKey("shared")) + shared = params.get("shared"); + if (params.containsKey("external")) + external = params.get("external"); adapter.createNetwork( req.getCloudSiteId(), req.getTenantId(), @@ -220,9 +246,12 @@ public class NetworkAdapterRest { req.getNetworkName(), req.getProviderVlanNetwork().getPhysicalNetworkName(), req.getProviderVlanNetwork().getVlans(), + shared, + external, req.getFailIfExists(), req.getBackout(), req.getSubnets(), + params, req.getMsoRequest(), networkId, neutronNetworkId, @@ -593,6 +622,12 @@ public class NetworkAdapterRest { try { Holder<Map<String, String>> subnetIdMap = new Holder<>(); Holder<NetworkRollback> rollback = new Holder<> (); + HashMap<String, String> params = (HashMap<String, String>) req.getNetworkParams(); + if (params == null) { + params = new HashMap<String,String>(); + } + String shared = null; + String external = null; if (req.getCloudSiteId().equals(TESTING_KEYWORD)) { subnetIdMap.value = testMap(); @@ -607,6 +642,20 @@ public class NetworkAdapterRest { ctn = new ContrailNetwork(); req.setContrailNetwork(ctn); } + if (params.containsKey("shared")) { + shared = params.get("shared"); + } else { + if (ctn.getShared() != null) { + shared = ctn.getShared(); + } + } + if (params.containsKey("external")) { + external = params.get("external"); + } else { + if (ctn.getExternal() != null) { + external = ctn.getExternal(); + } + } adapter.updateNetworkContrail( req.getCloudSiteId(), req.getTenantId(), @@ -615,9 +664,10 @@ public class NetworkAdapterRest { req.getNetworkStackId(), req.getNetworkName(), req.getContrailNetwork().getRouteTargets(), - req.getContrailNetwork().getShared(), - req.getContrailNetwork().getExternal(), + shared, + external, req.getSubnets(), + params, req.getContrailNetwork().getPolicyFqdns(), req.getContrailNetwork().getRouteTableFqdns(), req.getMsoRequest(), @@ -629,6 +679,12 @@ public class NetworkAdapterRest { pvn = new ProviderVlanNetwork(); req.setProviderVlanNetwork(pvn); } + if (params.containsKey("shared")) { + shared = params.get("shared"); + } + if (params.containsKey("external")) { + external = params.get("external"); + } adapter.updateNetwork( req.getCloudSiteId(), req.getTenantId(), @@ -638,7 +694,10 @@ public class NetworkAdapterRest { req.getNetworkName(), req.getProviderVlanNetwork().getPhysicalNetworkName(), req.getProviderVlanNetwork().getVlans(), + shared, + external, req.getSubnets(), + params, req.getMsoRequest(), subnetIdMap, rollback); diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java index 094d308221..f8dcddde04 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/adapters/network/MsoNetworkAdapterAsyncImplTest.java @@ -25,10 +25,12 @@ import org.junit.Test; import org.onap.so.adapters.vnf.BaseRestTestUtils; import org.onap.so.entity.MsoRequest; import org.onap.so.openstack.beans.NetworkRollback; +import org.onap.so.openstack.beans.Subnet; import org.springframework.beans.factory.annotation.Autowired; import java.io.IOException; import java.util.ArrayList; +import java.util.HashMap; import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; import static com.github.tomakehurst.wiremock.client.WireMock.containing; @@ -184,8 +186,11 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { " </soapenv:Body>\n" + "</soapenv:Envelope>") .withStatus(HttpStatus.SC_OK))); + HashMap<String,String> networkParams = new HashMap<String,String>(); + networkParams.put("shared", "true"); + networkParams.put("external", "false"); impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "dvspg-VCE_VPE-mtjnj40avbc", - "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId", + "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<Subnet>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @@ -199,14 +204,17 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { mockOpenStackGetStackCreated_200("OpenstackResponse_Stack_Created.json", "dvspg-VCE_VPE-mtjnj40avbc"); mockOpenStackGetStackDeleteOrUpdateComplete_200("OpenstackResponse_Stack_UpdateComplete.json"); mockOpenStackPutPublicUrlStackByNameAndID_NETWORK2_200(); + HashMap<String,String> networkParams = new HashMap<String,String>(); + networkParams.put("shared", "true"); + networkParams.put("external", "false"); impl.updateNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "dvspg-VCE_VPE-mtjnj40avbc", - "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId", + "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @Test public void updateNetworkATest_NetworkException() { impl.updateNetworkA("cloudSiteId", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "networkId", - "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), "messageId", + "dvspg-VCE_VPE-mtjnj40avbc", "physicalNetworkName", new ArrayList<>(), new ArrayList<>(), new HashMap<String,String>(), "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @@ -237,8 +245,10 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { .withStatus(HttpStatus.SC_OK))); mockOpenStackGetStackCreatedVUSP_200(); mockOpenStackPostStacks_200(); + mockOpenStackPostStacks_200(); + HashMap<String,String> networkParams = new HashMap<String,String>(); impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", - "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId", + "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @@ -251,15 +261,18 @@ public class MsoNetworkAdapterAsyncImplTest extends BaseRestTestUtils { .withStatus(HttpStatus.SC_OK))); mockOpenStackGetStackCreatedVUSP_200(); mockOpenStackPostStacks_200(); + HashMap<String,String> networkParams = new HashMap<String,String>(); + networkParams.put("shared", "true"); + networkParams.put("external", "false"); impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", - "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId", + "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), networkParams, "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } @Test public void createNetworkATest_NetworkException() { impl.createNetworkA("mtn13", "tenantId", "networkType", "3bdbb104-476c-483e-9f8b-c095b3d3068c", "vUSP-23804-T-01-dpa2b_EVUSP-CORE-VIF-TSIG0_net_0", - "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), "messageId", + "physicalNetworkName", new ArrayList<>(), false, false, new ArrayList<>(), new HashMap<String,String>(), "messageId", new MsoRequest(), "http://localhost:"+wireMockPort+"/notificationUrl"); } } 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 6123415b41..3910d9ec44 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 @@ -88,7 +88,7 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { request.setSkipAAI(true); request.setFailIfExists(false); MsoRequest msoReq = new MsoRequest(); - NetworkTechnology networkTechnology = NetworkTechnology.CONTRAIL; + String networkTechnology = "CONTRAIL"; msoReq.setRequestId(MSO_REQUEST_ID); msoReq.setServiceInstanceId(MSO_SERVICE_INSTANCE_ID); @@ -296,6 +296,33 @@ public class NetworkAdapterRestTest extends BaseRestTestUtils { assertThat(response.getBody(), sameBeanAs(expectedResponse)); } + @Test + public void testCreateNetworkNC_Shared_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/CreateNetwork4.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/CreateNetworkResponse4.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/CreateNetwork4.json b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork4.json new file mode 100644 index 0000000000..3a116a6fc1 --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/CreateNetwork4.json @@ -0,0 +1,46 @@ +{ + "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, + "networkParams": { + "shared": "true", + "external": "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/CreateNetworkResponse4.json b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse4.json new file mode 100644 index 0000000000..2e5517cebb --- /dev/null +++ b/adapters/mso-openstack-adapters/src/test/resources/__files/CreateNetworkResponse4.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 |