Search in sources :

Example 11 with AddressModel

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;
}
Also used : IpRange(org.platformlayer.ops.networks.IpRange) AddressModel(org.platformlayer.core.model.AddressModel) InetAddress(java.net.InetAddress)

Aggregations

AddressModel (org.platformlayer.core.model.AddressModel)11 OpsProvider (org.platformlayer.ops.OpsProvider)6 DirectHost (org.platformlayer.service.cloud.direct.model.DirectHost)4 File (java.io.File)3 InetAddress (java.net.InetAddress)3 TagChanges (org.platformlayer.core.model.TagChanges)3 OpsException (org.platformlayer.ops.OpsException)3 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)3 NetworkPoolBuilder (org.platformlayer.ops.pool.NetworkPoolBuilder)3 DirectInstance (org.platformlayer.service.cloud.direct.model.DirectInstance)3 InetSocketAddress (java.net.InetSocketAddress)2 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)2 Command (org.platformlayer.ops.Command)2 InterfaceModel (org.platformlayer.ops.networks.InterfaceModel)2 IpRange (org.platformlayer.ops.networks.IpRange)2 NetworkAddressPoolAssignment (org.platformlayer.ops.pool.NetworkAddressPoolAssignment)2 PoolBuilder (org.platformlayer.ops.pool.PoolBuilder)2 SocketAddressPoolAssignment (org.platformlayer.ops.pool.SocketAddressPoolAssignment)2 CloudInstanceMapper (org.platformlayer.service.cloud.direct.ops.CloudInstanceMapper)2 DownloadImage (org.platformlayer.service.cloud.direct.ops.DownloadImage)2