Package io.fathom.cloud.protobuf.CloudModel

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


    @GET
    @Path("{id}/os-security-groups")
    public SecurityGroupList listSecurityGroups(@PathParam("id") String id) throws CloudException {
        Project project = getProject();

        InstanceData instance = getInstance(id);

        SecurityGroupList response = new SecurityGroupList();

        response.securityGroups = Lists.newArrayList();

        for (long sgId : instance.getSecurityGroupIdList()) {
            SecurityGroupData data = securityGroups.find(getProject(), sgId);
            if (data == null) {
                log.warn("Cannot find sg: {}", sgId);
                continue;
            }
View Full Code Here


        return response;
    }

    private InstanceData getInstance(String id) throws CloudException {
        InstanceData instance = instanceStateStore.getInstances(getProject().getId()).find(Long.valueOf(id));
        if (instance == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }
        return instance;
    }
View Full Code Here

    private InstanceData getInstance() throws CloudException {
        String remoteAddr = httpRequest.getRemoteAddr();

        InetAddress remoteAddress = InetAddresses.forString(remoteAddr);

        InstanceData instance = computeServices.findInstanceByAddress(remoteAddress);
        if (instance == null) {
            throw new WebApplicationException(Status.FORBIDDEN);
        }
        return instance;
    }
View Full Code Here

        result.instances = Lists.newArrayList();

        List<StartInstanceData> startInstances = Lists.newArrayList();
        for (int i = 0; i < hosts.size(); i++) {
            SchedulerHost host = hosts.get(i);
            InstanceData instanceInfo;
            {
                InstanceData.Builder b = InstanceData.newBuilder(instanceTemplate);
                b.setProjectId(project.getId());
                b.setHostId(host.getId());
                b.setReservationId(reservationInfo.getId());

                b.setInstanceState(InstanceState.PENDING);
                b.setLaunchIndex(i);

                b.setLaunchTime(time);

                instanceInfo = computeServices.createInstance(auth, project, b);
            }

            result.instances.add(instanceInfo);

            StartInstanceData data = new StartInstanceData();
            data.instanceInfo = instanceInfo;
            data.token = authService.createServiceToken(auth, instanceInfo.getId());

            startInstances.add(data);
        }

        asyncTasks.startInstances(auth, project, startInstances);
View Full Code Here

    @Path("openstack/{version}/meta_data.json")
    @GET
    @Produces({ JSON })
    public JsonElement getOpenstackMetadata() throws CloudException {
        InstanceData instance = getInstance();

        String identityUri = "http://[fd00::c10d]:8080/openstack/identity/";
        // String identityUri = authServices.getIdentityUri(baseUrl);

        // String uuid = UUID.randomUUID().toString();
        JsonObject o = new JsonObject();
        o.addProperty("uuid", instance.getId());
        o.addProperty("identity_uri", identityUri);

        JsonObject meta = new JsonObject();
        MetadataData metadata = instance.getMetadata();
        for (MetadataEntryData entry : metadata.getEntryList()) {
            meta.addProperty(entry.getKey(), entry.getValue());
        }
        o.add("meta", meta);
View Full Code Here

    }

    @Path("openstack/{version}/secret/{key}")
    @GET
    public byte[] getSecret(@PathParam("key") String key) throws CloudException {
        InstanceData instance = getInstance();

        byte[] secretData = computeServices.getSecret(instance.getProjectId(), instance.getId(), key);
        if (secretData == null) {
            throw new WebApplicationException(Status.NOT_FOUND);
        }

        return secretData;
View Full Code Here

    @Path("openstack/{version}/peers")
    @GET
    @Produces({ JSON })
    public JsonArray getOpenstackPeers() throws CloudException {
        InstanceData instance = getInstance();

        JsonArray ret = new JsonArray();

        for (InstanceData peer : computeServices.getPeers(instance)) {
            // TODO: Should we skip ourselves??
            if (peer.getId() == instance.getId()) {
                continue;
            }

            // TODO: Return a typed object
            InstanceState state = peer.getInstanceState();
View Full Code Here

    }

    @Path("{version}/meta-data/{key}")
    @GET
    public String getEc2MetadataValue(@PathParam("key") String key) throws CloudException {
        InstanceData instance = getInstance();

        if (key.equals("public-keys")) {
            if (instance.hasKeyPair()) {
                KeyPairData keyPair = instance.getKeyPair();

                String name = keyPair.getKey();

                String s = "0=" + name;
                return s;
View Full Code Here

    @Path("{version}/meta-data/{key}/{index}/{subkey}")
    @GET
    public String getEc2MetadataArrayValue(@PathParam("key") String key, @PathParam("index") int index,
            @PathParam("subkey") String subkey) throws CloudException {
        InstanceData instance = getInstance();

        if (key.equals("public-keys")) {
            if (subkey.equals("openssh-key")) {
                if (index == 0 && instance.hasKeyPair()) {
                    KeyPairData keyPair = instance.getKeyPair();

                    String s = keyPair.getPublicKey();
                    return s;
                }
            }
View Full Code Here

TOP

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

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.