Merge "Remove ovsdb related in resources"
authorSam Hague <shague@redhat.com>
Wed, 4 May 2016 01:26:38 +0000 (01:26 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 4 May 2016 01:26:38 +0000 (01:26 +0000)
18 files changed:
features/pom.xml
features/src/main/features/features.xml
openstack/net-virt-providers/src/main/java/org/opendaylight/netvirt/openstack/netvirt/providers/openflow13/OF13Provider.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/src/main/java/org/opendaylight/netvirt/openstack/netvirt/ConfigActivator.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/PortSecurityHandler.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/api/EgressAclProvider.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/api/IngressAclProvider.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/api/SecurityServicesManager.java
openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/impl/HostConfigService.java [new file with mode: 0644]
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/SecurityServicesImpl.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/crud/impl/NeutronPortInterface.java
resources/commons/NetvirtSfc.v2.json.postman_collection

index 68f37ab3ee8bd392fbceeef183cec1c60f06cf01..519060f095e2d78c93a32b167197a4c4cea19431 100644 (file)
@@ -166,20 +166,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <classifier>features</classifier>
       <type>xml</type>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.openflowplugin</groupId>
-      <artifactId>features-openflowplugin-li</artifactId>
-      <version>${openflowplugin.version}</version>
-      <classifier>features</classifier>
-      <type>xml</type>
-    </dependency>
-    <dependency>
-      <groupId>org.opendaylight.openflowplugin</groupId>
-      <artifactId>features-openflowplugin-extension-li</artifactId>
-      <version>${openflowplugin.version}</version>
-      <classifier>features</classifier>
-      <type>xml</type>
-    </dependency>
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>openstack.net-virt</artifactId>
index f80997a4a58eb4a6e4ca03362d05f1782d24dfc7..752f8e6ded03962fb650a011584c59f29a86066a 100644 (file)
@@ -8,8 +8,6 @@
   <repository>mvn:org.opendaylight.netconf/features-restconf/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-extension/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin/{{VERSION}}/xml/features</repository>
-  <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-extension-li/{{VERSION}}/xml/features</repository>
-  <repository>mvn:org.opendaylight.openflowplugin/features-openflowplugin-li/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.neutron/features-neutron/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.ovsdb/hwvtepsouthbound-features/{{VERSION}}/xml/features</repository>
   <repository>mvn:org.opendaylight.ovsdb/southbound-features/{{VERSION}}/xml/features</repository>
     <bundle>mvn:org.opendaylight.netvirt/utils.neutron-utils/{{VERSION}}</bundle>
   </feature>
 
-  <feature name="odl-ovsdb-openstack-clusteraware" description="OpenDaylight :: OVSDB :: OpenStack Network Virtualization - Cluster Aware"
-           version='${project.version}'>
-    <feature version='${controller.mdsal.version}'>odl-mdsal-broker</feature>
-    <feature version="${openflowplugin.version}">odl-openflowplugin-nsf-model-li</feature>
-    <feature version="${neutron.version}">odl-neutron-service</feature>
-    <feature version="${ovsdb.version}">odl-ovsdb-southbound-impl</feature>
-    <feature version="${openflowplugin.version}">odl-openflowplugin-flow-services-li</feature>
-    <feature version="${openflowplugin.version}">odl-openflowplugin-nxm-extensions-li</feature>
-    <bundle>mvn:org.opendaylight.netvirt/utils.servicehelper/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.netvirt/utils.neutron-utils/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.netvirt/utils.mdsal-utils/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.ovsdb/utils.mdsal-utils/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.ovsdb/utils.southbound-utils/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.netvirt/openstack.net-virt/{{VERSION}}</bundle>
-    <bundle>mvn:org.opendaylight.netvirt/openstack.net-virt-providers/{{VERSION}}</bundle>
-    <bundle>mvn:commons-net/commons-net/{{VERSION}}</bundle>
-    <configfile finalname="etc/opendaylight/karaf/netvirt-impl-default-config.xml">mvn:org.opendaylight.netvirt/openstack.net-virt/{{VERSION}}/xml/config</configfile>
-    <configfile finalname="etc/opendaylight/karaf/netvirt-providers-impl-default-config.xml">mvn:org.opendaylight.netvirt/openstack.net-virt-providers/{{VERSION}}/xml/config</configfile>
-  </feature>
-
   <feature name="odl-ovsdb-ui" description="OpenDaylight :: OVSDB :: DLUX Integration Plugin" version='${project.version}'>
     <feature version="${dlux.version}">odl-dlux-core</feature>
     <bundle>mvn:org.opendaylight.netvirt/ovsdb-ui-bundle/{{VERSION}}</bundle>
index 85be27b31af2762b3284f9c651e29d33f055b335..356be18770cd1bd0f53506b459b23d2fd67ff1ca 100644 (file)
@@ -1000,49 +1000,43 @@ public class OF13Provider implements ConfigInterface, NetworkingProvider {
     }
 
     private void programLocalSecurityGroupRules(String attachedMac, Node node, OvsdbTerminationPointAugmentation intf,
-                                 Long dpid,long localPort, String segmentationId,
-                                 boolean write) {
+                                                Long dpid,long localPort, String segmentationId,
+                                                boolean write) {
 
         LOG.debug("programLocalRules: Program fixed security group rules for interface {}", intf.getName());
+        boolean isPortSecurityEnabled = securityServicesManager.isPortSecurityEnabled(intf);
+        if (!isPortSecurityEnabled) {
+            LOG.info("Port security is not enabled" + intf);
+            return;
+        }
         NeutronPort dhcpPort = securityServicesManager.getDhcpServerPort(intf);
-        boolean isComputePort = false;
-        boolean isLastPortinBridge = false;
-        boolean isLastPortinSubnet = false;
         List<Neutron_IPs> srcAddressList = null;
         if (null != dhcpPort) {
-            isComputePort = securityServicesManager.isComputePort(intf);
-            isLastPortinBridge = securityServicesManager.isLastPortinBridge(node, intf);
-            isLastPortinSubnet = false;
-            if (isComputePort) {
-                isLastPortinSubnet = securityServicesManager.isLastPortinSubnet(node, intf);
-                srcAddressList = securityServicesManager.getIpAddressList(intf);
-                if (null == srcAddressList) {
-                    LOG.warn("programLocalRules: No Ip address assigned {}", intf);
-                    return;
-                }
+            srcAddressList = securityServicesManager.getIpAddressList(intf);
+            if (null == srcAddressList) {
+                LOG.warn("programLocalRules: No Ip address assigned {}", intf);
+                return;
             }
             ingressAclProvider.programFixedSecurityGroup(dpid, segmentationId, dhcpPort.getMacAddress(), localPort,
-                                                       isLastPortinSubnet, isComputePort, attachedMac, write);
+                                                         attachedMac, write);
             egressAclProvider.programFixedSecurityGroup(dpid, segmentationId, attachedMac, localPort,
-                                                      srcAddressList, isLastPortinBridge, isComputePort,write);
+                                                        srcAddressList, write);
             /* If the network type is tunnel based (VXLAN/GRRE/etc) with Neutron Port Security ACLs */
             /* TODO SB_MIGRATION */
 
             LOG.debug("Neutron port has a Port Security Group");
             // Retrieve the security group from the Neutron Port and apply the rules
-            if (securityServicesManager.isPortSecurityReady(intf)) {
-                //Associate the security group flows.
-                List<NeutronSecurityGroup> securityGroupListInPort = securityServicesManager
-                        .getSecurityGroupInPortList(intf);
-                String neutronPortId = southbound.getInterfaceExternalIdsValue(intf,
-                                                                               Constants.EXTERNAL_ID_INTERFACE_ID);
-                for (NeutronSecurityGroup securityGroupInPort:securityGroupListInPort) {
-                    ingressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
-                                                              securityGroupInPort, neutronPortId, write);
-                    egressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
-                                                             securityGroupInPort, neutronPortId, write);
-                }
+            List<NeutronSecurityGroup> securityGroupListInPort = securityServicesManager
+                    .getSecurityGroupInPortList(intf);
+            String neutronPortId = southbound.getInterfaceExternalIdsValue(intf,
+                                                                           Constants.EXTERNAL_ID_INTERFACE_ID);
+            for (NeutronSecurityGroup securityGroupInPort:securityGroupListInPort) {
+                ingressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
+                                                            securityGroupInPort, neutronPortId, write);
+                egressAclProvider.programPortSecurityGroup(dpid, segmentationId, attachedMac, localPort,
+                                                           securityGroupInPort, neutronPortId, write);
             }
