Search in sources :

Example 1 with PoolBuilder

use of org.platformlayer.ops.pool.PoolBuilder in project platformlayer by platformlayer.

the class DirectCloudUtils method getAddressPool6.

public OpsProvider<ResourcePool<AddressModel>> getAddressPool6() {
    OpsProvider<PoolBuilder<AddressModel>> poolBuilder = new OpsProvider<PoolBuilder<AddressModel>>() {

        @Override
        public PoolBuilder<AddressModel> get() throws OpsException {
            DirectHost host = OpsContext.get().getInstance(DirectHost.class);
            PlatformLayerKey sharedNetworkKey = getSharedNetworkKey();
            // Skip the first entries in the CIDR as it's probably not valid
            // 0: Network identifier
            // 1: Gateway
            // 2: Host
            int skipCount = 3;
            if (sharedNetworkKey != null) {
                DirectNetwork network = platformLayer.getItem(sharedNetworkKey, DirectNetwork.class);
                for (AddressModel net : network.getNetworks()) {
                    if (Strings.isNullOrEmpty(net.cidr)) {
                        continue;
                    }
                    IpRange cidr = IpRange.parse(net.cidr);
                    if (!cidr.isIpv6()) {
                        continue;
                    }
                    return new NetworkPoolBuilder(net.cidr, skipCount, net);
                }
                log.warn("Unable to find an IPV6 network configured on " + sharedNetworkKey);
                return null;
            } else {
                String privateCidr = host.ipv6;
                if (privateCidr != null) {
                    return new NetworkPoolBuilder(privateCidr, skipCount, null);
                }
                return null;
            }
        }
    };
    return getNetworkPoolProvider(AddressModel.class, "addresses-ipv6", poolBuilder);
}
Also used : IpRange(org.platformlayer.ops.networks.IpRange) DirectNetwork(org.platformlayer.service.cloud.direct.model.DirectNetwork) DirectHost(org.platformlayer.service.cloud.direct.model.DirectHost) OpsProvider(org.platformlayer.ops.OpsProvider) NetworkPoolBuilder(org.platformlayer.ops.pool.NetworkPoolBuilder) PoolBuilder(org.platformlayer.ops.pool.PoolBuilder) NetworkPoolBuilder(org.platformlayer.ops.pool.NetworkPoolBuilder) AddressModel(org.platformlayer.core.model.AddressModel) PlatformLayerKey(org.platformlayer.core.model.PlatformLayerKey) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint)

Example 2 with PoolBuilder

use of org.platformlayer.ops.pool.PoolBuilder in project platformlayer by platformlayer.

the class DirectCloudUtils method getPrivateAddressPool4.

public static OpsProvider<ResourcePool<AddressModel>> getPrivateAddressPool4() {
    OpsProvider<PoolBuilder<AddressModel>> poolBuilder = new OpsProvider<PoolBuilder<AddressModel>>() {

        @Override
        public PoolBuilder<AddressModel> get() {
            DirectHost host = OpsContext.get().getInstance(DirectHost.class);
            String privateCidr = host.ipv4Private;
            if (privateCidr != null) {
                // Skip the first entries in the CIDR as it's probably not valid
                // 0: Network identifier
                // 1: Gateway (?)
                // 2: Host (?)
                int skipCount = 3;
                return new NetworkPoolBuilder(privateCidr, skipCount);
            }
            return null;
        }
    };
    return getUnsharedPrivatePoolProvider(AddressModel.class, "addresses-ipv4-private", poolBuilder);
}
Also used : DirectHost(org.platformlayer.service.cloud.direct.model.DirectHost) OpsProvider(org.platformlayer.ops.OpsProvider) NetworkPoolBuilder(org.platformlayer.ops.pool.NetworkPoolBuilder) PoolBuilder(org.platformlayer.ops.pool.PoolBuilder) NetworkPoolBuilder(org.platformlayer.ops.pool.NetworkPoolBuilder) AddressModel(org.platformlayer.core.model.AddressModel) NetworkPoint(org.platformlayer.ops.networks.NetworkPoint)

Aggregations

AddressModel (org.platformlayer.core.model.AddressModel)2 OpsProvider (org.platformlayer.ops.OpsProvider)2 NetworkPoint (org.platformlayer.ops.networks.NetworkPoint)2 NetworkPoolBuilder (org.platformlayer.ops.pool.NetworkPoolBuilder)2 PoolBuilder (org.platformlayer.ops.pool.PoolBuilder)2 DirectHost (org.platformlayer.service.cloud.direct.model.DirectHost)2 PlatformLayerKey (org.platformlayer.core.model.PlatformLayerKey)1 IpRange (org.platformlayer.ops.networks.IpRange)1 DirectNetwork (org.platformlayer.service.cloud.direct.model.DirectNetwork)1