Package io.fathom.cloud.protobuf.CloudModel

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


        // if (rack == null) {
        // throw new IllegalArgumentException("Specified rack not found");
        // }
        // }

        HostGroupData parent = networkMap.findHostGroupByKey(parentKey);
        if (parent == null) {
            throw new IllegalArgumentException("Specified parent not found");
        }

        // List<HostData> hosts = networkMap.listHosts(rack);
        // long max = 0;
        // for (HostData host : hosts) {
        // long v = host.getKey();
        // max = Math.max(v, max);
        // }
        //
        // long next = max + 1;
        //
        // if (next < 16) {
        // // We reserve the first 16 for operational stuff
        // next = 16;
        // }
        //
        // if (next >= 65500) {
        // // Reserve some at the end as well
        // // TODO: Reclaim deleted hosts??
        // throw new
        // IllegalArgumentException("Too many machines already configured in rack");
        // }

        // IpRange parentRange = IpRange.parse(parent.getCidr());
        // if (!containsStrict(parentRange, range)) {
        // throw new
        // IllegalArgumentException("Child CIDR must be a sub-range of the parent range");
        // }

        HostData.Builder b = HostData.newBuilder();
        if (label != null) {
            b.setLabel(label);
        }
        b.setHostGroup(parent.getId());
        b.setCidr(cidr);
        b.setNetworkDevice(networkDevice);

        HostData created = networkMap.createHost(b);
View Full Code Here


                throw new IllegalArgumentException("CIDR cannot be provided for AWS virtual-IP pools");
            }
        }

        if (hostGroupKey != null) {
            HostGroupData hostGroup = networkMap.findHostGroupByKey(hostGroupKey);
            if (hostGroup == null) {
                throw new IllegalArgumentException("Host group is not found");
            }

            b.setHostGroupId(hostGroup.getId());
        }

        VirtualIpPoolData created = ipPools.createVipPool(b);

        return created;
View Full Code Here

        for (HostGroupData hostGroupData : hostStore.getHostGroups().list()) {
            hostGroups.put(hostGroupData.getId(), hostGroupData);
        }

        for (HostData hostData : hostStore.getHosts().list()) {
            HostGroupData hostGroupData = hostGroups.get(hostData.getHostGroup());
            if (hostGroupData == null) {
                throw new IllegalStateException();
            }

            DatacenterManager datacenter = datacenters.get(hostGroupData.getId());
            if (datacenter == null) {
                switch (hostGroupData.getHostGroupType()) {
                case HOST_GROUP_TYPE_RAW:
                    datacenter = new RawDatacenterManager();
                    break;
                case HOST_GROUP_TYPE_AMAZON_EC2:
                    HostGroupSecretData secretData = computeSecrets.getSecretData(hostGroupData);
                    datacenter = new Ec2DatacenterManager(hostGroupData, secretData);
                    break;
                default:
                    throw new IllegalStateException();
                }

                datacenters.put(hostGroupData.getId(), datacenter);
            }

            IpRange ipRange = IpRange.parse(hostData.getCidr());

            InetAddress address = ipRange.getAddress();
View Full Code Here

        if (networkMap.findHostGroupByKey(key) != null) {
            throw new IllegalArgumentException("Host group already exists");
        }

        HostGroupData parent = null;
        if (parentKey != null) {
            parent = networkMap.findHostGroupByKey(parentKey);
            if (parent == null) {
                throw new IllegalArgumentException("Specified parent not found");
            }
        }

        HostGroupData.Builder b = HostGroupData.newBuilder();

        if (label != null) {
            b.setLabel(label);
        }
        b.setKey(key);

        type = type.toLowerCase().trim();
        if (type.equals("ec2")) {
            b.setHostGroupType(HostGroupType.HOST_GROUP_TYPE_AMAZON_EC2);
        } else if (type.equals("bare")) {
            b.setHostGroupType(HostGroupType.HOST_GROUP_TYPE_RAW);
        } else {
            throw new IllegalArgumentException("Expected type to be 'bare' or 'ec2'");
        }

        {
            HostGroupSecretData.Builder sb = HostGroupSecretData.newBuilder();

            // We're going to rely on IAM ... so much easier + more secure
            // if (username != null) {
            // sb.setUsername(username);
            // }
            //
            // if (password != null) {
            // sb.setPassword(password);
            // }

            SecretData secretData = computeSecrets.encrypt(sb.build());
            b.setSecretData(secretData);
        }

        if (parent != null) {
            b.setParent(parent.getId());

            // IpRange parentRange = IpRange.parse(parent.getCidr());
            // if (!containsStrict(parentRange, range)) {
            // throw new
            // IllegalArgumentException("Child CIDR must be a sub-range of the parent range");
            // }
        }

        HostGroupData created = networkMap.createHostGroup(b);
        return created;
    }
View Full Code Here

TOP

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

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.