Repository: jclouds-site Updated Branches: refs/heads/master da788861a -> 806ffc459
Add softlayer getting started Project: http://git-wip-us.apache.org/repos/asf/jclouds-site/repo Commit: http://git-wip-us.apache.org/repos/asf/jclouds-site/commit/806ffc45 Tree: http://git-wip-us.apache.org/repos/asf/jclouds-site/tree/806ffc45 Diff: http://git-wip-us.apache.org/repos/asf/jclouds-site/diff/806ffc45 Branch: refs/heads/master Commit: 806ffc459dd1b074487547d1bd00c650b4db1eb1 Parents: a8029d6 Author: Andrea Turli <[email protected]> Authored: Thu Oct 16 00:11:50 2014 +0200 Committer: Ignasi Barrera <[email protected]> Committed: Mon Nov 9 23:00:15 2015 +0100 ---------------------------------------------------------------------- guides/index.md | 1 + guides/softlayer.md | 141 ++++++++++++++++++++++++++++++++++++++++++++ reference/providers.md | 4 +- 3 files changed, 144 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jclouds-site/blob/806ffc45/guides/index.md ---------------------------------------------------------------------- diff --git a/guides/index.md b/guides/index.md index 78c38ec..fdb99d6 100644 --- a/guides/index.md +++ b/guides/index.md @@ -15,6 +15,7 @@ Use these guides for getting started with any of the cloud providers below: * [OpenStack](openstack) * [ProfitBricks](profitbricks) * [Rackspace](rackspace) +* [SoftLayer](softlayer) Use these guides for more in depth usage: http://git-wip-us.apache.org/repos/asf/jclouds-site/blob/806ffc45/guides/softlayer.md ---------------------------------------------------------------------- diff --git a/guides/softlayer.md b/guides/softlayer.md new file mode 100644 index 0000000..721ee4c --- /dev/null +++ b/guides/softlayer.md @@ -0,0 +1,141 @@ +--- +layout: page +title: "SoftLayer: Getting Started Guide" +permalink: /guides/softlayer/ +--- +This page helps you get started using the jclouds API with SoftLayer. + +Currently, *SoftLayer* offers 3 main âcloudâ flavours: + +- `Bare Metal Server` (*BMS*): SoftLayer dedicated servers give you options from entry-level single processor servers to quad proc, hex-core, and even GPU-powered workhorses. +- `Virtual Server` (*BMI*): Single-tenant environment with SoftLayer managed hypervisor, ideal for applications with stringent resource requirements. It can be considered as a specialized configuration of Bare Metal Servers with limited options. +- `Public Cloud Instances` (*CCI*): Multi-tenant environment with SoftLayer managed hypervisor, ideal for rapid scalability and higher-cost effectiveness. + +Starting from 1.8.0, Jclouds supports officially only Public Cloud Instances (CCI). + +## Getting Started +1. Sign up for [SoftLayer Cloud](https://www.softlayer.com/cloud-servers/). +2. Log in to the +2. Get your Username and API Key: + - Sign in to [SoftLayer Customer Portal](https://control.softlayer.com) + - Navigate to [Users](https://control.softlayer.com/account/users) + - Click on "View" under `API Key` to see the API credential. +3. Ensure you are using a recent version of Java 6. +4. Setup your project to include `softlayer`. + * Get the dependencies `org.jclouds.provider/softlayer` using jclouds [Installation](/start/install). +5. Start coding. + +## SoftLayer Compute + +{% highlight java %} +// Get a context with softlayer that offers the portable ComputeService API +ComputeServiceContext computeServiceContext = ContextBuilder.newBuilder("softlayer") + .credentials("username", "apiKey") + .modules(ImmutableSet.<Module> of(new Log4JLoggingModule(), + new SshjSshClientModule())) + .buildView(ComputeServiceContext.class); + +ComputeService computeService = computeServiceContext.getComputeService(); + +// List availability zones +Set<? extends Location> locations = computeService.listAssignableLocations(); + +// List nodes +Set<? extends ComputeMetadata> nodes = computeService.listNodes(); + +// List hardware profiles +Set<? extends Hardware> hardware = computeService.listHardwareProfiles(); + +// List images +Set<? extends org.jclouds.compute.domain.Image> image = computeService.listImages(); +{% endhighlight %} + +NB: "computeService.listImages()" returns `operatingSystems` from [SoftLayer_Container_Virtual_Guest_Configuration](http://sldn.softlayer.com/reference/datatypes/SoftLayer_Container_Virtual_Guest_Configuration). + +{% highlight java %} +// Create nodes with templates +Template template = computeService.templateBuilder().osFamily(OsFamily.UBUNTU).build(); +Set<? extends NodeMetadata> groupedNodes = computeService.createNodesInGroup("myGroup", 2, template); + +// Reboot images in a group +computeService.rebootNodesMatching(inGroup("myGroup")); +{% endhighlight %} + +### TemplateOptions and SoftLayerTemplateOptions +In jclouds, the standard mechanism to specify template options is by using the TemplateBuilder. This supports a number of configuration supported by all the api/provider jclouds + +For example, the location id is used to specify the "region" provider where to spin your VM: +{% highlight java %} +TemplateBuilder templateBuilder = context.getComputeService().templateBuilder(); +templateBuilder.locationId("ams01"); +{% endhighlight %} + +If you need to specify a public image supported by SoftLayer can be referenced as follows: +{% highlight java %} +templateBuilder.imageId("CENTOS_6_64"); +{% endhighlight %} + +If you want instead to specify a `private` image, you need to set the `globalIdentifier` of a VirtualGuestBlockDeviceTemplateGroup, like: +{% highlight java %} +templateBuilder.imageId("3d7697d8-beef-437a-8921-5a2a18bc116f"); +{% endhighlight %} + +Notice, if you don't know the globalIdentifier upfront you can use the following curl command: +{% highlight java %} +curl -uusername:apiKey https://api.softlayer.com/rest/v3/SoftLayer_Account/getBlockDeviceTemplateGroups?objectMask=children.blockDevices.diskImage.softwareReferences.softwareDescription +{% endhighlight %} + +and use the globalIdentifier desired + +jclouds is able to leverage SoftLayer CCI specific-options described at [createObject](http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject) by doing the following: +{% highlight java %} +SoftLayerTemplateOptions options = template.getOptions().as(SoftLayerTemplateOptions.class); +// domain +options.domainName("live.org"); +// multi-disk +options.blockDevices(ImmutableList.of(25, 400, 400)); +// disk type (SAN, LOCAL) +options.diskType("SAN"); +//tags +options.tags(ImmutableList.of("jclouds")); +// primaryNetworkComponent.networkVlan.id +options.primaryNetworkComponentNetworkVlanId(vlanId); +// primaryBackendNetworkComponent.networkVlan.id +options.primaryBackendNetworkComponentNetworkVlanId(backendVlanId); +{% endhighlight %} +NB: notice, vlandId and backendVlanId should be the internal IDs and not the vlan number! One can easily retrieve it from the SoftLayer web UI by clicking on VLAN number link of `https://control.softlayer.com/network/vlans` +The url will show something like `https://control.softlayer.com/network/vlans/1234567` where the vlanId is *1234567* + +### Provider-specific APIs +When you need access to SoftLayer features, use the provider-specific context +{% highlight java %} +SoftLayerApi api = computeServiceContext.unwrapApi(SoftLayerApi.class); +// and then get access to the delegate API groups +api.getVirtualGuestApi(); +api.getDatacenterApi(); +api.getSoftwareDescriptionApi(); +api.getVirtualGuestBlockDeviceTemplateGroupApi(); +api.getAccountApi(); + +// Be sure to close the context when done +computeServiceContext.close(); +{% endhighlight %} + +## SoftLayer Object Storage +SoftLayer Object Storage is an OpenStack® based blobstore storage system. + +{% highlight java %} +// Get a context with softlayer that offers the portable BlobStore API +BlobStoreContext context = ContextBuilder.newBuilder("swift") + .credentials("tenantName:accessKey", "apiKey) + .endpoint("https://<locationId>.objectstorage.softlayer.net/auth/v1.0") + .buildView(BlobStoreContext.class); + +// Create a container in the default location +context.getBlobStore().createContainerInLocation(null, container); + +// Be sure to close the context when done +context.close(); +{% endhighlight %} + +For more examples, see <a href="/guides/openstack/">Openstack</a> documentation. http://git-wip-us.apache.org/repos/asf/jclouds-site/blob/806ffc45/reference/providers.md ---------------------------------------------------------------------- diff --git a/reference/providers.md b/reference/providers.md index 868bd03..08d6477 100644 --- a/reference/providers.md +++ b/reference/providers.md @@ -145,9 +145,9 @@ The Maven Group ID for all supported providers below is [org.apache.jclouds.prov <td>MY-10</td> </tr> <tr> - <td>SoftLayer</td> + <td><a href="/guides/softlayer/">SoftLayer</a></td> <td>softlayer</td> - <td></td> + <td>SG,US-CA,US-TX,US-VA,US-WA,<p/>NL,HK,NSFTW-IL,AU,CA-ON,GB</td> </tr> </tbody> </table>
