mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[bbg] update specs and models to get shared_examples passing
This commit is contained in:
parent
676fb4d760
commit
a5907a9fdc
4 changed files with 18 additions and 43 deletions
|
@ -17,10 +17,12 @@ module Fog
|
|||
attribute :status
|
||||
attribute :flavor_id
|
||||
# attribute :image_id
|
||||
|
||||
attr_accessor :image_id
|
||||
attribute :template
|
||||
|
||||
# Not reported by the API, but used at create time
|
||||
attr_accessor :name, :password, :hash, :text, :error
|
||||
attr_accessor :name, :password, :ssh_key
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
|
@ -49,8 +51,15 @@ module Fog
|
|||
end
|
||||
|
||||
def save
|
||||
requires :flavor_id, :image_id, :name, :password
|
||||
data = connection.create_block(@flavor_id, @image_id, @name, @password)
|
||||
requires :flavor_id, :image_id, :name
|
||||
options = if !@password && !@ssh_key
|
||||
raise(ArgumentError, "password or ssh_key is required for this operation")
|
||||
elsif @ssh_key
|
||||
{'ssh_key' => @ssh_key}
|
||||
elsif @password
|
||||
{'password' => @password}
|
||||
end
|
||||
data = connection.create_block(@flavor_id, @image_id, @name, options)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
|
|
@ -5,12 +5,10 @@ describe 'Fog::Bluebox::Server' do
|
|||
|
||||
it_should_behave_like "Server"
|
||||
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
subject {
|
||||
@flavor_id = "94fd37a7-2606-47f7-84d5-9000deda52ae" # Block 1GB Virtual Server
|
||||
@image_id = "03807e08-a13d-44e4-b011-ebec7ef2c928" # Ubuntu 10.04 x64 LTS
|
||||
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
||||
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :name => Time.now.to_i.to_s, :password => "chunkybacon")
|
||||
@server
|
||||
}
|
||||
|
||||
before(:each) do
|
||||
|
@ -24,29 +22,4 @@ describe 'Fog::Bluebox::Server' do
|
|||
end
|
||||
end
|
||||
|
||||
describe "#initialize" do
|
||||
|
||||
it "should remap attributes from parser" do
|
||||
server = @servers.new({
|
||||
'ips' => 'ips',
|
||||
'image_id' => 'image_id',
|
||||
'flavor_id' => 'flavor_id',
|
||||
'cpu' => 'cpu',
|
||||
'memory' => 'memory',
|
||||
'storage' => 'storage',
|
||||
'hostname' => 'hostname',
|
||||
'status' => 'status'
|
||||
})
|
||||
server.ips.should == 'ips'
|
||||
server.flavor_id.should == 'flavor_id'
|
||||
server.image_id.should == 'image_id'
|
||||
server.cpu.should == 'cpu'
|
||||
server.memory.should == 'memory'
|
||||
server.storage.should == 'storage'
|
||||
server.hostname.should == 'hostname'
|
||||
server.status.should == 'status'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,17 +5,10 @@ describe 'Fog::Bluebox::Servers' do
|
|||
|
||||
it_should_behave_like "Servers"
|
||||
|
||||
it "should have the proper status after a create call" do
|
||||
subject.save
|
||||
new_server = @servers.get(subject.id)
|
||||
subject.status.should == "queued"
|
||||
new_server.status.should == "queued"
|
||||
end
|
||||
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
subject {
|
||||
@flavor_id = "94fd37a7-2606-47f7-84d5-9000deda52ae" # Block 1GB Virtual Server
|
||||
@image_id = "03807e08-a13d-44e4-b011-ebec7ef2c928" # Ubuntu 10.04 x64 LTS
|
||||
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||
@image_id = 'a00baa8f-b5d0-4815-8238-b471c4c4bf72' # Ubuntu 9.10 64bit
|
||||
@server = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :name => Time.now.to_i.to_s, :password => "chunkybacon")
|
||||
@server
|
||||
}
|
||||
|
|
|
@ -74,8 +74,8 @@ module Bluebox
|
|||
class << self
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
credentials = Fog.credentials.reject do |k, v|
|
||||
![:bluebox_api_key, :bluebox_host, :bluebox_port, :bluebox_scheme].include?(k)
|
||||
credentials = Fog.credentials.reject do |k,v|
|
||||
![:bluebox_api_key, :bluebox_customer_id].include?(k)
|
||||
end
|
||||
hash[key] = case key
|
||||
when :blocks
|
||||
|
|
Loading…
Reference in a new issue