+
         } else {
             LOG.warn("programLocalRules: No DCHP port seen in  network of {}", intf);
         }
index 47fdc7029db4e62054078920927d4edae899b6b5..e7ac0c244e0c0ba4b4719d77c0c8f0185a0b7469 100644 (file)
@@ -230,41 +230,39 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
 
     @Override
     public void programFixedSecurityGroup(Long dpid, String segmentationId, String attachedMac,
-                                        long localPort, List<Neutron_IPs> srcAddressList,
-                                        boolean isLastPortinBridge, boolean isComputePort ,boolean write) {
-        // If it is the only port in the bridge add the rule to allow any DHCP client traffic
-        //if (isLastPortinBridge) {
-        egressAclDhcpAllowClientTrafficFromVm(dpid, write, Constants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY);
-        egressAclDhcpv6AllowClientTrafficFromVm(dpid, write, Constants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY);
-        // }
-        if (isComputePort) {
-            programArpRule(dpid, segmentationId, localPort, attachedMac, write);
-            if (securityServicesManager.isConntrackEnabled()) {
-                programEgressAclFixedConntrackRule(dpid, segmentationId, localPort, attachedMac, write);
-            }
-            // add rule to drop the DHCP server traffic originating from the vm.
-            egressAclDhcpDropServerTrafficfromVm(dpid, localPort, write,
-                                                 Constants.PROTO_DHCP_CLIENT_SPOOF_MATCH_PRIORITY_DROP);
-            egressAclDhcpv6DropServerTrafficfromVm(dpid, localPort, write,
-                                                   Constants.PROTO_DHCP_CLIENT_SPOOF_MATCH_PRIORITY_DROP);
-            //Adds rule to check legitimate ip/mac pair for each packet from the vm
-            for (Neutron_IPs srcAddress : srcAddressList) {
-                try {
-                    InetAddress address = InetAddress.getByName(srcAddress.getIpAddress());
-                    if (address instanceof Inet4Address) {
-                        String addressWithPrefix = srcAddress.getIpAddress() + HOST_MASK;
-                        egressAclAllowTrafficFromVmIpMacPair(dpid, localPort, attachedMac, addressWithPrefix,
-                                                             Constants.PROTO_VM_IP_MAC_MATCH_PRIORITY,write);
-                    } else if (address instanceof Inet6Address) {
-                        String addressWithPrefix = srcAddress.getIpAddress() + V6_HOST_MASK;
-                        egressAclAllowTrafficFromVmIpV6MacPair(dpid, localPort, attachedMac, addressWithPrefix,
-                                                               Constants.PROTO_VM_IP_MAC_MATCH_PRIORITY,write);
-                    }
-                } catch (UnknownHostException e) {
-                    LOG.warn("Invalid IP address {}", srcAddress.getIpAddress(), e);
+                                          long localPort, List<Neutron_IPs> srcAddressList, boolean write) {
+
+        egressAclDhcpAllowClientTrafficFromVm(dpid, write, localPort,
+                                              Constants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY);
+        egressAclDhcpv6AllowClientTrafficFromVm(dpid, write, localPort,
+                                                Constants.PROTO_DHCP_CLIENT_TRAFFIC_MATCH_PRIORITY);
+        programArpRule(dpid, segmentationId, localPort, attachedMac, write);
+        if (securityServicesManager.isConntrackEnabled()) {
+            programEgressAclFixedConntrackRule(dpid, segmentationId, localPort, attachedMac, write);
+        }
+        // add rule to drop the DHCP server traffic originating from the vm.
+        egressAclDhcpDropServerTrafficfromVm(dpid, localPort, write,
+                                             Constants.PROTO_DHCP_CLIENT_SPOOF_MATCH_PRIORITY_DROP);
+        egressAclDhcpv6DropServerTrafficfromVm(dpid, localPort, write,
+                                               Constants.PROTO_DHCP_CLIENT_SPOOF_MATCH_PRIORITY_DROP);
+        //Adds rule to check legitimate ip/mac pair for each packet from the vm
+        for (Neutron_IPs srcAddress : srcAddressList) {
+            try {
+                InetAddress address = InetAddress.getByName(srcAddress.getIpAddress());
+                if (address instanceof Inet4Address) {
+                    String addressWithPrefix = srcAddress.getIpAddress() + HOST_MASK;
+                    egressAclAllowTrafficFromVmIpMacPair(dpid, localPort, attachedMac, addressWithPrefix,
+                                                         Constants.PROTO_VM_IP_MAC_MATCH_PRIORITY,write);
+                } else if (address instanceof Inet6Address) {
+                    String addressWithPrefix = srcAddress.getIpAddress() + V6_HOST_MASK;
+                    egressAclAllowTrafficFromVmIpV6MacPair(dpid, localPort, attachedMac, addressWithPrefix,
+                                                           Constants.PROTO_VM_IP_MAC_MATCH_PRIORITY,write);
                 }
+            } catch (UnknownHostException e) {
+                LOG.warn("Invalid IP address {}", srcAddress.getIpAddress(), e);
             }
         }
+
     }
 
     private void programArpRule(Long dpid, String segmentationId, long localPort, String attachedMac, boolean write) {
@@ -683,16 +681,18 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
      *
      * @param dpidLong the dpid
      * @param write whether to write or delete the flow
+     * @param localPort the local port.
      * @param priority the priority
      */
     private void egressAclDhcpAllowClientTrafficFromVm(Long dpidLong,
-                                                       boolean write, Integer priority) {
-        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
+                                                       boolean write, long localPort, Integer priority) {
         String flowName = "Egress_DHCP_Client"  + "_Permit_";
         MatchBuilder matchBuilder = new MatchBuilder();
+        MatchUtils.createInPortMatch(matchBuilder, dpidLong, localPort);
         MatchUtils.createDhcpMatch(matchBuilder, DHCP_DESTINATION_PORT, DHCP_SOURCE_PORT);
         FlowBuilder flowBuilder = FlowUtils.createFlowBuilder(flowName, priority, matchBuilder, getTable());
         addPipelineInstruction(flowBuilder, null, false);
+        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
         syncFlow(flowBuilder ,nodeBuilder, write);
     }
 
@@ -701,16 +701,18 @@ public class EgressAclService extends AbstractServiceInstance implements EgressA
      *
      * @param dpidLong the dpid
      * @param write whether to write or delete the flow
+     * @param localPort the local port
      * @param priority the priority
      */
     private void egressAclDhcpv6AllowClientTrafficFromVm(Long dpidLong,
-                                                         boolean write, Integer priority) {
-        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
+                                                         boolean write, long localPort, Integer priority) {
         String flowName = "Egress_DHCPv6_Client"  + "_Permit_";
         MatchBuilder matchBuilder = new MatchBuilder();
+        MatchUtils.createInPortMatch(matchBuilder, dpidLong, localPort);
         MatchUtils.createDhcpv6Match(matchBuilder, DHCPV6_DESTINATION_PORT, DHCPV6_SOURCE_PORT);
         FlowBuilder flowBuilder = FlowUtils.createFlowBuilder(flowName, priority, matchBuilder, getTable());
         addPipelineInstruction(flowBuilder, null, false);
+        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
         syncFlow(flowBuilder ,nodeBuilder, write);
     }
 
index d0d3cf03ef6817c4a79e1c649fd28b6056715a94..ce9155ca9c81fd84d924bf80530df187b0115df8 100644 (file)
@@ -215,21 +215,17 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
 
     @Override
     public void programFixedSecurityGroup(Long dpid, String segmentationId, String dhcpMacAddress,
-                                        long localPort, boolean isLastPortinSubnet,
-                                        boolean isComputePort, String attachMac, boolean write) {
-        //If this port is the only port in the compute node add the DHCP server rule.
-        if (isLastPortinSubnet && isComputePort ) {
-            ingressAclDhcpAllowServerTraffic(dpid, segmentationId,dhcpMacAddress,
-                                             write,Constants.PROTO_DHCP_SERVER_MATCH_PRIORITY);
-            ingressAclDhcpv6AllowServerTraffic(dpid, segmentationId,dhcpMacAddress,
-                                               write,Constants.PROTO_DHCP_SERVER_MATCH_PRIORITY);
-        }
-        if (isComputePort) {
-            if (securityServicesManager.isConntrackEnabled()) {
-                programIngressAclFixedConntrackRule(dpid, segmentationId, attachMac, localPort, write);
-            }
-            programArpRule(dpid, segmentationId, localPort, attachMac, write);
+                                        long localPort, String attachMac, boolean write) {
+
+        ingressAclDhcpAllowServerTraffic(dpid, segmentationId,dhcpMacAddress, attachMac,
+                                         write,Constants.PROTO_DHCP_SERVER_MATCH_PRIORITY);
+        ingressAclDhcpv6AllowServerTraffic(dpid, segmentationId,dhcpMacAddress, attachMac,
+                                           write,Constants.PROTO_DHCP_SERVER_MATCH_PRIORITY);
+
+        if (securityServicesManager.isConntrackEnabled()) {
+            programIngressAclFixedConntrackRule(dpid, segmentationId, attachMac, localPort, write);
         }
+        programArpRule(dpid, segmentationId, localPort, attachMac, write);
     }
 
     private void programArpRule(Long dpid, String segmentationId, long localPort, String attachMac, boolean write) {
@@ -654,18 +650,21 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
      * @param dpidLong the dpid
      * @param segmentationId the segmentation id
      * @param dhcpMacAddress the DHCP server mac address
+     * @param attachMac the mac address of  the port
      * @param write is write or delete
      * @param protoPortMatchPriority the priority
      */
     private void ingressAclDhcpAllowServerTraffic(Long dpidLong, String segmentationId, String dhcpMacAddress,
-                                                  boolean write, Integer protoPortMatchPriority) {
+                                                  String attachMac, boolean write, Integer protoPortMatchPriority) {
 
-        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
         MatchBuilder matchBuilder = new MatchBuilder();
-        MatchUtils.createDhcpServerMatch(matchBuilder, dhcpMacAddress, 67, 68).build();
+        matchBuilder = MatchUtils.createV4EtherMatchWithType(matchBuilder,dhcpMacAddress,attachMac,
+                                                             MatchUtils.ETHERTYPE_IPV4);
+        MatchUtils.addLayer4Match(matchBuilder, MatchUtils.UDP_SHORT, 67, 68);
         String flowId = "Ingress_DHCP_Server" + segmentationId + "_" + dhcpMacAddress + "_Permit_";
         FlowBuilder flowBuilder = FlowUtils.createFlowBuilder(flowId, protoPortMatchPriority, matchBuilder, getTable());
         addPipelineInstruction(flowBuilder, null, false);
+        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
         syncFlow(flowBuilder ,nodeBuilder, write);
     }
 
@@ -675,18 +674,21 @@ public class IngressAclService extends AbstractServiceInstance implements Ingres
      * @param dpidLong the dpid
      * @param segmentationId the segmentation id
      * @param dhcpMacAddress the DHCP server mac address
+     * @param attachMac the mac address of  the port
      * @param write is write or delete
      * @param protoPortMatchPriority the priority
      */
     private void ingressAclDhcpv6AllowServerTraffic(Long dpidLong, String segmentationId, String dhcpMacAddress,
-                                                    boolean write, Integer protoPortMatchPriority) {
+                                                    String attachMac, boolean write, Integer protoPortMatchPriority) {
 
-        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
         MatchBuilder matchBuilder = new MatchBuilder();
-        MatchUtils.createDhcpv6ServerMatch(matchBuilder, dhcpMacAddress, 547, 546).build();
+        matchBuilder = MatchUtils.createV4EtherMatchWithType(matchBuilder,dhcpMacAddress,attachMac,
+                                                             MatchUtils.ETHERTYPE_IPV6);
+        MatchUtils.addLayer4Match(matchBuilder, MatchUtils.UDP_SHORT, 547, 546);
         String flowId = "Ingress_DHCPv6_Server" + segmentationId + "_" + dhcpMacAddress + "_Permit_";
         FlowBuilder flowBuilder = FlowUtils.createFlowBuilder(flowId, protoPortMatchPriority, matchBuilder, getTable());
         addPipelineInstruction(flowBuilder, null, false);
+        NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong);
         syncFlow(flowBuilder ,nodeBuilder, write);
     }
 
index 48f6717168288aeb861b21f21608005c20341cab..3bbd1d84e21079032020b1c0442203a5963b4c92 100644 (file)
@@ -48,6 +48,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.Icmpv6Match;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatch;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbTerminationPointAugmentation;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.powermock.api.mockito.PowerMockito;
 import org.powermock.api.support.membermodification.MemberModifier;
@@ -1504,40 +1505,13 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test With isConntrackEnabled false isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLAdd1() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(false);
-
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, true);
-
-        verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(2)).submit();
-        verify(commitFuture, times(2)).checkedGet();
-    }
-    /**
-     *  Test With isConntrackEnabled false isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLRemove1() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(false);
-
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, false);
-
-        verify(writeTransaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(2)).submit();
-        verify(commitFuture, times(2)).get();
-    }
-
-    /**
-     *  Test With isConntrackEnabled false isComputeNode true
+      *  Test With isConntrackEnabled false
      */
     @Test
     public void testProgramFixedSecurityACLAdd2() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(false);
 
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, true);
+        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true);
 
         verify(writeTransaction, times(9)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
         verify(writeTransaction, times(9)).submit();
@@ -1545,13 +1519,13 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test With isConntrackEnabled false isComputeNode true
+     *  Test With isConntrackEnabled false
      */
     @Test
     public void testProgramFixedSecurityACLRemove2() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(false);
 
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, false);
+        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false);
 
         verify(writeTransaction, times(9)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
         verify(writeTransaction, times(9)).submit();
@@ -1559,41 +1533,13 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test With isConntrackEnabled true isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLAdd3() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(true);
-
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, true);
-
-        verify(writeTransaction, times(2)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(2)).submit();
-        verify(commitFuture, times(2)).checkedGet();
-    }
-
-    /**
-     *  Test With isConntrackEnabled true isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLRemove3() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(true);
-
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, false, false);
-
-        verify(writeTransaction, times(2)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(2)).submit();
-        verify(commitFuture, times(2)).get();
-    }
-
-    /**
-     *  Test With isConntrackEnabled true isComputeNode true
+     *  Test With isConntrackEnabled true
      */
     @Test
     public void testProgramFixedSecurityACLAdd4() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(true);
 
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, true);
+        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, true);
 
         verify(writeTransaction, times(14)).put(any(LogicalDatastoreType.class),
                                                any(InstanceIdentifier.class), any(Node.class), eq(true));
