mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
made it through hackday, going back to start filling in rackspace specs
This commit is contained in:
parent
7f09aec594
commit
5376a7a4c4
15 changed files with 147 additions and 32 deletions
|
@ -21,19 +21,19 @@ unless Fog.mocking?
|
|||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'servers'<~Hash>:
|
||||
# * 'adminPass'<~String> - Admin password for server
|
||||
# * 'id'<~Integer> - Id of server
|
||||
# * 'name<~String> - Name of server
|
||||
# * 'imageId'<~Integer> - Id of image used to boot server
|
||||
# * 'flavorId'<~Integer> - Id of servers current flavor
|
||||
# * 'hostId'<~String>
|
||||
# * 'status'<~String> - Current server status
|
||||
# * 'progress'<~Integer> - Progress through current status
|
||||
# * 'server'<~Hash>:
|
||||
# * 'addresses'<~Hash>:
|
||||
# * 'public'<~Array> - public address strings
|
||||
# * 'private'<~Array> - private address strings
|
||||
# * 'adminPass'<~String> - Admin password for server
|
||||
# * 'flavorId'<~Integer> - Id of servers current flavor
|
||||
# * 'hostId'<~String>
|
||||
# * 'id'<~Integer> - Id of server
|
||||
# * 'imageId'<~Integer> - Id of image used to boot server
|
||||
# * 'metadata'<~Hash> - metadata
|
||||
# * 'name<~String> - Name of server
|
||||
# * 'progress'<~Integer> - Progress through current status
|
||||
# * 'status'<~String> - Current server status
|
||||
def create_server(flavor_id, image_id, options = {})
|
||||
data = {
|
||||
'server' => {
|
||||
|
|
|
@ -4,23 +4,23 @@ unless Fog.mocking?
|
|||
module Rackspace
|
||||
class Servers
|
||||
|
||||
# List server details for id
|
||||
# Get details about a server
|
||||
#
|
||||
# ==== Returns
|
||||
# * response<~Fog::AWS::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'servers'<~Array>:
|
||||
# * 'id'<~Integer> - Id of server
|
||||
# * 'name<~String> - Name of server
|
||||
# * 'imageId'<~Integer> - Id of image used to boot server
|
||||
# * 'flavorId'<~Integer> - Id of servers current flavor
|
||||
# * 'hostId'<~String>
|
||||
# * 'status'<~String> - Current server status
|
||||
# * 'progress'<~Integer> - Progress through current status
|
||||
# * 'server'<~Hash>:
|
||||
# * 'addresses'<~Hash>:
|
||||
# * 'public'<~Array> - public address strings
|
||||
# * 'private'<~Array> - private address strings
|
||||
# * 'flavorId'<~Integer> - Id of servers current flavor
|
||||
# * 'hostId'<~String>
|
||||
# * 'id'<~Integer> - Id of server
|
||||
# * 'imageId'<~Integer> - Id of image used to boot server
|
||||
# * 'metadata'<~Hash> - metadata
|
||||
# * 'name<~String> - Name of server
|
||||
# * 'progress'<~Integer> - Progress through current status
|
||||
# * 'status'<~String> - Current server status
|
||||
def get_server_details(id)
|
||||
request(
|
||||
:expects => 200,
|
||||
|
|
|
@ -7,11 +7,12 @@ unless Fog.mocking?
|
|||
# Update an existing server
|
||||
#
|
||||
# ==== Parameters
|
||||
# # server_id<~Integer> - Id of server to update
|
||||
# * options<~Hash>:
|
||||
# * name<~String> - New name for server
|
||||
# * adminPass<~String> - New admin password for server
|
||||
#
|
||||
def update_server(options = {})
|
||||
def update_server(server_id, options = {})
|
||||
request(
|
||||
:body => options.to_json,
|
||||
:expects => 204,
|
||||
|
|
|
@ -8,6 +8,7 @@ describe 'EC2.run_instances' do
|
|||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
# ami-5ee70037 = gentoo
|
||||
actual = ec2.run_instances('ami-5ee70037', 1, 1)
|
||||
@instance_id = actual.body['instancesSet'].first['instanceId']
|
||||
actual.body['groupSet'].should be_an(Array)
|
||||
|
|
12
spec/rackspace/requests/servers/create_image_spec.rb
Normal file
12
spec/rackspace/requests/servers/create_image_spec.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Rackspace::Servers.create_image' do
|
||||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.create_image(id)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -3,18 +3,30 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'Rackspace::Servers.create_server' do
|
||||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
# flavor 1 = 256
|
||||
# image 3 = gentoo 2008.0
|
||||
data = servers.create_server(1, 3)
|
||||
p data
|
||||
while true do
|
||||
sleep(1)
|
||||
details = servers.list_servers_details.body
|
||||
p details['servers'].first['progress']
|
||||
break if details['servers'].first['status'] == 'ACTIVE'
|
||||
after(:each) do
|
||||
eventually(128) do
|
||||
servers.delete_server(@server_id)
|
||||
end
|
||||
servers.delete_server(data.body['server']['id'])
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
actual = servers.create_server(1, 3).body['server']
|
||||
@server_id = actual['id']
|
||||
actual['addresses'].should be_a(Hash)
|
||||
actual['addresses']['private'].should be_an(Array)
|
||||
actual['addresses']['private'].first.should be_a(String)
|
||||
actual['addresses']['public'].should be_an(Array)
|
||||
actual['addresses']['public'].first.should be_a(String)
|
||||
actual['adminPass'].should be_a(String)
|
||||
actual['flavorId'].should be_an(Integer)
|
||||
actual['hostId'].should be_a(String)
|
||||
actual['id'].should be_an(Integer)
|
||||
actual['imageId'].should be_an(Integer)
|
||||
actual['metadata'].should be_a(Hash)
|
||||
actual['name'].should be_a(String)
|
||||
actual['progress'].should be_an(Integer)
|
||||
actual['status'].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
12
spec/rackspace/requests/servers/delete_image.rb
Normal file
12
spec/rackspace/requests/servers/delete_image.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Rackspace::Servers.delete_image' do
|
||||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.delete_image(id)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
|
@ -3,8 +3,24 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'Rackspace::Servers.delete_server' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
@server_id = servers.create_server(1, 3).body['server']['id']
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
p servers.delete_server(id)
|
||||
eventually(128) do
|
||||
servers.delete_server(@server_id)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
describe 'failure' do
|
||||
|
||||
it "should raise a NotFound error if the server does not exist" do
|
||||
lambda {
|
||||
servers.delete_server(0)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -3,8 +3,41 @@ require File.dirname(__FILE__) + '/../../../spec_helper'
|
|||
describe 'Rackspace::Servers.get_server_details' do
|
||||
describe 'success' do
|
||||
|
||||
before(:each) do
|
||||
# flavor 1 = 256, image 3 = gentoo 2008.0
|
||||
@server_id = servers.create_server(1, 3).body['server']['id']
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
eventually(128) do
|
||||
servers.delete_server(@server_id)
|
||||
end
|
||||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
p servers.get_server_details(id)
|
||||
actual = servers.get_server_details(@server_id).body['server']
|
||||
actual['addresses'].should be_a(Hash)
|
||||
actual['addresses']['private'].should be_an(Array)
|
||||
actual['addresses']['private'].first.should be_a(String)
|
||||
actual['addresses']['public'].should be_an(Array)
|
||||
actual['addresses']['public'].first.should be_a(String)
|
||||
actual['flavorId'].should be_an(Integer)
|
||||
actual['hostId'].should be_a(String)
|
||||
actual['id'].should be_an(Integer)
|
||||
actual['imageId'].should be_an(Integer)
|
||||
actual['metadata'].should be_a(Hash)
|
||||
actual['name'].should be_a(String)
|
||||
actual['progress'].should be_an(Integer)
|
||||
actual['status'].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
describe 'failure' do
|
||||
|
||||
it "should raise a NotFound error if the server does not exist" do
|
||||
lambda {
|
||||
servers.get_server_details(0)
|
||||
}.should raise_error(Fog::Errors::NotFound)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'Rackspace::Servers.list_flavors' do
|
|||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.list_flavors
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'Rackspace::Servers.list_images' do
|
|||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.list_images
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'Rackspace::Servers.list_servers_details' do
|
|||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.list_servers_details
|
||||
end
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ describe 'Rackspace::Servers.list_servers' do
|
|||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.list_servers
|
||||
end
|
||||
|
||||
|
|
12
spec/rackspace/requests/servers/reboot_server.rb
Normal file
12
spec/rackspace/requests/servers/reboot_server.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Rackspace::Servers.reboot_server' do
|
||||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.reboot_server(id, 'HARD')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
12
spec/rackspace/requests/servers/update_server.rb
Normal file
12
spec/rackspace/requests/servers/update_server.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
require File.dirname(__FILE__) + '/../../../spec_helper'
|
||||
|
||||
describe 'Rackspace::Servers.update_server' do
|
||||
describe 'success' do
|
||||
|
||||
it "should return proper attributes" do
|
||||
pending
|
||||
p servers.update_server(id, :name => 'foo', :adminPass => 'bar')
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Add table
Reference in a new issue