0

A very open question which I need some advice on and more importantly pointers in the right direction.

I'm looking at using openstack for my private cloud (currently using VMware) as the main aim is to be able to launch a new VM instance from within our web application so this could be trigger via a php page to deploy new apache worker server for example. The next aim is to develop our code to be able to see when a server load is getting high or needs more worker servers to preform a task to auto launch an instance?

I've been looking at the openstack API to see if this is the best approach? But also looking at juju to see if you can use charms to do this and seeing if the api for juju to is best?

The aim is get this working with VMware or to replace vmware.

My current setup is running openstack on a laptop using nova as the storage so any help with the pointers would be great

I know its a open question

Grimlockz
  • 2,541
  • 7
  • 31
  • 38

1 Answers1

1

Well there is an SDK page listing many of the OpenStack API client SDKs that exist.

Ref:

https://wiki.openstack.org/wiki/SDKs#PHP

Listed in there are two PHP SDKs for OpenStack currently:

Ref:

https://github.com/rackspace/php-opencloud https://github.com/zendframework/ZendService_OpenStack

I wouldn't use Juju as an interface. And frankly I am not sure OpenStack is the right tool for what you are doing. But, if you want to play with devstack and get an idea, I think rackspace's php client SDK is probably a good start. Devstack is not a bad way to get that experience either.

example of spinning up a server with php-opencloud:

$server = $compute->server();

try {
$response = $server->create(array(
    'name'     => 'My lovely server',
    'image'    => $ubuntu,
    'flavor'   => $twoGbFlavor
));
} catch (\Guzzle\Http\Exception\BadResponseException $e) {

// No! Something failed. Let's find out:

$responseBody = (string) $e->getResponse()->getBody();
$statusCode   = $e->getResponse()->getStatusCode();
$headers      = $e->getResponse()->getHeaderLines();

echo sprintf("Status: %s\nBody: %s\nHeaders: %s", $statusCode, $responseBody, implode(', ', $headers));
}

This would be a polling function:

use OpenCloud\Compute\Constants\ServerState;

$callback = function($server) {
if (!empty($server->error)) {
    var_dump($server->error);
    exit;
} else {
    echo sprintf(
        "Waiting on %s/%-12s %4s%%",
        $server->name(),
        $server->status(),
        isset($server->progress) ? $server->progress : 0
    );
}
};

$server->waitFor(ServerState::ACTIVE, 600, $callback);
Matt Joyce
  • 2,010
  • 2
  • 20
  • 31