}\r
\r
public boolean isEnableDHCP() {\r
- if (enableDHCP == null)\r
+ if (enableDHCP == null) {\r
return true;\r
+ }\r
return enableDHCP;\r
}\r
\r
public Boolean getEnableDHCP() { return enableDHCP; }\r
\r
public void setEnableDHCP(Boolean newValue) {\r
- this.enableDHCP = newValue;\r
+ enableDHCP = newValue;\r
}\r
\r
public String getTenantID() {\r
Iterator<String> i = fields.iterator();\r
while (i.hasNext()) {\r
String s = i.next();\r
- if (s.equals("id"))\r
+ if (s.equals("id")) {\r
ans.setSubnetUUID(this.getSubnetUUID());\r
- if (s.equals("network_id"))\r
+ }\r
+ if (s.equals("network_id")) {\r
ans.setNetworkUUID(this.getNetworkUUID());\r
- if (s.equals("name"))\r
+ }\r
+ if (s.equals("name")) {\r
ans.setName(this.getName());\r
- if (s.equals("ip_version"))\r
+ }\r
+ if (s.equals("ip_version")) {\r
ans.setIpVersion(this.getIpVersion());\r
- if (s.equals("cidr"))\r
+ }\r
+ if (s.equals("cidr")) {\r
ans.setCidr(this.getCidr());\r
- if (s.equals("gateway_ip"))\r
+ }\r
+ if (s.equals("gateway_ip")) {\r
ans.setGatewayIP(this.getGatewayIP());\r
+ }\r
if (s.equals("dns_nameservers")) {\r
List<String> nsList = new ArrayList<String>();\r
nsList.addAll(this.getDnsNameservers());\r
hRoutes.addAll(this.getHostRoutes());\r
ans.setHostRoutes(hRoutes);\r
}\r
- if (s.equals("enable_dhcp"))\r
+ if (s.equals("enable_dhcp")) {\r
ans.setEnableDHCP(this.getEnableDHCP());\r
- if (s.equals("tenant_id"))\r
+ }\r
+ if (s.equals("tenant_id")) {\r
ans.setTenantID(this.getTenantID());\r
+ }\r
}\r
return ans;\r
}\r
try {\r
SubnetUtils util = new SubnetUtils(cidr);\r
SubnetInfo info = util.getInfo();\r
- if (!info.getNetworkAddress().equals(info.getAddress()))\r
+ if (!info.getNetworkAddress().equals(info.getAddress())) {\r
return false;\r
+ }\r
} catch (Exception e) {\r
return false;\r
}\r
Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();\r
while (i.hasNext()) {\r
NeutronSubnet_IPAllocationPool pool = i.next();\r
- if (pool.contains(gatewayIP))\r
+ if (pool.contains(gatewayIP)) {\r
return true;\r
+ }\r
}\r
return false;\r
}\r
\r
- public void initDefaults() {\r
- if (enableDHCP == null)\r
+ public boolean initDefaults() {\r
+ if (enableDHCP == null) {\r
enableDHCP = true;\r
- if (ipVersion == null)\r
+ }\r
+ if (ipVersion == null) {\r
ipVersion = 4;\r
+ }\r
gatewayIPAssigned = false;\r
dnsNameservers = new ArrayList<String>();\r
allocationPools = new ArrayList<NeutronSubnet_IPAllocationPool>();\r
try {\r
SubnetUtils util = new SubnetUtils(cidr);\r
SubnetInfo info = util.getInfo();\r
- if (gatewayIP == null)\r
+ if (gatewayIP == null) {\r
gatewayIP = info.getLowAddress();\r
+ }\r
if (allocationPools.size() < 1) {\r
NeutronSubnet_IPAllocationPool source =\r
new NeutronSubnet_IPAllocationPool(info.getLowAddress(),\r
allocationPools = source.splitPool(gatewayIP);\r
}\r
} catch (Exception e) {\r
+ return false;\r
}\r
+ return true;\r
}\r
\r
public List<NeutronPort> getPortsInSubnet() {\r
* available allocation pools or not\r
*/\r
public boolean isIPInUse(String ipAddress) {\r
- if (ipAddress.equals(gatewayIP) && !gatewayIPAssigned )\r
+ if (ipAddress.equals(gatewayIP) && !gatewayIPAssigned ) {\r
return false;\r
+ }\r
Iterator<NeutronSubnet_IPAllocationPool> i = allocationPools.iterator();\r
while (i.hasNext()) {\r
NeutronSubnet_IPAllocationPool pool = i.next();\r
- if (pool.contains(ipAddress))\r
+ if (pool.contains(ipAddress)) {\r
return false;\r
+ }\r
}\r
return true;\r
}\r
}\r
else\r
if (NeutronSubnet_IPAllocationPool.convert(pool.getPoolStart()) <\r
- NeutronSubnet_IPAllocationPool.convert(ans))\r
+ NeutronSubnet_IPAllocationPool.convert(ans)) {\r
ans = pool.getPoolStart();\r
+ }\r
}\r
return ans;\r
}\r
if (pool.contains(ipAddress)) {\r
List<NeutronSubnet_IPAllocationPool> pools = pool.splitPool(ipAddress);\r
newList.addAll(pools);\r
- } else\r
+ } else {\r
newList.add(pool);\r
+ }\r
}\r
}\r
allocationPools = newList;\r
NeutronSubnet_IPAllocationPool pool = i.next();\r
long lIP = NeutronSubnet_IPAllocationPool.convert(pool.getPoolStart());\r
long hIP = NeutronSubnet_IPAllocationPool.convert(pool.getPoolEnd());\r
- if (sIP+1 == lIP)\r
+ if (sIP+1 == lIP) {\r
hPool = pool;\r
- if (sIP-1 == hIP)\r
+ }\r
+ if (sIP-1 == hIP) {\r
lPool = pool;\r
+ }\r
}\r
//if (lPool == NULL and hPool == NULL) create new pool where low = ip = high\r
- if (lPool == null && hPool == null)\r
+ if (lPool == null && hPool == null) {\r
allocationPools.add(new NeutronSubnet_IPAllocationPool(ipAddress,ipAddress));\r
+ }\r
//if (lPool == NULL and hPool != NULL) change low address of hPool to ipAddr\r
- if (lPool == null && hPool != null)\r
+ if (lPool == null && hPool != null) {\r
hPool.setPoolStart(ipAddress);\r
+ }\r
//if (lPool != NULL and hPool == NULL) change high address of lPool to ipAddr\r
- if (lPool != null && hPool == null)\r
+ if (lPool != null && hPool == null) {\r
lPool.setPoolEnd(ipAddress);\r
+ }\r
//if (lPool != NULL and hPool != NULL) remove lPool and hPool and create new pool\r
// where low address = lPool.low address and high address = hPool.high Address\r
if (lPool != null && hPool != null) {\r