profitbricks 0.9.9 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +3 -2
- data/Gemfile.lock +19 -22
- data/Guardfile +9 -0
- data/Manifest.txt +15 -0
- data/README.md +1 -1
- data/Rakefile +13 -5
- data/lib/profitbricks.rb +7 -5
- data/lib/profitbricks/data_center.rb +19 -20
- data/lib/profitbricks/extensions.rb +0 -3
- data/lib/profitbricks/firewall.rb +14 -20
- data/lib/profitbricks/image.rb +4 -6
- data/lib/profitbricks/ip_block.rb +5 -6
- data/lib/profitbricks/load_balancer.rb +23 -48
- data/lib/profitbricks/model.rb +8 -35
- data/lib/profitbricks/nic.rb +17 -22
- data/lib/profitbricks/profitbricks.rb +35 -27
- data/lib/profitbricks/rule.rb +2 -2
- data/lib/profitbricks/server.rb +96 -18
- data/lib/profitbricks/storage.rb +17 -22
- data/profitbricks.gemspec +6 -6
- data/spec/fixtures/get_server/two_nics.json +1 -0
- data/spec/fixtures/get_server/two_nics.xml +1 -0
- data/spec/fixtures/get_storage/mount_image.json +21 -0
- data/spec/fixtures/get_storage/mount_image.xml +1 -0
- data/spec/fixtures/power_off_server/success.json +1 -0
- data/spec/fixtures/power_off_server/success.xml +1 -0
- data/spec/fixtures/reset_server/success.json +1 -0
- data/spec/fixtures/reset_server/success.xml +1 -0
- data/spec/fixtures/shutdown_server/success.json +1 -0
- data/spec/fixtures/shutdown_server/success.xml +1 -0
- data/spec/fixtures/start_server/success.json +1 -0
- data/spec/fixtures/start_server/success.xml +1 -0
- data/spec/live/data_center_spec.rb +47 -0
- data/spec/live/server_spec.rb +58 -0
- data/spec/profitbricks/cli_spec.rb +13 -6
- data/spec/profitbricks/data_center_spec.rb +54 -29
- data/spec/profitbricks/firewall_spec.rb +17 -11
- data/spec/profitbricks/image_spec.rb +8 -5
- data/spec/profitbricks/ip_block_spec.rb +8 -5
- data/spec/profitbricks/load_balancer_spec.rb +23 -16
- data/spec/profitbricks/model_spec.rb +10 -13
- data/spec/profitbricks/nic_spec.rb +16 -13
- data/spec/profitbricks/server_spec.rb +117 -11
- data/spec/profitbricks/storage_spec.rb +22 -13
- data/spec/spec_helper.rb +10 -23
- metadata +19 -5
- data/.gemtest +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7eff0a7923f9a91e6b21df7f6a0ed25dd958099a
|
4
|
+
data.tar.gz: 535952263dae50c778ff480e9a6b36304056aece
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4756b5b0e0685ea5fabf087b54222d7081da44270effa01a95db5a288651d26284020a9e4bd58af0889a5040fbb24ce8d1604d9993e079660271032927569d9
|
7
|
+
data.tar.gz: 26e43a768c5d4a9d783a7a45be46836e2c641ff0a56f6c1789962fdcb3e387ca0949c621c95614788d8c9792ac4c42c6112f6df27b27db3dc5c049f3396ab666
|
data/Gemfile
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
|
-
gem 'savon'
|
2
|
+
gem 'savon', '~> 2.2.0'
|
3
3
|
|
4
4
|
group :test, :development do
|
5
5
|
gem 'json'
|
6
6
|
gem 'rspec'
|
7
|
-
gem '
|
7
|
+
gem 'rspec-mocks'
|
8
8
|
gem 'simplecov', require: false
|
9
9
|
gem 'rake'
|
10
10
|
gem 'guard'
|
11
11
|
gem 'guard-rspec'
|
12
|
+
gem 'rb-inotify'
|
12
13
|
gem 'coveralls', require: false
|
13
14
|
platforms :mri do
|
14
15
|
# Temporary fix till hoe works with rbx in 1.9 mode
|
data/Gemfile.lock
CHANGED
@@ -4,7 +4,7 @@ GEM
|
|
4
4
|
akami (1.2.0)
|
5
5
|
gyoku (>= 0.4.0)
|
6
6
|
nokogiri (>= 1.4.0)
|
7
|
-
builder (3.
|
7
|
+
builder (3.2.0)
|
8
8
|
coderay (1.0.9)
|
9
9
|
colorize (0.5.8)
|
10
10
|
coveralls (0.6.7)
|
@@ -14,6 +14,7 @@ GEM
|
|
14
14
|
simplecov (>= 0.7)
|
15
15
|
thor
|
16
16
|
diff-lcs (1.1.3)
|
17
|
+
ffi (1.6.0)
|
17
18
|
formatador (0.2.4)
|
18
19
|
guard (1.7.0)
|
19
20
|
formatador (>= 0.2.4)
|
@@ -23,7 +24,7 @@ GEM
|
|
23
24
|
thor (>= 0.14.6)
|
24
25
|
guard-rspec (1.2.1)
|
25
26
|
guard (>= 1.1)
|
26
|
-
gyoku (0.
|
27
|
+
gyoku (1.0.0)
|
27
28
|
builder (>= 2.1.2)
|
28
29
|
hoe (3.0.3)
|
29
30
|
rake (~> 0.8)
|
@@ -33,25 +34,24 @@ GEM
|
|
33
34
|
hoe (>= 2.2.0)
|
34
35
|
hoe-git (1.5.0)
|
35
36
|
hoe (>= 2.2.0)
|
36
|
-
httpi (
|
37
|
+
httpi (2.0.2)
|
37
38
|
rack
|
38
39
|
json (1.7.7)
|
39
40
|
listen (0.7.3)
|
40
41
|
lumberjack (1.0.3)
|
41
|
-
metaclass (0.0.1)
|
42
42
|
method_source (0.8.1)
|
43
43
|
mime-types (1.23)
|
44
|
-
mocha (0.10.5)
|
45
|
-
metaclass (~> 0.0.1)
|
46
44
|
multi_json (1.7.2)
|
47
|
-
nokogiri (1.5.
|
48
|
-
nori (
|
45
|
+
nokogiri (1.5.9)
|
46
|
+
nori (2.1.0)
|
49
47
|
pry (0.9.12)
|
50
48
|
coderay (~> 1.0.5)
|
51
49
|
method_source (~> 0.8)
|
52
50
|
slop (~> 3.4)
|
53
|
-
rack (1.
|
51
|
+
rack (1.5.2)
|
54
52
|
rake (0.9.2.2)
|
53
|
+
rb-inotify (0.9.0)
|
54
|
+
ffi (>= 0.5.0)
|
55
55
|
rest-client (1.6.7)
|
56
56
|
mime-types (>= 1.16)
|
57
57
|
rspec (2.9.0)
|
@@ -62,26 +62,22 @@ GEM
|
|
62
62
|
rspec-expectations (2.9.1)
|
63
63
|
diff-lcs (~> 1.1.3)
|
64
64
|
rspec-mocks (2.9.0)
|
65
|
-
savon (
|
65
|
+
savon (2.2.0)
|
66
66
|
akami (~> 1.2.0)
|
67
67
|
builder (>= 2.1.2)
|
68
|
-
gyoku (~> 0.
|
69
|
-
httpi (~>
|
68
|
+
gyoku (~> 1.0.0)
|
69
|
+
httpi (~> 2.0.2)
|
70
70
|
nokogiri (>= 1.4.0)
|
71
|
-
nori (~>
|
72
|
-
wasabi (~>
|
73
|
-
savon_spec (0.1.6)
|
74
|
-
mocha (>= 0.9.8)
|
75
|
-
rspec (>= 2.0.0)
|
76
|
-
savon (>= 0.8.0)
|
71
|
+
nori (~> 2.1.0)
|
72
|
+
wasabi (~> 3.1.0)
|
77
73
|
simplecov (0.7.1)
|
78
74
|
multi_json (~> 1.0)
|
79
75
|
simplecov-html (~> 0.7.1)
|
80
76
|
simplecov-html (0.7.1)
|
81
77
|
slop (3.4.4)
|
82
78
|
thor (0.18.1)
|
83
|
-
wasabi (
|
84
|
-
httpi (~>
|
79
|
+
wasabi (3.1.0)
|
80
|
+
httpi (~> 2.0)
|
85
81
|
nokogiri (>= 1.4.0)
|
86
82
|
|
87
83
|
PLATFORMS
|
@@ -98,7 +94,8 @@ DEPENDENCIES
|
|
98
94
|
jruby-openssl
|
99
95
|
json
|
100
96
|
rake
|
97
|
+
rb-inotify
|
101
98
|
rspec
|
102
|
-
|
103
|
-
|
99
|
+
rspec-mocks
|
100
|
+
savon (~> 2.2.0)
|
104
101
|
simplecov
|
data/Guardfile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard 'rspec', :spec_paths => ["spec/profitbricks"], :exclude => "./spec/live/*" do
|
5
|
+
watch(%r{^spec/profitbricks/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/profitbricks/(.+)\.rb$}) { |m| "spec/profitbricks/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
watch('lib/profitbricks.rb')
|
9
|
+
end
|
data/Manifest.txt
CHANGED
@@ -4,6 +4,7 @@
|
|
4
4
|
CHANGELOG.md
|
5
5
|
Gemfile
|
6
6
|
Gemfile.lock
|
7
|
+
Guardfile
|
7
8
|
Manifest.txt
|
8
9
|
README.md
|
9
10
|
Rakefile
|
@@ -105,8 +106,14 @@ spec/fixtures/get_server/after_create.json
|
|
105
106
|
spec/fixtures/get_server/after_create.xml
|
106
107
|
spec/fixtures/get_server/connected_storage.json
|
107
108
|
spec/fixtures/get_server/connected_storage.xml
|
109
|
+
spec/fixtures/get_server/two_nics.json
|
110
|
+
spec/fixtures/get_server/two_nics.xml
|
111
|
+
spec/fixtures/get_storage/mount_image.json
|
112
|
+
spec/fixtures/get_storage/mount_image.xml
|
108
113
|
spec/fixtures/get_storage/success.json
|
109
114
|
spec/fixtures/get_storage/success.xml
|
115
|
+
spec/fixtures/power_off_server/success.json
|
116
|
+
spec/fixtures/power_off_server/success.xml
|
110
117
|
spec/fixtures/reboot_server/success.json
|
111
118
|
spec/fixtures/reboot_server/success.xml
|
112
119
|
spec/fixtures/register_servers_on_load_balancer/success.json
|
@@ -119,10 +126,16 @@ spec/fixtures/remove_public_ip_from_nic/success.json
|
|
119
126
|
spec/fixtures/remove_public_ip_from_nic/success.xml
|
120
127
|
spec/fixtures/reserve_public_ip_block/success.json
|
121
128
|
spec/fixtures/reserve_public_ip_block/success.xml
|
129
|
+
spec/fixtures/reset_server/success.json
|
130
|
+
spec/fixtures/reset_server/success.xml
|
122
131
|
spec/fixtures/set_image_os_type/success.json
|
123
132
|
spec/fixtures/set_image_os_type/success.xml
|
124
133
|
spec/fixtures/set_internet_access/success.json
|
125
134
|
spec/fixtures/set_internet_access/success.xml
|
135
|
+
spec/fixtures/shutdown_server/success.json
|
136
|
+
spec/fixtures/shutdown_server/success.xml
|
137
|
+
spec/fixtures/start_server/success.json
|
138
|
+
spec/fixtures/start_server/success.xml
|
126
139
|
spec/fixtures/update_data_center/success.json
|
127
140
|
spec/fixtures/update_data_center/success.xml
|
128
141
|
spec/fixtures/update_load_balancer/success.json
|
@@ -133,6 +146,8 @@ spec/fixtures/update_server/basic.json
|
|
133
146
|
spec/fixtures/update_server/basic.xml
|
134
147
|
spec/fixtures/update_storage/success.json
|
135
148
|
spec/fixtures/update_storage/success.xml
|
149
|
+
spec/live/data_center_spec.rb
|
150
|
+
spec/live/server_spec.rb
|
136
151
|
spec/profitbricks/cli_spec.rb
|
137
152
|
spec/profitbricks/data_center_spec.rb
|
138
153
|
spec/profitbricks/firewall_spec.rb
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Profitbricks [![Build Status](https://secure.travis-ci.org/dsander/profitbricks.png?branch=master)](http://travis-ci.org/dsander/profitbricks) [![Coverage Status](https://coveralls.io/repos/dsander/profitbricks/badge.png?branch=master)](https://coveralls.io/r/dsander/profitbricks)
|
1
|
+
# Profitbricks [![Build Status](https://secure.travis-ci.org/dsander/profitbricks.png?branch=master)](http://travis-ci.org/dsander/profitbricks) [![Coverage Status](https://coveralls.io/repos/dsander/profitbricks/badge.png?branch=master)](https://coveralls.io/r/dsander/profitbricks) [![Code Climate](https://codeclimate.com/github/dsander/profitbricks.png)](https://codeclimate.com/github/dsander/profitbricks)
|
2
2
|
|
3
3
|
* http://github.com/dsander/profitbricks
|
4
4
|
* http://rubydoc.info/github/dsander/profitbricks/master/frames
|
data/Rakefile
CHANGED
@@ -16,22 +16,30 @@ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'ruby'
|
|
16
16
|
Hoe.plugin :bundler
|
17
17
|
Hoe.plugin :gemcutter
|
18
18
|
Hoe.plugins.delete :rubyforge
|
19
|
+
Hoe.plugins.delete :test
|
19
20
|
|
20
21
|
Hoe.spec 'profitbricks' do
|
21
22
|
developer('Dominik Sander', 'git@dsander.de')
|
22
23
|
|
23
24
|
self.readme_file = 'README.md'
|
24
25
|
self.history_file = 'CHANGELOG.md'
|
25
|
-
self.extra_deps << ["savon", "
|
26
|
+
self.extra_deps << ["savon", "2.2.0"]
|
26
27
|
end
|
27
28
|
|
28
29
|
task :prerelease => [:clobber, :check_manifest, :test]
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
end
|
31
|
+
|
32
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
33
|
+
spec.pattern = 'spec/profitbricks/*_spec.rb'
|
34
|
+
spec.rspec_opts = ['--backtrace']
|
35
|
+
end
|
36
|
+
namespace :spec do
|
37
|
+
RSpec::Core::RakeTask.new(:live) do |spec|
|
38
|
+
spec.pattern = 'spec/live/*_spec.rb'
|
32
39
|
spec.rspec_opts = ['--backtrace']
|
33
40
|
end
|
34
41
|
end
|
35
42
|
|
43
|
+
|
36
44
|
task :default => :spec
|
37
|
-
task :test => :spec
|
45
|
+
task :test => :spec
|
data/lib/profitbricks.rb
CHANGED
@@ -3,17 +3,19 @@ require 'profitbricks/profitbricks'
|
|
3
3
|
require 'profitbricks/extensions'
|
4
4
|
require 'profitbricks/config'
|
5
5
|
require 'profitbricks/model'
|
6
|
-
require 'profitbricks/
|
6
|
+
require 'profitbricks/rule'
|
7
|
+
require 'profitbricks/firewall'
|
8
|
+
require 'profitbricks/nic'
|
9
|
+
require 'profitbricks/load_balancer'
|
7
10
|
require 'profitbricks/server'
|
11
|
+
require 'profitbricks/data_center'
|
8
12
|
require 'profitbricks/image'
|
9
13
|
require 'profitbricks/storage'
|
10
14
|
require 'profitbricks/ip_block'
|
11
|
-
require 'profitbricks/load_balancer'
|
12
|
-
require 'profitbricks/firewall'
|
13
15
|
require 'profitbricks/rule'
|
14
16
|
|
15
17
|
module Profitbricks
|
16
|
-
VERSION = '0.
|
18
|
+
VERSION = '1.0.0'
|
17
19
|
end
|
18
20
|
|
19
|
-
PB = Profitbricks
|
21
|
+
PB = Profitbricks
|
@@ -7,18 +7,18 @@ module Profitbricks
|
|
7
7
|
# Deletes an empty Virtual Data Center. All components must be removed first.
|
8
8
|
# @return [Boolean] true on success, false otherwise
|
9
9
|
def delete
|
10
|
-
response = Profitbricks.request :delete_data_center,
|
11
|
-
response
|
10
|
+
response = Profitbricks.request :delete_data_center, data_center_id: self.id
|
11
|
+
response ? true : false
|
12
12
|
end
|
13
13
|
|
14
14
|
# Removes all components from the current Virtual Data Center.
|
15
15
|
# @return The current Virtual Data Center
|
16
16
|
def clear
|
17
|
-
response = Profitbricks.request :clear_data_center,
|
17
|
+
response = Profitbricks.request :clear_data_center, data_center_id: self.id
|
18
18
|
@provisioning_state = nil
|
19
19
|
@servers = []
|
20
20
|
@storages = []
|
21
|
-
return self if response
|
21
|
+
return self if response
|
22
22
|
end
|
23
23
|
|
24
24
|
# Renames the Virtual Data Center.
|
@@ -26,9 +26,8 @@ module Profitbricks
|
|
26
26
|
# @param [String] Name
|
27
27
|
# @return [DataCenter] The renamed DataCenter
|
28
28
|
def rename(name)
|
29
|
-
response = Profitbricks.request :update_data_center,
|
30
|
-
|
31
|
-
if response.to_hash[:update_data_center_response][:return]
|
29
|
+
response = Profitbricks.request :update_data_center, data_center_id: self.id, data_center_name: name
|
30
|
+
if response
|
32
31
|
@name = name
|
33
32
|
end
|
34
33
|
self
|
@@ -41,27 +40,27 @@ module Profitbricks
|
|
41
40
|
#
|
42
41
|
# @return [String] Provisioning State of the target Virtual Data Center (INACTIVE, INPROCESS, AVAILABLE, DELETED)
|
43
42
|
def update_state
|
44
|
-
response = Profitbricks.request :get_data_center_state,
|
45
|
-
@provisioning_state = response
|
43
|
+
response = Profitbricks.request :get_data_center_state, data_center_id: self.id
|
44
|
+
@provisioning_state = response
|
46
45
|
self.provisioning_state
|
47
46
|
end
|
48
47
|
|
49
48
|
# Creates a Server in the current Virtual Data Center, automatically sets the :data_center_id
|
50
49
|
# @see Profitbricks::Server#create
|
51
50
|
def create_server(options)
|
52
|
-
Server.create(options.merge(:
|
51
|
+
Server.create(options.merge(data_center_id: self.id))
|
53
52
|
end
|
54
53
|
|
55
54
|
# Creates a Storage in the current Virtual Data Center, automatically sets the :data_center_id
|
56
55
|
# @see Profitbricks::Storage#create
|
57
56
|
def create_storage(options)
|
58
|
-
Storage.create(options.merge(:
|
57
|
+
Storage.create(options.merge(data_center_id: self.id))
|
59
58
|
end
|
60
59
|
|
61
60
|
# Creates a Load Balancer in the current Virtual Data Center, automatically sets the :data_center_id
|
62
61
|
# @see Profitbricks::LoadBalancer#create
|
63
62
|
def create_load_balancer(options)
|
64
|
-
LoadBalancer.create(options.merge(:
|
63
|
+
LoadBalancer.create(options.merge(data_center_id: self.id))
|
65
64
|
end
|
66
65
|
|
67
66
|
# Checks if the Data Center was successfully provisioned
|
@@ -90,8 +89,7 @@ module Profitbricks
|
|
90
89
|
# @return [Array <DataCenter>] Array of all available DataCenter
|
91
90
|
def all
|
92
91
|
resp = Profitbricks.request :get_all_data_centers
|
93
|
-
|
94
|
-
[datacenters].flatten.compact.collect do |dc|
|
92
|
+
[resp].flatten.compact.collect do |dc|
|
95
93
|
PB::DataCenter.find(:id => PB::DataCenter.new(dc).id)
|
96
94
|
end
|
97
95
|
end
|
@@ -104,10 +102,9 @@ module Profitbricks
|
|
104
102
|
# @return [DataCenter] The newly created Virtual Data Center
|
105
103
|
def create(options)
|
106
104
|
raise ArgumentError.new(":region has to be one of 'DEFAULT', 'NORTH_AMERICA', or 'EUROPE'") if options[:region] and !['DEFAULT', 'EUROPE', 'NORTH_AMERICA'].include? options[:region]
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
self.find(:id => response.to_hash[:create_data_center_response][:return][:data_center_id] )
|
105
|
+
options[:data_center_name] = options.delete :name
|
106
|
+
response = Profitbricks.request :create_data_center, options
|
107
|
+
self.find(:id => response[:data_center_id] )
|
111
108
|
end
|
112
109
|
|
113
110
|
# Finds a Virtual Data Center
|
@@ -120,8 +117,10 @@ module Profitbricks
|
|
120
117
|
options[:id] = dc.id if dc
|
121
118
|
end
|
122
119
|
raise "Unable to locate the datacenter named '#{options[:name]}'" unless options[:id]
|
123
|
-
|
124
|
-
|
120
|
+
options[:data_center_id] = options.delete :id
|
121
|
+
options.delete :name
|
122
|
+
response = Profitbricks.request :get_data_center, options
|
123
|
+
PB::DataCenter.new(response)
|
125
124
|
end
|
126
125
|
end
|
127
126
|
|
@@ -15,23 +15,17 @@ module Profitbricks
|
|
15
15
|
# @param [Array<FirewallRule>] Array of FirewallRules to add
|
16
16
|
# @return [Boolean] true on success, false otherwise
|
17
17
|
def add_rules(rules)
|
18
|
-
|
18
|
+
options = {request: []}
|
19
19
|
rules.each do |rule|
|
20
|
-
|
21
|
-
xml += rule.get_xml_and_update_attributes rule.attributes, rule.attributes.keys
|
22
|
-
xml += "</request>"
|
20
|
+
options[:request] << rule.attributes
|
23
21
|
end
|
24
22
|
response = nil
|
25
23
|
if @parent.class == Profitbricks::LoadBalancer
|
26
|
-
|
27
|
-
|
28
|
-
update_attributes(response.to_hash[:add_firewall_rules_to_load_balancer_response][:return])
|
29
|
-
return true if response.to_hash[:add_firewall_rules_to_load_balancer_response][:return]
|
24
|
+
response = Profitbricks.request :add_firewall_rules_to_load_balancer, options.merge(load_balancer_id: @parent.id)
|
25
|
+
self.reload
|
30
26
|
else
|
31
|
-
|
32
|
-
|
33
|
-
update_attributes(response.to_hash[:add_firewall_rules_to_nic_response][:return])
|
34
|
-
return true if response.to_hash[:add_firewall_rules_to_nic_response][:return]
|
27
|
+
response = Profitbricks.request :add_firewall_rules_to_nic, options.merge(nic_id: self.nic_id)
|
28
|
+
self.reload
|
35
29
|
end
|
36
30
|
|
37
31
|
end
|
@@ -40,24 +34,24 @@ module Profitbricks
|
|
40
34
|
#
|
41
35
|
# @return [Boolean] true on success, false otherwise
|
42
36
|
def activate
|
43
|
-
response = Profitbricks.request :activate_firewalls,
|
44
|
-
return true
|
37
|
+
response = Profitbricks.request :activate_firewalls, firewall_ids: self.id
|
38
|
+
return true
|
45
39
|
end
|
46
40
|
|
47
41
|
# Deactivates the Firewall
|
48
42
|
#
|
49
43
|
# @return [Boolean] true on success, false otherwise
|
50
44
|
def deactivate
|
51
|
-
response = Profitbricks.request :deactivate_firewalls,
|
52
|
-
return true
|
45
|
+
response = Profitbricks.request :deactivate_firewalls, firewall_ids: self.id
|
46
|
+
return true
|
53
47
|
end
|
54
48
|
|
55
49
|
# Deletes the Firewall
|
56
50
|
#
|
57
51
|
# @return [Boolean] true on success, false otherwise
|
58
52
|
def delete
|
59
|
-
response = Profitbricks.request :delete_firewalls,
|
60
|
-
return true
|
53
|
+
response = Profitbricks.request :delete_firewalls, firewall_ids: self.id
|
54
|
+
return true
|
61
55
|
end
|
62
56
|
class << self
|
63
57
|
# Returns information about the respective firewall.
|
@@ -67,9 +61,9 @@ module Profitbricks
|
|
67
61
|
# @option options [String] :id The id of the firewall to locate (required)
|
68
62
|
# @return [Firewall] The located Firewall
|
69
63
|
def find(options = {})
|
70
|
-
response = Profitbricks.request :get_firewall,
|
64
|
+
response = Profitbricks.request :get_firewall, firewall_id: options[:id]
|
71
65
|
# FIXME we cannot load the Firewall without knowing if it is belonging to a NIC or a LoadBalancer
|
72
|
-
PB::Firewall.new(response
|
66
|
+
PB::Firewall.new(response, nil)
|
73
67
|
end
|
74
68
|
end
|
75
69
|
end
|
data/lib/profitbricks/image.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module Profitbricks
|
2
2
|
class Image < Profitbricks::Model
|
3
|
+
belongs_to :mount_image, :class_name => :image
|
3
4
|
|
4
5
|
# Sets the OS Type of an individual HDD and/or CD-ROM/DVD image that has been uploaded on the ProfitBricks FTP server.
|
5
6
|
#
|
@@ -7,7 +8,7 @@ module Profitbricks
|
|
7
8
|
# @return [Image] Updated Image Object
|
8
9
|
def set_os_type(type)
|
9
10
|
raise ArgumentError.new(":os_type has to be either 'WINDOWS' or 'OTHER'") if !['WINDOWS', 'OTHER'].include? type
|
10
|
-
response = Profitbricks.request :set_image_os_type,
|
11
|
+
response = Profitbricks.request :set_image_os_type, image_id: self.id, os_type: type
|
11
12
|
@os_type = type
|
12
13
|
self
|
13
14
|
end
|
@@ -23,14 +24,11 @@ module Profitbricks
|
|
23
24
|
def find(options = {})
|
24
25
|
image = nil
|
25
26
|
if options[:name]
|
26
|
-
image = PB::Image.all().select { |d| d.name == options[:name] }.first
|
27
|
+
image = PB::Image.all().select { |d| d.name == options[:name] && (options[:region] ? d.region == options[:region] : true) }.first
|
27
28
|
options[:id] = image.id if image
|
28
29
|
end
|
29
30
|
raise "Unable to locate the image named '#{options[:name]}'" unless options[:id]
|
30
31
|
image
|
31
|
-
# This does not work for public images
|
32
|
-
#response = Profitbricks.request :get_image, "<imageId>#{options[:id]}</imageId>"
|
33
|
-
#PB::Image.new(response.to_hash[:get_image_response][:return])
|
34
32
|
end
|
35
33
|
|
36
34
|
# Outputs a list of all HDD and/or CD-ROM/DVD images existing on or uploaded to the Profit-Bricks FTP server.
|
@@ -38,7 +36,7 @@ module Profitbricks
|
|
38
36
|
# @return [Array<Image>] List of all available Images
|
39
37
|
def all
|
40
38
|
resp = Profitbricks.request :get_all_images
|
41
|
-
resp.
|
39
|
+
resp.collect do |dc|
|
42
40
|
PB::Image.new(dc)
|
43
41
|
end
|
44
42
|
end
|