Skip to content
Connector to ComputeNext External API using JClouds package
Java JavaScript
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
.settings
bin
src
target
.classpath
.project
README.md
pom.xml

README.md

jclouds-computenext

Connector to ComputeNext External API using the jclouds package. The ComputeNext API abstracts multiple cloud providers into a single API including CloudSigma, HPCloud, Joyent, Bit Refinery, Arsys, Softlayer, and much more! This package helps to abstract the ComputeNext REST API into a common java library, and utilizes several features provided by jclouds interfaces. jclouds is licensed under the Apache License, Version 2.0

Features

Even if you don't need the portable apis we provide, or could roll it your own, programming against cloud environments can be challenging. We focus on the following areas so that you can focus on using the cloud, rather than troubleshooting it!

  • SINGLE SIGN-ON Access the world’s public clouds from a single ComputeNext API account. Build and deploy servers across all major cloud platforms and choose from a growing selection of cloud providers worldwide.

  • SEARCH AND DISCOVERY Define your computing needs and find the right provider for you. Increase your workloads’ efficiency and potential with search and discovery by specs, SLA, price (or pricing structures) and region.

  • ONE ACCOUNT / ONE BILL Consolidate your cloud spend with a single point of payment. ComputeNext, as merchant of record, can increase visibility on your cloud spend and lessen the growing pain of scalable solutions.

  • REST API ABSTRACTION With jclouds, the ComputeNext API is abstracted into a common and simple interface with a familiar java programming model

Installation Guide

Using Eclipse / Maven Plugin

  1. Make sure the maven plugin installed in eclipse. See http://maven.apache.org/eclipse-plugin.html for more details.
  2. Once maven is installed, right click the Package Explorer in Eclipse and select Import Existing Maven Project
  3. Browse to the location where the jclouds-computenext directory was downloaded
  4. After the import process is finished, run mvn install on the project to build it
  5. If the jclouds maven repository was not automatically downloaded during this process, you can download it directly here https://github.com/jclouds/jclouds
  6. Run the HelloWorld.java example in the org.jclouds.computenexttext package

Using Shell / Command line

  1. Make sure maven has been installed. See http://maven.apache.org/download.html for more details.
  2. Once maven is installed, navigate to the directory where jclouds-computenext is located and run mvn install -dskipTests=true
  3. If the jclouds maven repository was not automatically downloaded during this process, you can download it directly here https://github.com/jclouds/jclouds
  4. Run the HelloWorld.java example in the org.jclouds.computenexttext package

HelloWorld Example

Search and choose the compute resources that fit your needs through our resource catalog and provision your dynamic workloads with ease.

Initializing ComputeNext RestContext:

// Specify your ComputeNext API credentials
ContextBuilder builder = ContextBuilder.newBuilder(Apis.withId("computenext"))
        .credentials(apikey,apisec);

builder.endpoint("http://www.computenext.com/apiv1.0");

RestContext<ComputeNextApi, ComputeNextAsyncApi> context = builder.build();

// Get the various APIs that are available from ComputeNext
WorkloadAsyncApi workloadApi = context.getAsyncApi().getWorkloadApi();
TransactionAsyncApi transactionApi = context.getAsyncApi().getTransactionApi();
ResourceAsyncApi resourceApi = context.getAsyncApi().getResourceApi();

Search For The Compute Resource You Want:

String imageId = null;
String instanceTypeId = null;
String region = null;
try {
    ListenableFuture<List<VirtualMachine>> response = resourceApi.listVirtualMachines();
    List<VirtualMachine> vmList = response.get();

    for (VirtualMachine v : vmList) {

        // Choose the VM you want based the number of cpus, the amount of ram, and the type of software
        if (v.getRam().equals("4")
                && v.getCpuCount.equals("2")
                && v.getSoftwareType().get(0).equals("CentOS 6")
                && v.isAvailable()) {
            imageId = v.getImageId();
            instanceTypeId = v.getInstanceTypeId();
            region = v.getRegion();
            break;
        }
    }
} catch (Exception e) {
    e.printStackTrace();
}

Add Your Choice To Your Workload:

Workload w = null;
String WorkloadId = null;

try {
    // Create your first workload
    ListenableFuture<Workload> workloadResponse = workloadApi.createWorkload("My-Workload");
    w = workloadResponse.get();
    WorkloadId = w.getWorkloadId();

    // Add your VMs details to your workload
    ListenableFuture<String> response = workloadApi.addVirtualMachine(WorkloadId, "My VM Choice", region, imageId, instanceTypeId);
    String workloadElementId = response.get();            
} catch (HttpResponseException e) {
    System.out.println(e);            
} catch (InterruptedException e) {
    e.printStackTrace();
} catch (ExecutionException e) {
    e.printStackTrace();
}

Deploy Your Workload:

String TransactionId = null;
try {
    // Start a transaction from your workload using a trial account
    ListenableFuture<String> response = transactionApi.createTransaction(WorkloadId, "Trial");
    TransactionId = response.get();

    // Retrieve the details of your transaction
    transactionResponse = transactionApi.getTransaction(TransactionId);        
    t = transactionResponse.get();
    System.out.println("* Transaction details: " + t);
} catch (InterruptedException e) {
    e.printStackTrace();
} catch (ExecutionException e) {
    e.printStackTrace();
} catch (Exception e) {
    e.printStackTrace();            
}

ComputeNext Resources

Jclouds Resources

License

Copyright (C) 2009-2012 jclouds, Inc.

Licensed under the Apache License, Version 2.0

Something went wrong with that request. Please try again.