profitbricks 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +4 -0
- data/Manifest.txt +2 -6
- data/README.md +6 -6
- data/lib/profitbricks.rb +1 -1
- data/lib/profitbricks/profitbricks.rb +4 -5
- data/lib/profitbricks/server.rb +9 -25
- data/spec/fixtures/{power_off_server → stop_server}/success.json +0 -0
- data/spec/fixtures/stop_server/success.xml +1 -0
- data/spec/live/data_center_spec.rb +2 -2
- data/spec/profitbricks/cli_spec.rb +1 -1
- data/spec/profitbricks/data_center_spec.rb +1 -1
- data/spec/profitbricks/load_balancer_spec.rb +2 -2
- data/spec/profitbricks/nic_spec.rb +2 -2
- data/spec/profitbricks/server_spec.rb +13 -27
- data/spec/profitbricks/storage_spec.rb +3 -3
- data/spec/spec_helper.rb +13 -0
- metadata +24 -14
- checksums.yaml +0 -7
- data/spec/fixtures/power_off_server/success.xml +0 -1
- data/spec/fixtures/reboot_server/success.json +0 -1
- data/spec/fixtures/reboot_server/success.xml +0 -1
- data/spec/fixtures/shutdown_server/success.json +0 -1
- data/spec/fixtures/shutdown_server/success.xml +0 -1
data/CHANGELOG.md
CHANGED
data/Manifest.txt
CHANGED
@@ -112,10 +112,6 @@ spec/fixtures/get_storage/mount_image.json
|
|
112
112
|
spec/fixtures/get_storage/mount_image.xml
|
113
113
|
spec/fixtures/get_storage/success.json
|
114
114
|
spec/fixtures/get_storage/success.xml
|
115
|
-
spec/fixtures/power_off_server/success.json
|
116
|
-
spec/fixtures/power_off_server/success.xml
|
117
|
-
spec/fixtures/reboot_server/success.json
|
118
|
-
spec/fixtures/reboot_server/success.xml
|
119
115
|
spec/fixtures/register_servers_on_load_balancer/success.json
|
120
116
|
spec/fixtures/register_servers_on_load_balancer/success.xml
|
121
117
|
spec/fixtures/release_public_ip_block/success.json
|
@@ -132,10 +128,10 @@ spec/fixtures/set_image_os_type/success.json
|
|
132
128
|
spec/fixtures/set_image_os_type/success.xml
|
133
129
|
spec/fixtures/set_internet_access/success.json
|
134
130
|
spec/fixtures/set_internet_access/success.xml
|
135
|
-
spec/fixtures/shutdown_server/success.json
|
136
|
-
spec/fixtures/shutdown_server/success.xml
|
137
131
|
spec/fixtures/start_server/success.json
|
138
132
|
spec/fixtures/start_server/success.xml
|
133
|
+
spec/fixtures/stop_server/success.json
|
134
|
+
spec/fixtures/stop_server/success.xml
|
139
135
|
spec/fixtures/update_data_center/success.json
|
140
136
|
spec/fixtures/update_data_center/success.xml
|
141
137
|
spec/fixtures/update_load_balancer/success.json
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# Profitbricks [](http://travis-ci.org/profitbricks/profitbricks-rb) [](https://coveralls.io/r/profitbricks/profitbricks-rb) [](https://codeclimate.com/github/dsander/profitbricks-rb)
|
2
2
|
|
3
|
-
*
|
4
|
-
* http://rubydoc.info/github/
|
3
|
+
* https://github.com/profitbricks/profitbricks-rb
|
4
|
+
* http://rubydoc.info/github/profitbricks/profitbricks-rb/master/frames
|
5
5
|
|
6
6
|
|
7
7
|
## DESCRIPTION
|
@@ -50,17 +50,17 @@ Check out the examples directory for more detailed usage information, or have a
|
|
50
50
|
## CLI
|
51
51
|
|
52
52
|
To use the profitbricks binary you first have to store your username and password in environment variables
|
53
|
-
|
53
|
+
|
54
54
|
export PROFITBRICKS_USER=yourusername
|
55
55
|
export PROFITBRICKS_PASSWORD=yourpassword
|
56
56
|
|
57
57
|
The binary always takes at least two arguments. The first represents a class name (in snake- or camel-case) and the second a method name of this class.
|
58
58
|
Get a list of all your datacenters:
|
59
|
-
|
59
|
+
|
60
60
|
profitbricks data_center all
|
61
61
|
|
62
62
|
The following arguments are coverted into a Hash and passed to the method, if you want to call instance methods you _have_ to provide the id of the Server/DataCenter, etc:
|
63
|
-
|
63
|
+
|
64
64
|
profitbricks server update id=03h17g46-3040-d1af-bb01-9579fe0300e7 cores=2 ram=1024
|
65
65
|
|
66
66
|
## License
|
data/lib/profitbricks.rb
CHANGED
@@ -4,7 +4,6 @@ module Profitbricks
|
|
4
4
|
NEED_PREFIX = [:create_nic, :create_load_balancer, :update_storage, :create_storage,
|
5
5
|
:update_data_center, :rom_drive, :update_nic, :create_server,
|
6
6
|
:update_load_balancer, :connect_storage_to_server, :update_server]
|
7
|
-
|
8
7
|
# Configure the Profitbricks API client
|
9
8
|
#
|
10
9
|
# @see Profitbricks::Config
|
@@ -19,13 +18,13 @@ module Profitbricks
|
|
19
18
|
|
20
19
|
@client = Savon::Client.new do |globals|
|
21
20
|
# FIXME the WSDL currently returns a wrong endpoint
|
22
|
-
|
23
|
-
globals.namespace "http://ws.api.profitbricks.com/"
|
24
|
-
globals.endpoint "https://api.profitbricks.com/1.2"
|
21
|
+
globals.wsdl "https://api.profitbricks.com/1.2/wsdl"
|
25
22
|
globals.convert_request_keys_to :lower_camelcase
|
26
23
|
globals.raise_errors true
|
27
24
|
globals.log Profitbricks::Config.log
|
28
25
|
globals.pretty_print_xml true
|
26
|
+
globals.open_timeout 5
|
27
|
+
globals.read_timeout 5
|
29
28
|
|
30
29
|
# Looks like ssl verifycation works with current jruby
|
31
30
|
#if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && !ENV['SSL_CERT_DIR']
|
@@ -50,7 +49,7 @@ module Profitbricks
|
|
50
49
|
def self.request(method, options={})
|
51
50
|
begin
|
52
51
|
message = if NEED_PREFIX.include? method
|
53
|
-
{
|
52
|
+
{ request: options }
|
54
53
|
else
|
55
54
|
options
|
56
55
|
end
|
data/lib/profitbricks/server.rb
CHANGED
@@ -3,20 +3,12 @@ module Profitbricks
|
|
3
3
|
has_many :nics
|
4
4
|
has_many :connected_storages, :class_name => :storage
|
5
5
|
|
6
|
-
# Deletes the virtual Server.
|
6
|
+
# Deletes the virtual Server.
|
7
7
|
# @return [Boolean] true on success, false otherwise
|
8
8
|
def delete
|
9
9
|
Profitbricks.request :delete_server, server_id: self.id
|
10
10
|
return true
|
11
11
|
end
|
12
|
-
|
13
|
-
# Reboots an existing virtual server (SOFT REBOOT).
|
14
|
-
# @return [Boolean] true on success, false otherwise
|
15
|
-
def reboot
|
16
|
-
@virtual_machine_state = 'NOSTATE'
|
17
|
-
Profitbricks.request :reboot_server, server_id: self.id
|
18
|
-
return true
|
19
|
-
end
|
20
12
|
|
21
13
|
# Resets an existing virtual server (POWER CYCLE).
|
22
14
|
# @return [Boolean] true on success, false otherwise
|
@@ -34,23 +26,15 @@ module Profitbricks
|
|
34
26
|
return true
|
35
27
|
end
|
36
28
|
|
37
|
-
# Stops an existing virtual server (HARD power off)
|
29
|
+
# Stops an existing virtual server (HARD power off)
|
38
30
|
# @return [Boolean] true on success, false otherwise
|
39
|
-
def
|
31
|
+
def stop
|
40
32
|
@virtual_machine_state = 'SHUTOFF'
|
41
|
-
Profitbricks.request :
|
33
|
+
Profitbricks.request :stop_server, server_id: self.id
|
42
34
|
return true
|
43
35
|
end
|
44
36
|
|
45
|
-
#
|
46
|
-
# @return [Boolean] true on success, false otherwise
|
47
|
-
def shutdown
|
48
|
-
@virtual_machine_state = 'SHUTDOWN'
|
49
|
-
Profitbricks.request :shutdown_server, server_id: self.id
|
50
|
-
return true
|
51
|
-
end
|
52
|
-
|
53
|
-
# Updates parameters of an existing virtual Server device.
|
37
|
+
# Updates parameters of an existing virtual Server device.
|
54
38
|
# @param [Hash] options parameters for the new server
|
55
39
|
# @option options [Fixnum] :cores Number of cores to be assigned to the specified server.
|
56
40
|
# @option options [Fixnum] :ram Number of RAM memory (in MiB) to be assigned to the server. Must be at least 256 and a multiple of it.
|
@@ -129,15 +113,15 @@ module Profitbricks
|
|
129
113
|
|
130
114
|
class << self
|
131
115
|
# Returns a list of all Servers created by the user.
|
132
|
-
#
|
116
|
+
#
|
133
117
|
# @return [Array <Server>] Array of all available Servers
|
134
118
|
def all
|
135
119
|
DataCenter.all.collect(&:servers).flatten.compact
|
136
120
|
end
|
137
121
|
|
138
|
-
# Creates a Virtual Server within an existing data center. Parameters can be specified to set up a
|
122
|
+
# Creates a Virtual Server within an existing data center. Parameters can be specified to set up a
|
139
123
|
# boot device and connect the server to an existing LAN or the Internet.
|
140
|
-
#
|
124
|
+
#
|
141
125
|
# @param [Hash] options parameters for the new server
|
142
126
|
# @option options [Fixnum] :cores Number of cores to be assigned to the specified server (required)
|
143
127
|
# @option options [Fixnum] :ram Number of RAM memory (in MiB) to be assigned to the server. Must be at least 256 and a multiple of it. (required)
|
@@ -180,6 +164,6 @@ module Profitbricks
|
|
180
164
|
def filter_nics_and_return_ips(&block)
|
181
165
|
return [] if self.nics.nil?
|
182
166
|
self.nics.select { |nic| yield nic }.collect(&:ips).flatten
|
183
|
-
end
|
167
|
+
end
|
184
168
|
end
|
185
169
|
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:stopServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50055</requestId></return></ns2:stopServerResponse></S:Body></S:Envelope>
|
@@ -21,11 +21,11 @@ describe Profitbricks::DataCenter do
|
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should return all DataCenters" do
|
24
|
-
DataCenter.all.length.should
|
24
|
+
DataCenter.all.length.should >= 1
|
25
25
|
end
|
26
26
|
|
27
27
|
it "should be found by name" do
|
28
|
-
DataCenter.find(name: 'PB_live_test_DC').id.
|
28
|
+
DataCenter.find(name: 'PB_live_test_DC').id.should_not be_nil
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should be renamed" do
|
@@ -67,7 +67,7 @@ describe Profitbricks::CLI do
|
|
67
67
|
|
68
68
|
it "should update a server" do
|
69
69
|
savon.expects(:get_server).with(message: {server_id: '1234-123'}).returns(f :get_server, :after_create)
|
70
|
-
savon.expects(:update_server).with(message: {
|
70
|
+
savon.expects(:update_server).with(message: {request: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f', server_name: 'meme', ram: 256, cores: 1}}).returns(f :update_server, :basic)
|
71
71
|
cli.run(%w(server update id=1234-123 name=meme ram=256 cores=1)).should == 0
|
72
72
|
end
|
73
73
|
end
|
@@ -73,7 +73,7 @@ describe Profitbricks::DataCenter do
|
|
73
73
|
dc.wait_for_provisioning
|
74
74
|
end
|
75
75
|
|
76
|
-
let(:rename_message) { {
|
76
|
+
let(:rename_message) { {request: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602', data_center_name: 'Test2'}} }
|
77
77
|
it "should rename a datacenter" do
|
78
78
|
savon.expects(:get_data_center).with(message: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_data_center, :two_servers_with_storage)
|
79
79
|
savon.expects(:update_data_center).with(message: rename_message).returns(f :update_data_center, :success)
|
@@ -9,7 +9,7 @@ describe Profitbricks::LoadBalancer do
|
|
9
9
|
let(:servers) { [Server.new(:id => "206d10f2-035f-4ef2-8d24-3022653e9706")]}
|
10
10
|
|
11
11
|
it "create a new LoadBalancer" do
|
12
|
-
create_msg = {
|
12
|
+
create_msg = {request: {data_center_id: "1111", name: "Test", server_ids: servers.collect(&:id), algorithm: 'ROUND_ROBIN'}}
|
13
13
|
savon.expects(:create_load_balancer).with(message: create_msg).returns(f :create_load_balancer, :success)
|
14
14
|
savon.expects(:get_load_balancer).with(message: {load_balancer_id: '5dadd2b2-3405-4ec5-a450-0df497bebab0'}).returns(f :get_load_balancer, :success)
|
15
15
|
lb = LoadBalancer.create(:data_center_id => "1111", :name => "Test", :servers => servers, :algorithm => 'ROUND_ROBIN')
|
@@ -20,7 +20,7 @@ describe Profitbricks::LoadBalancer do
|
|
20
20
|
|
21
21
|
it "should update an existing LoadBalancer" do
|
22
22
|
savon.expects(:get_load_balancer).with(message: {load_balancer_id: '5dadd2b2-3405-4ec5-a450-0df497bebab0'}).returns(f :get_load_balancer, :success)
|
23
|
-
savon.expects(:update_load_balancer).with(message: {
|
23
|
+
savon.expects(:update_load_balancer).with(message: {request: {load_balancer_id: '3e3cb642-4d50-4371-980a-65959b2fa428', load_balancer_name: 'Wee'}}).returns(f :update_load_balancer, :success)
|
24
24
|
savon.expects(:get_load_balancer).with(message: {load_balancer_id: '3e3cb642-4d50-4371-980a-65959b2fa428'}).returns(f :get_load_balancer, :success)
|
25
25
|
lb = LoadBalancer.find(:id => "5dadd2b2-3405-4ec5-a450-0df497bebab0")
|
26
26
|
lb.update(:name => "Wee").should == true
|
@@ -7,7 +7,7 @@ describe Profitbricks::Nic do
|
|
7
7
|
after(:all) { savon.unmock! }
|
8
8
|
|
9
9
|
it "create a new Nic" do
|
10
|
-
savon.expects(:create_nic).with(message: {
|
10
|
+
savon.expects(:create_nic).with(message: {request: {lan_id: 1, ip: '192.168.0.11', nic_name: 'Internal', server_id: '4cb6550f-3777-4818-8f4c-51233162a980'}}).returns(f :create_nic, :success)
|
11
11
|
savon.expects(:get_nic).with(message: {nic_id: 'cba8af39-b5de-477b-9795-2f02ea9cf04f'}).returns(f :get_nic, :success)
|
12
12
|
nic = Nic.create(:lan_id => 1, :ip => "192.168.0.11", :name => "Internal", :server_id => "4cb6550f-3777-4818-8f4c-51233162a980")
|
13
13
|
nic.name.should == "Internal"
|
@@ -17,7 +17,7 @@ describe Profitbricks::Nic do
|
|
17
17
|
|
18
18
|
it "should update an existing Nic" do
|
19
19
|
savon.expects(:get_nic).with(message: {nic_id: 'cba8af39-b5de-477b-9795-2f02ea9cf04f'}).returns(f :get_nic, :success)
|
20
|
-
savon.expects(:update_nic).with(message: {
|
20
|
+
savon.expects(:update_nic).with(message: {request: {nic_id: 'cba8af39-b5de-477b-9795-2f02ea9cf04f', nic_name: 'External'}}).returns(f :update_nic, :success)
|
21
21
|
nic = Nic.find(:id => "cba8af39-b5de-477b-9795-2f02ea9cf04f")
|
22
22
|
nic.update(:name => "External").should == true
|
23
23
|
nic.name.should == "External"
|
@@ -5,8 +5,8 @@ describe Profitbricks::Server do
|
|
5
5
|
|
6
6
|
before(:all) { savon.mock! }
|
7
7
|
after(:all) { savon.unmock! }
|
8
|
-
|
9
|
-
describe "enforcing required arguments" do
|
8
|
+
|
9
|
+
describe "enforcing required arguments" do
|
10
10
|
describe "on create" do
|
11
11
|
it "should require :cores and :ram" do
|
12
12
|
expect { Server.create(:cores => 1) }.to raise_error(ArgumentError, "You must provide :cores and :ram")
|
@@ -25,7 +25,7 @@ describe Profitbricks::Server do
|
|
25
25
|
raise_error(ArgumentError, ":availability_zone has to be either 'AUTO', 'ZONE_1', or 'ZONE_2'")
|
26
26
|
|
27
27
|
['AUTO', 'ZONE_1', 'ZONE_2'].each do |zone|
|
28
|
-
expect { Server.create(:ram => 256, :cores => 1, :availability_zone => zone) }.not_to
|
28
|
+
expect { Server.create(:ram => 256, :cores => 1, :availability_zone => zone) }.not_to
|
29
29
|
raise_error(ArgumentError, ":availability_zone has to be either 'AUTO', 'ZONE_1', or 'ZONE_2'")
|
30
30
|
end
|
31
31
|
end
|
@@ -35,14 +35,14 @@ describe Profitbricks::Server do
|
|
35
35
|
raise_error(ArgumentError, ":os_type has to be either 'WINDOWS' or 'OTHER'")
|
36
36
|
|
37
37
|
['WINDOWS', 'OTHER'].each do |type|
|
38
|
-
expect { Server.create(:ram => 256, :cores => 1, :os_type => type) }.not_to
|
38
|
+
expect { Server.create(:ram => 256, :cores => 1, :os_type => type) }.not_to
|
39
39
|
raise_error(ArgumentError, ":os_type has to be either 'WINDOWS' or 'OTHER'")
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
describe "on update" do
|
44
44
|
before(:each) do
|
45
|
-
savon.expects(:create_server).with(message: {
|
45
|
+
savon.expects(:create_server).with(message: {request: {ram: 256, cores: 1}}).returns(f :create_server, :minimal)
|
46
46
|
savon.expects(:get_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :get_server, :after_create)
|
47
47
|
@server = Server.create(:ram => 256, :cores => 1)
|
48
48
|
end
|
@@ -58,7 +58,7 @@ describe Profitbricks::Server do
|
|
58
58
|
raise_error(ArgumentError, ":availability_zone has to be either 'AUTO', 'ZONE_1', or 'ZONE_2'")
|
59
59
|
|
60
60
|
['AUTO', 'ZONE_1', 'ZONE_2'].each do |zone|
|
61
|
-
expect { @server.update(:ram => 256, :cores => 1, :availability_zone => zone) }.not_to
|
61
|
+
expect { @server.update(:ram => 256, :cores => 1, :availability_zone => zone) }.not_to
|
62
62
|
raise_error(ArgumentError, ":availability_zone has to be either 'AUTO', 'ZONE_1', or 'ZONE_2'")
|
63
63
|
end
|
64
64
|
end
|
@@ -68,7 +68,7 @@ describe Profitbricks::Server do
|
|
68
68
|
raise_error(ArgumentError, ":os_type has to be either 'WINDOWS' or 'OTHER'")
|
69
69
|
|
70
70
|
['WINDOWS', 'OTHER'].each do |type|
|
71
|
-
expect { @server.update(:ram => 256, :cores => 1, :os_type => type) }.not_to
|
71
|
+
expect { @server.update(:ram => 256, :cores => 1, :os_type => type) }.not_to
|
72
72
|
raise_error(ArgumentError, ":os_type has to be either 'WINDOWS' or 'OTHER'")
|
73
73
|
end
|
74
74
|
end
|
@@ -77,7 +77,7 @@ describe Profitbricks::Server do
|
|
77
77
|
|
78
78
|
|
79
79
|
it "should create a new server with minimal arguments" do
|
80
|
-
savon.expects(:create_server).with(message: {
|
80
|
+
savon.expects(:create_server).with(message: {request: {ram: 256, cores: 1, server_name: 'Test Server', data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}}).returns(f :create_server, :minimal)
|
81
81
|
savon.expects(:get_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :get_server, :after_create)
|
82
82
|
s = Server.create(:cores => 1, :ram => 256, :name => 'Test Server', :data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
83
83
|
s.cores.should == 1
|
@@ -86,13 +86,6 @@ describe Profitbricks::Server do
|
|
86
86
|
s.data_center_id.should == "b3eebede-5c78-417c-b1bc-ff5de01a0602"
|
87
87
|
end
|
88
88
|
|
89
|
-
it "should reboot on request" do
|
90
|
-
savon.expects(:get_server).with(message: {server_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_server, :after_create)
|
91
|
-
savon.expects(:reboot_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :reboot_server, :success)
|
92
|
-
s = Server.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
93
|
-
s.reboot.should == true
|
94
|
-
end
|
95
|
-
|
96
89
|
it "should reset on request" do
|
97
90
|
savon.expects(:get_server).with(message: {server_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_server, :after_create)
|
98
91
|
savon.expects(:reset_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :reset_server, :success)
|
@@ -109,16 +102,9 @@ describe Profitbricks::Server do
|
|
109
102
|
|
110
103
|
it "should power off on request" do
|
111
104
|
savon.expects(:get_server).with(message: {server_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_server, :after_create)
|
112
|
-
savon.expects(:
|
105
|
+
savon.expects(:stop_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :stop_server, :success)
|
113
106
|
s = Server.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
114
|
-
s.
|
115
|
-
end
|
116
|
-
|
117
|
-
it "should shutdown on request" do
|
118
|
-
savon.expects(:get_server).with(message: {server_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_server, :after_create)
|
119
|
-
savon.expects(:shutdown_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :shutdown_server, :success)
|
120
|
-
s = Server.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
121
|
-
s.shutdown.should == true
|
107
|
+
s.stop.should == true
|
122
108
|
end
|
123
109
|
|
124
110
|
it "should check if its running" do
|
@@ -141,7 +127,7 @@ describe Profitbricks::Server do
|
|
141
127
|
savon.expects(:get_server).with(message: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f'}).returns(f :get_server, :after_create)
|
142
128
|
s.provisioned?.should == false
|
143
129
|
end
|
144
|
-
|
130
|
+
|
145
131
|
it "should return true on provisioned?" do
|
146
132
|
savon.expects(:get_server).with(message: {server_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_server, :after_create)
|
147
133
|
s = Server.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
@@ -203,9 +189,9 @@ describe Profitbricks::Server do
|
|
203
189
|
end
|
204
190
|
|
205
191
|
describe "updating" do
|
206
|
-
it "should update basic attributes correctly" do
|
192
|
+
it "should update basic attributes correctly" do
|
207
193
|
savon.expects(:get_server).with(message: {server_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602'}).returns(f :get_server, :after_create)
|
208
|
-
savon.expects(:update_server).with(message: {
|
194
|
+
savon.expects(:update_server).with(message: {request: {server_id: 'b7a5f3d1-324a-4490-aa8e-56cdec436e3f', server_name: 'Power of two', os_type: 'WINDOWS', cores: 2, ram: 512}}).returns(f :update_server, :basic)
|
209
195
|
s = Server.find(:id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
210
196
|
s.update(:cores => 2, :ram => 512, :name => "Power of two", :os_type => 'WINDOWS')
|
211
197
|
s.cores.should == 2
|
@@ -7,7 +7,7 @@ describe Profitbricks::Storage do
|
|
7
7
|
after(:all) { savon.unmock! }
|
8
8
|
|
9
9
|
it "should create a new server with minimal arguments" do
|
10
|
-
savon.expects(:create_storage).with(message: {
|
10
|
+
savon.expects(:create_storage).with(message: {request: {data_center_id: 'b3eebede-5c78-417c-b1bc-ff5de01a0602', size: 5, storage_name: 'Test Storage'}}).returns(f :create_storage, :success)
|
11
11
|
savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
|
12
12
|
storage = Storage.create(:size => 5, :name => "Test Storage", :data_center_id => "b3eebede-5c78-417c-b1bc-ff5de01a0602")
|
13
13
|
storage.name.should == "Test Storage"
|
@@ -16,7 +16,7 @@ describe Profitbricks::Storage do
|
|
16
16
|
|
17
17
|
it "should be connectable to a server" do
|
18
18
|
savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
|
19
|
-
savon.expects(:connect_storage_to_server).with(message: {
|
19
|
+
savon.expects(:connect_storage_to_server).with(message: {request: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11', server_id: '4cb6550f-3777-4818-8f4c-51233162a980', bus_type: 'VIRTIO'}}).returns(f :connect_storage_to_server, :success)
|
20
20
|
savon.expects(:get_server).with(message: {server_id: '4cb6550f-3777-4818-8f4c-51233162a980'}).returns(f :get_server, :connected_storage)
|
21
21
|
storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
|
22
22
|
storage.connect(:server_id => "4cb6550f-3777-4818-8f4c-51233162a980", :bus_type => "VIRTIO").should == true
|
@@ -34,7 +34,7 @@ describe Profitbricks::Storage do
|
|
34
34
|
|
35
35
|
it "should be updated" do
|
36
36
|
savon.expects(:get_storage).with(message: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11'}).returns(f :get_storage, :success)
|
37
|
-
savon.expects(:update_storage).with(message: {
|
37
|
+
savon.expects(:update_storage).with(message: {request: {storage_id: 'f55952bc-da27-4e29-af89-ed212ea28e11', size: 10, storage_name: 'Updated'}}).returns(f :update_storage, :success)
|
38
38
|
storage = Storage.find(:id => "f55952bc-da27-4e29-af89-ed212ea28e11")
|
39
39
|
storage.update(:name => "Updated", :size => 10).should == true
|
40
40
|
storage.name.should == "Updated"
|
data/spec/spec_helper.rb
CHANGED
@@ -37,3 +37,16 @@ Profitbricks.configure do |config|
|
|
37
37
|
config.password = "none"
|
38
38
|
config.polling_interval = 0.1
|
39
39
|
end
|
40
|
+
|
41
|
+
client = Savon::Client.new do |globals|
|
42
|
+
globals.namespace "http://ws.api.profitbricks.com/"
|
43
|
+
globals.endpoint "https://api.profitbricks.com/1.2"
|
44
|
+
globals.convert_request_keys_to :lower_camelcase
|
45
|
+
globals.raise_errors true
|
46
|
+
globals.log Profitbricks::Config.log
|
47
|
+
globals.pretty_print_xml true
|
48
|
+
globals.open_timeout 5
|
49
|
+
globals.read_timeout 5
|
50
|
+
globals.basic_auth [Profitbricks::Config.username, Profitbricks::Config.password]
|
51
|
+
end
|
52
|
+
Profitbricks.client = client
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: profitbricks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Dominik Sander
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: savon
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - '='
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - '='
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,6 +30,7 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rdoc
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
35
|
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
@@ -34,6 +38,7 @@ dependencies:
|
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
43
|
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
@@ -41,6 +46,7 @@ dependencies:
|
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: hoe
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
51
|
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
@@ -48,6 +54,7 @@ dependencies:
|
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
59
|
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
@@ -175,10 +182,6 @@ files:
|
|
175
182
|
- spec/fixtures/get_storage/mount_image.xml
|
176
183
|
- spec/fixtures/get_storage/success.json
|
177
184
|
- spec/fixtures/get_storage/success.xml
|
178
|
-
- spec/fixtures/power_off_server/success.json
|
179
|
-
- spec/fixtures/power_off_server/success.xml
|
180
|
-
- spec/fixtures/reboot_server/success.json
|
181
|
-
- spec/fixtures/reboot_server/success.xml
|
182
185
|
- spec/fixtures/register_servers_on_load_balancer/success.json
|
183
186
|
- spec/fixtures/register_servers_on_load_balancer/success.xml
|
184
187
|
- spec/fixtures/release_public_ip_block/success.json
|
@@ -195,10 +198,10 @@ files:
|
|
195
198
|
- spec/fixtures/set_image_os_type/success.xml
|
196
199
|
- spec/fixtures/set_internet_access/success.json
|
197
200
|
- spec/fixtures/set_internet_access/success.xml
|
198
|
-
- spec/fixtures/shutdown_server/success.json
|
199
|
-
- spec/fixtures/shutdown_server/success.xml
|
200
201
|
- spec/fixtures/start_server/success.json
|
201
202
|
- spec/fixtures/start_server/success.xml
|
203
|
+
- spec/fixtures/stop_server/success.json
|
204
|
+
- spec/fixtures/stop_server/success.xml
|
202
205
|
- spec/fixtures/update_data_center/success.json
|
203
206
|
- spec/fixtures/update_data_center/success.xml
|
204
207
|
- spec/fixtures/update_load_balancer/success.json
|
@@ -222,9 +225,8 @@ files:
|
|
222
225
|
- spec/profitbricks/server_spec.rb
|
223
226
|
- spec/profitbricks/storage_spec.rb
|
224
227
|
- spec/spec_helper.rb
|
225
|
-
homepage:
|
228
|
+
homepage: https://github.com/profitbricks/profitbricks-rb
|
226
229
|
licenses: []
|
227
|
-
metadata: {}
|
228
230
|
post_install_message:
|
229
231
|
rdoc_options:
|
230
232
|
- --main
|
@@ -232,19 +234,27 @@ rdoc_options:
|
|
232
234
|
require_paths:
|
233
235
|
- lib
|
234
236
|
required_ruby_version: !ruby/object:Gem::Requirement
|
237
|
+
none: false
|
235
238
|
requirements:
|
236
|
-
- - '>='
|
239
|
+
- - ! '>='
|
237
240
|
- !ruby/object:Gem::Version
|
238
241
|
version: '0'
|
242
|
+
segments:
|
243
|
+
- 0
|
244
|
+
hash: 748897856804736441
|
239
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
|
+
none: false
|
240
247
|
requirements:
|
241
|
-
- - '>='
|
248
|
+
- - ! '>='
|
242
249
|
- !ruby/object:Gem::Version
|
243
250
|
version: '0'
|
251
|
+
segments:
|
252
|
+
- 0
|
253
|
+
hash: 748897856804736441
|
244
254
|
requirements: []
|
245
255
|
rubyforge_project: profitbricks
|
246
|
-
rubygems_version:
|
256
|
+
rubygems_version: 1.8.23
|
247
257
|
signing_key:
|
248
|
-
specification_version:
|
258
|
+
specification_version: 3
|
249
259
|
summary: A Ruby client for the ProfitBricks API.
|
250
260
|
test_files: []
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: c7b4d1eb20600d65ab78c002755ac2869426785a
|
4
|
-
data.tar.gz: c7280d386007c4a9b9889455a38f6ded432a539b
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: fecca29515ddaae5fe833b29e402eec0f4c2a37d3a70895ead1ae1876b3b7e9717d4741297ea0a20d4215915ee6f919b860a82714e539b9dffa58aeb72abbc3a
|
7
|
-
data.tar.gz: 92bae68c2d6399c18d9d32888c5a725545f21ae49b910ff2adc38fdb6dd584aa8927ed1539442d58e5fa066cd2a171f995c2435d1c359bad2065db132dc7b4ce
|
@@ -1 +0,0 @@
|
|
1
|
-
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:powerOffServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50055</requestId></return></ns2:powerOffServerResponse></S:Body></S:Envelope>
|
@@ -1 +0,0 @@
|
|
1
|
-
{"reboot_server_response":{"return":{"request_id":"1187"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
|
@@ -1 +0,0 @@
|
|
1
|
-
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:rebootServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>1187</requestId></return></ns2:rebootServerResponse></S:Body></S:Envelope>
|
@@ -1 +0,0 @@
|
|
1
|
-
{"shutdown_server_response":{"return":{"request_id":"50056"},"@xmlns:ns2":"http://ws.api.profitbricks.com/"}}
|
@@ -1 +0,0 @@
|
|
1
|
-
<?xml version='1.0' encoding='UTF-8'?><S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><S:Body><ns2:shutdownServerResponse xmlns:ns2="http://ws.api.profitbricks.com/"><return><requestId>50056</requestId></return></ns2:shutdownServerResponse></S:Body></S:Envelope>
|