Package io.fathom.cloud.protobuf.CloudModel

Examples of io.fathom.cloud.protobuf.CloudModel.NetworkAddressData


                }
            }

            List<NetworkAddressData> addresses = instance.getNetwork().getAddressesList();
            if (addresses != null && !addresses.isEmpty()) {
                NetworkAddressData bestIpv4 = null;
                NetworkAddressData bestIpv6 = null;

                for (NetworkAddressData address : addresses) {
                    InetAddress inetAddress = InetAddresses.forString(address.getIp());
                    if (inetAddress instanceof Inet4Address) {
                        if (bestIpv4 == null) {
                            bestIpv4 = address;
                        } else {
                            log.warn("Cannot choose between IPv4 addresses");
                        }
                    } else if (inetAddress instanceof Inet6Address) {
                        if (bestIpv6 == null) {
                            bestIpv6 = address;
                        } else {
                            log.warn("Cannot choose between IPv6 addresses");
                        }
                    } else {
                        throw new IllegalStateException();
                    }
                }
                if (bestIpv4 != null) {
                    lxcConfig.ipv4Gateway = bestIpv4.getGateway();
                    lxcConfig.ipv4 = bestIpv4.getIp() + "/" + bestIpv4.getPrefixLength();
                }

                if (bestIpv6 != null) {
                    lxcConfig.ipv6Gateway = bestIpv6.getGateway();
                    lxcConfig.ipv6 = bestIpv6.getIp() + "/" + bestIpv6.getPrefixLength();
                }

                if (bestIpv6 != null && bestIpv6.hasMacAddress()) {
                    lxcConfig.hwaddr = bestIpv6.getMacAddress();
                } else if (bestIpv4 != null && bestIpv4.hasMacAddress()) {
                    lxcConfig.hwaddr = bestIpv4.getMacAddress();
                }
            }
View Full Code Here


        addr.setNetworkKey(getNetworkKey());

        addr.setProjectId(instance.getProjectId());
        addr.setInstanceId(instance.getId());

        NetworkAddressData allocated = networkPools.networkStateStore.markIpAllocated(this, addr);
        return new Allocation(allocated);
    }
View Full Code Here

        instance.ebsOptimized = false;

        if (instanceInfo.hasNetwork()) {
            InstanceNetworkData network = instanceInfo.getNetwork();

            NetworkAddressData bestPublic = null;
            NetworkAddressData bestPrivate = null;

            for (NetworkAddressData address : network.getAddressesList()) {
                if (address.getPublicAddress()) {
                    if (bestPublic == null) {
                        bestPublic = address;
                    } else {
                        log.warn("Selection between public addresses is primitive");
                    }
                } else {
                    if (bestPrivate == null) {
                        bestPrivate = address;
                    } else {
                        log.warn("Selection between private addresses is primitive");
                    }
                }
            }

            if (bestPublic != null) {
                instance.ipAddress = bestPublic.getIp();
            }

            if (bestPrivate != null) {
                instance.privateIpAddress = bestPrivate.getIp();
            }
        }
        return instance;
    }
View Full Code Here

            return null;
        }

        String ip = InetAddresses.toAddrString(address);

        NetworkAddressData addressInfo = computeRepository.getHostIps(network.getHost().getId(), network.getKey())
                .find(ip);
        if (addressInfo == null) {
            return null;
        }

        long projectId = addressInfo.getProjectId();
        long instanceId = addressInfo.getInstanceId();
        if (projectId == 0 || instanceId == 0) {
            return null;
        }

        InstanceData instance = computeRepository.getInstances(projectId).find(instanceId);
View Full Code Here

TOP

Related Classes of io.fathom.cloud.protobuf.CloudModel.NetworkAddressData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.