Package io.fathom.cloud.compute.networks

Examples of io.fathom.cloud.compute.networks.VirtualIp


        this.ip = vip.getData().getIp();
    }

    @Override
    public boolean run() throws CloudException, IOException {
        VirtualIp vip = ipPools.findVirtualIp(project, ip);
        if (vip == null) {
            log.warn("Virtual IP not found, giving up: {}", ip);
            throw new IllegalStateException();
        }

        if (vip.getData().hasInstanceId()) {
            log.warn("Virtual IP attached to new machine: {}", ip);
            throw new IllegalStateException();
        }

        InstanceData instance = computeServices.findInstance(project.getId(), instanceId);
View Full Code Here


    @GET
    @Path("{id}")
    public WrappedFloatingIp find(@PathParam("id") String id) throws CloudException {
        String address = toAddress(id);

        VirtualIp vip = ipPools.findVirtualIp(getProject(), address);
        if (vip == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        WrappedFloatingIp response = new WrappedFloatingIp();
View Full Code Here

    @DELETE
    @Path("{id}")
    public void delete(@PathParam("id") String id) throws CloudException {
        String address = toAddress(id);
        VirtualIp vip = ipPools.findVirtualIp(getProject(), address);
        if (vip == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        ipPools.deallocateFloatingIp(getProject(), vip.getData().getIp());
    }
View Full Code Here

        VirtualIpPoolData pool = findPool(template.pool);
        if (pool == null) {
            throw new IllegalArgumentException();
        }

        VirtualIp vip = ipPools.allocateFloatingIp(getProject(), pool);

        WrappedFloatingIp response = new WrappedFloatingIp();
        response.floatingIp = toModel(vip);
        return response;
    }
View Full Code Here

        this.ip = vip.getData().getIp();
    }

    @Override
    public boolean run() throws CloudException, IOException {
        VirtualIp vip = ipPools.findVirtualIp(project, ip);
        if (vip == null) {
            log.warn("Virtual IP not found, giving up: {}", ip);
            throw new IllegalStateException();
        }

        if (!vip.getData().hasInstanceId()) {
            log.warn("Virtual IP not attached to machine, giving up: {}", ip);
            throw new IllegalStateException();
        }

        if (vip.getData().getInstanceId() != instanceId) {
            log.warn("Virtual IP not attached to same machine, giving up: {}", ip);
            throw new IllegalStateException();
        }

        InstanceData instance = computeServices.findInstance(project.getId(), instanceId);
View Full Code Here

            if (vip.getProjectId() != project.getId()) {
                continue;
            }

            return new VirtualIp(pool, vip);
        }
        return null;
    }
View Full Code Here

        for (VirtualIpPoolData pool : computeRepository.getVirtualIpPools().list()) {
            for (VirtualIpData vip : computeRepository.getAllocatedVips(pool.getId()).list()) {
                if (vip.getProjectId() != project.getId()) {
                    continue;
                }
                ret.add(new VirtualIp(pool, vip));
            }
        }
        return ret;
    }
View Full Code Here

        if (address == null) {
            // TODO: Auto-allocate a suitable floating ip from the networks the
            // instance can see
            throw new IllegalArgumentException();
        }
        VirtualIp vip = findVirtualIp(project, address);
        if (vip == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        if (vip.getData().hasInstanceId()) {
            throw new WebApplicationException(Status.CONFLICT);
        }

        VirtualIpData.Builder b = VirtualIpData.newBuilder(vip.getData());
        b.setInstanceId(instance.getId());
        VirtualIpData updated = computeRepository.getAllocatedVips(vip.getPoolData().getId()).update(b);

        asyncTasks.attachFloatingIp(project, instance, new VirtualIp(vip.getPoolData(), updated));
    }
View Full Code Here

        String address = request.address;
        if (address == null) {
            throw new IllegalArgumentException();
        }

        VirtualIp vip = findVirtualIp(project, address);
        if (vip == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        VirtualIpData vipData = vip.getData();

        if (!vipData.hasInstanceId() || vipData.getInstanceId() != instance.getId()) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        VirtualIpData.Builder b = VirtualIpData.newBuilder(vip.getData());
        b.clearInstanceId();
        VirtualIpData updated = computeRepository.getAllocatedVips(vip.getPoolData().getId()).update(b);

        asyncTasks.detachFloatingIp(project, instance, new VirtualIp(vip.getPoolData(), updated));
    }
View Full Code Here

        return ((MappableIpNetworkPool.Allocation) allocation).getVirtualIp();
    }

    public void deallocateFloatingIp(Project project, String ip) throws CloudException {
        VirtualIp vip = findVirtualIp(project, ip);
        if (vip == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        if (vip.getData().hasInstanceId()) {
            // TODO: Auto-detach?
            throw new WebApplicationException(Status.CONFLICT);
        }

        NetworkPool pool = networkPools.buildPool(vip.getPoolData());
        pool.markIpNotAllocated(vip);
    }
View Full Code Here

TOP

Related Classes of io.fathom.cloud.compute.networks.VirtualIp

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.