neutron: unbreak of neutron northbound yang model revise 20/40320/7
authorRitu Sood <ritu.sood@intel.com>
Tue, 14 Jun 2016 00:14:52 +0000 (17:14 -0700)
committerIsaku Yamahata <isaku.yamahata@intel.com>
Tue, 21 Jun 2016 00:56:48 +0000 (17:56 -0700)
This patch provides the corresponding change needed to fix
compilation issues after the Yang model revise
Neutron changes:
https://git.opendaylight.org/gerrit/#/q/project:neutron+branch:master+topic:yang-model-revise

Change-Id: I15850089233d72038a70e1edcb4db1e69445fe57
Signed-off-by: Ritu Sood <ritu.sood@intel.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
43 files changed:
netvirt/renderers/neutron/src/test/java/org/opendaylight/netvirt/netvirt/renderers/neutron/NeutronPortDataProcessorTest.java
openstack/net-virt-it/src/test/java/org/opendaylight/netvirt/openstack/netvirt/it/NetvirtIT.java
openstack/net-virt-providers/src/main/java/org/opendaylight/netvirt/openstack/netvirt/providers/openflow13/services/EgressAclService.java
openstack/net-virt-providers/src/main/java/org/opendaylight/netvirt/openstack/netvirt/providers/openflow13/services/IngressAclService.java
openstack/net-virt-providers/src/test/java/org/opendaylight/netvirt/openstack/netvirt/providers/openflow13/services/EgressAclServiceTest.java
openstack/net-virt-providers/src/test/java/org/opendaylight/netvirt/openstack/netvirt/providers/openflow13/services/IngressAclServiceTest.java
openstack/net-virt/pom.xml
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/impl/NeutronL3Adapter.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/impl/SecurityGroupCacheManagerImpl.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/NeutronPort.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/NeutronRouter.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/NeutronSecurityGroup.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronLoadBalancerInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronLoadBalancerPoolInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronPortInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronRouterInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronSecurityGroupInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronSecurityRuleInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/crud/impl/NeutronSubnetInterface.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/iaware/impl/NeutronLoadBalancerPoolChangeListener.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/iaware/impl/NeutronPortChangeListener.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/iaware/impl/NeutronRouterChangeListener.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/iaware/impl/NeutronSecurityGroupDataChangeListener.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/iaware/impl/NeutronSecurityRuleDataChangeListener.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/translator/iaware/impl/NeutronSubnetChangeListener.java
openstack/net-virt/src/test/java/org/opendaylight/netvirt/openstack/netvirt/impl/SecurityGroupCacheManagerImplTest.java
openstack/net-virt/src/test/java/org/opendaylight/netvirt/openstack/netvirt/impl/SecurityServicesImplTest.java
utils/neutron-utils/src/main/java/org/opendaylight/netvirt/utils/neutron/utils/NeutronUtils.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpExternalTunnelManager.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpInterfaceEventListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpNeutronPortListener.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpPktHandler.java
vpnservice/dhcpservice/dhcpservice-impl/src/main/java/org/opendaylight/netvirt/dhcpservice/DhcpServiceUtils.java
vpnservice/features/pom.xml
vpnservice/features/src/main/features/features.xml
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronNetworkChangeListener.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListener.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronRouterChangeListener.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronSubnetChangeListener.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnManager.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnProvider.java
vpnservice/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/netvirt/neutronvpn/NeutronvpnUtils.java
vpnservice/neutronvpn/neutronvpn-impl/src/test/java/org/opendaylight/netvirt/neutronvpn/NeutronPortChangeListenerTest.java

index 345dbca47f4af0472a12ada80c1ec11532c60cfe..d3295615ee0168e0199653e57ed500dba1a8a0c3 100644 (file)
@@ -12,6 +12,7 @@ import org.opendaylight.controller.md.sal.binding.test.AbstractDataBrokerTest;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder;
@@ -61,7 +62,7 @@ public class NeutronPortDataProcessorTest extends AbstractDataBrokerTest {
                 .setDeviceOwner("compute:nova")
                 .setDeviceId("12345678-1234-1234-1234-123456789012")
                 .setUuid(uuid)
-                .setMacAddress("00:00:01:02:03:04")
+                .setMacAddress(new MacAddress("00:00:01:02:03:04"))
                 .setFixedIps(ips)
                 .build());
     }