@@ -1602,13 +1548,13 @@ public class EgressAclServiceTest {
     }
 
     /**
-     *  Test With isConntrackEnabled true isComputeNode true
+     *  Test With isConntrackEnabled true
      */
     @Test
     public void testProgramFixedSecurityACLRemove4() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(true);
 
-        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false, true, false);
+        egressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", MAC_ADDRESS, 1, neutronDestIpList, false);
 
         verify(writeTransaction, times(14)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
         verify(writeTransaction, times(14)).submit();
index 5d2e75d7d04b035efb59fbdb90977b7e8add0ee3..e5d3b061d1eda5d49224cd350ffd9a6fa922f62b 100644 (file)
@@ -1536,108 +1536,56 @@ public class IngressAclServiceTest {
     }
 
     /**
-     *  Test With isConntrackEnabled false isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLAdd1() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(false);
-
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, false, MAC_ADDRESS, true);
-
-        verify(writeTransaction, times(0)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(0)).submit();
-        verify(commitFuture, times(0)).get();
-    }
-    /**
-     *  Test With isConntrackEnabled false isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLRemove1() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(false);
-
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, false, MAC_ADDRESS, false);
-
-        verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(0)).submit();
-        verify(commitFuture, times(0)).get();
-    }
-    /**
-     *  Test With isConntrackEnabled false isComputeNode false
+     *  Test With isConntrackEnabled false
      */
     @Test
     public void testProgramFixedSecurityACLAdd2() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(false);
 
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, true, MAC_ADDRESS, true);
+        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, MAC_ADDRESS, true);
 
