Just another blog

Rackspace Cloud API PHP Library

Posted by PAS on 13 August 2009

I am pleased to annouce my very first open source project hosted at github. The project, called Rackspace Cloud PHP Library is a simple, single PHP file to easily make Cloud Server API calls. Rackspace have not yet released any libraries for their API, possibly because it is still kind of in beta. If they do, I believe there will be of little use for my project, but right now, it has value.

So what was my motivation for this?

Well the Rackspace Cloud Management Console is severly lacking in features. Things such as creating an image of a server (just like you can in AWS EC2), and sharing an IP address between servers (something you cannot do in EC2 – an IP address can only be attached to a single instance at a time). It is this second feature that I am most interested in because it means I can use a virtual IP address (floating IP) to create a HA (highly available) “cluster” of Tomcat servers. I plan on using keepalived to do the IP switching, and Apache with mod_proxy_balancer and mod_proxy_ajp to talk to multiple Tomcat servers. Without reading the poorly written API documention and learning that I could create a shared IP group, I would not have known this was possible.

This project is very much a work in progress, and what is in there now represents only about 8 hours of work. I welcome any feedback, and anyone else who wants to join.

6 Responses to “Rackspace Cloud API PHP Library”

  1. Tomas said

    Can you please give some detail how to handle this API for rackspace cloud?

    we need floating ips between two RACkspace host servers, but i am not sure how to make it work ?

    Thanks a lot.

  2. PAS said

    Hi Tomas,

    There are a few steps you need to go though. First, bring up server01 and get it’s ID

    Both servers will need to be members of the same Shared IP Address Group:
    $rsc->sharedIpGroupCreate(“Floating IP Group 01”, $idOfServer01);

    Next you can bring up your second server into the above Shared IP Address Group. Unfortunately, you cannot add an already running server to a group, unless you are creating a group (as above).
    $rsc->serverCreate(“server02”, 1, 1, $sharedIpGroupId);

    Finally, the annoying part – if you want a new IP Address to float between server01 and server02, while keeping the public IP Address of both servers, you need to email Rackspace Support. As you may know, we are running out of IPv4, so they require an email to justify the need for another IP Address. You will also need to state that you allow them to charge you an extra $2/month for it. The process can take a day or 2.

    After the new IP is assigned to a server, you need to share that IP Address with the group (so that it can float). Sometimes, Rackspace Support do that for you, but if you want to do it using the API:
    $rsc->erverAddressShare($server02Id, $ipAddressToShare, $sharedIpGroupId, TRUE);

    Hopefully that helps… Let me know if you have any other questions.

  3. dreamcat4 said

    Im curious about this. Would the extra IP Address be used to log back into server01 after it had crashed ? Is it true that for a heartbeat system with just 2 public ip, then when server02-keepalived takes over the shared ip address from server01, then server01 would be unreachable?

    But then couldn't you configure these servers to forward ssh on an alternative port (between their internal private ip) ? The private ip are presumably are still separate and not shared. 
    Finally, if your server completely failed (no sshd), couldn't you at least backup the image of server01 and try to reboot it into a new instance (to read the log files)?
  4. dreamcat4 said

    Been reading this guide: Keepalived seems more straightforward to configure when theres 3 public ips. So i guess thats the answer here.

  5. PAS said

    @Dreamcat4: Yes the reason I suggest getting and paying for an extra IP address is so that you still have public access to each machine. If you feel comfortable without a public IP (perhaps using an SSH tunnel from 1 machine to the private IP of the other), then you can go that route.

    And yes, I don’t see any reason why you can’t create an image of a “crashed” machine, start the image on a new instance and read the log file.

  6. Thanks! This helped me out a lot in getting a good test-drive with the Rackspace Cloud. I’m looking to build support there for PANTHEON Mercury, and it was frustrating to see there was no working support for images. Your library was a huge help in getting things moving forward!

Sorry, the comment form is closed at this time.

%d bloggers like this: