Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Rackspace Cloud Servers API "personality" field work?

I'm using the Ruby binding to the CloudServers API to spin up a cluster of machines.

The API includes the ability to "inject" files into the filesystem of the newly created machine, using a field called "personality". However, I'm not able to upload files via the "personality" key. The machine is created properly, but the file is not present when the server is created.

Here's a test script that demonstrates this:

 #!/usr/bin/env ruby
 require 'rubygems'
 require 'cloudservers'

 cs = CloudServers::Connection.new(:username=>"user",:api_key=>"key")

 begin
   server = cs.create_server(:flavorId=>1,
                :name=>"personality-test",
                :imageId=>7888402,
                :personality=>{"/tmp/foo"=>"/tmp/foo" })
 rescue
   print "Failed to create server ", $!, "\n"
 end

Has anyone been able to make this work?

like image 351
John Stauffer Avatar asked Nov 06 '22 04:11

John Stauffer


1 Answers

I'm not sure which library you're using, but I've successfully used personalities via Fog's Rackspace Cloud backend.

server = Fog::Compute.new(:provider => 'Rackspace',
                          :rackspace_username => config[:rackspace_api_username], 
                          :rackspace_api_key => config[:rackspace_api_key])
server.flavor_id = sizes[args[:size]]
server.image_id = 49 # Ubuntu 10.04
server.name = args[:fqdn]

server.personality = [ 
  {  
    'path' => '/etc/install-chef', 
    'contents' => File.read("install-chef.sh")
  }
]
server.save
like image 161
Jon Wood Avatar answered Nov 15 '22 02:11

Jon Wood