-        verify(writeTransaction, times(1)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(1)).submit();
-        verify(commitFuture, times(1)).checkedGet();
+        verify(writeTransaction, times(3)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(3)).submit();
+        verify(commitFuture, times(3)).checkedGet();
     }
     /**
-     *  Test With isConntrackEnabled false isComputeNode false
+     *  Test With isConntrackEnabled false
      */
     @Test
     public void testProgramFixedSecurityACLRemove2() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(false);
 
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, true, MAC_ADDRESS, false);
+        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, MAC_ADDRESS, false);
 
-        verify(writeTransaction, times(1)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(1)).submit();
-        verify(commitFuture, times(1)).get();
-    }
-    /**
-     *  Test With isConntrackEnabled true isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLAdd3() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(true);
-
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, false, MAC_ADDRESS, true);
-
-        verify(writeTransaction, times(0)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(0)).submit();
-        verify(commitFuture, times(0)).get();
-    }
-    /**
-     *  Test With isConntrackEnabled true isComputeNode false
-     */
-    @Test
-    public void testProgramFixedSecurityACLRemove3() throws Exception {
-        when(securityServices.isConntrackEnabled()).thenReturn(true);
-
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, false, MAC_ADDRESS, false);
-
-        verify(writeTransaction, times(0)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(0)).submit();
-        verify(commitFuture, times(0)).get();
+        verify(writeTransaction, times(3)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(3)).submit();
+        verify(commitFuture, times(3)).get();
     }
     /**
-     *  Test With isConntrackEnabled true isComputeNode true
+     *  Test With isConntrackEnabled true
      */
     @Test
     public void testProgramFixedSecurityACLAdd4() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(true);
 
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, true, MAC_ADDRESS, true);
+        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, MAC_ADDRESS, true);
 