index c1d3547dfe83ee8a0bf2e7f67642137d881b574b..a65a008298aeb856edfa03abe53a40677a01d1b7 100644 (file)
@@ -535,9 +535,8 @@ public class NetvirtIT extends AbstractMdsalTestBase {
         assertNotNull("Could not find ineutronSecurityRuleCRUD Service", ineutronSecurityRuleCRUD);
 
         NeutronSecurityGroup neutronSG = new NeutronSecurityGroup();
-        neutronSG.setSecurityGroupDescription("testig defaultSG-IT");
         neutronSG.setSecurityGroupName("DefaultSG");
-        neutronSG.setSecurityGroupUUID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
+        neutronSG.setID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
         neutronSG.setTenantID(tenantId);
 
         List<NeutronSecurityRule> nsrs = new ArrayList<>();
@@ -548,7 +547,7 @@ public class NetvirtIT extends AbstractMdsalTestBase {
         nsrIN.setSecurityRuleGroupID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
         nsrIN.setSecurityRuleProtocol("TCP");
         nsrIN.setSecurityRuleRemoteIpPrefix("10.0.0.0/24");
-        nsrIN.setSecurityRuleUUID("823faaf7-175d-4f01-a271-0bf56fb1e7e6");
+        nsrIN.setID("823faaf7-175d-4f01-a271-0bf56fb1e7e6");
         nsrIN.setTenantID(tenantId);
 
         NeutronSecurityRule nsrEG = new NeutronSecurityRule();
@@ -558,13 +557,12 @@ public class NetvirtIT extends AbstractMdsalTestBase {
         nsrEG.setSecurityRuleGroupID("d3329053-bae5-4bf4-a2d1-7330f11ba5db");
         nsrEG.setSecurityRuleProtocol("TCP");
         nsrEG.setSecurityRuleRemoteIpPrefix("10.0.0.0/24");
-        nsrEG.setSecurityRuleUUID("823faaf7-175d-4f01-a271-0bf56fb1e7e1");
+        nsrEG.setID("823faaf7-175d-4f01-a271-0bf56fb1e7e1");
         nsrEG.setTenantID(tenantId);
 
         nsrs.add(nsrIN);
         nsrs.add(nsrEG);
 
-        neutronSG.setSecurityRules(nsrs);
         ineutronSecurityRuleCRUD.addNeutronSecurityRule(nsrIN);
         ineutronSecurityRuleCRUD.addNeutronSecurityRule(nsrEG);
         ineutronSecurityGroupCRUD.add(neutronSG);
index e7ac0c244e0c0ba4b4719d77c0c8f0185a0b7469..d30e2dc3edb4960fc4517b6f8113264dc2f87e59 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.netvirt.openstack.netvirt.providers.openflow13.Service;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
 import org.opendaylight.netvirt.utils.mdsal.openflow.ActionUtils;
 import org.opendaylight.netvirt.utils.mdsal.openflow.FlowUtils;
 import org.opendaylight.netvirt.utils.mdsal.openflow.InstructionUtils;
@@ -45,6 +46,7 @@ import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -53,6 +55,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
     private static final Logger LOG = LoggerFactory.getLogger(EgressAclService.class);
     private volatile SecurityServicesManager securityServicesManager;
     private volatile SecurityGroupCacheManger securityGroupCacheManger;
+    private volatile INeutronSecurityRuleCRUD neutronSecurityRule;
     private static final int DHCP_SOURCE_PORT = 67;
     private static final int DHCP_DESTINATION_PORT = 68;
     private static final int DHCPV6_SOURCE_PORT = 547;
@@ -75,11 +78,11 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
                                        NeutronSecurityGroup securityGroup, String portUuid, boolean write) {
 
         LOG.trace("programPortSecurityGroup: neutronSecurityGroup: {} ", securityGroup);
-        if (securityGroup == null || securityGroup.getSecurityRules() == null) {
+        if (securityGroup == null || getSecurityRulesforGroup(securityGroup) == null) {
             return;
         }
 
-        List<NeutronSecurityRule> portSecurityList = securityGroup.getSecurityRules();
+        List<NeutronSecurityRule> portSecurityList = getSecurityRulesforGroup(securityGroup);
         /* Iterate over the Port Security Rules in the Port Security Group bound to the port*/
         for (NeutronSecurityRule portSecurityRule : portSecurityList) {
 
@@ -878,6 +881,16 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
         }
     }
 
+    private List<NeutronSecurityRule> getSecurityRulesforGroup(NeutronSecurityGroup securityGroup) {
+        List<NeutronSecurityRule> securityRules = new ArrayList<>();
+        List<NeutronSecurityRule> rules = neutronSecurityRule.getAllNeutronSecurityRules();
+        for (NeutronSecurityRule securityRule : rules) {
+            if (securityGroup.getID().equals(securityRule.getSecurityRuleGroupID())) {
+                securityRules.add(securityRule);
+            }
+        }
+        return securityRules;
+    }
 
     @Override
     public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
@@ -886,6 +899,7 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
                 (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
         securityGroupCacheManger =
                 (SecurityGroupCacheManger) ServiceHelper.getGlobalInstance(SecurityGroupCacheManger.class, this);
+        neutronSecurityRule = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
     }
 
     @Override
index ce9155ca9c81fd84d924bf80530df187b0115df8..671fba98643ebbde2a7bed2706d71e39989ff177 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.netvirt.openstack.netvirt.providers.ConfigInterface;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
 import org.opendaylight.netvirt.utils.mdsal.openflow.ActionUtils;
 import org.opendaylight.netvirt.utils.mdsal.openflow.FlowUtils;
 import org.opendaylight.netvirt.utils.mdsal.openflow.InstructionUtils;
@@ -44,6 +45,7 @@ import java.net.Inet4Address;
 import java.net.Inet6Address;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 
@@ -51,6 +53,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
     private static final Logger LOG = LoggerFactory.getLogger(IngressAclService.class);
     private volatile SecurityServicesManager securityServicesManager;
     private volatile SecurityGroupCacheManger securityGroupCacheManger;
+    private volatile INeutronSecurityRuleCRUD neutronSecurityRule;
     private static final int PORT_RANGE_MIN = 1;
     private static final int PORT_RANGE_MAX = 65535;
 
@@ -68,11 +71,11 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                                        String portUuid, boolean write) {
 
         LOG.trace("programPortSecurityGroup neutronSecurityGroup: {} ", securityGroup);
-        if (securityGroup == null || securityGroup.getSecurityRules() == null) {
+        if (securityGroup == null || getSecurityRulesforGroup(securityGroup) == null) {
             return;
         }
 
-        List<NeutronSecurityRule> portSecurityList = securityGroup.getSecurityRules();
+        List<NeutronSecurityRule> portSecurityList = getSecurityRulesforGroup(securityGroup);
         /* Iterate over the Port Security Rules in the Port Security Group bound to the port*/
         for (NeutronSecurityRule portSecurityRule : portSecurityList) {
 
@@ -764,6 +767,17 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
         }
     }
 
+    private List<NeutronSecurityRule> getSecurityRulesforGroup(NeutronSecurityGroup securityGroup) {
+        List<NeutronSecurityRule> securityRules = new ArrayList<>();
+        List<NeutronSecurityRule> rules = neutronSecurityRule.getAllNeutronSecurityRules();
+        for (NeutronSecurityRule securityRule : rules) {
+            if (securityGroup.getID().equals(securityRule.getSecurityRuleGroupID())) {
+                securityRules.add(securityRule);
+            }
+        }
+        return securityRules;
+    }
+
     @Override
     public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
         super.setDependencies(bundleContext.getServiceReference(IngressAclProvider.class.getName()), this);
@@ -771,6 +785,7 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
                 (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
         securityGroupCacheManger =
                 (SecurityGroupCacheManger) ServiceHelper.getGlobalInstance(SecurityGroupCacheManger.class, this);
+        neutronSecurityRule = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
     }
 
     @Override
index 3bbd1d84e21079032020b1c0442203a5963b4c92..ec2a38e258bf6d4270041287609427ba3e53f516 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.netvirt.openstack.netvirt.api.SecurityGroupCacheManger;
 import org.opendaylight.netvirt.openstack.netvirt.api.SecurityServicesManager;
 import org.opendaylight.netvirt.openstack.netvirt.providers.openflow13.PipelineOrchestrator;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
@@ -75,6 +76,7 @@ public class EgressAclServiceTest {
     @Mock private NeutronSecurityRule portSecurityRule;
     @Mock private NeutronSecurityGroup securityGroupIpv6;
     @Mock private NeutronSecurityRule portSecurityIpv6Rule;
+    @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
 
     @Mock private SecurityServicesManager securityServices;
     @Mock private SecurityGroupCacheManger securityGroupCacheManger;
@@ -151,7 +153,7 @@ public class EgressAclServiceTest {
 
         List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
         portSecurityIpv6List.add(portSecurityIpv6Rule);
-        when(securityGroupIpv6.getSecurityRules()).thenReturn(portSecurityIpv6List);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityIpv6List);
 
         neutron_ipv6_dest_1 = new Neutron_IPs();
         neutron_ipv6_dest_1.setIpAddress(IPV6_DEST_IP_1);
@@ -161,7 +163,7 @@ public class EgressAclServiceTest {
         neutron_ipv6_dest_2.setIpAddress(IPV6_DEST_IP_2);
         neutronDestIpList.add(neutron_ipv6_dest_2);
 
-        when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
         when(securityServices.getVmListForSecurityGroup(PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
 
         NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class);
@@ -200,7 +202,7 @@ public class EgressAclServiceTest {
         portSecurityList.add(portSecurityRule4);
 
         NeutronSecurityGroup localSecurityGroup = mock(NeutronSecurityGroup.class);
-        when(localSecurityGroup.getSecurityRules()).thenReturn(portSecurityList);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
 
         egressAclServiceSpy.programPortSecurityGroup(DP_ID_LONG, SEGMENT_ID, MAC_ADDRESS, LOCAL_PORT,
                 localSecurityGroup, PORT_UUID, true);
index e5d3b061d1eda5d49224cd350ffd9a6fa922f62b..7f723569f68b47dbc6569bdb369a44b34e3ce51a 100644 (file)
@@ -39,6 +39,7 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGrou
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.netvirt.openstack.netvirt.api.SecurityGroupCacheManger;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
@@ -77,6 +78,7 @@ public class IngressAclServiceTest {
     @Mock private NeutronSecurityRule portSecurityIpv6Rule;
     @Mock private SecurityServicesManager securityServices;
     @Mock private SecurityGroupCacheManger securityGroupCacheManger;
+    @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
 
     private List<Neutron_IPs> neutronSrcIpList = new ArrayList<>();
     private List<Neutron_IPs> neutronDestIpList = new ArrayList<>();
@@ -152,7 +154,7 @@ public class IngressAclServiceTest {
 
         List<NeutronSecurityRule> portSecurityIpv6List = new ArrayList<>();
         portSecurityIpv6List.add(portSecurityIpv6Rule);
-        when(securityGroupIpv6.getSecurityRules()).thenReturn(portSecurityIpv6List);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityIpv6List);
 
         neutron_ipv6_dest_1 = new Neutron_IPs();
         neutron_ipv6_dest_1.setIpAddress(IPV6_DEST_IP_1);
@@ -162,7 +164,7 @@ public class IngressAclServiceTest {
         neutron_ipv6_dest_2.setIpAddress(IPV6_DEST_IP_2);
         neutronDestIpList.add(neutron_ipv6_dest_2);
 
-        when(securityGroup.getSecurityRules()).thenReturn(portSecurityList);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
         when(securityServices.getVmListForSecurityGroup
              (PORT_UUID, SECURITY_GROUP_UUID)).thenReturn(neutronDestIpList);
         NetvirtProvidersProvider netvirtProvider = mock(NetvirtProvidersProvider.class);
@@ -200,7 +202,7 @@ public class IngressAclServiceTest {
         portSecurityList.add(portSecurityRule4);
 
         NeutronSecurityGroup localSecurityGroup = mock(NeutronSecurityGroup.class);
-        when(localSecurityGroup.getSecurityRules()).thenReturn(portSecurityList);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(portSecurityList);
 
         ingressAclServiceSpy.programPortSecurityGroup(
                 Long.valueOf(1554), "2", MAC_ADDRESS, 124, localSecurityGroup, PORT_UUID, false);
index 2a5dfe8c0899ccf2972204319018cabd8b4d600f..d9575ad5e9761cc9941f6b4d6ab4c3fc0b8e6d8e 100644 (file)
@@ -170,6 +170,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
             <Embed-Transitive>true</Embed-Transitive>
             <Export-Package>
               org.opendaylight.netvirt.openstack.netvirt.translator,
+              org.opendaylight.netvirt.openstack.netvirt.translator.crud,
               org.opendaylight.netvirt.openstack.netvirt.api,
               org.opendaylight.netvirt.openstack.netvirt
             </Export-Package>
index 335c8038cc92902d1a3af9515352011de57c47a2..990dc709e30a8e82519ad76189794d978ead0e6f 100644 (file)
@@ -257,7 +257,7 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
                                 port.getDeviceOwner().equals(OWNER_ROUTER_INTERFACE)) {
                             LOG.debug("L3 Cache Population : Router interface {} found.",port);
                             networkIdToRouterMacCache.put(port.getNetworkId().getValue()
-                                    , port.getMacAddress());
+                                    , port.getMacAddress().getValue());
 
                             networkIdToRouterIpListCache.put(port.getNetworkId().getValue(),
                                     NeutronIAwareUtil.convertMDSalIpToNeutronIp(port.getFixedIps()));
index 11bb2a501bed88e56de357010be91a7c036cc357..cfebe8b5805ebf64fbd8e7abeabb8c1b14448405 100644 (file)
@@ -16,6 +16,8 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronPort;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
+import org.opendaylight.netvirt.utils.neutron.utils.NeutronUtils;
 import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
@@ -41,6 +43,7 @@ public class SecurityGroupCacheManagerImpl implements ConfigInterface, SecurityG
     private volatile SecurityServicesManager securityServicesManager;
     private volatile INeutronPortCRUD neutronPortCache;
     private volatile NeutronL3Adapter neutronL3Adapter;
+    private volatile INeutronSecurityRuleCRUD neutronSecurityRule;
 
     @Override
     public void portAdded(String securityGroupUuid, String portUuid) {
@@ -188,7 +191,7 @@ public class SecurityGroupCacheManagerImpl implements ConfigInterface, SecurityG
         List<NeutronSecurityRule> remoteSecurityRules = new ArrayList<>();
         List<NeutronSecurityGroup> securityGroups = port.getSecurityGroups();
         for (NeutronSecurityGroup securityGroup : securityGroups) {
-            List<NeutronSecurityRule> securityRules = securityGroup.getSecurityRules();
+            List<NeutronSecurityRule> securityRules = getSecurityRulesforGroup(securityGroup);
             for (NeutronSecurityRule securityRule : securityRules) {
                 if (securityGroupUuid.equals(securityRule.getSecurityRemoteGroupID())) {
                     remoteSecurityRules.add(securityRule);
@@ -207,7 +210,7 @@ public class SecurityGroupCacheManagerImpl implements ConfigInterface, SecurityG
             List<NeutronSecurityGroup> securityGroupList = port.getSecurityGroups();
             if ( null != securityGroupList) {
                 for (NeutronSecurityGroup securityGroup : securityGroupList) {
-                    List<NeutronSecurityRule> securityRuleList = securityGroup.getSecurityRules();
+                    List<NeutronSecurityRule> securityRuleList = getSecurityRulesforGroup(securityGroup);
                     if ( null != securityRuleList) {
                         for (NeutronSecurityRule securityRule : securityRuleList) {
                             if (null != securityRule.getSecurityRemoteGroupID()) {
@@ -220,6 +223,17 @@ public class SecurityGroupCacheManagerImpl implements ConfigInterface, SecurityG
         }
     }
 
+    private List<NeutronSecurityRule> getSecurityRulesforGroup(NeutronSecurityGroup securityGroup) {
+        List<NeutronSecurityRule> securityRules = new ArrayList<>();
+        List<NeutronSecurityRule> rules = neutronSecurityRule.getAllNeutronSecurityRules();
+        for (NeutronSecurityRule securityRule : rules) {
+            if (securityGroup.getID().equals(securityRule.getSecurityRuleGroupID())) {
+                securityRules.add(securityRule);
+            }
+        }
+        return securityRules;
+    }
+
     @Override
     public void setDependencies(ServiceReference serviceReference) {
         neutronL3Adapter =
@@ -227,6 +241,7 @@ public class SecurityGroupCacheManagerImpl implements ConfigInterface, SecurityG
         securityServicesManager =
                 (SecurityServicesManager) ServiceHelper.getGlobalInstance(SecurityServicesManager.class, this);
         neutronPortCache = (INeutronPortCRUD) ServiceHelper.getGlobalInstance(INeutronPortCRUD.class, this);
+        neutronSecurityRule = (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
         init();
     }
 
index a7b4a6196fff1c84e751d809cab3db4c580d34fb..d5a5a55de3cd736a8905945db5c13873b9953516 100644 (file)
@@ -12,6 +12,7 @@ package org.opendaylight.netvirt.openstack.netvirt.translator;
 import java.io.Serializable;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
@@ -78,7 +79,7 @@ public class NeutronPort implements Serializable, INeutronObject {
 
     //@XmlElement (name = "binding:vif_details")
     @XmlElement (namespace = "binding", name = "vif_details")
-    List<NeutronPort_VIFDetail> vifDetails;
+    Map<String, String> vifDetails;
 
     @XmlElement (name = "extra_dhcp_opts")
     List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
@@ -131,7 +132,7 @@ public class NeutronPort implements Serializable, INeutronObject {
     public Boolean getAdminStateUp() { return adminStateUp; }
 
     public void setAdminStateUp(Boolean newValue) {
-            adminStateUp = newValue;
+        adminStateUp = newValue;
     }
 
     public String getStatus() {
@@ -206,20 +207,20 @@ public class NeutronPort implements Serializable, INeutronObject {
         this.extraDHCPOptions = extraDHCPOptions;
     }
 
-    public List<NeutronPort_VIFDetail> getVIFDetail() {
+    public Map<String, String> getVIFDetails() {
         return vifDetails;
     }
 
-    public void setVIFDetail(List<NeutronPort_VIFDetail> vifDetails) {
+    public void setVIFDetails(Map<String, String> vifDetails) {
         this.vifDetails = vifDetails;
     }
 
     public String getBindinghostID() {
-      return bindinghostID;
+        return bindinghostID;
     }
 
     public void setBindinghostID(String bindinghostID) {
-      this.bindinghostID = bindinghostID;
+        this.bindinghostID = bindinghostID;
     }
 
     public String getBindingvnicType() {
index 050c7849cc3be063bdcf4fcc3ec1288dbeeaf41e..d98da01e5646a4885619dac0441c0fb5485b8ec2 100644 (file)
@@ -55,15 +55,6 @@ public class NeutronRouter implements Serializable, INeutronObject {
     @XmlElement (name = "routes")
     List<Routes> routes;
 
-    /* Holds a map of OpenStackRouterInterfaces by subnet UUID
-     * used for internal mapping to DOVE
-     */
-    Map<String, NeutronRouter_Interface> interfaces;
-
-    public NeutronRouter() {
-        interfaces = new HashMap<>();
-    }
-
     public String getID() { return routerUUID; }
 
     public void setID(String id) { this.routerUUID = id; }
@@ -190,22 +181,6 @@ public class NeutronRouter implements Serializable, INeutronObject {
         return ans;
     }
 
-    public void setInterfaces(Map<String, NeutronRouter_Interface> input) {
-        interfaces = input;
-    }
-
-    public Map<String, NeutronRouter_Interface> getInterfaces() {
-        return interfaces;
-    }
-
-    public void addInterface(String s, NeutronRouter_Interface i) {
-        interfaces.put(s, i);
-    }
-
-    public void removeInterface(String s) {
-        interfaces.remove(s);
-    }
-
     public void initDefaults() {
         adminStateUp = true;
     }
@@ -222,8 +197,6 @@ public class NeutronRouter implements Serializable, INeutronObject {
             ", distributed=" + distributed +
             ", gw_port_id=" + gatewayPortId +
             ", routes=" + routes +
-            ", interfaces=" + interfaces +
             "]";
     }
-
 }
index 78a61dd7abee3fde5ff2eeb1142f1a06e9439afe..e0305b4d811572ca0685dc5edc33f3910c9bae57 100644 (file)
@@ -26,7 +26,6 @@ import javax.xml.bind.annotation.XmlRootElement;
  * name                 String name of the security group.
  * description          String name of the security group.
  * tenant_id            uuid-str Owner of security rule..
- * security_group_rules List&lt;NeutronSecurityRule&gt; nested RO in the sec group.
  */
 
 @XmlRootElement
@@ -47,12 +46,7 @@ public class NeutronSecurityGroup implements Serializable, INeutronObject {
     @XmlElement(name = "tenant_id")
     String securityGroupTenantID;
 
-    @XmlElement(name = "security_group_rules")
-    List<NeutronSecurityRule> neutronSecurityRule;
-
     public NeutronSecurityGroup() {
-        neutronSecurityRule = new ArrayList<>();
-
     }
 
     public String getID() {
@@ -97,15 +91,6 @@ public class NeutronSecurityGroup implements Serializable, INeutronObject {
         this.securityGroupTenantID = securityGroupTenantID;
     }
 
-    // Rules In Group
-    public List<NeutronSecurityRule> getSecurityRules() {
-        return neutronSecurityRule;
-    }
-
-    public void setSecurityRules(List<NeutronSecurityRule> neutronSecurityRule) {
-        this.neutronSecurityRule = neutronSecurityRule;
-    }
-
     public NeutronSecurityGroup extractFields(List<String> fields) {
         NeutronSecurityGroup ans = new NeutronSecurityGroup ();
         for (String s : fields) {
@@ -122,9 +107,6 @@ public class NeutronSecurityGroup implements Serializable, INeutronObject {
                 case "tenant_id":
                     ans.setSecurityGroupTenantID(this.getSecurityGroupTenantID());
                     break;
-                case "security_group_rules":
-                    ans.setSecurityRules(this.getSecurityRules());
-                    break;
             }
         }
         return ans;
@@ -137,7 +119,7 @@ public class NeutronSecurityGroup implements Serializable, INeutronObject {
                 ", securityGroupName='" + securityGroupName + '\'' +
                 ", securityGroupDescription='" + securityGroupDescription + '\'' +
                 ", securityGroupTenantID='" + securityGroupTenantID + '\'' +
-                ", securityRules=" + neutronSecurityRule + "]";
+                "]";
     }
 
     public void initDefaults() {
index a0b1f410e2344f2c4d6a07458827b0c281d4cc39..3820afa65cd2a8d239f0d5f8eb2f9182c6544d89 100644 (file)
@@ -124,9 +124,6 @@ public class NeutronLoadBalancerInterface extends AbstractNeutronInterface<Loadb
     protected Loadbalancer toMd(NeutronLoadBalancer loadBalancer) {
         LoadbalancerBuilder loadBalancersBuilder = new LoadbalancerBuilder();
         loadBalancersBuilder.setAdminStateUp(loadBalancer.getLoadBalancerAdminStateUp());
-        if (loadBalancer.getLoadBalancerDescription() != null) {
-            loadBalancersBuilder.setDescr(loadBalancer.getLoadBalancerDescription());
-        }
         if (loadBalancer.getLoadBalancerName() != null) {
             loadBalancersBuilder.setName(loadBalancer.getLoadBalancerName());
         }
index 48d43ac66da230b7dc684c15ee0ae7e7d0ff2fe6..fa4d56d5738319ebf9fdc4a868b0bf1ea94ea4c3 100644 (file)
@@ -139,9 +139,6 @@ public class NeutronLoadBalancerPoolInterface extends AbstractNeutronInterface<P
     protected Pool toMd(NeutronLoadBalancerPool pool) {
         PoolBuilder poolBuilder = new PoolBuilder();
         poolBuilder.setAdminStateUp(pool.getLoadBalancerPoolAdminIsStateIsUp());
-        if (pool.getLoadBalancerPoolDescription() != null) {
-            poolBuilder.setDescr(pool.getLoadBalancerPoolDescription());
-        }
         if (pool.getNeutronLoadBalancerPoolHealthMonitorID() != null) {
             poolBuilder.setHealthmonitorId(toUuid(pool.getNeutronLoadBalancerPoolHealthMonitorID()));
         }
index e2dbab6d227f76e075592a0d58c1156e3f46981c..5cb2854d5d48659d9dab459281744eee37308da8 100644 (file)
@@ -9,8 +9,10 @@
 package org.opendaylight.netvirt.openstack.netvirt.translator.crud.impl;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
@@ -24,6 +26,7 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronPort;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityGroup;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtension;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.binding.rev150712.PortBindingExtensionBuilder;
@@ -41,6 +44,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.por
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.portsecurity.rev150712.PortSecurityExtension;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.portsecurity.rev150712.PortSecurityExtensionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.types.rev160517.IpPrefixOrAddress;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceRegistration;
@@ -140,14 +144,11 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
         PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
         result.setBindinghostID(binding.getHostId());
         if (binding.getVifDetails() != null) {
-            List<NeutronPort_VIFDetail> details = new ArrayList<>();
-            for (VifDetails vifDetail : binding.getVifDetails()) {
-                NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
-                detail.setPortFilter(vifDetail.isPortFilter());
-                detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
-                details.add(detail);
+            final Map<String, String> details = new HashMap<String, String>(binding.getVifDetails().size());
+            for (final VifDetails vifDetail : binding.getVifDetails()) {
+                details.put(vifDetail.getDetailsKey(), vifDetail.getValue());
             }
-            result.setVIFDetail(details);
+            result.setVIFDetails(details);
         }
         result.setBindingvifType(binding.getVifType());
         result.setBindingvnicType(binding.getVnicType());
@@ -167,8 +168,8 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
             List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
             for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
                 NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
-                pair.setIpAddress(mdPair.getIpAddress());
-                pair.setMacAddress(mdPair.getMacAddress());
+                pair.setIpAddress(String.valueOf(mdPair.getIpAddress().getValue()));
+                pair.setMacAddress(mdPair.getMacAddress().getValue());
                 pairs.add(pair);
             }
             result.setAllowedAddressPairs(pairs);
@@ -195,7 +196,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
             }
             result.setFixedIPs(ips);
         }
-        result.setMacAddress(port.getMacAddress());
+        result.setMacAddress(port.getMacAddress().getValue());
         result.setName(port.getName());
         result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
         if (port.getSecurityGroups() != null) {
@@ -228,15 +229,16 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
         if (neutronPort.getBindinghostID() != null) {
             bindingBuilder.setHostId(neutronPort.getBindinghostID());
         }
-        if (neutronPort.getVIFDetail() != null) {
-            List<VifDetails> listVifDetail = new ArrayList<>();
-            for (NeutronPort_VIFDetail detail: neutronPort.getVIFDetail()) {
-                VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
-                if (detail.getPortFilter() != null) {
-                    vifDetailsBuilder.setPortFilter(detail.getPortFilter());
+        if (neutronPort.getVIFDetails() != null) {
+            final Map<String, String> vifDetails = neutronPort.getVIFDetails();
+            final List<VifDetails> listVifDetail = new ArrayList<VifDetails>(vifDetails.size());
+            for (final Map.Entry<String, String> vifDetail : vifDetails.entrySet()) {
+                final VifDetailsBuilder vifDetailsBuilder = new VifDetailsBuilder();
+                if (vifDetail.getKey() != null) {
+                    vifDetailsBuilder.setDetailsKey(vifDetail.getKey());
                 }
-                if (detail.getOvsHybridPlug() != null) {
-                    vifDetailsBuilder.setOvsHybridPlug(detail.getOvsHybridPlug());
+                if (vifDetail.getValue() != null) {
+                    vifDetailsBuilder.setValue(vifDetail.getValue());
                 }
                 listVifDetail.add(vifDetailsBuilder.build());
             }
@@ -262,8 +264,8 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
             List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<>();
             for (NeutronPort_AllowedAddressPairs allowedAddressPairs : neutronPort.getAllowedAddressPairs()) {
                     AllowedAddressPairsBuilder allowedAddressPairsBuilder = new AllowedAddressPairsBuilder();
-                    allowedAddressPairsBuilder.setIpAddress(allowedAddressPairs.getIpAddress());
-                    allowedAddressPairsBuilder.setMacAddress(allowedAddressPairs.getMacAddress());
+                    allowedAddressPairsBuilder.setIpAddress(new IpPrefixOrAddress(allowedAddressPairs.getIpAddress().toCharArray()));
+                    allowedAddressPairsBuilder.setMacAddress(new MacAddress(allowedAddressPairs.getMacAddress()));
                     listAllowedAddressPairs.add(allowedAddressPairsBuilder.build());
             }
             portBuilder.setAllowedAddressPairs(listAllowedAddressPairs);
@@ -295,7 +297,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
             portBuilder.setFixedIps(listNeutronIPs);
         }
         if (neutronPort.getMacAddress() != null) {
-            portBuilder.setMacAddress(neutronPort.getMacAddress());
+            portBuilder.setMacAddress(new MacAddress(neutronPort.getMacAddress()));
         }
         if (neutronPort.getName() != null) {
         portBuilder.setName(neutronPort.getName());
index cf4ddd7b9c2e39edc870b2df1e4fcb964b6a71ae..12c53647a48ce96878586828d1200443736bb105 100644 (file)
@@ -17,7 +17,6 @@ import java.util.Map.Entry;
 import java.util.Set;
 
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
-import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_Interface;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronRouterCRUD;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_NetworkReference;
@@ -29,7 +28,6 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.router
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.RouterBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfo;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.ExternalGatewayInfoBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIpsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
@@ -109,11 +107,7 @@ public class NeutronRouterInterface extends  AbstractNeutronInterface<Router, Ne
 
     @Override
     public boolean routerInUse(String routerUUID) {
-        if (!routerExists(routerUUID)) {
-            return true;
-        }
-        NeutronRouter target = getRouter(routerUUID);
-        return (target.getInterfaces().size() > 0);
+        return !routerExists(routerUUID);
     }
 
     @Override
@@ -167,14 +161,6 @@ public class NeutronRouterInterface extends  AbstractNeutronInterface<Router, Ne
             }
             routerBuilder.setExternalGatewayInfo(externalGatewayInfo);
         }
-        if (router.getInterfaces() != null) {
-            Map<String, NeutronRouter_Interface> mapInterfaces = new HashMap<>();
-            List<Interfaces> interfaces = new ArrayList<>();
-            for (Entry<String, NeutronRouter_Interface> entry : mapInterfaces.entrySet()) {
-                interfaces.add((Interfaces) entry.getValue());
-            }
-            routerBuilder.setInterfaces(interfaces);
-        }
         if (router.getID() != null) {
             routerBuilder.setUuid(toUuid(router.getID()));
         } else {
@@ -237,19 +223,6 @@ public class NeutronRouterInterface extends  AbstractNeutronInterface<Router, Ne
             result.setExternalGatewayInfo(extGwInfo);
         }
 
-        if (router.getInterfaces() != null) {
-            Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
-            for (Interfaces mdInterface : router.getInterfaces()) {
-                NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
-                String id = String.valueOf(mdInterface.getUuid().getValue());
-                pojoInterface.setID(id);
-                pojoInterface.setTenantID(String.valueOf(mdInterface.getTenantId().getValue()));
-                pojoInterface.setSubnetUUID(String.valueOf(mdInterface.getSubnetId().getValue()));
-                pojoInterface.setPortUUID(String.valueOf(mdInterface.getPortId().getValue()));
-                interfaces.put(id, pojoInterface);
-            }
-            result.setInterfaces(interfaces);
-        }
         return result;
     }
     
index 9cf54415339bd8ddbb49f9fa1ea96e697b4368d4..b1a645bb2da90edeea8bc35a46bdf1a3cb7f0e03 100644 (file)
@@ -109,30 +109,9 @@ public class NeutronSecurityGroupInterface extends AbstractNeutronInterface<Secu
         if (group.getName() != null) {
             answer.setSecurityGroupName(group.getName());
         }
-        if (group.getDescription() != null) {
-            answer.setSecurityGroupDescription(group.getDescription());
-        }
         if (group.getTenantId() != null) {
             answer.setSecurityGroupTenantID(group.getTenantId().getValue().replace("-",""));
         }
-
-        // Bug 4550
-        // https://bugs.opendaylight.org/show_bug.cgi?id=4550
-        // Now SecurityGroup::securityGroupRule isn't updated.
-        // always rebuid it from security group rules
-        NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
-            .fetchINeutronSecurityRuleCRUD(this);
-        INeutronSecurityRuleCRUD srCrud = interfaces.getSecurityRuleInterface();
-
-        List<NeutronSecurityRule> rules = new ArrayList<>();
-        String sgId = group.getUuid().getValue();
-        for (NeutronSecurityRule rule: srCrud.getAllNeutronSecurityRules()) {
-            if (rule.getSecurityRuleGroupID().equals(sgId)) {
-                rules.add(rule);
-            }
-        }
-        answer.setSecurityRules(rules);
-
         if (group.getUuid() != null) {
             answer.setID(group.getUuid().getValue());
         }
@@ -145,18 +124,9 @@ public class NeutronSecurityGroupInterface extends AbstractNeutronInterface<Secu
         if (securityGroup.getSecurityGroupName() != null) {
             securityGroupBuilder.setName(securityGroup.getSecurityGroupName());
         }
-        if (securityGroup.getSecurityGroupDescription() != null) {
-            securityGroupBuilder.setDescription(securityGroup.getSecurityGroupDescription());
-        }
         if (securityGroup.getSecurityGroupTenantID() != null) {
             securityGroupBuilder.setTenantId(toUuid(securityGroup.getSecurityGroupTenantID()));
         }
-
-        // don't update security group rule, always empty list
-        // Bug 4550
-        // https://bugs.opendaylight.org/show_bug.cgi?id=4550
-        securityGroupBuilder.setSecurityRules(new ArrayList<>());
-
         if (securityGroup.getID() != null) {
             securityGroupBuilder.setUuid(toUuid(securityGroup.getID()));
         } else {
index 5847059a0384d4023bb627e6322438bd2ecf3aa5..7e968e44250bdaa4331b569df2d5e7dd28928454 100644 (file)
@@ -31,7 +31,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolIcmpV6;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolTcp;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.ProtocolUdp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.NeutronUtils;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.SecurityRuleAttributes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.SecurityRules;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRule;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.secgroups.rev150712.security.rules.attributes.security.rules.SecurityRuleBuilder;
@@ -64,40 +66,6 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
         super(providerContext);
     }
 
-    private void updateSecGroupRuleInSecurityGroup(NeutronSecurityRule input) {
-        NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
-            .fetchINeutronSecurityGroupCRUD(this);
-        INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
-        NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
-        if(sg != null && sg.getSecurityRules() != null) {
-            for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
-                if(sgr != null && sgr.getID() != null && sgr.getID().equals(input.getID())) {
-                    int index = sg.getSecurityRules().indexOf(sgr);
-                    sg.getSecurityRules().set(index, input);
-                }
-            }
-        }
-        if (sg != null) {
-            sg.getSecurityRules().add(input);
-        }
-    }
-
-    private void removeSecGroupRuleFromSecurityGroup(NeutronSecurityRule input) {
-        NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
-            .fetchINeutronSecurityGroupCRUD(this);
-        INeutronSecurityGroupCRUD sgCrud = interfaces.getSecurityGroupInterface();
-        NeutronSecurityGroup sg = sgCrud.getNeutronSecurityGroup(input.getSecurityRuleGroupID());
-        if(sg != null && sg.getSecurityRules() != null) {
-            List<NeutronSecurityRule> toRemove = new ArrayList<>();
-            for(NeutronSecurityRule sgr :sg.getSecurityRules()) {
-                if(sgr.getID() != null && sgr.getID().equals(input.getID())) {
-                    toRemove.add(sgr);
-                }
-            }
-            sg.getSecurityRules().removeAll(toRemove);
-        }
-    }
-
     @Override
     public boolean neutronSecurityRuleExists(String uuid) {
         SecurityRule rule = readMd(createInstanceIdentifier(toMd(uuid)));
@@ -131,7 +99,6 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
         if (neutronSecurityRuleExists(input.getID())) {
             return false;
         }
-        updateSecGroupRuleInSecurityGroup(input);
         addMd(input);
         return true;
     }
@@ -141,7 +108,6 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
         if (!neutronSecurityRuleExists(uuid)) {
             return false;
         }
-        removeSecGroupRuleFromSecurityGroup(getNeutronSecurityRule(uuid));
         removeMd(toMd(uuid));
         return true;
     }
@@ -151,7 +117,6 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
         if (!neutronSecurityRuleExists(uuid)) {
             return false;
         }
-        updateSecGroupRuleInSecurityGroup(delta);
         updateMd(delta);
         return true;
     }
@@ -180,7 +145,14 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
                     rule.getRemoteIpPrefix().getIpv4Prefix().getValue():rule.getRemoteIpPrefix().getIpv6Prefix().getValue());
         }
         if (rule.getProtocol() != null) {
-            answer.setSecurityRuleProtocol(PROTOCOL_MAP.get(rule.getProtocol()));
+            SecurityRuleAttributes.Protocol protocol = rule.getProtocol();
+            if (protocol.getUint8() != null) {
+                // uint8
+                answer.setSecurityRuleProtocol(protocol.getUint8().toString());
+            } else {
+               // symbolic protocol name
+               answer.setSecurityRuleProtocol(NeutronUtils.ProtocolMapper.getName(protocol.getIdentityref()));
+            }
         }
         if (rule.getEthertype() != null) {
             answer.setSecurityRuleEthertype(ETHERTYPE_MAP.get(rule.getEthertype()));
@@ -191,8 +163,8 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
         if (rule.getPortRangeMax() != null) {
             answer.setSecurityRulePortMax(rule.getPortRangeMax());
         }
-        if (rule.getId() != null) {
-            answer.setID(rule.getId().getValue());
+        if (rule.getUuid() != null) {
+            answer.setID(rule.getUuid().getValue());
         }
         return answer;
     }
@@ -219,9 +191,9 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             securityRuleBuilder.setRemoteIpPrefix(new IpPrefix(securityRule.getSecurityRuleRemoteIpPrefix().toCharArray()));
         }
         if (securityRule.getSecurityRuleProtocol() != null) {
-            ImmutableBiMap<String, Class<? extends ProtocolBase>> mapper =
-                    PROTOCOL_MAP.inverse();
-            securityRuleBuilder.setProtocol(mapper.get(securityRule.getSecurityRuleProtocol()));
+            String protocolString = securityRule.getSecurityRuleProtocol();
+            SecurityRuleAttributes.Protocol protocol = new SecurityRuleAttributes.Protocol(protocolString.toCharArray());
+            securityRuleBuilder.setProtocol(protocol);
         }
         if (securityRule.getSecurityRuleEthertype() != null) {
             ImmutableBiMap<String, Class<? extends EthertypeBase>> mapper =
@@ -235,7 +207,7 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
             securityRuleBuilder.setPortRangeMax(securityRule.getSecurityRulePortMax());
         }
         if (securityRule.getID() != null) {
-            securityRuleBuilder.setId(toUuid(securityRule.getID()));
+            securityRuleBuilder.setUuid(toUuid(securityRule.getID()));
         } else {
             LOGGER.warn("Attempting to write neutron securityRule without UUID");
         }
@@ -257,7 +229,7 @@ public class NeutronSecurityRuleInterface extends AbstractNeutronInterface<Secur
     @Override
     protected SecurityRule toMd(String uuid) {
         SecurityRuleBuilder securityRuleBuilder = new SecurityRuleBuilder();
-        securityRuleBuilder.setId(toUuid(uuid));
+        securityRuleBuilder.setUuid(toUuid(uuid));
         return securityRuleBuilder.build();
     }
 
index e124d3aadfe26d702b2c9af620ff9bcb1a68e978..7b91d77d213c4e3a29fd371afe06fbdc6e2e726f 100644 (file)
@@ -22,6 +22,7 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.NeutronCRUDInterfaces;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Base;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Off;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.constants.rev150712.Dhcpv6Slaac;
@@ -144,7 +145,7 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Neu
         result.setTenantID(String.valueOf(subnet.getTenantId().getValue()).replace("-",""));
         result.setNetworkUUID(subnet.getNetworkId().getValue());
         result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
-        result.setCidr(subnet.getCidr());
+        result.setCidr(String.valueOf(subnet.getCidr().getValue()));
         result.setIpV6RaMode(DHCPV6_MAP.get(subnet.getIpv6RaMode()));
         result.setIpV6AddressMode(DHCPV6_MAP.get(subnet.getIpv6AddressMode()));
         result.setEnableDHCP(subnet.isEnableDhcp());
@@ -152,8 +153,8 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Neu
             List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
             for (AllocationPools allocationPool : subnet.getAllocationPools()) {
                 NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
-                pool.setPoolStart(allocationPool.getStart());
-                pool.setPoolEnd(allocationPool.getEnd());
+                pool.setPoolStart(String.valueOf(allocationPool.getStart().getValue()));
+                pool.setPoolEnd(String.valueOf(allocationPool.getEnd().getValue()));
                 allocationPools.add(pool);
             }
             result.setAllocationPools(allocationPools);
@@ -210,7 +211,8 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Neu
                     .getIpVersion()));
         }
         if (subnet.getCidr() != null) {
-            subnetBuilder.setCidr(subnet.getCidr());
+            IpPrefix ipPrefix = new IpPrefix(subnet.getCidr().toCharArray());
+            subnetBuilder.setCidr(ipPrefix);
         }
         if (subnet.getGatewayIP() != null) {
             IpAddress ipAddress = new IpAddress(subnet.getGatewayIP()
@@ -233,8 +235,8 @@ public class NeutronSubnetInterface extends AbstractNeutronInterface<Subnet, Neu
             for (NeutronSubnetIPAllocationPool allocationPool : subnet
                     .getAllocationPools()) {
                 AllocationPoolsBuilder builder = new AllocationPoolsBuilder();
-                builder.setStart(allocationPool.getPoolStart());
-                builder.setEnd(allocationPool.getPoolEnd());
+                builder.setStart(new IpAddress(allocationPool.getPoolStart().toCharArray()));
+                builder.setEnd(new IpAddress(allocationPool.getPoolEnd().toCharArray()));
                 AllocationPools temp = builder.build();
                 allocationPools.add(temp);
             }
index 98df6b769c4a524177bb87ef7658fe991714b78b..915917868af89932a9c1bd83078ce5bb4c17112d 100644 (file)
@@ -136,9 +136,6 @@ public class NeutronLoadBalancerPoolChangeListener implements ClusteredDataChang
         if (pool.getName() != null) {
             result.setLoadBalancerPoolName(pool.getName());
         }
-        if (pool.getDescr() != null) {
-            result.setLoadBalancerPoolDescription(pool.getDescr());
-        }
         if (pool.getProtocol() != null) {
             result.setLoadBalancerPoolProtocol(PROTOCOL_MAP.get(pool.getProtocol()));
         }
index e28ff4e888a3a21068edd23f8756fa40b574f3d1..2f9d578546fab879796d51c2f93c16ba4e70ad2f 100644 (file)
@@ -136,8 +136,8 @@ public class NeutronPortChangeListener implements ClusteredDataChangeListener, A
             List<NeutronPort_AllowedAddressPairs> pairs = new ArrayList<>();
             for (AllowedAddressPairs mdPair : port.getAllowedAddressPairs()) {
                 NeutronPort_AllowedAddressPairs pair = new NeutronPort_AllowedAddressPairs();
-                pair.setIpAddress(mdPair.getIpAddress());
-                pair.setMacAddress(mdPair.getMacAddress());
+                pair.setIpAddress(String.valueOf(mdPair.getIpAddress().getValue()));
+                pair.setMacAddress(mdPair.getMacAddress().getValue());
                 pairs.add(pair);
             }
             result.setAllowedAddressPairs(pairs);
@@ -164,7 +164,7 @@ public class NeutronPortChangeListener implements ClusteredDataChangeListener, A
             }
             result.setFixedIPs(ips);
         }
-        result.setMacAddress(port.getMacAddress());
+        result.setMacAddress(port.getMacAddress().getValue());
         result.setName(port.getName());
         result.setNetworkUUID(String.valueOf(port.getNetworkId().getValue()));
         if (port.getSecurityGroups() != null) {
@@ -194,14 +194,11 @@ public class NeutronPortChangeListener implements ClusteredDataChangeListener, A
         PortBindingExtension binding = port.getAugmentation(PortBindingExtension.class);
         result.setBindinghostID(binding.getHostId());
         if (binding.getVifDetails() != null) {
-            List<NeutronPort_VIFDetail> details = new ArrayList<>();
-            for (VifDetails vifDetail : binding.getVifDetails()) {
-                NeutronPort_VIFDetail detail = new NeutronPort_VIFDetail();
-                detail.setPortFilter(vifDetail.isPortFilter());
-                detail.setOvsHybridPlug(vifDetail.isOvsHybridPlug());
-                details.add(detail);
+            final Map<String, String> details = new HashMap<String, String>(binding.getVifDetails().size());
+            for (final VifDetails vifDetail : binding.getVifDetails()) {
+                details.put(vifDetail.getDetailsKey(), vifDetail.getValue());
             }
-            result.setVIFDetail(details);
+            result.setVIFDetails(details);
         }
         result.setBindingvifType(binding.getVifType());
         result.setBindingvnicType(binding.getVnicType());
index 911a203743c6c5d30960ab8f782f87ce60b2050f..9ff45910396814b991401239c2a8f31a29fc04be 100644 (file)
@@ -20,14 +20,12 @@ import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataCh
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter;
-import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_Interface;
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronRouter_NetworkReference;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.netvirt.openstack.netvirt.translator.iaware.INeutronRouterAware;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.l3.attributes.Routes;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.Routers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.Router;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.Interfaces;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l3.rev150712.routers.attributes.routers.router.external_gateway_info.ExternalFixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -150,21 +148,6 @@ public class NeutronRouterChangeListener implements ClusteredDataChangeListener,
             result.setExternalGatewayInfo(extGwInfo);
         }
 
-        if (router.getInterfaces() != null) {
-            Map<String, NeutronRouter_Interface> interfaces = new HashMap<>();
-            for (Interfaces mdInterface : router.getInterfaces()) {
-                NeutronRouter_Interface pojoInterface = new NeutronRouter_Interface();
-                String id = String.valueOf(mdInterface.getUuid().getValue());
-                pojoInterface.setID(id);
-                if (mdInterface.getTenantId() != null) {
-                     pojoInterface.setTenantID(String.valueOf(mdInterface.getTenantId().getValue()));
-                }
-                pojoInterface.setSubnetUUID(String.valueOf(mdInterface.getSubnetId().getValue()));
-                pojoInterface.setPortUUID(String.valueOf(mdInterface.getPortId().getValue()));
-                interfaces.put(id, pojoInterface);
-            }
-            result.setInterfaces(interfaces);
-        }
         return result;
     }
 
index e21d0d95fdba7c0a25e80b1d9a4ec7a596835361..31b6051d49c255cc1c41d46b2e9a2e7e0afb86e3 100644 (file)
@@ -118,25 +118,10 @@ public class NeutronSecurityGroupDataChangeListener implements ClusteredDataChan
         if (group.getName() != null) {
             answer.setSecurityGroupName(group.getName());
         }
-        if (group.getDescription() != null) {
-            answer.setSecurityGroupDescription(group.getDescription());
-        }
         if (group.getTenantId() != null) {
             answer.setSecurityGroupTenantID(group.getTenantId().getValue()
                     .replace("-", ""));
         }
-        if (group.getSecurityRules() != null) {
-            NeutronCRUDInterfaces interfaces = new NeutronCRUDInterfaces()
-                    .fetchINeutronSecurityRuleCRUD(this);
-            INeutronSecurityRuleCRUD srCrud = interfaces
-                    .getSecurityRuleInterface();
-
-            List<NeutronSecurityRule> rules = new ArrayList<>();
-            for (Uuid uuid : group.getSecurityRules()) {
-                rules.add(srCrud.getNeutronSecurityRule(uuid.getValue()));
-            }
-            answer.setSecurityRules(rules);
-        }
         if (group.getUuid() != null) {
             answer.setID(group.getUuid().getValue());
         }
index 439dfe2a30d8857683851e8ab513b2553e31efe0..db81334f9fa0edb785b59b34499e0f5298831749 100644 (file)
@@ -162,8 +162,8 @@ public class NeutronSecurityRuleDataChangeListener implements ClusteredDataChang
         if (rule.getPortRangeMax() != null) {
             answer.setSecurityRulePortMax(rule.getPortRangeMax());
         }
-        if (rule.getId() != null) {
-            answer.setID(rule.getId().getValue());
+        if (rule.getUuid() != null) {
+            answer.setID(rule.getUuid().getValue());
         }
         return answer;
     }
index d13c21458d665ab89d4c04ede2a7bef7cfba0901..7fa316d2f0c6959ae403238112ebbbbdc89faaa0 100644 (file)
@@ -144,7 +144,7 @@ public class NeutronSubnetChangeListener implements ClusteredDataChangeListener,
         }
         result.setNetworkUUID(subnet.getNetworkId().getValue());
         result.setIpVersion(IPV_MAP.get(subnet.getIpVersion()));
-        result.setCidr(subnet.getCidr());
+        result.setCidr(String.valueOf(subnet.getCidr().getValue()));
         if (subnet.getGatewayIp() != null) {
             result.setGatewayIP(String.valueOf(subnet.getGatewayIp().getValue()));
         }
@@ -159,8 +159,8 @@ public class NeutronSubnetChangeListener implements ClusteredDataChangeListener,
             List<NeutronSubnetIPAllocationPool> allocationPools = new ArrayList<>();
             for (AllocationPools allocationPool : subnet.getAllocationPools()) {
                 NeutronSubnetIPAllocationPool pool = new NeutronSubnetIPAllocationPool();
-                pool.setPoolStart(allocationPool.getStart());
-                pool.setPoolEnd(allocationPool.getEnd());
+                pool.setPoolStart(String.valueOf(allocationPool.getStart().getValue()));
+                pool.setPoolEnd(String.valueOf(allocationPool.getEnd().getValue()));
                 allocationPools.add(pool);
             }
             result.setAllocationPools(allocationPools);
index 5e0b980a886690f451b380b8b2bfa67c4227a008..bc6215358b3bb506853389a957ef51acf060b8af 100644 (file)
@@ -30,6 +30,7 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronPortCRUD;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityGroupCRUD;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
 
 /**
  * Unit test fort {@link SecurityGroupCacheManagerImpl}
@@ -40,6 +41,7 @@ public class SecurityGroupCacheManagerImplTest {
     @InjectMocks private SecurityGroupCacheManagerImpl securityGroupCacheManagerImpl;
     @Mock private INeutronPortCRUD neutronPortCache;
     @Mock private INeutronSecurityGroupCRUD securityGroupCache;
+    @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
     @Mock NeutronPort neutronPort_Vm1;
     @Mock NeutronPort neutronPort_Vm2;
     @Mock NeutronPort neutronPort_Vm3;
@@ -81,12 +83,10 @@ public class SecurityGroupCacheManagerImplTest {
         securityGroups_Vm_2.add(neutronSecurityGroup_2);
         List<NeutronSecurityGroup> securityGroups_Vm_3 = new ArrayList<>();
         securityGroups_Vm_3.add(neutronSecurityGroup_3);
-        List<NeutronSecurityRule> securityRule_1 = new ArrayList<>();
-        securityRule_1.add(neutronSecurityRule_1);
-        List<NeutronSecurityRule> securityRule_2 = new ArrayList<>();
-        securityRule_2.add(neutronSecurityRule_2);
-        List<NeutronSecurityRule> securityRule_3 = new ArrayList<>();
-        securityRule_3.add(neutronSecurityRule_3);
+        List<NeutronSecurityRule> securityRule = new ArrayList<>();
+        securityRule.add(neutronSecurityRule_1);
+        securityRule.add(neutronSecurityRule_2);
+        securityRule.add(neutronSecurityRule_3);
 
         neutron_IPs_1.add(neutron_ip_1);
         neutron_IPs_2.add(neutron_ip_2);
@@ -104,12 +104,16 @@ public class SecurityGroupCacheManagerImplTest {
         when(neutronPort_Vm3.getSecurityGroups()).thenReturn(securityGroups_Vm_3);
         when(neutronPort_Vm4.getSecurityGroups()).thenReturn(securityGroups_Vm_1);
         when(neutronPort_Vm5.getSecurityGroups()).thenReturn(securityGroups_Vm_3);
-        when(neutronSecurityGroup_1.getSecurityRules()).thenReturn(securityRule_1);
-        when(neutronSecurityGroup_2.getSecurityRules()).thenReturn(securityRule_2);
-        when(neutronSecurityGroup_3.getSecurityRules()).thenReturn(securityRule_3);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(securityRule);
         when(neutronSecurityGroup_1.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_1);
         when(neutronSecurityGroup_2.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_2);
         when(neutronSecurityGroup_3.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_3);
+        when(neutronSecurityGroup_1.getID()).thenReturn(SECURITY_GROUP_ID_1);
+        when(neutronSecurityGroup_2.getID()).thenReturn(SECURITY_GROUP_ID_2);
+        when(neutronSecurityGroup_3.getID()).thenReturn(SECURITY_GROUP_ID_3);
+        when(neutronSecurityRule_1.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_1);
+        when(neutronSecurityRule_2.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_2);
+        when(neutronSecurityRule_3.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_3);
         when(neutronSecurityRule_1.getSecurityRemoteGroupID()).thenReturn(SECURITY_GROUP_ID_1);
         when(neutronSecurityRule_3.getSecurityRemoteGroupID()).thenReturn(SECURITY_GROUP_ID_2);
         when(neutronPort_Vm1.getFixedIPs()).thenReturn(neutron_IPs_1);
index b2a1c95f323c46f255253ef2a6cf0eac8f5d880d..c33ca348c16ef4b9ab595062f6770fba84a68ab8 100644 (file)
@@ -41,6 +41,7 @@ import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSecurityRule
 import org.opendaylight.netvirt.openstack.netvirt.translator.NeutronSubnet;
 import org.opendaylight.netvirt.openstack.netvirt.translator.Neutron_IPs;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSecurityRuleCRUD;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
 import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105
@@ -62,6 +63,7 @@ public class SecurityServicesImplTest {
     @Mock private INeutronSubnetCRUD subNetCache;
     @Mock private Southbound southbound;
     @Mock private ConfigurationService configurationService;
+    @Mock private INeutronSecurityRuleCRUD neutronSecurityRuleCache;
     @Mock NeutronNetwork neutronNetwork;
     @Mock NeutronPort neutronPort_Vm1;
     @Mock NeutronPort neutronPort_Vm2;
@@ -105,12 +107,10 @@ public class SecurityServicesImplTest {
         securityGroups_2.add(neutronSecurityGroup_2);
         List<NeutronSecurityGroup> securityGroups_3 = new ArrayList<>();
         securityGroups_3.add(neutronSecurityGroup_3);
-        List<NeutronSecurityRule> securityRule_1 = new ArrayList<>();
-        securityRule_1.add(neutronSecurityRule_1);
-        List<NeutronSecurityRule> securityRule_2 = new ArrayList<>();
-        securityRule_1.add(neutronSecurityRule_2);
-        List<NeutronSecurityRule> securityRule_3 = new ArrayList<>();
-        securityRule_1.add(neutronSecurityRule_3);
+        List<NeutronSecurityRule> securityRule = new ArrayList<>();
+        securityRule.add(neutronSecurityRule_1);
+        securityRule.add(neutronSecurityRule_2);
+        securityRule.add(neutronSecurityRule_3);
 
         neutron_IPs_1.add(neutron_ip_1);
         neutron_IPs_2.add(neutron_ip_2);
@@ -122,12 +122,16 @@ public class SecurityServicesImplTest {
         when(neutronPort_Vm1.getSecurityGroups()).thenReturn(securityGroups_1);
         when(neutronPort_Vm2.getSecurityGroups()).thenReturn(securityGroups_2);
         when(neutronPort_Vm3.getSecurityGroups()).thenReturn(securityGroups_3);
-        when(neutronSecurityGroup_1.getSecurityRules()).thenReturn(securityRule_1);
-        when(neutronSecurityGroup_2.getSecurityRules()).thenReturn(securityRule_2);
-        when(neutronSecurityGroup_3.getSecurityRules()).thenReturn(securityRule_3);
+        when(neutronSecurityRuleCache.getAllNeutronSecurityRules()).thenReturn(securityRule);
         when(neutronSecurityGroup_1.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_1);
         when(neutronSecurityGroup_2.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_2);
         when(neutronSecurityGroup_3.getSecurityGroupUUID()).thenReturn(SECURITY_GROUP_ID_3);
+        when(neutronSecurityGroup_1.getID()).thenReturn(SECURITY_GROUP_ID_1);
+        when(neutronSecurityGroup_2.getID()).thenReturn(SECURITY_GROUP_ID_2);
+        when(neutronSecurityGroup_3.getID()).thenReturn(SECURITY_GROUP_ID_3);
+        when(neutronSecurityRule_1.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_1);
+        when(neutronSecurityRule_2.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_2);
+        when(neutronSecurityRule_3.getSecurityRuleGroupID()).thenReturn(SECURITY_GROUP_ID_3);
         when(neutronPort_Vm1.getDeviceOwner()).thenReturn(DEVICE_OWNER_VM);
         when(neutronPort_Vm2.getDeviceOwner()).thenReturn(DEVICE_OWNER_VM);
         when(neutronPort_Vm3.getDeviceOwner()).thenReturn(DEVICE_OWNER_VM);
index b9063a368ddc55cdada58b7131f6cd57cba88feb..f62a06a740e784b689a69ad4f31fa3eb3359e817 100644 (file)
@@ -108,7 +108,7 @@ public class NeutronUtils {
     public NeutronSecurityRule buildNeutronSecurityRule(String direction, String ethertype, String protocol,
                                                          String ipPrefix, Integer portMin, Integer portMax) {
         NeutronSecurityRule rule = new NeutronSecurityRule();
-        rule.setSecurityRuleUUID(UUID.randomUUID().toString());
+        rule.setID(UUID.randomUUID().toString());
         rule.setSecurityRemoteGroupID(null);
         rule.setSecurityRuleDirection(direction);
         rule.setSecurityRuleEthertype(ethertype);
@@ -136,7 +136,7 @@ public class NeutronUtils {
         String id = UUID.randomUUID().toString();
         NeutronSecurityGroup sg = new NeutronSecurityGroup();
         sg.setSecurityGroupName("SG-" + id);
-        sg.setSecurityGroupUUID(id);
+        sg.setID(id);
         sg.setTenantID(tenantId);
 
         List<NeutronSecurityRule> ruleList = new ArrayList<>(rules.length);
@@ -147,7 +147,6 @@ public class NeutronUtils {
             ruleCRUD.addNeutronSecurityRule(rule);
         }
 
-        sg.setSecurityRules(ruleList);
         groupCRUD.add(sg);
 
         return sg;
@@ -160,12 +159,26 @@ public class NeutronUtils {
     public void removeNeutronSecurityGroupAndRules(NeutronSecurityGroup sg) {
         INeutronSecurityGroupCRUD groupCRUD =
                 (INeutronSecurityGroupCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityGroupCRUD.class, this);
+
+        groupCRUD.removeNeutronSecurityGroup(sg.getID());
+    }
+
+    /**
+     * Get the NeutronSecurityRule and its associated NeutronSecurityGroup
+     * @param sg NeutronSecurityGroup to to get the rules for
+     * @return List of NeutronSecurityRule
+     */
+    public List<NeutronSecurityRule>  getNeutronSecurityGroupRules(NeutronSecurityGroup sg) {
         INeutronSecurityRuleCRUD ruleCRUD =
                 (INeutronSecurityRuleCRUD) ServiceHelper.getGlobalInstance(INeutronSecurityRuleCRUD.class, this);
 
-        for (NeutronSecurityRule rule : sg.getSecurityRules()) {
-            ruleCRUD.removeNeutronSecurityRule(rule.getSecurityRuleUUID());
+        List<NeutronSecurityRule> rules = new ArrayList<>();
+        List<NeutronSecurityRule> securityRules = ruleCRUD.getAllNeutronSecurityRules();
+        for (NeutronSecurityRule securityRule : securityRules) {
+            if (sg.getID().equals(securityRule.getSecurityRuleGroupID())) {
+                rules.add(securityRule);
+            }
         }
-        groupCRUD.removeNeutronSecurityGroup(sg.getID());
+        return rules;
     }
 }
index 42561639f738c9da89660f037750ff5120371942..bcfbd96771e1c059490f1d6ef9e02fd4cde71444 100644 (file)
@@ -122,7 +122,7 @@ public class DhcpExternalTunnelManager {
                 if(NeutronUtils.isPortVnicTypeNormal(port)) {
                     continue;
                 }
-                String macAddress = port.getMacAddress();
+                String macAddress = port.getMacAddress().getValue();
                 Uuid networkId = port.getNetworkId();
                 String segmentationId = DhcpServiceUtils.getSegmentationId(networkId, broker);
                 if (segmentationId == null) {
index 6119dc559e0722bce50a26bffc7cd4d8cdea6dcb..05c1c5990f363670f23e355511bc6193d8366915 100644 (file)
@@ -194,7 +194,7 @@ public class DhcpInterfaceEventListener extends AbstractDataChangeListener<Inter
         Port port = dhcpManager.getNeutronPort(interfaceName);
         if (port!=null) {
             logger.trace("Port found in neutron. Interface Name {}, port {}", interfaceName, port);
-            return port.getMacAddress();
+            return port.getMacAddress().getValue();
         }
         return null;
     }
index 207bd4dbd814bbe3771f46d18635e4cd97e9e777..a32da0be59b229ce0701a646a0bf8810a4a8cdca 100644 (file)
@@ -139,7 +139,7 @@ public class DhcpNeutronPortListener extends AsyncClusteredDataChangeListenerBas
     }
 
     private String getMacAddress(Port port) {
-        String macAddress = port.getMacAddress();
+        String macAddress = port.getMacAddress().getValue();
         return macAddress;
     }
 }
index e039ecd284bdcf960e217b981cabc2613578b7cd..124daffacbce7a04cb79154ac6dcab8cbb369acd 100644 (file)
@@ -165,7 +165,7 @@ public class DhcpPktHandler implements AutoCloseable, PacketProcessingListener {
             List<IpAddress> dnsServers = nSubnet.getDnsNameservers();
             dhcpInfo = new DhcpInfo();
             dhcpInfo.setClientIp(clientIp).setServerIp(serverIp)
-                .setCidr(nSubnet.getCidr()).setHostRoutes(nSubnet.getHostRoutes())
+                .setCidr(String.valueOf(nSubnet.getCidr().getValue())).setHostRoutes(nSubnet.getHostRoutes())
                 .setDnsServersIpAddrs(dnsServers).setGatewayIp(serverIp);
         }
         return dhcpInfo;
index d99bd7a857619731d167f4012d6b448a838ce094..46fdb1b1a9663f1e027b0042437ecd5e1554f410 100644 (file)
@@ -220,6 +220,6 @@ public class DhcpServiceUtils {
             logger.warn("Trunk port {} not available for sub-port", parentRefName);
             return null;
         }
-        return trunkPort.get().getMacAddress();
+        return trunkPort.get().getMacAddress().getValue();
     }
-}
\ No newline at end of file
+}
index 5226853a1464cd6041507d0e3a2f1132661259c2..57b29f73b2c5b8f75d24d6989748f30efa694871 100644 (file)
@@ -135,11 +135,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <type>xml</type>
       <scope>runtime</scope>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.neutron</groupId>
-      <artifactId>dummyprovider</artifactId>
-      <version>${neutron.version}</version>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>vpnmanager-impl</artifactId>
index 83941747f601cd4d06b37a310452c64aef9015d2..4d93c9dae41981412f1f708fcf535edae2493ed0 100644 (file)
@@ -85,12 +85,10 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   </feature>
   <feature name='odl-netvirt-vpnservice-core' version='${project.version}' description='OpenDaylight :: vpnservice :: core'>
     <feature version="${neutron.version}">odl-neutron-service</feature>
-    <bundle>mvn:org.opendaylight.neutron/dummyprovider/{{VERSION}}</bundle>
     <feature version="${project.version}">odl-netvirt-vpnservice-impl-ui</feature>
   </feature>
   <feature name='odl-netvirt-vpnservice-openstack' version='${project.version}' description='OpenDaylight :: vpnservice :: openstack'>
     <feature version="${neutron.version}">odl-neutron-service</feature>
-    <bundle>mvn:org.opendaylight.neutron/dummyprovider/{{VERSION}}</bundle>
     <feature version="${project.version}">odl-netvirt-vpnservice-impl-rest</feature>
   </feature>
   </features>
index 8413eea274f97e9c8ead5fd30b82330619ccb4b3..0ce0413203ccb689617016319c4439f71a32f231 100644 (file)
@@ -37,16 +37,14 @@ public class NeutronNetworkChangeListener extends AbstractDataChangeListener<Net
     private final DataBroker broker;
     private NeutronvpnManager nvpnManager;
     private NeutronvpnNatManager nvpnNatManager;
-    private NeutronvpnUtils neutronvpnUtils;
 
 
     public NeutronNetworkChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr, NeutronvpnNatManager
-            nVpnNatMgr, NeutronvpnUtils nVpnUtils) {
+            nVpnNatMgr) {
         super(Network.class);
         broker = db;
         nvpnManager = nVpnMgr;
         nvpnNatManager = nVpnNatMgr;
-        neutronvpnUtils = nVpnUtils;
         registerListener(db);
     }
 
@@ -91,7 +89,7 @@ public class NeutronNetworkChangeListener extends AbstractDataChangeListener<Net
         createElanInstance(input);
         if (input.getAugmentation(NetworkL3Extension.class).isExternal()) {
             nvpnNatManager.addExternalNetwork(input);
-            neutronvpnUtils.addToNetworkCache(input);
+            NeutronvpnUtils.addToNetworkCache(input);
         }
     }
 
@@ -109,7 +107,7 @@ public class NeutronNetworkChangeListener extends AbstractDataChangeListener<Net
         deleteElanInstance(input.getUuid().getValue());
         if (input.getAugmentation(NetworkL3Extension.class).isExternal()) {
             nvpnNatManager.removeExternalNetwork(input);
-            neutronvpnUtils.removeFromNetworkCache(input);
+            NeutronvpnUtils.removeFromNetworkCache(input);
         }
     }
 
index 042822df0f0e4acf0f943f8c58fbe9fd7b172df4..5327242e4fbb6a5027441a5616c646a0532576e5 100644 (file)
@@ -63,19 +63,16 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     private LockManagerService lockManager;
     private NotificationPublishService notificationPublishService;
     private NotificationService notificationService;
-    private NeutronvpnUtils neutronvpnUtils;
 
 
     public NeutronPortChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr,NeutronvpnNatManager nVpnNatMgr,
-                                     NotificationPublishService notiPublishService, NotificationService notiService,
-                                     NeutronvpnUtils nVpnUtils) {
+                                     NotificationPublishService notiPublishService, NotificationService notiService) {
         super(Port.class);
         broker = db;
         nvpnManager = nVpnMgr;
         nvpnNatManager = nVpnNatMgr;
         notificationPublishService = notiPublishService;
         notificationService = notiService;
-        neutronvpnUtils = nVpnUtils;
         registerListener(db);
     }
 
@@ -129,7 +126,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
             }
         }
         handleNeutronPortCreated(input);
-        neutronvpnUtils.addToPortCache(input);
+        NeutronvpnUtils.addToPortCache(input);
 
     }
 
@@ -153,8 +150,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
             }
         }
         handleNeutronPortDeleted(input);
-        neutronvpnUtils.removeFromPortCache(input);
-
+        NeutronvpnUtils.removeFromPortCache(input);
     }
 
     @Override
@@ -191,7 +187,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
                 }
             }
             handleNeutronPortUpdated(original, update);
-            neutronvpnUtils.addToPortCache(update);
+            NeutronvpnUtils.addToPortCache(update);
         }
     }
 
@@ -361,7 +357,7 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener<Port>
     private void createElanInterface(Port port, String name) {
         String elanInstanceName = port.getNetworkId().getValue();
         List<PhysAddress> physAddresses = new ArrayList<>();
-        physAddresses.add(new PhysAddress(port.getMacAddress()));
+        physAddresses.add(new PhysAddress(port.getMacAddress().getValue()));
 
         InstanceIdentifier<ElanInterface> id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface
                 .class, new ElanInterfaceKey(name)).build();
index fa2b6f87af72f104af04f1427465857ef3b7fcae..09fec3934d9936a2d669b383367e420a0da1d5d7 100644 (file)
@@ -33,16 +33,14 @@ public class NeutronRouterChangeListener extends AbstractDataChangeListener<Rout
     private final DataBroker broker;
     private NeutronvpnManager nvpnManager;
     private NeutronvpnNatManager nvpnNatManager;
-    private NeutronvpnUtils neutronvpnUtils;
 
 
     public NeutronRouterChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr, NeutronvpnNatManager
-            nVpnNatMgr, NeutronvpnUtils nVpnUtils) {
+            nVpnNatMgr) {
         super(Router.class);
         broker = db;
         nvpnManager = nVpnMgr;
         nvpnNatManager = nVpnNatMgr;
-        neutronvpnUtils = nVpnUtils;
         registerListener(db);
     }
 
@@ -78,7 +76,7 @@ public class NeutronRouterChangeListener extends AbstractDataChangeListener<Rout
         }
         // Create internal VPN
         nvpnManager.createL3Vpn(input.getUuid(), null, null, null, null, null, input.getUuid(), null);
-        neutronvpnUtils.addToRouterCache(input);
+        NeutronvpnUtils.addToRouterCache(input);
     }
 
     @Override
