Skip to content
Browse files

ABICLOUDPREMIUM-3789 create leases without colons (':')

  • Loading branch information...
1 parent 4164f66 commit 505a83c97f7ac369616e7620511622ddf03b27ec Jaume Devesa committed Apr 27, 2012
Showing with 29 additions and 25 deletions.
  1. +29 −25 api/src/main/java/com/abiquo/api/services/NetworkService.java
View
54 api/src/main/java/com/abiquo/api/services/NetworkService.java
@@ -92,8 +92,9 @@ public static Rasd createRasdEntity(final VirtualMachine vm, final IpPoolManagem
{
// create the Rasd object.
Rasd rasd =
- new Rasd(UUID.randomUUID().toString(), IpPoolManagement.DEFAULT_RESOURCE_NAME, Integer
- .valueOf(IpPoolManagement.DISCRIMINATOR));
+ new Rasd(UUID.randomUUID().toString(),
+ IpPoolManagement.DEFAULT_RESOURCE_NAME,
+ Integer.valueOf(IpPoolManagement.DISCRIMINATOR));
rasd.setDescription(IpPoolManagement.DEFAULT_RESOURCE_DESCRIPTION);
rasd.setConnection("");
@@ -169,8 +170,11 @@ public NetworkService(final EntityManager em)
public DhcpOption addDhcpOption(final DhcpOptionDto dto)
{
DhcpOption opt =
- new DhcpOption(dto.getOption(), dto.getGateway(), dto.getNetworkAddress(), dto
- .getMask(), dto.getNetmask());
+ new DhcpOption(dto.getOption(),
+ dto.getGateway(),
+ dto.getNetworkAddress(),
+ dto.getMask(),
+ dto.getNetmask());
if (!opt.isValid())
{
@@ -212,7 +216,7 @@ public void assignDefaultNICToVirtualMachine(final Integer vmId)
ip = new IpPoolManagement(vlan, "?", "?", "?", vlan.getName());
ip.setVirtualDatacenter(vdc);
ip.setMac(IPNetworkRang.requestRandomMacAddress(vdc.getHypervisorType()));
- ip.setName(ip.getMac() + "_host");
+ ip.setName(ip.getMac().replace(":", "") + "_host");
repo.insertIpManagement(ip);
break;
@@ -223,7 +227,7 @@ public void assignDefaultNICToVirtualMachine(final Integer vmId)
.getGateway());
ip.setVirtualDatacenter(vdc);
ip.setMac(IPNetworkRang.requestRandomMacAddress(vdc.getHypervisorType()));
- ip.setName(ip.getMac() + "_host");
+ ip.setName(ip.getMac().replace(":", "") + "_host");
}
Rasd rasd = createRasdEntity(vm, ip);
@@ -387,9 +391,9 @@ public VLANNetwork createPrivateNetwork(final Integer vdcId, final VLANNetwork n
// once we have validated we have IPs in all IP parameters (isValid() method), we should
// ensure they are
// actually PRIVATE IPs. Also check if the gateway is in the range, and
- checkAddressAndMaskCoherency(IPAddress
- .newIPAddress(newVlan.getConfiguration().getAddress()), newVlan.getConfiguration()
- .getMask());
+ checkAddressAndMaskCoherency(
+ IPAddress.newIPAddress(newVlan.getConfiguration().getAddress()), newVlan
+ .getConfiguration().getMask());
List<DhcpOption> opts = new ArrayList<DhcpOption>(newVlan.getDhcpOption());
for (DhcpOption dhcpOption : newVlan.getDhcpOption())
@@ -613,8 +617,8 @@ public IpPoolManagement getIpPoolManagementByVirtualMachine(final Integer vdcId,
{
// needed for REST links.
DatacenterLimits dl =
- datacenterRepo.findDatacenterLimits(ip.getVlanNetwork().getEnterprise(), vdc
- .getDatacenter());
+ datacenterRepo.findDatacenterLimits(ip.getVlanNetwork().getEnterprise(),
+ vdc.getDatacenter());
ip.getVlanNetwork().setLimitId(dl.getId());
}
@@ -789,8 +793,8 @@ public IpPoolManagement getIpPoolManagementByVlan(final Integer vdcId, final Int
{
// needed for REST links.
DatacenterLimits dl =
- datacenterRepo.findDatacenterLimits(ip.getVlanNetwork().getEnterprise(), vdc
- .getDatacenter());
+ datacenterRepo.findDatacenterLimits(ip.getVlanNetwork().getEnterprise(),
+ vdc.getDatacenter());
ip.getVlanNetwork().setLimitId(dl.getId());
}
}
@@ -831,8 +835,8 @@ public IpPoolManagement getIpPoolManagementByVlan(final Integer vdcId, final Int
{
// needed for REST links.
DatacenterLimits dl =
- datacenterRepo.findDatacenterLimits(ip.getVlanNetwork().getEnterprise(), vdc
- .getDatacenter());
+ datacenterRepo.findDatacenterLimits(ip.getVlanNetwork().getEnterprise(),
+ vdc.getDatacenter());
ip.getVlanNetwork().setLimitId(dl.getId());
}
}
@@ -944,8 +948,8 @@ public VMNetworkConfiguration getVirtualMachineConfiguration(final Integer vdcId
IpPoolManagement resultIp = ips.get(0);
for (IpPoolManagement ip : ips)
{
- if (ip.getVlanNetwork().getConfiguration().getId().equals(
- vm.getNetworkConfiguration().getId()))
+ if (ip.getVlanNetwork().getConfiguration().getId()
+ .equals(vm.getNetworkConfiguration().getId()))
{
resultIp = ip;
break;
@@ -958,8 +962,8 @@ public VMNetworkConfiguration getVirtualMachineConfiguration(final Integer vdcId
vmconfig.setPrimaryDNS(vlan.getConfiguration().getPrimaryDNS());
vmconfig.setSecondaryDNS(vlan.getConfiguration().getSecondaryDNS());
vmconfig.setSuffixDNS(vlan.getConfiguration().getSufixDNS());
- vmconfig.setUsed(vlan.getConfiguration().getId().equals(
- vm.getNetworkConfiguration().getId()));
+ vmconfig.setUsed(vlan.getConfiguration().getId()
+ .equals(vm.getNetworkConfiguration().getId()));
vmconfig.setId(vlan.getConfiguration().getId());
LOGGER
@@ -1165,10 +1169,10 @@ public VLANNetwork updatePrivateNetwork(final Integer vdcId, final Integer vlanI
userService.checkCurrentEnterpriseForPostMethods(vdc.getEnterprise());
// Values 'address', 'mask', and 'tag' can not be changed by the edit process
- if (!oldNetwork.getConfiguration().getAddress().equalsIgnoreCase(
- newNetwork.getConfiguration().getAddress())
- || !oldNetwork.getConfiguration().getMask().equals(
- newNetwork.getConfiguration().getMask())
+ if (!oldNetwork.getConfiguration().getAddress()
+ .equalsIgnoreCase(newNetwork.getConfiguration().getAddress())
+ || !oldNetwork.getConfiguration().getMask()
+ .equals(newNetwork.getConfiguration().getMask())
|| oldNetwork.getTag() == null
&& newNetwork.getTag() != null
|| oldNetwork.getTag() != null
@@ -1181,8 +1185,8 @@ public VLANNetwork updatePrivateNetwork(final Integer vdcId, final Integer vlanI
}
// Check the new gateway is inside the range of IPs.
- if (!newNetwork.getConfiguration().getGateway().equalsIgnoreCase(
- oldNetwork.getConfiguration().getGateway()))
+ if (!newNetwork.getConfiguration().getGateway()
+ .equalsIgnoreCase(oldNetwork.getConfiguration().getGateway()))
{
IPAddress networkIP =
IPAddress.newIPAddress(newNetwork.getConfiguration().getAddress());

0 comments on commit 505a83c

Please sign in to comment.
Something went wrong with that request. Please try again.