Like any cloud provider, ProfitBricks has its own set of terms in cloud computing. To abstract this into jclouds' Compute interface, these terms were associated:
Server
and Storage
Images
; and Snapshots
DataCenters
and Region
(Las Vegas, Frankfurt, etc.)Assuming that there's atleast one datacenter existing in your account, the provider needs only an identity (your ProfitBricks email), and credentials (password) to provision a Node
, by using a ProfitBricks-provided ubuntu-12.04 image as a template.
ComputeService compute = ContextBuilder.newBuilder( "profitbricks" ) .credentials( "profitbricks email", "password" ) .buildView( ComputeServiceContext.class ) .getComputeService();
This works well; however, we won‘t be able to use jclouds’ ability to execute scripts on a remote node. This is because, ProfitBricks' default images require users to change passwords upon first log in.
To enable jclouds to execute script, we need to use a custom image. The easiest way to do this is via ProfitBricks snapshot:
~ ssh root@<remote-ip> ... Changing password for root. (current) UNIX password: Enter new UNIX password: Retype new UNIX password: ~ root@ubuntu:~# exit
Template template = compute.templateBuilder() .imageNameMatches( "<ideally-unique-snapshot-name>" ) .options( compute.templateOptions() .overrideLoginUser( "root" ) // unless you changed the user .overrideLoginPassword( "<changed-password>" )) // more options, as you need .build(); compute.createNodesInGroup( "cluster1", 1, template );
If no
locationId
is specified in the template, jclouds will look for aDataCenter
that is of same scope as theImage
.
Take note that these features are still accessible by unwraping the ProfitBricks API, but this'll reduce portability of your code. See Concepts.