@@ -91,7 +89,7 @@ public class NeutronRouterChangeListener extends AbstractDataChangeListener<Rout
         //will be removed from VPN by invocations from NeutronPortChangeListener
         List<Uuid> routerSubnetIds = new ArrayList<>();
         nvpnManager.handleNeutronRouterDeleted(routerId, routerSubnetIds);
-        neutronvpnUtils.removeFromRouterCache(input);
+        NeutronvpnUtils.removeFromRouterCache(input);
         // Handle router deletion for the NAT service
         if (input.getExternalGatewayInfo() != null) {
             Uuid extNetId = input.getExternalGatewayInfo().getExternalNetworkId();
index 5040c523461f92e30dfeca7d4c73305c3cb22792..3ecd00b84e42604f1db0b88fc29a15d8e74920f4 100644 (file)
@@ -38,14 +38,12 @@ public class NeutronSubnetChangeListener extends AbstractDataChangeListener<Subn
     private ListenerRegistration<DataChangeListener> listenerRegistration;
     private final DataBroker broker;
     private NeutronvpnManager nvpnManager;
-    private NeutronvpnUtils neutronvpnUtils;
 
 
-    public NeutronSubnetChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr, NeutronvpnUtils nVpnUtils) {
+    public NeutronSubnetChangeListener(final DataBroker db, NeutronvpnManager nVpnMgr) {
         super(Subnet.class);
         broker = db;
         nvpnManager = nVpnMgr;
-        neutronvpnUtils = nVpnUtils;
         registerListener(db);
     }
 
@@ -87,8 +85,8 @@ public class NeutronSubnetChangeListener extends AbstractDataChangeListener<Subn
                     input.getName(), network);
             return;
         }
