fog-ecloud 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1048 -11
- data/Rakefile +6 -4
- data/lib/fog/compute/ecloud.rb +18 -3
- data/lib/fog/compute/ecloud/errors.rb +91 -0
- data/lib/fog/compute/ecloud/models/admin_organizations.rb +2 -1
- data/lib/fog/compute/ecloud/models/api_keys.rb +2 -1
- data/lib/fog/compute/ecloud/models/associations.rb +2 -1
- data/lib/fog/compute/ecloud/models/authentication_levels.rb +2 -1
- data/lib/fog/compute/ecloud/models/backup_internet_services.rb +2 -1
- data/lib/fog/compute/ecloud/models/catalog.rb +3 -2
- data/lib/fog/compute/ecloud/models/catalog_configurations.rb +2 -1
- data/lib/fog/compute/ecloud/models/compute_pools.rb +2 -1
- data/lib/fog/compute/ecloud/models/cpu_usage_detail_summary.rb +2 -1
- data/lib/fog/compute/ecloud/models/detached_disks.rb +3 -2
- data/lib/fog/compute/ecloud/models/environments.rb +2 -1
- data/lib/fog/compute/ecloud/models/firewall_acls.rb +2 -1
- data/lib/fog/compute/ecloud/models/groups.rb +2 -1
- data/lib/fog/compute/ecloud/models/guest_processes.rb +2 -1
- data/lib/fog/compute/ecloud/models/hardware_configurations.rb +2 -1
- data/lib/fog/compute/ecloud/models/internet_services.rb +7 -6
- data/lib/fog/compute/ecloud/models/ip_addresses.rb +2 -1
- data/lib/fog/compute/ecloud/models/layouts.rb +2 -1
- data/lib/fog/compute/ecloud/models/locations.rb +2 -1
- data/lib/fog/compute/ecloud/models/login_banners.rb +2 -1
- data/lib/fog/compute/ecloud/models/memory_usage_detail_summary.rb +2 -1
- data/lib/fog/compute/ecloud/models/monitors.rb +2 -1
- data/lib/fog/compute/ecloud/models/networks.rb +3 -2
- data/lib/fog/compute/ecloud/models/nodes.rb +3 -2
- data/lib/fog/compute/ecloud/models/operating_system_families.rb +2 -1
- data/lib/fog/compute/ecloud/models/operating_systems.rb +2 -1
- data/lib/fog/compute/ecloud/models/organizations.rb +2 -1
- data/lib/fog/compute/ecloud/models/password_complexity_rules.rb +2 -1
- data/lib/fog/compute/ecloud/models/physical_devices.rb +2 -1
- data/lib/fog/compute/ecloud/models/public_ips.rb +3 -2
- data/lib/fog/compute/ecloud/models/rnats.rb +2 -1
- data/lib/fog/compute/ecloud/models/roles.rb +2 -1
- data/lib/fog/compute/ecloud/models/rows.rb +2 -1
- data/lib/fog/compute/ecloud/models/server.rb +40 -41
- data/lib/fog/compute/ecloud/models/server_configuration_options.rb +2 -1
- data/lib/fog/compute/ecloud/models/servers.rb +10 -9
- data/lib/fog/compute/ecloud/models/ssh_keys.rb +3 -2
- data/lib/fog/compute/ecloud/models/storage_usage_detail_summary.rb +2 -1
- data/lib/fog/compute/ecloud/models/support_tickets.rb +2 -1
- data/lib/fog/compute/ecloud/models/tags.rb +2 -1
- data/lib/fog/compute/ecloud/models/tasks.rb +2 -1
- data/lib/fog/compute/ecloud/models/templates.rb +2 -1
- data/lib/fog/compute/ecloud/models/trusted_network_groups.rb +2 -1
- data/lib/fog/compute/ecloud/models/users.rb +2 -1
- data/lib/fog/compute/ecloud/models/virtual_machine_assigned_ips.rb +5 -4
- data/lib/fog/compute/ecloud/requests/get_admin_organization.rb +4 -2
- data/lib/fog/compute/ecloud/requests/get_compute_pool.rb +4 -2
- data/lib/fog/compute/ecloud/requests/get_environment.rb +5 -3
- data/lib/fog/compute/ecloud/requests/get_ip_address.rb +5 -3
- data/lib/fog/compute/ecloud/requests/get_network.rb +4 -2
- data/lib/fog/compute/ecloud/requests/get_operating_system.rb +5 -3
- data/lib/fog/compute/ecloud/requests/get_ssh_key.rb +3 -1
- data/lib/fog/compute/ecloud/requests/get_template.rb +5 -3
- data/lib/fog/compute/ecloud/requests/ssh_key_edit.rb +2 -1
- data/lib/fog/ecloud/version.rb +1 -1
- data/tests/compute/livespec/auth_tests.rb +101 -0
- data/tests/compute/models/ssh_key_tests.rb +12 -11
- metadata +4 -2
@@ -20,7 +20,8 @@ module Fog
|
|
20
20
|
def get(uri)
|
21
21
|
data = service.get_node(uri).body
|
22
22
|
new(data)
|
23
|
-
rescue
|
23
|
+
rescue ServiceError => e
|
24
|
+
raise e unless e.status_code == 404
|
24
25
|
nil
|
25
26
|
end
|
26
27
|
|
@@ -30,7 +31,7 @@ module Fog
|
|
30
31
|
options[:enabled] ||= true
|
31
32
|
options[:description] ||= ""
|
32
33
|
data = service.node_service_create(options).body
|
33
|
-
|
34
|
+
new(data)
|
34
35
|
end
|
35
36
|
|
36
37
|
def internet_service_id
|
@@ -17,13 +17,14 @@ module Fog
|
|
17
17
|
def get(uri)
|
18
18
|
data = service.get_public_ip(uri).body
|
19
19
|
new(data)
|
20
|
-
rescue
|
20
|
+
rescue ServiceError => e
|
21
|
+
raise e unless e.status_code == 404
|
21
22
|
nil
|
22
23
|
end
|
23
24
|
|
24
25
|
def activate
|
25
26
|
data = service.public_ip_activate(href + "/action/activatePublicIp").body
|
26
|
-
|
27
|
+
Fog::Compute::Ecloud::PublicIps.new(:service => service, :href => data[:href])[0]
|
27
28
|
end
|
28
29
|
end
|
29
30
|
end
|
@@ -31,7 +31,7 @@ module Fog
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def flavor_id
|
34
|
-
{:ram => hardware_configuration.memory.to_i, :cpus => hardware_configuration.processor_count}
|
34
|
+
{ :ram => hardware_configuration.memory.to_i, :cpus => hardware_configuration.processor_count }
|
35
35
|
end
|
36
36
|
|
37
37
|
def storage
|
@@ -39,7 +39,7 @@ module Fog
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def tasks
|
42
|
-
@tasks ||=
|
42
|
+
@tasks ||= service.tasks(:href => "#{service.base_path}/tasks/virtualMachines/#{id}")
|
43
43
|
end
|
44
44
|
|
45
45
|
def processes
|
@@ -47,11 +47,11 @@ module Fog
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def hardware_configuration=(hardware_configuration)
|
50
|
-
@hardware_configuration =
|
50
|
+
@hardware_configuration = service.hardware_configurations.new(hardware_configuration)
|
51
51
|
end
|
52
52
|
|
53
53
|
def hardware_configuration
|
54
|
-
@hardware_configuration ||=
|
54
|
+
@hardware_configuration ||= service.hardware_configurations.new(:href => "#{service.base_path}/virtualMachines/#{id}/hardwareConfiguration")
|
55
55
|
@hardware_configuration.reload
|
56
56
|
end
|
57
57
|
|
@@ -60,36 +60,36 @@ module Fog
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def ips
|
63
|
-
@ips =
|
63
|
+
@ips = service.virtual_machine_assigned_ips(:virtual_machine_id => id)
|
64
64
|
end
|
65
65
|
|
66
66
|
def networks
|
67
|
-
@networks ||=
|
67
|
+
@networks ||= service.networks(:href => "#{service.base_path}/virtualMachines/#{id}/assignedIps")
|
68
68
|
end
|
69
69
|
|
70
70
|
def power_on
|
71
|
-
power_operation(
|
71
|
+
power_operation(:power_on => :powerOn)
|
72
72
|
end
|
73
73
|
|
74
74
|
def power_off
|
75
|
-
power_operation(
|
75
|
+
power_operation(:power_off => :powerOff)
|
76
76
|
end
|
77
77
|
|
78
78
|
def shutdown
|
79
|
-
power_operation(
|
79
|
+
power_operation(:power_shutdown => :shutdown)
|
80
80
|
end
|
81
81
|
|
82
82
|
def power_reset
|
83
|
-
power_operation(
|
83
|
+
power_operation(:power_reset => :reboot)
|
84
84
|
end
|
85
85
|
|
86
86
|
def delete
|
87
87
|
data = service.virtual_machine_delete(href).body
|
88
|
-
|
88
|
+
service.tasks.new(data)
|
89
89
|
end
|
90
90
|
|
91
91
|
def copy(options = {})
|
92
|
-
options = {:type => :copy}.merge(options)
|
92
|
+
options = { :type => :copy }.merge(options)
|
93
93
|
options[:source] ||= href
|
94
94
|
if options[:type] == :copy
|
95
95
|
options[:cpus] ||= 1
|
@@ -103,7 +103,7 @@ module Fog
|
|
103
103
|
options[:network_uri] = options[:network_uri].is_a?(String) ? [options[:network_uri]] : options[:network_uri]
|
104
104
|
options[:network_uri].each do |uri|
|
105
105
|
index = options[:network_uri].index(uri)
|
106
|
-
ip = Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => uri).
|
106
|
+
ip = Fog::Compute::Ecloud::IpAddresses.new(:service => service, :href => uri).detect { |i| i.host == nil }.name
|
107
107
|
options[:ips] ||= []
|
108
108
|
options[:ips][index] = ip
|
109
109
|
end
|
@@ -142,7 +142,7 @@ module Fog
|
|
142
142
|
def edit(options = {})
|
143
143
|
data = service.virtual_machine_edit(href, options).body
|
144
144
|
if data[:type] == "application/vnd.tmrk.cloud.task"
|
145
|
-
|
145
|
+
Fog::Compute::Ecloud::Tasks.new(:service => service, :href => data[:href])[0]
|
146
146
|
end
|
147
147
|
end
|
148
148
|
|
@@ -150,7 +150,7 @@ module Fog
|
|
150
150
|
options[:host_ip_href] ||= ips.first.href
|
151
151
|
options[:uri] = "#{service.base_path}/rnats/environments/#{environment_id}/action/createAssociation"
|
152
152
|
data = service.rnat_associations_create_device(options).body
|
153
|
-
|
153
|
+
Fog::Compute::Ecloud::Associations.new(:service => service, :href => data[:href])[0]
|
154
154
|
end
|
155
155
|
|
156
156
|
def disks
|
@@ -161,18 +161,18 @@ module Fog
|
|
161
161
|
|
162
162
|
def add_disk(size)
|
163
163
|
index = disks.map { |d| d[:Index].to_i }.sort[-1] + 1
|
164
|
-
vm_disks = disks << {:Index => index.to_s, :Size=>{:Unit => "GB", :Value => size.to_s}, :Name => "Hard Disk #{index + 1}"}
|
164
|
+
vm_disks = disks << { :Index => index.to_s, :Size => { :Unit => "GB", :Value => size.to_s }, :Name => "Hard Disk #{index + 1}" }
|
165
165
|
data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:disks => vm_disks)).body
|
166
|
-
|
166
|
+
service.tasks.new(data)
|
167
167
|
end
|
168
168
|
|
169
169
|
def detach_disk(index)
|
170
170
|
options = {}
|
171
|
-
options[:disk] = disks.
|
172
|
-
options[:name] =
|
173
|
-
options[:description] =
|
171
|
+
options[:disk] = disks.detect { |disk_hash| disk_hash[:Index] == index.to_s }
|
172
|
+
options[:name] = name
|
173
|
+
options[:description] = description
|
174
174
|
data = service.virtual_machine_detach_disk(href + "/hardwareconfiguration/disks/actions/detach", options).body
|
175
|
-
|
175
|
+
service.detached_disks.new(data)
|
176
176
|
end
|
177
177
|
|
178
178
|
def attach_disk(detached_disk)
|
@@ -180,13 +180,13 @@ module Fog
|
|
180
180
|
options[:name] = detached_disk.name
|
181
181
|
options[:href] = detached_disk.href
|
182
182
|
data = service.virtual_machine_attach_disk(href + "/hardwareconfiguration/disks/actions/attach", options).body
|
183
|
-
|
183
|
+
service.tasks.new(data)
|
184
184
|
end
|
185
185
|
|
186
186
|
def delete_disk(index)
|
187
187
|
vm_disks = disks.delete_if { |h| h[:Index] == index.to_s }
|
188
188
|
data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareconfiguration", _configuration_data(:disks => vm_disks)).body
|
189
|
-
|
189
|
+
service.tasks.new(data)
|
190
190
|
end
|
191
191
|
|
192
192
|
def nics
|
@@ -197,9 +197,9 @@ module Fog
|
|
197
197
|
|
198
198
|
def add_nic(network)
|
199
199
|
unit_number = nics.map { |n| n[:UnitNumber].to_i }.sort[-1] + 1
|
200
|
-
vm_nics = nics << {:UnitNumber => unit_number, :Network => {:href => network.href, :name => network.name, :type => "application/vnd.tmrk.cloud.network"}}
|
200
|
+
vm_nics = nics << { :UnitNumber => unit_number, :Network => { :href => network.href, :name => network.name, :type => "application/vnd.tmrk.cloud.network" } }
|
201
201
|
data = service.virtual_machine_edit_hardware_configuration(href + "/hardwareConfiguration", _configuration_data(:nics => vm_nics)).body
|
202
|
-
|
202
|
+
service.tasks.new(:href => data[:href])[0]
|
203
203
|
end
|
204
204
|
|
205
205
|
def add_ip(options)
|
@@ -211,7 +211,7 @@ module Fog
|
|
211
211
|
slice_networks = if slice_ips.empty?
|
212
212
|
[]
|
213
213
|
else
|
214
|
-
ips.map { |ip| { :href => ip.network.href, :name => ip.network.name.split(" ")[0], :type => ip.network.type} }.push(:href => options[:href], :name => options[:network_name], :type => "application/vnd.tmrk.cloud.network").uniq
|
214
|
+
ips.map { |ip| { :href => ip.network.href, :name => ip.network.name.split(" ")[0], :type => ip.network.type } }.push(:href => options[:href], :name => options[:network_name], :type => "application/vnd.tmrk.cloud.network").uniq
|
215
215
|
end
|
216
216
|
slice_ips = slice_ips.map { |i| { :name => i.address.name, :network_name => i.network.name } }.push(:name => options[:ip], :network_name => options[:network_name]).uniq
|
217
217
|
slice_ips.each do |ip|
|
@@ -223,7 +223,7 @@ module Fog
|
|
223
223
|
end
|
224
224
|
end
|
225
225
|
data = service.virtual_machine_edit_assigned_ips(href + "/assignedIps", slice_networks).body
|
226
|
-
|
226
|
+
service.tasks.new(data)
|
227
227
|
end
|
228
228
|
|
229
229
|
def delete_ip(options)
|
@@ -243,7 +243,7 @@ module Fog
|
|
243
243
|
}
|
244
244
|
end # .delete_if { |ip| ip[:href] == options[:href] && ip[:name] == options[:network_name] }
|
245
245
|
end
|
246
|
-
slice_ips.map! { |i| {:name => i.address.name, :network_name => i.network.name } }.delete_if { |ip| ip[:name] == options[:ip] }
|
246
|
+
slice_ips.map! { |i| { :name => i.address.name, :network_name => i.network.name } }.delete_if { |ip| ip[:name] == options[:ip] }
|
247
247
|
slice_ips.each do |ip|
|
248
248
|
slice_networks.each do |network|
|
249
249
|
if network[:name] == ip[:network_name]
|
@@ -252,7 +252,7 @@ module Fog
|
|
252
252
|
end
|
253
253
|
end
|
254
254
|
data = service.virtual_machine_edit_assigned_ips(href + "/assignedips", slice_networks).body
|
255
|
-
|
255
|
+
service.tasks.new(data)
|
256
256
|
end
|
257
257
|
|
258
258
|
def upload_file(options)
|
@@ -261,16 +261,15 @@ module Fog
|
|
261
261
|
end
|
262
262
|
|
263
263
|
def storage_size
|
264
|
-
|
265
|
-
disks.map! { |d| d[:Size][:Value].to_i }.reduce(0){|sum,item| sum + item} * 1024 * 1024
|
264
|
+
disks.map! { |d| d[:Size][:Value].to_i }.inject(0) { |sum, item| sum + item } * 1024 * 1024
|
266
265
|
end
|
267
266
|
|
268
267
|
def ready?
|
269
268
|
load_unless_loaded!
|
270
|
-
|
271
|
-
true
|
272
|
-
else
|
269
|
+
if status =~ /NotDeployed|Orphaned|TaskInProgress|CopyInProgress/
|
273
270
|
false
|
271
|
+
else
|
272
|
+
true
|
274
273
|
end
|
275
274
|
end
|
276
275
|
|
@@ -283,16 +282,16 @@ module Fog
|
|
283
282
|
end
|
284
283
|
|
285
284
|
def compute_pool_id
|
286
|
-
other_links.
|
285
|
+
other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href].scan(/\d+/)[0]
|
287
286
|
end
|
288
287
|
|
289
288
|
def compute_pool
|
290
289
|
reload if other_links.nil?
|
291
|
-
@compute_pool =
|
290
|
+
@compute_pool = service.compute_pools.new(:href => other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.computePool" }[:href])
|
292
291
|
end
|
293
292
|
|
294
293
|
def environment_id
|
295
|
-
other_links.
|
294
|
+
other_links.detect { |l| l[:type] == "application/vnd.tmrk.cloud.environment" }[:href].scan(/\d+/)[0]
|
296
295
|
end
|
297
296
|
|
298
297
|
def id
|
@@ -302,15 +301,15 @@ module Fog
|
|
302
301
|
private
|
303
302
|
|
304
303
|
def _configuration_data(options = {})
|
305
|
-
{:cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.memory), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics)}
|
304
|
+
{ :cpus => (options[:cpus] || hardware_configuration.processor_count), :memory => (options[:memory] || hardware_configuration.memory), :disks => (options[:disks] || disks), :nics => (options[:nics] || nics) }
|
306
305
|
end
|
307
306
|
|
308
307
|
def power_operation(op)
|
309
308
|
requires :href
|
310
309
|
begin
|
311
|
-
service.send(op.keys.first, href + "/action/#{op.values.first}"
|
312
|
-
rescue
|
313
|
-
#Frankly we shouldn't get here ...
|
310
|
+
service.send(op.keys.first, href + "/action/#{op.values.first}")
|
311
|
+
rescue ServiceError => e
|
312
|
+
# Frankly we shouldn't get here ...
|
314
313
|
raise e unless e.to_s =~ /because it is already powered o(n|ff)/
|
315
314
|
end
|
316
315
|
true
|
@@ -23,7 +23,8 @@ module Fog
|
|
23
23
|
def get(uri)
|
24
24
|
data = service.get_server(uri).body
|
25
25
|
new(data)
|
26
|
-
rescue
|
26
|
+
rescue ServiceError => e
|
27
|
+
raise e unless e.status_code == 404
|
27
28
|
nil
|
28
29
|
end
|
29
30
|
|
@@ -31,11 +32,11 @@ module Fog
|
|
31
32
|
new(data)
|
32
33
|
end
|
33
34
|
|
34
|
-
def create(
|
35
|
-
options[:cpus]
|
36
|
-
options[:memory]
|
35
|
+
def create(template_uri, options)
|
36
|
+
options[:cpus] ||= 1
|
37
|
+
options[:memory] ||= 512
|
37
38
|
options[:description] ||= ""
|
38
|
-
options[:tags]
|
39
|
+
options[:tags] ||= []
|
39
40
|
|
40
41
|
if template_uri =~ /\/templates\/\d+/
|
41
42
|
options[:uri] = href + "/action/createVirtualMachine"
|
@@ -46,17 +47,17 @@ module Fog
|
|
46
47
|
else
|
47
48
|
[*options[:network_uri]].each do |uri|
|
48
49
|
index = options[:network_uri].index(uri)
|
49
|
-
ip =
|
50
|
+
ip = service.ip_addresses(:href => uri).detect { |i| i.host == nil && i.detected_on.nil? }.name
|
50
51
|
options[:ips] ||= []
|
51
52
|
options[:ips][index] = ip
|
52
53
|
end
|
53
54
|
end
|
54
|
-
data = service.virtual_machine_create_from_template(
|
55
|
+
data = service.virtual_machine_create_from_template(template_uri, options).body
|
55
56
|
else
|
56
57
|
options[:uri] = href + "/action/importVirtualMachine"
|
57
|
-
data = service.virtual_machine_import(
|
58
|
+
data = service.virtual_machine_import(template_uri, options).body
|
58
59
|
end
|
59
|
-
object =
|
60
|
+
object = service.servers.new(data)
|
60
61
|
object
|
61
62
|
end
|
62
63
|
end
|
@@ -9,7 +9,7 @@ module Fog
|
|
9
9
|
model Fog::Compute::Ecloud::SshKey
|
10
10
|
|
11
11
|
def all
|
12
|
-
data = service.get_ssh_keys(href).body[:SshKey]
|
12
|
+
data = service.get_ssh_keys(href).body[:SshKey] || []
|
13
13
|
load(data)
|
14
14
|
end
|
15
15
|
|
@@ -17,7 +17,8 @@ module Fog
|
|
17
17
|
if data = service.get_ssh_key(uri).body
|
18
18
|
new(data)
|
19
19
|
end
|
20
|
-
rescue
|
20
|
+
rescue ServiceError => e
|
21
|
+
raise e unless e.status_code == 404
|
21
22
|
nil
|
22
23
|
end
|
23
24
|
|