Skip to content

Instantly share code, notes, and snippets.

@chx
Created October 29, 2012 23:45
Show Gist options
  • Save chx/3977407 to your computer and use it in GitHub Desktop.
Save chx/3977407 to your computer and use it in GitHub Desktop.
php script to create the server
<?php
require('rackspace.inc');
$conn = new OpenCloud\Rackspace(
'https://identity.api.rackspacecloud.com/v2.0/',
array(
'username' => '',
'apiKey' => '',
'tenantName' => 'this is your account number'
));
$compute = $conn->Compute('cloudServersOpenStack', 'DFW', 'publicURL');
$server = $compute->Server();
$image = $compute->Image('');
// 512: flavor 2.
$flavor = $compute->flavor('2');
exec("hostname -i|sed 's/ /\\n/g'|grep -F '10.'", $output);
// Check it worked.
print $output[0] ."\n";
// really, why doesn't the class encode??
$server->addFile('/etc/ssh/master/ip', base64_encode($output[0]));
$server->Create(array(
'name' => 'something',
'image' => $image,
'flavor' => $flavor));
printf("The root password is %s\n", $server->adminPass);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment