Created
October 29, 2012 23:45
-
-
Save chx/3977407 to your computer and use it in GitHub Desktop.
php script to create the server
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('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