Skip to content

SoftLayer Integration

kumamoto edited this page Jan 24, 2013 · 3 revisions

SoftLayer Integration

This document refers to this Openmix app

In this example, we will be using the current Network status to allow Openmix to switch between hosts on an hourly compute instance. In a "real world" case you might want to interact with bare metal or more permanent instances, please refer to SoftLayer's public API for more details.

SoftLayer exposes the status of the primary network component of your virtual server via their REST API:

curl -u username:api_key https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/xxxxx/PrimaryNetworkComponent.json

{
	"createDate": "2013-01-23T15:37:36-08:00",
    "guestId": xxxxx,
    "id": 999427,
    "macAddress": "06:9f:43:04:ec:62",
    "maxSpeed": 10,
    "modifyDate": "2013-01-23T15:37:58-08:00",
    "name": "eth",
    "networkId": 783589,
    "port": 1,
    "speed": 10,
    "status": "ACTIVE",
    "uuid": "fcca96ec-b79c-9ba4-f752-310dd7debc36",
    "primaryIpAddress": "xx.xx.xxx.xx"
}

We're going to write our Openmix app based on the "status" variable. If it is set as anything other than ACTIVE, we will remove the provider from the available providers.

Let's get started!

Assumptions

  • You have a SoftLayer Account
  • You have at least 2 servers provisioned
  • You have setup a user and granted the necessary permissions to access those servers
  • You have granted this user API access and got an API key

Getting started

  1. Open a browser to the Cedexis Portal

  2. Browse to Customer Portal > Openmix > Applications

  3. Create Application > PHP

  4. Upload this OpenmixApplication.php as a new Application

  5. Create a Custom platform with an alias of "softlayer_a" with Sonar Load configured to a URL similar to (Note: the basic auth credentials username and api_key are passed in the URL)

     https://username:api_key@api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/xxxxx/PrimaryNetworkComponent.json
    
  6. Create a Custom platform with an alias of "softlayer_b". It is just a placeholder for the other choice.

  7. Using the CNAME corresponding to your openmix app, open a new terminal, get a steady stream of DNS requests to the app by running:

     watch -n 1 dig +short __your_openmix_cname__.cdx.cedexis.net
    
  8. Watch Openmix switch randomly between softlayer_a and softlayer_b in your terminal window

  9. Now, for testing, shutdown the primary network component for softlayer_a by sending this request (Note: replace the server guest id by the corresponding value):

    curl -u username:api_key https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/xxxxx/shutdownPublicPort.json
    
  10. Depending on the Sonar refresh rate you have setup in step 6, you should see in your terminal the Openmix decisions switch to softlayer_b exclusively.

  11. Turn the network back on of softlayer_a by issueing this request:

    curl -u username:api_key https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/xxxxx/activatePublicPort.json
    
  12. Watch the traffic come back to round robin and distributed to both softlayer_a and softlayer_b

  13. To get a visual of how the decision were being made in this example, we can look at the Openmix Decisions Dashboard.

Clone this wiki locally