-        verify(writeTransaction, times(6)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
-        verify(writeTransaction, times(6)).submit();
-        verify(commitFuture, times(6)).checkedGet();
+        verify(writeTransaction, times(8)).put(any(LogicalDatastoreType.class), any(InstanceIdentifier.class), any(Node.class), eq(true));
+        verify(writeTransaction, times(8)).submit();
+        verify(commitFuture, times(8)).checkedGet();
     }
     /**
-     *  Test With isConntrackEnabled true isComputeNode true
+     *  Test With isConntrackEnabled true
      */
     @Test
     public void testProgramFixedSecurityACLRemove4() throws Exception {
         when(securityServices.isConntrackEnabled()).thenReturn(true);
 
-        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, false, true, MAC_ADDRESS, false);
+        ingressAclServiceSpy.programFixedSecurityGroup(Long.valueOf(1554), "2", DHCP_MAC_ADDRESS, 1, MAC_ADDRESS, false);
 
-        verify(writeTransaction, times(6)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
-        verify(writeTransaction, times(6)).submit();
-        verify(commitFuture, times(6)).get();
+        verify(writeTransaction, times(8)).delete(any(LogicalDatastoreType.class), any(InstanceIdentifier.class));
+        verify(writeTransaction, times(8)).submit();
+        verify(commitFuture, times(8)).get();
     }
 
 }
index 91e77d7430b7c1b911af7f397bfc2922f9c23936..7623e8cb7a8a99184333d543b5f24b8fa9219fd6 100644 (file)
@@ -49,6 +49,7 @@ import org.opendaylight.netvirt.openstack.netvirt.impl.ProviderNetworkManagerImp
 import org.opendaylight.netvirt.openstack.netvirt.impl.SecurityGroupCacheManagerImpl;
 import org.opendaylight.netvirt.openstack.netvirt.impl.SecurityServicesImpl;
 import org.opendaylight.netvirt.openstack.netvirt.impl.SouthboundImpl;
+import org.opendaylight.netvirt.openstack.netvirt.impl.HostConfigService;
 import org.opendaylight.netvirt.openstack.netvirt.impl.VlanConfigurationCacheImpl;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
 import org.opendaylight.netvirt.openstack.netvirt.translator.crud.INeutronLoadBalancerPoolCRUD;
