开发者

Does Rackspace Cloud Servers API "personality" field work?

开发者 https://www.devze.com 2023-02-06 02:25 出处:网络
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

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?


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
0

精彩评论

暂无评论...
验证码 换一张
取 消