summaryrefslogtreecommitdiffstats
path: root/adapters/mso-network-adapter/src/main/java
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-03-14 02:07:32 -0400
committerRob Daugherty <rd472p@att.com>2018-03-14 04:08:41 -0400
commit38f720752af4d4aad8c4e467a288d9048659f688 (patch)
treee81066a8b5c77272e30fb57a64999573c4db4d86 /adapters/mso-network-adapter/src/main/java
parentaee3d223f92a6f250f43e17558a2dfd576ff7294 (diff)
AT&T 1712 and 1802 release code
This is code from AT&T's 1712 and 1802 releases. Change-Id: Ie1e85851e94bc66c4d9514a0226c221939531a04 Issue-ID: SO-425 Signed-off-by: Rob Daugherty <rd472p@att.com>
Diffstat (limited to 'adapters/mso-network-adapter/src/main/java')
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java8
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java2
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java34
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java67
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java58
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java2
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java2
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java7
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java160
-rw-r--r--adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java3
10 files changed, 266 insertions, 77 deletions
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java
index 0504627377..e3c6ffd827 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRef.java
@@ -21,13 +21,13 @@
package org.openecomp.mso.adapters.network;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.ObjectMapper;
-
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
public class ContrailPolicyRef {
private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java
index c07678be85..56917a9ff4 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailPolicyRefSeq.java
@@ -21,7 +21,7 @@
package org.openecomp.mso.adapters.network;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class ContrailPolicyRefSeq {
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java
index ec523b87d9..9018524126 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnet.java
@@ -20,18 +20,20 @@
package org.openecomp.mso.adapters.network;
+import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty;
+
import java.util.ArrayList;
import java.util.List;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.ObjectMapper;
-
import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
+import org.openecomp.mso.openstack.beans.HostRoute;
import org.openecomp.mso.openstack.beans.Pool;
import org.openecomp.mso.openstack.beans.Subnet;
-import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
public class ContrailSubnet {
private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
@@ -49,19 +51,20 @@ public class ContrailSubnet {
private Boolean enableDhcp;
@JsonProperty("network_ipam_refs_data_ipam_subnets_addr_from_start")
- private Boolean addrFromStart = true;
-
+ private Boolean addrFromStart = true;
/** future - leave this commented
private String subnet_uuid;
private String dns_server_address;
private List<String> dns_nameservers;
private String dhcp_option_list;
- private String host_routes;
**/
@JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools")
private List<ContrailSubnetPool> allocationPools = new ArrayList <> ();
+ @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes")
+ private ContrailSubnetHostRoutes host_routes = new ContrailSubnetHostRoutes();
+
public ContrailSubnet() {
super();
}
@@ -179,12 +182,24 @@ public class ContrailSubnet {
}
}
}
+ if (inputSubnet.getHostRoutes() != null)
+ {
+ List<ContrailSubnetHostRoute> hrList = host_routes.getHost_routes();
+ for (HostRoute hr : inputSubnet.getHostRoutes())
+ {
+ if ( !isNullOrEmpty(hr.getPrefix()) || !isNullOrEmpty(hr.getNextHop()) )
+ {
+ ContrailSubnetHostRoute cshr = new ContrailSubnetHostRoute();
+ cshr.populateWith(hr);
+ hrList.add (cshr);
+ }
+ }
+ }
}
}
@Override
public String toString() {
-
StringBuilder buf = new StringBuilder ();
for (ContrailSubnetPool pool : allocationPools)
{
@@ -193,4 +208,5 @@ public class ContrailSubnet {
return "ContrailSubnet [subnet=" + subnet.toString() + " default_gateway=" + defaultGateway
+ " enable_dhcp=" + enableDhcp + " addr_from_start=" + addrFromStart + " subnet_name=" + subnetName + " allocation_pools=" + buf + " ]";
}
+
}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java
new file mode 100644
index 0000000000..3cb16d451c
--- /dev/null
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoute.java
@@ -0,0 +1,67 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.mso.adapters.network;
+
+
+import org.openecomp.mso.openstack.beans.HostRoute;
+import com.fasterxml.jackson.annotation.JsonProperty;
+public class ContrailSubnetHostRoute {
+
+ @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes_route_prefix")
+ private String prefix;
+
+ @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes_route_next_hop")
+ private String nextHop;
+
+ public ContrailSubnetHostRoute() {
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public void setPrefix(String prefix) {
+ this.prefix = prefix;
+ }
+
+ public String getNextHop() {
+ return nextHop;
+ }
+
+ public void setNextHop(String nextHop) {
+ this.nextHop = nextHop;
+ }
+
+ public void populateWith(HostRoute hostRoute)
+ {
+ if (hostRoute != null)
+ {
+ prefix = hostRoute.getPrefix();
+ nextHop = hostRoute.getNextHop();
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "ContrailSubnetHostRoute [prefix=" + prefix + ", nextHop=" + nextHop + "]";
+ }
+
+}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java
new file mode 100644
index 0000000000..91b5aef2cf
--- /dev/null
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetHostRoutes.java
@@ -0,0 +1,58 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP - SO
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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.openecomp.mso.adapters.network;
+
+
+import org.openecomp.mso.openstack.beans.HostRoute;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+public class ContrailSubnetHostRoutes {
+
+ @JsonProperty("network_ipam_refs_data_ipam_subnets_host_routes_route")
+ private List<ContrailSubnetHostRoute> host_routes = new ArrayList <ContrailSubnetHostRoute> ();
+
+ public ContrailSubnetHostRoutes() {
+ }
+
+ public List<ContrailSubnetHostRoute> getHost_routes() {
+ return host_routes;
+ }
+
+ public void setHost_routes(List<ContrailSubnetHostRoute> host_routes) {
+ this.host_routes = host_routes;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder buf = new StringBuilder ();
+ if (host_routes != null)
+ {
+ for (ContrailSubnetHostRoute hr : host_routes)
+ {
+ buf.append(hr.toString());
+ }
+ }
+ return "ContrailSubnetHostRoutes [" + buf.toString() + "]";
+ }
+}
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java
index b7af894f8b..a144de539a 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetIp.java
@@ -21,7 +21,7 @@
package org.openecomp.mso.adapters.network;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class ContrailSubnetIp {
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java
index 6429e49e41..950ca07234 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/ContrailSubnetPool.java
@@ -22,7 +22,7 @@ package org.openecomp.mso.adapters.network;
import org.openecomp.mso.openstack.beans.Pool;
-import org.codehaus.jackson.annotate.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonProperty;
public class ContrailSubnetPool {
@JsonProperty("network_ipam_refs_data_ipam_subnets_allocation_pools_start")
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java
index 21dd4ff007..ebcbe8b0dd 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapter.java
@@ -36,6 +36,7 @@ import org.openecomp.mso.entity.MsoRequest;
import org.openecomp.mso.openstack.beans.NetworkRollback;
import org.openecomp.mso.openstack.beans.NetworkStatus;
import org.openecomp.mso.openstack.beans.Subnet;
+import org.openecomp.mso.openstack.beans.RouteTarget;
@WebService (name="NetworkAdapter", targetNamespace="http://org.openecomp.mso/network")
public interface MsoNetworkAdapter
@@ -70,7 +71,7 @@ public interface MsoNetworkAdapter
@WebParam(name="networkType") @XmlElement(required=true) String networkType,
@WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
@WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="routeTargets") List<String> routeTargets,
+ @WebParam(name="routeTargets") List<RouteTarget> routeTargets,
@WebParam(name="shared") String shared,
@WebParam(name="external") String external,
@WebParam(name="failIfExists") Boolean failIfExists,
@@ -112,7 +113,7 @@ public interface MsoNetworkAdapter
@WebParam(name="modelCustomizationUuid") String modelCustomizationUuid,
@WebParam(name="networkId") @XmlElement(required=true) String networkId,
@WebParam(name="networkName") @XmlElement(required=true) String networkName,
- @WebParam(name="routeTargets") List<String> routeTargets,
+ @WebParam(name="routeTargets") List<RouteTarget> routeTargets,
@WebParam(name="shared") String shared,
@WebParam(name="external") String external,
@WebParam(name="subnets") List<Subnet> subnets,
@@ -192,7 +193,7 @@ public interface MsoNetworkAdapter
@WebParam(name="networkId", mode=Mode.OUT) Holder<String> networkId,
@WebParam(name="neutronNetworkId", mode=Mode.OUT) Holder<String> neutronNetworkId,
@WebParam(name="status", mode=Mode.OUT) Holder<NetworkStatus> status,
- @WebParam(name="routeTargets", mode=Mode.OUT) Holder<List<String>> routeTargets,
+ @WebParam(name="routeTargets", mode=Mode.OUT) Holder<List<RouteTarget>> routeTargets,
@WebParam(name="subnetIdMap", mode=Mode.OUT) Holder<Map<String, String>> subnetIdMap)
throws NetworkException;
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
index 6063956af9..e5e6c853db 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/MsoNetworkAdapterImpl.java
@@ -21,6 +21,8 @@
package org.openecomp.mso.adapters.network;
+import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -30,9 +32,6 @@ import java.util.Optional;
import javax.jws.WebService;
import javax.xml.ws.Holder;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
-
import org.openecomp.mso.adapters.network.exceptions.NetworkException;
import org.openecomp.mso.cloud.CloudConfig;
import org.openecomp.mso.cloud.CloudConfigFactory;
@@ -50,6 +49,7 @@ import org.openecomp.mso.openstack.beans.NetworkInfo;
import org.openecomp.mso.openstack.beans.NetworkRollback;
import org.openecomp.mso.openstack.beans.NetworkStatus;
import org.openecomp.mso.openstack.beans.Pool;
+import org.openecomp.mso.openstack.beans.RouteTarget;
import org.openecomp.mso.openstack.beans.StackInfo;
import org.openecomp.mso.openstack.beans.Subnet;
import org.openecomp.mso.openstack.exceptions.MsoAdapterException;
@@ -62,7 +62,8 @@ import org.openecomp.mso.openstack.utils.MsoNeutronUtils.NetworkType;
import org.openecomp.mso.properties.MsoPropertiesException;
import org.openecomp.mso.properties.MsoPropertiesFactory;
-import static org.openecomp.mso.openstack.utils.MsoCommonUtils.isNullOrEmpty;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
@WebService(serviceName = "NetworkAdapter", endpointInterface = "org.openecomp.mso.adapters.network.MsoNetworkAdapter", targetNamespace = "http://org.openecomp.mso/network")
public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
@@ -159,7 +160,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String networkType,
String modelCustomizationUuid,
String networkName,
- List <String> routeTargets,
+ List <RouteTarget> routeTargets,
String shared,
String external,
Boolean failIfExists,
@@ -232,7 +233,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String networkName,
String physicalNetworkName,
List <Integer> vlans,
- List <String> routeTargets,
+ List <RouteTarget> routeTargets,
String shared,
String external,
Boolean failIfExists,
@@ -734,7 +735,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String modelCustomizationUuid,
String networkId,
String networkName,
- List <String> routeTargets,
+ List <RouteTarget> routeTargets,
String shared,
String external,
List <Subnet> subnets,
@@ -796,7 +797,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String networkName,
String physicalNetworkName,
List <Integer> vlans,
- List <String> routeTargets,
+ List <RouteTarget> routeTargets,
String shared,
String external,
List <Subnet> subnets,
@@ -1208,7 +1209,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String networkName,
String physicalNetworkName,
List <Integer> vlans,
- List <String> routeTargets,
+ List <RouteTarget> routeTargets,
CloudSite cloudSite) throws NetworkException {
// Retrieve the Network Resource definition
NetworkResource networkResource = null;
@@ -1320,6 +1321,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
neutronNetworkId,
status,
vlans,
+ null,
subnetIdMap);
}
@@ -1332,7 +1334,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
Holder <String> networkId,
Holder <String> neutronNetworkId,
Holder <NetworkStatus> status,
- Holder <List <String>> routeTargets,
+ Holder <List <RouteTarget>> routeTargets,
Holder <Map <String, String>> subnetIdMap) throws NetworkException {
queryNetworkInfo(cloudSiteId,
tenantId,
@@ -1343,6 +1345,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
neutronNetworkId,
status,
null,
+ routeTargets,
subnetIdMap);
}
@@ -1362,6 +1365,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
Holder <String> neutronNetworkId,
Holder <NetworkStatus> status,
Holder <List <Integer>> vlans,
+ Holder <List <RouteTarget>> routeTargets,
Holder <Map <String, String>> subnetIdMap) throws NetworkException {
MsoLogger.setLogContext (msoRequest);
MsoLogger.setServiceName ("QueryNetwork");
@@ -1782,7 +1786,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String networkName,
String physicalNetwork,
List <Integer> vlans,
- List <String> routeTargets) {
+ List <RouteTarget> routeTargets) {
String sep = "";
StringBuilder missing = new StringBuilder ();
if (isNullOrEmpty(networkName)) {
@@ -1807,7 +1811,7 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
String networkName,
String physicalNetwork,
List <Integer> vlans,
- List <String> routeTargets,
+ List <RouteTarget> routeTargets,
String shared,
String external,
boolean aic3template) {
@@ -1837,23 +1841,62 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
stackParams.put (PHYSICAL_NETWORK, physicalNetwork);
stackParams.put (VLANS, csl);
}
- if (routeTargets != null && !routeTargets.isEmpty()) {
- StringBuilder sb = new StringBuilder ();
+
+ if (routeTargets != null) {
+
+ String rtGlobal = "";
+ String rtImport = "";
+ String rtExport = "";
String sep = "";
- for (String rt : routeTargets) {
- if (!isNullOrEmpty(rt))
+ for (RouteTarget rt : routeTargets) {
+ boolean rtIsNull = false;
+ if (rt != null) {
+ String routeTarget = rt.getRouteTarget();
+ String routeTargetRole = rt.getRouteTargetRole();
+ LOGGER.debug("Checking for an actually null route target: " + rt.toString());
+ if (routeTarget == null || routeTarget.equals("") || routeTarget.equalsIgnoreCase("null"))
+ rtIsNull = true;
+ if (routeTargetRole == null || routeTargetRole.equals("") || routeTargetRole.equalsIgnoreCase("null"))
+ rtIsNull = true;
+ } else {
+ rtIsNull = true;
+ }
+ if (!rtIsNull)
{
- if (aic3template)
- sb.append(sep).append("target:").append(rt);
- else
- sb.append (sep).append (rt);
-
- sep = ",";
+ LOGGER.debug("Input RT:" + rt.toString());
+ String role = rt.getRouteTargetRole();
+ String rtValue = rt.getRouteTarget();
+
+ if ("IMPORT".equalsIgnoreCase(role))
+ {
+ sep = rtImport.isEmpty() ? "" : ",";
+ rtImport = aic3template ? rtImport + sep + "target:" + rtValue : rtImport + sep + rtValue ;
+ }
+ else if ("EXPORT".equalsIgnoreCase(role))
+ {
+ sep = rtExport.isEmpty() ? "" : ",";
+ rtExport = aic3template ? rtExport + sep + "target:" + rtValue : rtExport + sep + rtValue ;
+ }
+ else // covers BOTH, empty etc
+ {
+ sep = rtGlobal.isEmpty() ? "" : ",";
+ rtGlobal = aic3template ? rtGlobal + sep + "target:" + rtValue : rtGlobal + sep + rtValue ;
+ }
}
}
- String csl = sb.toString ();
-
- stackParams.put ("route_targets", csl);
+
+ if (!rtImport.isEmpty())
+ {
+ stackParams.put ("route_targets_import", rtImport);
+ }
+ if (!rtExport.isEmpty())
+ {
+ stackParams.put ("route_targets_export", rtExport);
+ }
+ if (!rtGlobal.isEmpty())
+ {
+ stackParams.put ("route_targets", rtGlobal);
+ }
}
if (isNullOrEmpty(shared)) {
stackParams.put ("shared", "False");
@@ -1901,22 +1944,24 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
}
- JsonNode node = null;
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- node = mapper.convertValue(prlist, JsonNode.class);
- String jsonString = mapper.writeValueAsString(prlist);
- LOGGER.debug("Json PolicyRefs Data:" + jsonString);
- }
- catch (Exception e)
+ String jsonString = null;
+ if (!prlist.isEmpty())
{
- String error = "Error creating JsonNode for policyRefs Data";
- LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "Openstack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception creating JsonNode for policyRefs Data", e);
- throw new MsoAdapterException (error);
+ try
+ {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonString = mapper.writeValueAsString(prlist);
+ LOGGER.debug("Json PolicyRefs Data:" + jsonString);
+ }
+ catch (Exception e)
+ {
+ String error = "Error creating JsonNode for policyRefs Data";
+ LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "Openstack", "", MsoLogger.ErrorCode.BusinessProcesssError, "Exception creating JsonNode for policyRefs Data", e);
+ throw new MsoAdapterException (error);
+ }
}
//update parameters
- if (pFqdns != null && node != null)
+ if (pFqdns != null && !isNullOrEmpty(jsonString))
{
StringBuilder buf = new StringBuilder ();
String sep = "";
@@ -1929,10 +1974,9 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
}
String csl = buf.toString ();
stackParams.put ("policy_refs", csl);
- stackParams.put ("policy_refsdata", node);
+ stackParams.put ("policy_refsdata", jsonString);
+ LOGGER.debug ("StackParams updated with policy refs:" + csl + " refs data:" + jsonString);
}
-
- LOGGER.debug ("StackParams updated with policy refs");
return;
}
@@ -2024,24 +2068,26 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
cslist.add(cs);
}
- JsonNode node = null;
- try
- {
- ObjectMapper mapper = new ObjectMapper();
- node = mapper.convertValue(cslist, JsonNode.class);
- String jsonString = mapper.writeValueAsString(cslist);
- LOGGER.debug("Json Subnet List:" + jsonString);
- }
- catch (Exception e)
+ String jsonString = null;
+ if (!cslist.isEmpty())
{
- String error = "Error creating JsonNode from input subnets";
- LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.DataError, "Exception creating JsonNode from input subnets", e);
- throw new MsoAdapterException (error);
+ try
+ {
+ ObjectMapper mapper = new ObjectMapper();
+ jsonString = mapper.writeValueAsString(cslist);
+ LOGGER.debug("Json Subnet List:" + jsonString);
+ }
+ catch (Exception e)
+ {
+ String error = "Error creating JsonNode from input subnets";
+ LOGGER.error (MessageEnum.RA_MARSHING_ERROR, error, "", "", MsoLogger.ErrorCode.DataError, "Exception creating JsonNode from input subnets", e);
+ throw new MsoAdapterException (error);
+ }
}
//update parameters
- if (node != null)
+ if (!isNullOrEmpty(jsonString))
{
- stackParams.put ("subnet_list", node);
+ stackParams.put ("subnet_list", jsonString);
}
//Outputs - All subnets are in one ipam_subnets structure
String outputTempl = " subnet:\n" + " description: Openstack subnet identifier\n"
@@ -2161,8 +2207,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter {
for (JsonNode sNode : rootNode.path("ipam_subnets"))
{
LOGGER.debug("Output Subnet Node" + sNode.toString());
- String name = sNode.path("subnet_name").getTextValue();
- String uuid = sNode.path("subnet_uuid").getTextValue();
+ String name = sNode.path("subnet_name").textValue();
+ String uuid = sNode.path("subnet_uuid").textValue();
String aaiId = name; // default
// try to find aaiId for name in input subnetList
if (subnets != null)
diff --git a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java
index 7c775eeb88..80d3331d42 100644
--- a/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java
+++ b/adapters/mso-network-adapter/src/main/java/org/openecomp/mso/adapters/network/NetworkAdapterRest.java
@@ -65,6 +65,7 @@ import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.openstack.beans.NetworkRollback;
import org.openecomp.mso.openstack.beans.NetworkStatus;
+import org.openecomp.mso.openstack.beans.RouteTarget;
import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
import org.openecomp.mso.properties.MsoPropertiesFactory;
@@ -344,7 +345,7 @@ public class NetworkAdapterRest {
Holder<String> networkId = new Holder<>();
Holder<String> neutronNetworkId = new Holder<>();
Holder<NetworkStatus> status = new Holder<>();
- Holder<List<String>> routeTargets = new Holder<>();
+ Holder<List<RouteTarget>> routeTargets = new Holder<>();
Holder<Map<String, String>> subnetIdMap = new Holder<>();
adapter.queryNetworkContrail(cloudSiteId, tenantId, aaiNetworkId, msoRequest,