5

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?

John Stauffer
  • 16,150
  • 10
  • 40
  • 35

1 Answers1

2

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
Jon Wood
  • 2,589
  • 1
  • 20
  • 17