From 4a2ece624ff1781cc2c9fea80981608f6d1f001e Mon Sep 17 00:00:00 2001 From: Ryan Moats Date: Sat, 15 Aug 2015 17:26:34 -0500 Subject: [PATCH] Remove Floating IP ConcurrentHashMap Replace internal fip ConcurrentHashMap with MD-SAL Change-Id: Iadf3bc7d88bf54540c1e9dd24eba534cb1471a36 Signed-off-by: Ryan Moats --- model/src/main/yang/neutron-L3.yang | 10 +- .../NeutronFloatingIPInterface.java | 93 ++++++++++++------- 2 files changed, 60 insertions(+), 43 deletions(-) diff --git a/model/src/main/yang/neutron-L3.yang b/model/src/main/yang/neutron-L3.yang index e1d8d9b0f..484dd3deb 100644 --- a/model/src/main/yang/neutron-L3.yang +++ b/model/src/main/yang/neutron-L3.yang @@ -77,7 +77,7 @@ module neutron-L3 { description "The floating IP address."; type inet:ip-address; } - list fixed-ip-address { + leaf fixed-ip-address { description "The fixed IP address associated with the floating IP. If you intend to associate the floating IP with a fixed IP at creation time, then you must indicate the identifier of the @@ -85,13 +85,7 @@ module neutron-L3 { multiple associated IP addresses, the service chooses the first IP unless you explicitly specify the parameter fixed_ip_address to select a specific IP."; - key subnet-id; - leaf subnet-id { - type yang:uuid; - } - leaf ip-address { - type inet:ip-address; - } + type inet:ip-address; } leaf status { type string; diff --git a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFloatingIPInterface.java b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFloatingIPInterface.java index 5215b9158..138cd3b51 100644 --- a/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFloatingIPInterface.java +++ b/transcriber/src/main/java/org/opendaylight/neutron/transcriber/NeutronFloatingIPInterface.java @@ -13,8 +13,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map.Entry; import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.neutron.spi.INeutronFloatingIPCRUD; @@ -28,8 +26,6 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types. import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev141002.floatingips.attributes.Floatingips; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev141002.floatingips.attributes.floatingips.Floatingip; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev141002.floatingips.attributes.floatingips.FloatingipBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev141002.l3.floatingip.attributes.FixedIpAddress; -import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev141002.l3.floatingip.attributes.FixedIpAddressBuilder; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150325.Neutron; import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; import org.osgi.framework.BundleContext; @@ -40,8 +36,6 @@ import org.slf4j.LoggerFactory; public class NeutronFloatingIPInterface extends AbstractNeutronInterface implements INeutronFloatingIPCRUD { private static final Logger LOGGER = LoggerFactory.getLogger(NeutronFloatingIPInterface.class); - private ConcurrentMap floatingIPDB = new ConcurrentHashMap(); - NeutronFloatingIPInterface(ProviderContext providerContext) { super(providerContext); } @@ -50,23 +44,27 @@ public class NeutronFloatingIPInterface extends AbstractNeutronInterface getAllFloatingIPs() { Set allIPs = new HashSet(); - for (Entry entry : floatingIPDB.entrySet()) { - NeutronFloatingIP floatingip = entry.getValue(); - allIPs.add(floatingip); + Floatingips fips = readMd(createInstanceIdentifier()); + if (fips != null) { + for (Floatingip fip: fips.getFloatingip()) { + allIPs.add(fromMd(fip)); + } } LOGGER.debug("Exiting getAllFloatingIPs, Found {} FloatingIPs", allIPs.size()); List ans = new ArrayList(); @@ -79,28 +77,27 @@ public class NeutronFloatingIPInterface extends AbstractNeutronInterface createInstanceIdentifier( - Floatingip item) { - return InstanceIdentifier.create(Neutron.class) - .child(Floatingips.class) - .child(Floatingip.class,item.getKey()); - } - @Override protected Floatingip toMd(NeutronFloatingIP floatingIp) { FloatingipBuilder floatingipBuilder = new FloatingipBuilder(); if (floatingIp.getFixedIPAddress() != null) { - List listFixedIpAddress = new ArrayList(); - FixedIpAddressBuilder fixedIpAddressBuilder = new FixedIpAddressBuilder(); - fixedIpAddressBuilder.setIpAddress(new IpAddress(floatingIp.getFixedIPAddress().toCharArray())); - listFixedIpAddress.add(fixedIpAddressBuilder.build()); - floatingipBuilder.setFixedIpAddress(listFixedIpAddress ); + floatingipBuilder.setFixedIpAddress(new IpAddress(floatingIp.getFixedIPAddress().toCharArray())); } if(floatingIp.getFloatingIPAddress() != null) { floatingipBuilder.setFloatingIpAddress(new IpAddress(floatingIp.getFloatingIPAddress().toCharArray())); @@ -155,6 +140,44 @@ public class NeutronFloatingIPInterface extends AbstractNeutronInterface createInstanceIdentifier( + Floatingip item) { + return InstanceIdentifier.create(Neutron.class) + .child(Floatingips.class) + .child(Floatingip.class,item.getKey()); + } + + protected InstanceIdentifier createInstanceIdentifier() { + return InstanceIdentifier.create(Neutron.class) + .child(Floatingips.class); + } + public static void registerNewInterface(BundleContext context, ProviderContext providerContext, List> registrations) { -- 2.36.6