-        handleNeutronSubnetCreated(input.getUuid(), input.getCidr(), networkId, input.getTenantId());
-        neutronvpnUtils.addToSubnetCache(input);
+        handleNeutronSubnetCreated(input.getUuid(), String.valueOf(input.getCidr().getValue()), input.getNetworkId(), input.getTenantId());
+        NeutronvpnUtils.addToSubnetCache(input);
     }
 
     @Override
@@ -105,7 +103,7 @@ public class NeutronSubnetChangeListener extends AbstractDataChangeListener<Subn
             return;
         }
         handleNeutronSubnetDeleted(input.getUuid(), networkId, null);
-        neutronvpnUtils.removeFromSubnetCache(input);
+        NeutronvpnUtils.removeFromSubnetCache(input);
     }
 
     @Override
@@ -122,7 +120,7 @@ public class NeutronSubnetChangeListener extends AbstractDataChangeListener<Subn
             return;
         }
         handleNeutronSubnetUpdated(update.getUuid(), networkId, update.getTenantId());
-        neutronvpnUtils.addToSubnetCache(update);
+        NeutronvpnUtils.addToSubnetCache(update);
     }
 
     private void handleNeutronSubnetCreated(Uuid subnetId, String subnetIp, Uuid networkId, Uuid tenantId) {
index 0561d7fa5913490e37f9a45d79dd7bbf929919d3..737e97308d2319fb1b32e5bd4373e5dc68b2bb17 100644 (file)
@@ -99,7 +99,6 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable , Eve
     IMdsalApiManager mdsalUtil;
     private NotificationPublishService notificationPublishService;
     private NotificationService notificationService;
-    private NeutronvpnUtils neutronvpnUtils;
     Boolean isExternalVpn;
 
     /**
@@ -107,14 +106,12 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable , Eve
      * @param mdsalManager - MDSAL Util API access
      */
     public NeutronvpnManager(final DataBroker db, IMdsalApiManager mdsalManager,NotificationPublishService notiPublishService,
-                             NotificationService notiService, NeutronvpnNatManager vpnNatMgr, NeutronvpnUtils
-                                     nVpnUtils) {
+                             NotificationService notiService, NeutronvpnNatManager vpnNatMgr) {
         broker = db;
         mdsalUtil = mdsalManager;
         nvpnNatManager = vpnNatMgr;
         notificationPublishService = notiPublishService;
         notificationService = notiService;
-        neutronvpnUtils = nVpnUtils;
     }
 
     public void setLockManager(LockManagerService lockManager) {
@@ -467,7 +464,7 @@ public class NeutronvpnManager implements NeutronvpnService, AutoCloseable , Eve
             StringBuilder IpPrefixBuild = new StringBuilder(ip.getIpAddress().getIpv4Address().getValue());
             String IpPrefix = IpPrefixBuild.append("/32").toString();
             Adjacency vmAdj = new AdjacencyBuilder().setKey(new AdjacencyKey(IpPrefix)).setIpAddress(IpPrefix)
-                    .setMacAddress(port.getMacAddress()).build();
+                    .setMacAddress(port.getMacAddress().getValue()).build();
             adjList.add(vmAdj);
             // create extra route adjacency
             if (rtr != null && rtr.getRoutes() != null) {
index d5bebb3b7e4dbcbf53cb71a7418740ef5b8b8ac8..4e4d6c297374877dbba7a7ff54a9404226154dd1 100644 (file)
@@ -34,7 +34,6 @@ public class NeutronvpnProvider implements BindingAwareProvider, INeutronVpnMana
     private static final Logger LOG = LoggerFactory.getLogger(NeutronvpnProvider.class);
     private NeutronvpnManager nvManager;
     private NeutronvpnNatManager nvNatManager;
-    private NeutronvpnUtils nVpnUtils;
     private IMdsalApiManager mdsalManager;
     private LockManagerService lockManager;
     private NeutronBgpvpnChangeListener bgpvpnListener;
@@ -83,15 +82,15 @@ public class NeutronvpnProvider implements BindingAwareProvider, INeutronVpnMana
             final DataBroker dbx = session.getSALService(DataBroker.class);
             nvNatManager = new NeutronvpnNatManager(dbx, mdsalManager);
             nvManager = new NeutronvpnManager(dbx, mdsalManager,notificationPublishService,notificationService,
-                    nvNatManager, nVpnUtils);
+                    nvNatManager);
             final BindingAwareBroker.RpcRegistration<NeutronvpnService> rpcRegistration =
                     getRpcProviderRegistry().addRpcImplementation(NeutronvpnService.class, nvManager);
             bgpvpnListener = new NeutronBgpvpnChangeListener(dbx, nvManager);
-            networkListener = new NeutronNetworkChangeListener(dbx, nvManager, nvNatManager, nVpnUtils);
-            subnetListener = new NeutronSubnetChangeListener(dbx, nvManager, nVpnUtils);
-            routerListener = new NeutronRouterChangeListener(dbx, nvManager, nvNatManager, nVpnUtils);
+            networkListener = new NeutronNetworkChangeListener(dbx, nvManager, nvNatManager);
+            subnetListener = new NeutronSubnetChangeListener(dbx, nvManager);
+            routerListener = new NeutronRouterChangeListener(dbx, nvManager, nvNatManager);
             portListener = new NeutronPortChangeListener(dbx, nvManager, nvNatManager,
-                    notificationPublishService,notificationService, nVpnUtils);
+                    notificationPublishService,notificationService);
             portListener.setLockManager(lockManager);
             portListener.setLockManager(lockManager);
             floatingIpMapListener = new NeutronFloatingToFixedIpMappingChangeListener(dbx);
@@ -156,7 +155,7 @@ public class NeutronvpnProvider implements BindingAwareProvider, INeutronVpnMana
 
     @Override
     public Subnet getNeutronSubnet(Uuid subnetId) {
-        return nVpnUtils.getNeutronSubnet(broker, subnetId);
+        return NeutronvpnUtils.getNeutronSubnet(broker, subnetId);
     }
 
     @Override
index 5a298c8196d7e5fe49ff1671a60cd76498fd6fcd..1ac1354c13eb71ffb5a4ff248a5262cda13ee4d5 100644 (file)
@@ -80,6 +80,10 @@ public class NeutronvpnUtils {
     public static ConcurrentHashMap<Uuid, Port> portMap = new ConcurrentHashMap<Uuid, Port>();
     public static ConcurrentHashMap<Uuid, Subnet> subnetMap = new ConcurrentHashMap<Uuid, Subnet>();
 
+    private NeutronvpnUtils() {
+        throw new UnsupportedOperationException("Utility class should not be instantiated");
+    }
+
     protected static Subnetmap getSubnetmap(DataBroker broker, Uuid subnetId) {
         InstanceIdentifier id = buildSubnetMapIdentifier(subnetId);
         Optional<Subnetmap> sn = read(broker, LogicalDatastoreType.CONFIGURATION, id);
@@ -329,7 +333,7 @@ public class NeutronvpnUtils {
                     .class).child(Subnet.class, subnetkey);
             Optional<Subnet> subnet = read(broker, LogicalDatastoreType.CONFIGURATION,subnetidentifier);
             if (subnet.isPresent()) {
-                cidr = subnet.get().getCidr();
+                cidr = String.valueOf(subnet.get().getCidr().getValue());
                 // Extract the prefix length from cidr
                 String[] parts = cidr.split("/");
                 if ((parts.length == 2)) {
index d034a802e7340fa4bff5563c145a699148f034f9..0a2de6231b20cb579fe32de7460d4e6a4de99e9f 100644 (file)
@@ -16,13 +16,16 @@ import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
 import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv6Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
@@ -30,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.por
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 
+import com.google.common.base.Optional;
 import com.google.common.util.concurrent.Futures;
 
 @RunWith(MockitoJUnitRunner.class)
@@ -51,6 +55,10 @@ public class NeutronPortChangeListenerTest {
     ListenerRegistration<DataChangeListener> dataChangeListenerRegistration;
     @Mock
     WriteTransaction mockWriteTx;
+    @Mock
+    ReadOnlyTransaction mockReadTx;
+    @Mock
+    Network mockNetwork;
 
     @Before
     public void setUp() {
@@ -61,6 +69,9 @@ public class NeutronPortChangeListenerTest {
                 thenReturn(dataChangeListenerRegistration);
         doReturn(mockWriteTx).when(dataBroker).newWriteOnlyTransaction();
         doReturn(Futures.immediateCheckedFuture(null)).when(mockWriteTx).submit();
+        doReturn(mockReadTx).when(dataBroker).newReadOnlyTransaction();
+        when(mockReadTx.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).
+            thenReturn(Futures.immediateCheckedFuture(Optional.of(mockNetwork)));
 
         neutronPortChangeListener = new NeutronPortChangeListener(dataBroker, nVpnMgr, nVpnNatMgr, notiPublishService, notiService);
     }
@@ -70,7 +81,7 @@ public class NeutronPortChangeListenerTest {
         PortBuilder pb = new PortBuilder();
         pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
         pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
-        pb.setMacAddress("AA:BB:CC:DD:EE:FF");
+        pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
         IpAddress ipv6 = new IpAddress(new Ipv6Address("1::1"));
         FixedIpsBuilder fib = new FixedIpsBuilder();
         fib.setIpAddress(ipv6);
@@ -86,7 +97,7 @@ public class NeutronPortChangeListenerTest {
         PortBuilder pb = new PortBuilder();
         pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
         pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
-        pb.setMacAddress("AA:BB:CC:DD:EE:FF");
+        pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
         IpAddress ipv4 = new IpAddress(new Ipv4Address("2.2.2.2"));
         FixedIpsBuilder fib = new FixedIpsBuilder();
         fib.setIpAddress(ipv4);
@@ -102,7 +113,7 @@ public class NeutronPortChangeListenerTest {
         PortBuilder pb = new PortBuilder();
         pb.setUuid(new Uuid("12345678-1234-1234-1234-123456789012"));
         pb.setNetworkId(new Uuid("12345678-1234-1234-1234-123456789012"));
-        pb.setMacAddress("AA:BB:CC:DD:EE:FF");
+        pb.setMacAddress(new MacAddress("AA:BB:CC:DD:EE:FF"));
         List<FixedIps> fixedIps = new ArrayList<FixedIps>();
         pb.setFixedIps(fixedIps);
         Port port = pb.build();