зеркало из https://github.com/microsoft/fog.git
fixes for shared server specs, and get them passing for rackspace
This commit is contained in:
Родитель
63d939f6ed
Коммит
15df1eb96e
|
@ -6,33 +6,44 @@ module Fog
|
||||||
|
|
||||||
identity :id
|
identity :id
|
||||||
|
|
||||||
attribute :admin_pass, 'adminPass'
|
attribute :addresses
|
||||||
attribute :name
|
attribute :password, 'adminPass'
|
||||||
attribute :image_id, 'imageId'
|
|
||||||
attribute :flavor_id, 'flavorId'
|
attribute :flavor_id, 'flavorId'
|
||||||
attribute :host_id, 'hostId'
|
attribute :host_id, 'hostId'
|
||||||
attribute :status
|
attribute :image_id, 'imageId'
|
||||||
|
attribute :metadata
|
||||||
|
attribute :name
|
||||||
attribute :personality
|
attribute :personality
|
||||||
attribute :progress
|
attribute :progress
|
||||||
attribute :addresses
|
attribute :status
|
||||||
attribute :metadata
|
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
|
|
||||||
connection.delete_server(@id)
|
connection.delete_server(@id)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def flavor
|
||||||
|
requires :flavor_id
|
||||||
|
connection.flavors.get(@flavor_id)
|
||||||
|
end
|
||||||
|
|
||||||
|
def image
|
||||||
|
requires :image_id
|
||||||
|
connection.images.get(@image_id)
|
||||||
|
end
|
||||||
|
|
||||||
def images
|
def images
|
||||||
requires :id
|
requires :id
|
||||||
|
|
||||||
connection.images(:server => self)
|
connection.images(:server => self)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def ready?
|
||||||
|
@status == 'ACTIVE'
|
||||||
|
end
|
||||||
|
|
||||||
def reboot(type = 'SOFT')
|
def reboot(type = 'SOFT')
|
||||||
requires :id
|
requires :id
|
||||||
|
|
||||||
connection.reboot_server(@id, type)
|
connection.reboot_server(@id, type)
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,7 +23,9 @@ module Fog
|
||||||
end
|
end
|
||||||
|
|
||||||
def get(server_id)
|
def get(server_id)
|
||||||
connection.get_server_details(server_id)
|
if server = connection.get_server_details(server_id).body['server']
|
||||||
|
new(server)
|
||||||
|
end
|
||||||
rescue Excon::Errors::NotFound
|
rescue Excon::Errors::NotFound
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,14 +13,15 @@ describe 'Fog::AWS::EC2::Server' do
|
||||||
|
|
||||||
after(:each) do
|
after(:each) do
|
||||||
if @server && !@server.new_record?
|
if @server && !@server.new_record?
|
||||||
eventually { @server.destroy }
|
@server.wait_for { ready? }
|
||||||
|
@server.destroy.should be_true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#initialize" do
|
describe "#initialize" do
|
||||||
|
|
||||||
it "should remap attributes from parser" do
|
it "should remap attributes from parser" do
|
||||||
server = ec2.servers.new({
|
server = @servers.new({
|
||||||
'amiLaunchIndex' => 'ami_launch_index',
|
'amiLaunchIndex' => 'ami_launch_index',
|
||||||
'dnsName' => 'dns_name',
|
'dnsName' => 'dns_name',
|
||||||
'groupId' => 'group_id',
|
'groupId' => 'group_id',
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||||
|
require File.dirname(__FILE__) + '/../../../shared_examples/server_examples'
|
||||||
|
|
||||||
|
describe 'Fog::AWS::EC2::Server' do
|
||||||
|
|
||||||
|
it_should_behave_like "Server"
|
||||||
|
|
||||||
|
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||||
|
subject { @server = @servers.new(:flavor_id => 1, :image_id => 3, :name => 'name') }
|
||||||
|
|
||||||
|
before(:each) do
|
||||||
|
@servers = servers.servers
|
||||||
|
end
|
||||||
|
|
||||||
|
after(:each) do
|
||||||
|
if @server && !@server.new_record?
|
||||||
|
@server.wait_for { ready? }
|
||||||
|
@server.destroy.should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe "#initialize" do
|
||||||
|
|
||||||
|
it "should remap attributes from parser" do
|
||||||
|
server = @servers.new({
|
||||||
|
'addresses' => 'addresses',
|
||||||
|
'adminPass' => 'password',
|
||||||
|
'flavorId' => 'flavor_id',
|
||||||
|
'hostId' => 'host_id',
|
||||||
|
'imageId' => 'image_id',
|
||||||
|
'metadata' => 'metadata',
|
||||||
|
'name' => 'name',
|
||||||
|
'personality' => 'personality',
|
||||||
|
'progress' => 'progress',
|
||||||
|
'status' => 'status'
|
||||||
|
})
|
||||||
|
server.addresses.should == 'addresses'
|
||||||
|
server.password.should == 'password'
|
||||||
|
server.flavor_id.should == 'flavor_id'
|
||||||
|
server.host_id.should == 'host_id'
|
||||||
|
server.image_id.should == 'image_id'
|
||||||
|
server.metadata.should == 'metadata'
|
||||||
|
server.name.should == 'name'
|
||||||
|
server.personality.should == 'personality'
|
||||||
|
server.progress.should == 'progress'
|
||||||
|
server.status.should == 'status'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
|
@ -1,10 +1,11 @@
|
||||||
shared_examples_for "Server" do
|
shared_examples_for "Server" do
|
||||||
|
|
||||||
describe "#destroy" do
|
describe "#reboot" do
|
||||||
|
|
||||||
it "should return true if the server is deleted" do
|
it "should succeed" do
|
||||||
subject.save
|
subject.save
|
||||||
subject.destroy.should be_true
|
subject.wait_for { ready? }
|
||||||
|
subject.reboot.should be_true
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -13,9 +14,8 @@ shared_examples_for "Server" do
|
||||||
|
|
||||||
it "should reset attributes to remote state" do
|
it "should reset attributes to remote state" do
|
||||||
subject.save
|
subject.save
|
||||||
eventually do
|
subject.wait_for { ready? }
|
||||||
@reloaded = subject.reload
|
@reloaded = subject.reload
|
||||||
end
|
|
||||||
subject.attributes.should == @reloaded.attributes
|
subject.attributes.should == @reloaded.attributes
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -33,9 +33,8 @@ shared_examples_for "Server" do
|
||||||
|
|
||||||
it "should exist remotely after save" do
|
it "should exist remotely after save" do
|
||||||
subject.save
|
subject.save
|
||||||
eventually do
|
subject.wait_for { ready? }
|
||||||
@servers.get(subject.id).should_not be_nil
|
@servers.get(subject.id).should_not be_nil
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Загрузка…
Ссылка в новой задаче