Created
April 29, 2015 19:29
-
-
Save notFloran/60d6095443078eee8884 to your computer and use it in GitHub Desktop.
PHP script to create a server on Runabove with php-opencloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require 'vendor/autoload.php'; | |
use OpenCloud\OpenStack; | |
use Guzzle\Http\Exception\BadResponseException; | |
$client = new OpenStack('https://auth.runabove.io/v2.0/', array( | |
'username' => '', // email | |
'password' => '', | |
'tenantName' => '' // get it on horizon - 8 digits | |
)); | |
// Region : SGB-1 - BHS-1 | |
$service = $client->computeService('nova', 'SBG-1'); | |
// 3. Get empty server | |
$server = $service->server(); | |
// 4. Create | |
try { | |
$response = $server->create(array( | |
'name' => 'Test', | |
'imageId' => '1f3b49ad-3566-4838-93f8-b657a36b870f', // Debian 8 | |
'flavorId' => '8f79ef0d-59ad-4792-82cd-829e0bb94f6b' // ra.intel.ha.s | |
)); | |
} catch (BadResponseException $e) { | |
echo $e->getResponse(); | |
} | |
$body = json_decode($response->getBody(true)); | |
// THIS IS YOUR ROOT PASSWORD - DO NOT LOSE! | |
$password = $body->server->adminPass; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment