\r
void setClusterContainerService(IClusterContainerServices s) {\r
logger.debug("Cluster Service set");\r
- this.clusterContainerService = s;\r
+ clusterContainerService = s;\r
}\r
\r
void unsetClusterContainerService(IClusterContainerServices s) {\r
- if (this.clusterContainerService == s) {\r
+ if (clusterContainerService == s) {\r
logger.debug("Cluster Service removed!");\r
- this.clusterContainerService = null;\r
+ clusterContainerService = null;\r
}\r
}\r
\r
@SuppressWarnings("deprecation")\r
private void allocateCache() {\r
- if (this.clusterContainerService == null) {\r
+ if (clusterContainerService == null) {\r
logger.error("un-initialized clusterContainerService, can't create cache");\r
return;\r
}\r
logger.debug("Creating Cache for OpenDOVE");\r
try {\r
// neutron caches\r
- this.clusterContainerService.createCache("neutronPorts",\r
+ clusterContainerService.createCache("neutronPorts",\r
EnumSet.of(IClusterServices.cacheMode.NON_TRANSACTIONAL));\r
} catch (CacheConfigException cce) {\r
logger.error("Cache couldn't be created for OpenDOVE - check cache mode");\r
\r
@SuppressWarnings({ "unchecked", "deprecation" })\r
private void retrieveCache() {\r
- if (this.clusterContainerService == null) {\r
+ if (clusterContainerService == null) {\r
logger.error("un-initialized clusterContainerService, can't retrieve cache");\r
return;\r
}\r
\r
logger.debug("Retrieving cache for Neutron Ports");\r
- portDB = (ConcurrentMap<String, NeutronPort>) this.clusterContainerService\r
+ portDB = (ConcurrentMap<String, NeutronPort>) clusterContainerService\r
.getCache("neutronPorts");\r
if (portDB == null) {\r
logger.error("Cache couldn't be retrieved for Neutron Ports");\r
\r
@SuppressWarnings("deprecation")\r
private void destroyCache() {\r
- if (this.clusterContainerService == null) {\r
+ if (clusterContainerService == null) {\r
logger.error("un-initialized clusterMger, can't destroy cache");\r
return;\r
}\r
logger.debug("Destroying Cache for HostTracker");\r
- this.clusterContainerService.destroyCache("neutronPorts");\r
+ clusterContainerService.destroyCache("neutronPorts");\r
}\r
\r
private void startUp() {\r
void init(Component c) {\r
Dictionary<?, ?> props = c.getServiceProperties();\r
if (props != null) {\r
- this.containerName = (String) props.get("containerName");\r
- logger.debug("Running containerName: {}", this.containerName);\r
+ containerName = (String) props.get("containerName");\r
+ logger.debug("Running containerName: {}", containerName);\r
} else {\r
// In the Global instance case the containerName is empty\r
- this.containerName = "";\r
+ containerName = "";\r
}\r
startUp();\r
}\r
\r
// IfNBPortCRUD methods\r
\r
+ @Override\r
public boolean portExists(String uuid) {\r
return portDB.containsKey(uuid);\r
}\r
\r
+ @Override\r
public NeutronPort getPort(String uuid) {\r
- if (!portExists(uuid))\r
+ if (!portExists(uuid)) {\r
return null;\r
+ }\r
return portDB.get(uuid);\r
}\r
\r
+ @Override\r
public List<NeutronPort> getAllPorts() {\r
Set<NeutronPort> allPorts = new HashSet<NeutronPort>();\r
for (Entry<String, NeutronPort> entry : portDB.entrySet()) {\r
return ans;\r
}\r
\r
+ @Override\r
public boolean addPort(NeutronPort input) {\r
- if (portExists(input.getID()))\r
+ if (portExists(input.getID())) {\r
return false;\r
+ }\r
portDB.putIfAbsent(input.getID(), input);\r
// if there are no fixed IPs, allocate one for each subnet in the network\r
INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);\r
Iterator<NeutronSubnet> subnetIterator = systemCRUD.getAllSubnets().iterator();\r
while (subnetIterator.hasNext()) {\r
NeutronSubnet subnet = subnetIterator.next();\r
- if (subnet.getNetworkUUID().equals(input.getNetworkUUID()))\r
+ if (subnet.getNetworkUUID().equals(input.getNetworkUUID())) {\r
list.add(new Neutron_IPs(subnet.getID()));\r
+ }\r
}\r
}\r
Iterator<Neutron_IPs> fixedIPIterator = input.getFixedIPs().iterator();\r
while (fixedIPIterator.hasNext()) {\r
Neutron_IPs ip = fixedIPIterator.next();\r
NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());\r
- if (ip.getIpAddress() == null)\r
+ if (ip.getIpAddress() == null) {\r
ip.setIpAddress(subnet.getLowAddr());\r
+ }\r
if (!ip.getIpAddress().equals(subnet.getGatewayIP())) {\r
subnet.allocateIP(ip.getIpAddress());\r
}\r
return true;\r
}\r
\r
+ @Override\r
public boolean removePort(String uuid) {\r
- if (!portExists(uuid))\r
+ if (!portExists(uuid)) {\r
return false;\r
+ }\r
NeutronPort port = getPort(uuid);\r
portDB.remove(uuid);\r
INeutronNetworkCRUD networkCRUD = NeutronCRUDInterfaces.getINeutronNetworkCRUD(this);\r
return true;\r
}\r
\r
+ @Override\r
public boolean updatePort(String uuid, NeutronPort delta) {\r
- if (!portExists(uuid))\r
+ if (!portExists(uuid)) {\r
return false;\r
+ }\r
NeutronPort target = portDB.get(uuid);\r
// remove old Fixed_IPs\r
- NeutronPort port = getPort(uuid);\r
- INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);\r
- Iterator<Neutron_IPs> fixedIPIterator = port.getFixedIPs().iterator();\r
- while (fixedIPIterator.hasNext()) {\r
- Neutron_IPs ip = fixedIPIterator.next();\r
- NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());\r
- subnet.releaseIP(ip.getIpAddress());\r
- }\r
+ if (delta.getFixedIPs() != null) {\r
+ NeutronPort port = getPort(uuid);\r
+ INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);\r
+ for (Neutron_IPs ip: port.getFixedIPs()) {\r
+ NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());\r
+ subnet.releaseIP(ip.getIpAddress());\r
+ }\r
\r
- // allocate new Fixed_IPs\r
- fixedIPIterator = delta.getFixedIPs().iterator();\r
- while (fixedIPIterator.hasNext()) {\r
- Neutron_IPs ip = fixedIPIterator.next();\r
- NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());\r
- if (ip.getIpAddress() == null)\r
- ip.setIpAddress(subnet.getLowAddr());\r
- subnet.allocateIP(ip.getIpAddress());\r
+ // allocate new Fixed_IPs\r
+ for (Neutron_IPs ip: delta.getFixedIPs()) {\r
+ NeutronSubnet subnet = systemCRUD.getSubnet(ip.getSubnetUUID());\r
+ if (ip.getIpAddress() == null) {\r
+ ip.setIpAddress(subnet.getLowAddr());\r
+ }\r
+ subnet.allocateIP(ip.getIpAddress());\r
+ }\r
}\r
return overwrite(target, delta);\r
}\r
\r
+ @Override\r
public boolean macInUse(String macAddress) {\r
List<NeutronPort> ports = getAllPorts();\r
Iterator<NeutronPort> portIterator = ports.iterator();\r
while (portIterator.hasNext()) {\r
NeutronPort port = portIterator.next();\r
- if (macAddress.equalsIgnoreCase(port.getMacAddress()))\r
+ if (macAddress.equalsIgnoreCase(port.getMacAddress())) {\r
return true;\r
+ }\r
}\r
return false;\r
}\r
\r
+ @Override\r
public NeutronPort getGatewayPort(String subnetUUID) {\r
INeutronSubnetCRUD systemCRUD = NeutronCRUDInterfaces.getINeutronSubnetCRUD(this);\r
NeutronSubnet subnet = systemCRUD.getSubnet(subnetUUID);\r
NeutronPort port = portIterator.next();\r
List<Neutron_IPs> fixedIPs = port.getFixedIPs();\r
if (fixedIPs.size() == 1) {\r
- if (subnet.getGatewayIP().equals(fixedIPs.get(0).getIpAddress()))\r
+ if (subnet.getGatewayIP().equals(fixedIPs.get(0).getIpAddress())) {\r
return port;\r
+ }\r
}\r
}\r
return null;\r