General Sonar clean-up
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / impl / SecurityServicesImpl.java
index c29e7adc52f85060d48f12ef734bd593bfaffc46..ed6e22fa740453ac3d02a0d15b4533c397ee154c 100644 (file)
@@ -23,15 +23,13 @@ import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.*;
 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.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.node.attributes.SupportingNode;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class SecurityServicesImpl implements ConfigInterface, SecurityServicesManager {
-    static final Logger logger = LoggerFactory.getLogger(TenantNetworkManagerImpl.class);
+    private static final Logger LOG = LoggerFactory.getLogger(TenantNetworkManagerImpl.class);
     private volatile INeutronPortCRUD neutronPortCache;
     private volatile INeutronSubnetCRUD neutronSubnetCache;
     private volatile Southbound southbound;
@@ -44,10 +42,10 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
      */
     public boolean isPortSecurityReady(OvsdbTerminationPointAugmentation terminationPointAugmentation) {
         if (neutronPortCache == null) {
-            logger.error("neutron port is null");
+            LOG.error("neutron port is null");
             return false;
         }
-        logger.trace("isPortSecurityReady for {}", terminationPointAugmentation.getName());
+        LOG.trace("isPortSecurityReady for {}", terminationPointAugmentation.getName());
         String neutronPortId = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
                 Constants.EXTERNAL_ID_INTERFACE_ID);
         if (neutronPortId == null) {
@@ -59,18 +57,16 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
         }
         String deviceOwner = neutronPort.getDeviceOwner();
         if (!deviceOwner.contains("compute")) {
-            logger.debug("Port {} is not a compute host, it is a: {}", neutronPortId, deviceOwner);
+            LOG.debug("Port {} is not a compute host, it is a: {}", neutronPortId, deviceOwner);
         }
-        logger.debug("isPortSecurityReady() is a {} ", deviceOwner);
+        LOG.debug("isPortSecurityReady() is a {} ", deviceOwner);
         List<NeutronSecurityGroup> securityGroups = neutronPort.getSecurityGroups();
         if (securityGroups.isEmpty()) {
-            logger.debug("Check for device: {} does not contain a Security Group for port: {}", deviceOwner,
+            LOG.debug("Check for device: {} does not contain a Security Group for port: {}", deviceOwner,
                     neutronPortId);
             return false;
         }
-        String vmPort = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
-                Constants.EXTERNAL_ID_VM_MAC);
-        logger.debug("Security Group Check {} DOES contain a Neutron Security Group", neutronPortId);
+        LOG.debug("Security Group Check {} DOES contain a Neutron Security Group", neutronPortId);
         return true;
     }
 