@@ -218,6 +219,10 @@ public class ConfigActivator implements BundleActivator {
         registerService(context,
                 new String[]{Southbound.class.getName()}, null, southbound);
 
+        HostConfigService hostConfigService = new HostConfigService(providerContext.getSALService(DataBroker.class));
+        registerService(context,
+                new String[]{HostConfigService.class.getName()}, null, hostConfigService);
+
         NodeCacheManagerImpl nodeCacheManager = new NodeCacheManagerImpl();
         registerAbstractHandlerService(context, new Class[] {NodeCacheManager.class},
                 AbstractEvent.HandlerType.NODE, nodeCacheManager);
index 0d3d8b370a8ecf78b68c34e474c184c0443cc5d8..78e1c4276b1e78c34a5e9e17ff500fcbc54a2852 100644 (file)
@@ -154,7 +154,10 @@ public class PortSecurityHandler extends AbstractHandler
 
     private void syncSecurityGroup(NeutronSecurityRule  securityRule,NeutronPort port,
                                    boolean write) {
-
+        if (!port.getPortSecurityEnabled()) {
+            LOG.info("Port security not enabled port", port);
+            return;
+        }
         if (null != securityRule.getSecurityRemoteGroupID()) {
             List<Neutron_IPs> vmIpList  = securityServicesManager
                     .getVmListForSecurityGroup(port.getID(), securityRule.getSecurityRemoteGroupID());
@@ -169,17 +172,17 @@ public class PortSecurityHandler extends AbstractHandler
     private List<NeutronPort> getPortWithSecurityGroup(String securityGroupUuid) {
 
         List<NeutronPort> neutronPortList = neutronPortCache.getAllPorts();
-        List<NeutronPort> neutronPortInSG = new ArrayList<NeutronPort>();
+        List<NeutronPort> neutronPortInSg = new ArrayList<NeutronPort>();
         for (NeutronPort neutronPort:neutronPortList) {
             List<NeutronSecurityGroup> securityGroupList = neutronPort.getSecurityGroups();
             for (NeutronSecurityGroup neutronSecurityGroup:securityGroupList) {
                 if (neutronSecurityGroup.getID().equals(securityGroupUuid)) {
-                    neutronPortInSG.add(neutronPort);
+                    neutronPortInSg.add(neutronPort);
                     break;
                 }
             }
         }
-        return neutronPortInSG;
+        return neutronPortInSg;
     }
 
     @Override
index d82f30aa90316eec29abf13f770368737c64a3c9..1f049b0838f4a526f79fae201576ebf9a7fe87a4 100644 (file)
@@ -55,11 +55,8 @@ public interface EgressAclProvider {
      * @param attachedMac the attached mac
      * @param localPort the local port
      * @param srcAddressList the list of source ip address assigned to vm
-     * @param isLastPortinBridge is this the last port in the bridge
-     * @param isComputePort indicates whether this port is a compute port or not
      * @param write is this flow writing or deleting
      */
     void programFixedSecurityGroup(Long dpid, String segmentationId,String attachedMac, long localPort,
-                                  List<Neutron_IPs> srcAddressList, boolean isLastPortinBridge,
-                                  boolean isComputePort, boolean write);
+                                  List<Neutron_IPs> srcAddressList, boolean write);
 }
\ No newline at end of file
index a4005e0c028fcad308ed0694b631e9742b8018ca..b587a245d13634f377673537ad3fe4fd84c47f9d 100644 (file)
@@ -52,11 +52,9 @@ public interface IngressAclProvider {
      * @param segmentationId the segmentation id
      * @param attachedMac the dhcp mac
      * @param localPort the local port
-     * @param isLastPortinSubnet is this the last port in the subnet
-     * @param isComputePort indicates whether this port is a compute port or not
      * @param attachedMac2 the src mac
      * @param write is this flow writing or deleting
      */
     void programFixedSecurityGroup(Long dpid, String segmentationId, String attachedMac, long localPort,
-                                  boolean isLastPortinSubnet, boolean isComputePort, String attachedMac2, boolean write);
+                                  String attachedMac2, boolean write);
 }
\ No newline at end of file
index 09d452ccc6f0a22ef18d5661bf6da0614b2838b1..2418792b289e82cfad7d0c0b40f5ff69ba2039f5 100644 (file)
@@ -70,7 +70,7 @@ public interface SecurityServicesManager {
     /**
      * Is this the last port in the subnet to which interface belongs to.
      * @param node The node to which the intf is connected.
-     * @param intf the intf
+     * @param intf the interface
      * @return whether last port in the subnet
      */
     boolean isLastPortinSubnet(Node node, OvsdbTerminationPointAugmentation intf);
@@ -116,4 +116,11 @@ public interface SecurityServicesManager {
      * @return whether connection tracking enabled.
      */
     boolean isConntrackEnabled();
+    /**
+     * Is the port a PortSecurity Enabled.
+     *
+     * @param intf the port
+     * @return  whether it is a compute port or not
+     */
+    boolean isPortSecurityEnabled(OvsdbTerminationPointAugmentation intf);
 }
\ No newline at end of file
diff --git a/openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/impl/HostConfigService.java b/openstack/net-virt/src/main/java/org/opendaylight/netvirt/openstack/netvirt/impl/HostConfigService.java
new file mode 100644 (file)
index 0000000..171abd0
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * Copyright (c) 2016 Intel Corporation.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netvirt.openstack.netvirt.impl;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.netvirt.openstack.netvirt.ClusterAwareMdsalUtils;
+import org.opendaylight.netvirt.openstack.netvirt.ConfigInterface;
+import org.opendaylight.netvirt.openstack.netvirt.api.Action;
+import org.opendaylight.netvirt.openstack.netvirt.api.OvsdbInventoryListener;
+import org.opendaylight.netvirt.openstack.netvirt.api.OvsdbInventoryService;
+import org.opendaylight.netvirt.openstack.netvirt.api.Southbound;
+import org.opendaylight.netvirt.openstack.netvirt.api.OvsdbTables;
+import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.Hostconfigs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.Hostconfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.hostconfig.rev150712.hostconfig.attributes.hostconfigs.HostconfigBuilder;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.osgi.framework.ServiceReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.List;
+
+
+public class HostConfigService implements OvsdbInventoryListener, ConfigInterface {
+    private static final Logger LOG = LoggerFactory.getLogger(HostConfigService.class);
+
+    private static final String OS_HOST_CONFIG_HOST_ID_KEY = "odl_os_hostconfig_hostid";
+    private static final String OS_HOST_CONFIG_HOST_TYPE_KEY = "odl_os_hostconfig_hosttype";
+    private static final String OS_HOST_CONFIG_CONFIG_KEY = "odl_os_hostconfig_config";
+
+    private final DataBroker databroker;
+    private final ClusterAwareMdsalUtils mdsalUtils;
+    private volatile OvsdbInventoryService ovsdbInventoryService;
+    private volatile Southbound southbound;
+
+    public HostConfigService(DataBroker dataBroker) {
+        this.databroker = dataBroker;
+        mdsalUtils = new ClusterAwareMdsalUtils(dataBroker);
+    }
+
+    @Override
+    public void ovsdbUpdate(Node node, DataObject resourceAugmentationData, OvsdbType ovsdbType, Action action) {
+        boolean result;
+        Hostconfig hostConfig;
+        InstanceIdentifier<Hostconfig> hostConfigId;
+
+        if (ovsdbType != OvsdbType.NODE) {
+            return;
+        }
+        hostConfig = buildHostConfigInfo(node);
+        if (hostConfig == null) {
+              return;
+        }
+        LOG.trace("ovsdbUpdate: {} - {} - <<{}>> <<{}>>", ovsdbType, action, node, resourceAugmentationData);
+        switch (action) {
+            case ADD:
+            case UPDATE:
+                    hostConfigId = createInstanceIdentifier(hostConfig);
+                    result = mdsalUtils.put(LogicalDatastoreType.OPERATIONAL, hostConfigId, hostConfig);
+                    LOG.trace("Add Node: result: {}", result);
+                break;
+            case DELETE:
+                    hostConfigId = createInstanceIdentifier(hostConfig);
+                    result = mdsalUtils.delete(LogicalDatastoreType.OPERATIONAL, hostConfigId);
+                    LOG.trace("Delete Node: result: {}", result);
+                break;
+        }
+    }
+
+    @Override
+    public void triggerUpdates() {
+        List<Node> ovsdbNodes = southbound.readOvsdbTopologyNodes();
+        for (Node node : ovsdbNodes) {
+            ovsdbUpdate(node, node.getAugmentation(OvsdbNodeAugmentation.class),
+                    OvsdbInventoryListener.OvsdbType.NODE, Action.ADD);
+        }
+    }
+
+    private Hostconfig buildHostConfigInfo(Node node) {
+        HostconfigBuilder hostconfigBuilder = new HostconfigBuilder();
+        String value;
+
+        value = southbound.getExternalId(node, OvsdbTables.OPENVSWITCH, OS_HOST_CONFIG_HOST_ID_KEY);
+        if (value == null){
+            return null;
+        }
+        hostconfigBuilder.setHostId(value);
+        value = southbound.getExternalId(node, OvsdbTables.OPENVSWITCH, OS_HOST_CONFIG_HOST_TYPE_KEY);
+        if (value == null) {
+            return null;
+        }
+        hostconfigBuilder.setHostType(value);
+        value = southbound.getExternalId(node, OvsdbTables.OPENVSWITCH, OS_HOST_CONFIG_CONFIG_KEY);
+        if (value == null) {
+            return null;
+        }
+        hostconfigBuilder.setConfig(value);
+        return hostconfigBuilder.build();
+    }
+
+    private InstanceIdentifier<Hostconfig> createInstanceIdentifier() {
+        return InstanceIdentifier.create(Neutron.class)
+                .child(Hostconfigs.class)
+                .child(Hostconfig.class);
+    }
+
+    private InstanceIdentifier<Hostconfig> createInstanceIdentifier(Hostconfig hostconfig) {
+        return InstanceIdentifier.create(Neutron.class)
+                .child(Hostconfigs.class)
+                .child(Hostconfig.class, hostconfig.getKey());
+    }
+
+    @Override
+    public void setDependencies(ServiceReference serviceReference) {
+        southbound =
+                (Southbound) ServiceHelper.getGlobalInstance(Southbound.class, this);
+        ovsdbInventoryService =
+                (OvsdbInventoryService) ServiceHelper.getGlobalInstance(OvsdbInventoryService.class, this);
+        ovsdbInventoryService.listenerAdded(this);
+    }
+
+    @Override
+    public void setDependencies(Object impl) {
+    }
+}
index d9a601338b3e9b7236873d53b27cf6b3b37b3dfc..13b535448aa30f0d9a865d560ef1eb2a5cee68e3 100644 (file)
@@ -428,7 +428,9 @@ public class NeutronL3Adapter extends AbstractHandler implements GatewayMacResol
         if (action == UPDATE) {
             // FIXME: Bug 4971 Move cleanup cache to SG Impl
             this.updatePortInCleanupCache(neutronPort, neutronPort.getOriginalPort());
-            this.processSecurityGroupUpdate(neutronPort);
+            if (neutronPort.getPortSecurityEnabled()) {
+                this.processSecurityGroupUpdate(neutronPort);
+            }
         }
 
         if (!this.enabled) {
index e853b4843ad38bc84589acee4dedc99076c4d978..fc2486aa91e4431923d5a15419f1c6df61fb6358 100644 (file)
@@ -575,6 +575,21 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
         return null;
     }
 
+    @Override
+    public boolean isPortSecurityEnabled(OvsdbTerminationPointAugmentation intf) {
+        NeutronPort neutronPort = getNeutronPortFromCache(intf);
+        if (null == neutronPort) {
+            LOG.error("Neutron Port is null: " + intf);
+            return false;
+        }
+        if (neutronPort.getPortSecurityEnabled()) {
+            LOG.info("Port Security is enabled for Port: " + neutronPort);
+            return true;
+        }
+        LOG.info("Port Security is  not enabled for Port: " + neutronPort);
+        return false;
+    }
+
     @Override
     public void setDependencies(ServiceReference serviceReference) {
         neutronL3Adapter =
index 903c388d27419ebeb9ae1e07b912b5e1ba562ced..a7b4a6196fff1c84e751d809cab3db4c580d34fb 100644 (file)
@@ -83,6 +83,11 @@ public class NeutronPort implements Serializable, INeutronObject {
     @XmlElement (name = "extra_dhcp_opts")
     List<NeutronPort_ExtraDHCPOption> extraDHCPOptions;
 
+    //Port security is enabled by default for backward compatibility.
+    @XmlElement (defaultValue = "true", name = "port_security_enabled")
+    Boolean portSecurityEnabled;
+
+
     NeutronPort originalPort;
 
     public NeutronPort() {
@@ -233,6 +238,18 @@ public class NeutronPort implements Serializable, INeutronObject {
         this.bindingvifType = bindingvifType;
     }
 
+    public Boolean getPortSecurityEnabled() {
+        if (portSecurityEnabled == null) {
+            return true;
+        }
+        return portSecurityEnabled;
+    }
+
+    public void setPortSecurityEnabled(Boolean newValue) {
+        portSecurityEnabled = newValue;
+    }
+
+
     public NeutronPort getOriginalPort() {
         return originalPort;
     }
@@ -288,12 +305,16 @@ public class NeutronPort implements Serializable, INeutronObject {
             if ("security_groups".equals(field)) {
                 ans.setSecurityGroups(new ArrayList<>(this.getSecurityGroups()));
             }
+            if ("port_security_enabled".equals(field)) {
+                ans.setPortSecurityEnabled(this.getPortSecurityEnabled());
+            }
         }
         return ans;
     }
 
     public void initDefaults() {
         adminStateUp = true;
+        portSecurityEnabled = true;
         if (status == null) {
             status = "ACTIVE";
         }
@@ -309,6 +330,6 @@ public class NeutronPort implements Serializable, INeutronObject {
                 + ", fixedIPs=" + fixedIPs + ", deviceID=" + deviceID + ", deviceOwner=" + deviceOwner + ", tenantID="
                 + tenantID + ", securityGroups=" + securityGroups
                 + ", bindinghostID=" + bindinghostID + ", bindingvnicType=" + bindingvnicType
-                + ", bindingvnicType=" + bindingvnicType + "]";
+                + ", bindingvnicType=" + bindingvnicType + ", portSecurityEnabled=" + portSecurityEnabled +"]";
     }
 }
index 8814fb39736d5b8a47bef747dcc91b7e08425823..e2dbab6d227f76e075592a0d58c1156e3f46981c 100644 (file)
@@ -38,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.por
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.PortBuilder;
+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.yangtools.yang.binding.InstanceIdentifier;
 import org.osgi.framework.BundleContext;
@@ -151,6 +153,13 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
         result.setBindingvnicType(binding.getVnicType());
     }
 
+    private void portSecurityExtension(Port port, NeutronPort result) {
+        PortSecurityExtension portSecurity = port.getAugmentation(PortSecurityExtension.class);
+        if(portSecurity != null && portSecurity.isPortSecurityEnabled() != null) {
+            result.setPortSecurityEnabled(portSecurity.isPortSecurityEnabled());
+        }
+    }
+
     protected NeutronPort fromMd(Port port) {
         NeutronPort result = new NeutronPort();
         result.setAdminStateUp(port.isAdminStateUp());
@@ -209,6 +218,7 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
         }
         result.setPortUUID(String.valueOf(port.getUuid().getValue()));
         addExtensions(port, result);
+        portSecurityExtension(port, result);
         return result;
     }
 
@@ -239,9 +249,14 @@ public class NeutronPortInterface extends AbstractNeutronInterface<Port, Neutron
             bindingBuilder.setVnicType(neutronPort.getBindingvnicType());
         }
 
+        PortSecurityExtensionBuilder portSecurityBuilder = new PortSecurityExtensionBuilder();
+        if (neutronPort.getPortSecurityEnabled() != null) {
+            portSecurityBuilder.setPortSecurityEnabled(neutronPort.getPortSecurityEnabled());
+        }
         PortBuilder portBuilder = new PortBuilder();
         portBuilder.addAugmentation(PortBindingExtension.class,
                                     bindingBuilder.build());
+        portBuilder.addAugmentation(PortSecurityExtension.class, portSecurityBuilder.build());
         portBuilder.setAdminStateUp(neutronPort.isAdminStateUp());
         if(neutronPort.getAllowedAddressPairs() != null) {
             List<AllowedAddressPairs> listAllowedAddressPairs = new ArrayList<>();
index 924754a30d60edc16b46ad20a413193803f98bbe..25b967ab7e16e2768e172d95eaa2fc704ba873ec 100644 (file)
             "version": 2,
             "preRequestScript": "",
             "tests": "",
-            "rawModeData": "{\n    \"netvirt-providers-config\": {\n        \"table-offset\": 10\n    }\n}"
+            "rawModeData": "{\n    \"netvirt-providers-config\": {\n        \"table-offset\": 1\n    }\n}"
         },
         {
             "id": "a1bd4157-09e1-d6a8-2ee7-8c503747511c",
             "rawModeData": "{\n    \"service-function-paths\": {\n        \"service-function-path\": [\n            {\n                \"name\": \"SFC-Path\",\n                \"symmetric\": false,\n                \"service-chain-name\": \"SFC\",\n                \"starting-index\": 255\n            }\n        ]\n    }\n}"
         }
     ]
-}
\ No newline at end of file
+}