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 :status
|
||||||
attribute :flavor_id
|
attribute :flavor_id
|
||||||
# attribute :image_id
|
# attribute :image_id
|
||||||
|
|
||||||
|
attr_accessor :image_id
|
||||||
attribute :template
|
attribute :template
|
||||||
|
|
||||||
# Not reported by the API, but used at create time
|
# 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
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
|
@ -49,8 +51,15 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
requires :flavor_id, :image_id, :name, :password
|
requires :flavor_id, :image_id, :name
|
||||||
data = connection.create_block(@flavor_id, @image_id, @name, @password)
|
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)
|
merge_attributes(data.body)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,12 +5,10 @@ describe 'Fog::Bluebox::Server' do
|
||||||
|
|
||||||
it_should_behave_like "Server"
|
it_should_behave_like "Server"
|
||||||
|
|
||||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
|
||||||
subject {
|
subject {
|
||||||
@flavor_id = "94fd37a7-2606-47f7-84d5-9000deda52ae" # Block 1GB Virtual Server
|
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||||
@image_id = "03807e08-a13d-44e4-b011-ebec7ef2c928" # Ubuntu 10.04 x64 LTS
|
@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 = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :name => Time.now.to_i.to_s, :password => "chunkybacon")
|
||||||
@server
|
|
||||||
}
|
}
|
||||||
|
|
||||||
before(:each) do
|
before(:each) do
|
||||||
|
@ -24,29 +22,4 @@ describe 'Fog::Bluebox::Server' do
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
@ -5,17 +5,10 @@ describe 'Fog::Bluebox::Servers' do
|
||||||
|
|
||||||
it_should_behave_like "Servers"
|
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
|
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||||
subject {
|
subject {
|
||||||
@flavor_id = "94fd37a7-2606-47f7-84d5-9000deda52ae" # Block 1GB Virtual Server
|
@flavor_id = '94fd37a7-2606-47f7-84d5-9000deda52ae' # Block 1GB Virtual Server
|
||||||
@image_id = "03807e08-a13d-44e4-b011-ebec7ef2c928" # Ubuntu 10.04 x64 LTS
|
@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 = @servers.new(:flavor_id => @flavor_id, :image_id => @image_id, :name => Time.now.to_i.to_s, :password => "chunkybacon")
|
||||||
@server
|
@server
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ module Bluebox
|
||||||
def [](service)
|
def [](service)
|
||||||
@@connections ||= Hash.new do |hash, key|
|
@@connections ||= Hash.new do |hash, key|
|
||||||
credentials = Fog.credentials.reject do |k,v|
|
credentials = Fog.credentials.reject do |k,v|
|
||||||
![:bluebox_api_key, :bluebox_host, :bluebox_port, :bluebox_scheme].include?(k)
|
![:bluebox_api_key, :bluebox_customer_id].include?(k)
|
||||||
end
|
end
|
||||||
hash[key] = case key
|
hash[key] = case key
|
||||||
when :blocks
|
when :blocks
|
||||||
|
|
Loading…
Reference in a new issue