use of org.platformlayer.core.model.AddressModel in project platformlayer by platformlayer.
the class NetworkPoolBuilder method toItem.
@Override
public AddressModel toItem(String key) {
AddressModel addressModel = new AddressModel();
if (this.addressModel == null) {
InetAddress address = InetAddresses.forString(key);
String cidr = address.getHostAddress() + "/" + range.getNetmaskLength();
addressModel.cidr = cidr;
AddressModels.populateDefaults(addressModel);
} else {
addressModel.copyFrom(this.addressModel);
addressModel.address = key;
IpRange netmask;
if (!Strings.isNullOrEmpty(addressModel.netmask)) {
netmask = IpRange.parse(addressModel.netmask);
} else {
netmask = this.range;
}
String cidr = addressModel.address + "/" + netmask.getNetmaskLength();
addressModel.cidr = cidr;
AddressModels.populateDefaults(addressModel);
}
return addressModel;
}
Aggregations