@@ -82,10 +78,10 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
      */
     public NeutronSecurityGroup getSecurityGroupInPort(OvsdbTerminationPointAugmentation terminationPointAugmentation) {
         if (neutronPortCache == null) {
-            logger.error("neutron port is null");
+            LOG.error("neutron port is null");
             return null;
         }
-        logger.trace("isPortSecurityReady for {}", terminationPointAugmentation.getName());
+        LOG.trace("isPortSecurityReady for {}", terminationPointAugmentation.getName());
         String neutronPortId = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
                 Constants.EXTERNAL_ID_INTERFACE_ID);
         if (neutronPortId == null) {
@@ -98,8 +94,7 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
 
         List<NeutronSecurityGroup> neutronSecurityGroups = neutronPort.getSecurityGroups();
         if (neutronSecurityGroups != null) {
-            NeutronSecurityGroup neutronSecurityGroup = (NeutronSecurityGroup) neutronSecurityGroups.toArray()[0];
-            return neutronSecurityGroup;
+            return (NeutronSecurityGroup) neutronSecurityGroups.toArray()[0];
         } else {
             return null;
         }
@@ -109,10 +104,10 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
     public NeutronPort getDHCPServerPort(
             OvsdbTerminationPointAugmentation terminationPointAugmentation) {
         if (neutronPortCache == null) {
-            logger.error("getDHCPServerPort: neutron port is null");
+            LOG.error("getDHCPServerPort: neutron port is null");
             return null;
         }
-        logger.trace("getDHCPServerPort for {}",
+        LOG.trace("getDHCPServerPort for {}",
                 terminationPointAugmentation.getName());
         String neutronPortId = southbound.getInterfaceExternalIdsValue(
                 terminationPointAugmentation,
@@ -125,7 +120,7 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
         List<Neutron_IPs> fixedIps = neutronPort.getFixedIPs();
         if(null==fixedIps || 0 == fixedIps.size() )
         {
-            logger.error("getDHCPServerPort: No fixed ip is assigned");
+            LOG.error("getDHCPServerPort: No fixed ip is assigned");
             return null;
         }
         String subnetUUID = fixedIps.iterator().next().getSubnetUUID();
@@ -144,10 +139,10 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
     @Override
     public boolean isComputePort(OvsdbTerminationPointAugmentation terminationPointAugmentation) {
         if (neutronPortCache == null) {
-            logger.error("neutron port is null");
+            LOG.error("neutron port is null");
             return false;
         }
-        logger.trace("isComputePort for {}", terminationPointAugmentation.getName());
+        LOG.trace("isComputePort for {}", terminationPointAugmentation.getName());
         String neutronPortId = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
                 Constants.EXTERNAL_ID_INTERFACE_ID);
         if (neutronPortId == null) {
@@ -159,7 +154,7 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
         }
         String deviceOwner = neutronPort.getDeviceOwner();
         if (!deviceOwner.contains("compute")) {
-            logger.debug("isComputePort : Port {} is not a DHCP server port", neutronPortId,deviceOwner);
+            LOG.debug("isComputePort : Port {} is not a DHCP server port", neutronPortId, deviceOwner);
             return false;
         }
         return true;
@@ -168,10 +163,10 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
     @Override
     public boolean isLastPortinSubnet(Node node, OvsdbTerminationPointAugmentation terminationPointAugmentation) {
         if (neutronPortCache == null) {
-            logger.error("isLastPortinSubnet: neutron port is null");
+            LOG.error("isLastPortinSubnet: neutron port is null");
             return false;
         }
-        logger.trace("isLastPortinSubnet: for {}", terminationPointAugmentation.getName());
+        LOG.trace("isLastPortinSubnet: for {}", terminationPointAugmentation.getName());
         String neutronPortId = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
                                                                        Constants.EXTERNAL_ID_INTERFACE_ID);
         if (neutronPortId == null) {
@@ -214,7 +209,7 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
 
     @Override
     public boolean isLastPortinBridge(Node node, OvsdbTerminationPointAugmentation terminationPointAugmentation) {
-        logger.trace("isLastPortinBridge: for {}", terminationPointAugmentation.getName());
+        LOG.trace("isLastPortinBridge: for {}", terminationPointAugmentation.getName());
         List<TerminationPoint> terminationPoints = node.getTerminationPoint();
         if(terminationPoints != null && !terminationPoints.isEmpty()){
             for(TerminationPoint tp : terminationPoints){
@@ -237,18 +232,17 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa
     public List<Neutron_IPs> getIpAddress(Node node,
                                 OvsdbTerminationPointAugmentation terminationPointAugmentation) {
         if (neutronPortCache == null) {
-            logger.error("getIpAddress: neutron port is null");
+            LOG.error("getIpAddress: neutron port is null");
             return null;
         }
-        logger.trace("getIpAddress: for {}", terminationPointAugmentation.getName());
+        LOG.trace("getIpAddress: for {}", terminationPointAugmentation.getName());
         String neutronPortId = southbound.getInterfaceExternalIdsValue(terminationPointAugmentation,
                 Constants.EXTERNAL_ID_INTERFACE_ID);
         if (neutronPortId == null) {
             return null;
         }
         NeutronPort neutronPort = neutronPortCache.getPort(neutronPortId);
-        List<Neutron_IPs> fixedIps = neutronPort.getFixedIPs();
-        return fixedIps;
+        return neutronPort.getFixedIPs();
     }
 
     @Override