deltacloud-core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +40 -28
- data/bin/deltacloud-db-upgrade +24 -0
- data/bin/deltacloudd +20 -9
- data/config.ru +12 -53
- data/db/migrations/1_add_realm_to_machine_template.rb +23 -0
- data/deltacloud-core.gemspec +11 -5
- data/lib/cimi/collections.rb +4 -31
- data/lib/cimi/collections/address_templates.rb +2 -5
- data/lib/cimi/collections/addresses.rb +2 -5
- data/lib/cimi/collections/base.rb +18 -6
- data/lib/cimi/collections/credentials.rb +2 -5
- data/lib/cimi/collections/machine_images.rb +2 -1
- data/lib/cimi/collections/machine_templates.rb +2 -5
- data/lib/cimi/collections/machines.rb +6 -9
- data/lib/cimi/collections/network_ports.rb +3 -3
- data/lib/cimi/collections/networks.rb +5 -8
- data/lib/cimi/collections/system_templates.rb +72 -0
- data/lib/cimi/collections/systems.rb +194 -0
- data/lib/cimi/collections/volume_configurations.rb +1 -1
- data/lib/cimi/collections/volume_images.rb +2 -1
- data/lib/cimi/collections/volume_templates.rb +3 -2
- data/lib/cimi/collections/volumes.rb +2 -2
- data/lib/cimi/dependencies.rb +0 -2
- data/lib/cimi/helpers/cimi_helper.rb +12 -57
- data/lib/cimi/helpers/database_helper.rb +0 -4
- data/lib/cimi/models.rb +25 -14
- data/lib/cimi/models/address.rb +4 -31
- data/lib/cimi/models/address_create.rb +51 -0
- data/lib/cimi/models/address_template.rb +8 -52
- data/lib/cimi/models/address_template_create.rb +44 -0
- data/lib/cimi/models/base.rb +44 -6
- data/lib/cimi/models/cloud_entry_point.rb +1 -1
- data/lib/cimi/models/credential.rb +1 -1
- data/lib/cimi/models/credential_create.rb +46 -0
- data/lib/cimi/models/credential_template.rb +24 -0
- data/lib/cimi/models/machine.rb +1 -71
- data/lib/cimi/models/machine_configuration.rb +3 -3
- data/lib/cimi/models/machine_create.rb +49 -0
- data/lib/cimi/models/machine_image.rb +2 -25
- data/lib/cimi/models/machine_image_create.rb +41 -0
- data/lib/cimi/models/machine_template.rb +14 -34
- data/lib/cimi/models/machine_template_create.rb +33 -0
- data/lib/cimi/models/network.rb +0 -38
- data/lib/cimi/models/network_create.rb +43 -0
- data/lib/cimi/models/network_port.rb +17 -17
- data/lib/cimi/models/network_template.rb +2 -3
- data/lib/cimi/models/resource.rb +22 -3
- data/lib/cimi/models/schema.rb +94 -8
- data/lib/cimi/models/system.rb +67 -0
- data/lib/cimi/models/system_template.rb +63 -0
- data/lib/cimi/models/volume.rb +2 -42
- data/lib/cimi/models/volume_configuration.rb +4 -4
- data/lib/cimi/models/volume_create.rb +58 -0
- data/lib/cimi/models/volume_image.rb +8 -17
- data/lib/cimi/models/volume_image_create.rb +47 -0
- data/lib/cimi/models/volume_template.rb +6 -19
- data/lib/cimi/models/volume_template_create.rb +33 -0
- data/lib/db.rb +14 -22
- data/lib/db/volume_template.rb +1 -1
- data/lib/deltacloud/api.rb +6 -5
- data/lib/deltacloud/collections.rb +4 -27
- data/lib/deltacloud/collections/base.rb +4 -0
- data/lib/deltacloud/collections/images.rb +1 -1
- data/lib/deltacloud/collections/instances.rb +2 -2
- data/lib/deltacloud/core_ext/array.rb +1 -0
- data/lib/deltacloud/core_ext/integer.rb +13 -9
- data/lib/deltacloud/core_ext/string.rb +45 -28
- data/lib/deltacloud/drivers/arubacloud/arubacloud_driver.rb +0 -9
- data/lib/deltacloud/drivers/base_driver.rb +45 -16
- data/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb +78 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +13 -9
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +44 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +164 -90
- data/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb +74 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +3 -3
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +3 -3
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -1
- data/lib/deltacloud/drivers/mock/mock_driver.rb +161 -204
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +80 -0
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +6 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +61 -68
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +0 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +11 -6
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +11 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +0 -12
- data/lib/deltacloud/helpers/collection_helper.rb +106 -0
- data/lib/deltacloud/helpers/deltacloud_helper.rb +12 -8
- data/lib/deltacloud/models/address.rb +19 -17
- data/lib/deltacloud/models/base_model.rb +29 -26
- data/lib/deltacloud/models/blob.rb +22 -20
- data/lib/deltacloud/models/bucket.rb +21 -16
- data/lib/deltacloud/models/firewall.rb +18 -16
- data/lib/deltacloud/models/firewall_rule.rb +22 -20
- data/lib/deltacloud/models/image.rb +29 -28
- data/lib/deltacloud/models/instance.rb +92 -94
- data/lib/deltacloud/models/instance_address.rb +42 -40
- data/lib/deltacloud/models/instance_profile.rb +28 -26
- data/lib/deltacloud/models/key.rb +47 -45
- data/lib/deltacloud/models/load_balancer.rb +32 -31
- data/lib/deltacloud/models/metric.rb +76 -29
- data/lib/deltacloud/models/provider.rb +15 -13
- data/lib/deltacloud/models/realm.rb +15 -21
- data/lib/deltacloud/models/storage_snapshot.rb +23 -19
- data/lib/deltacloud/models/storage_volume.rb +35 -34
- data/lib/deltacloud/version.rb +1 -1
- data/lib/deltacloud_rack.rb +22 -0
- data/lib/initialize.rb +28 -0
- data/lib/initializers/database_initialize.rb +76 -0
- data/lib/initializers/frontend_initialize.rb +42 -0
- data/lib/initializers/mock_initialize.rb +33 -0
- data/lib/sinatra/rack_logger.rb +35 -24
- data/tests/cimi/collections/cloud_entry_point_test.rb +1 -7
- data/tests/cimi/collections/machine_images_test.rb +2 -2
- data/tests/cimi/collections/machine_templates_test.rb +75 -0
- data/tests/cimi/collections/machines_test.rb +2 -2
- data/tests/cimi/collections/system_templates_test.rb +41 -0
- data/tests/cimi/collections/systems_test.rb +50 -0
- data/tests/cimi/db/database_helper_test.rb +17 -25
- data/tests/cimi/db/db_helper.rb +1 -12
- data/tests/cimi/db/entity_test.rb +7 -8
- data/tests/cimi/model/machine_create_spec.rb +44 -0
- data/tests/cimi/model/machine_template_spec.rb +29 -0
- data/tests/cimi/model/resource_spec.rb +40 -0
- data/tests/cimi/model/schema_spec.rb +37 -0
- data/tests/cimi/spec_helper.rb +3 -0
- data/tests/deltacloud/collections/buckets_collection_test.rb +1 -1
- data/tests/deltacloud/collections/drivers_collection_test.rb +2 -2
- data/tests/deltacloud/collections/hardware_profiles_collection_test.rb +2 -2
- data/tests/deltacloud/collections/images_collection_test.rb +2 -2
- data/tests/deltacloud/collections/instance_states_collection_test.rb +1 -1
- data/tests/deltacloud/collections/instances_collection_test.rb +6 -3
- data/tests/deltacloud/collections/keys_collection_test.rb +2 -2
- data/tests/deltacloud/collections/realms_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_snapshots_collection_test.rb +2 -2
- data/tests/deltacloud/collections/storage_volumes_collection_test.rb +2 -2
- data/tests/deltacloud/collections_test.rb +5 -5
- data/tests/deltacloud/common.rb +2 -13
- data/tests/deltacloud/launcher_test.rb +3 -3
- data/tests/deltacloud/rack_test.rb +2 -2
- data/tests/deltacloud/server_test.rb +1 -1
- data/tests/drivers/base/base_driver_test.rb +5 -5
- data/tests/drivers/base/common.rb +2 -12
- data/tests/drivers/ec2/buckets_test.rb +1 -1
- data/tests/drivers/ec2/images_test.rb +2 -2
- data/tests/drivers/ec2/instance_test.rb +6 -6
- data/tests/drivers/ec2/keys_test.rb +3 -3
- data/tests/drivers/ec2/realms_test.rb +2 -2
- data/tests/drivers/ec2/storage_snapshots_test.rb +1 -1
- data/tests/drivers/fgcp/common.rb +32 -0
- data/tests/drivers/fgcp/firewall_test.rb +70 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +61 -0
- data/tests/drivers/fgcp/images_test.rb +46 -0
- data/tests/drivers/fgcp/provider_test.rb +27 -0
- data/tests/drivers/fgcp/realms_test.rb +53 -0
- data/tests/drivers/fgcp/storage_volumes_test.rb +58 -0
- data/tests/drivers/gogrid/images_test.rb +2 -2
- data/tests/drivers/gogrid/instances_test.rb +2 -2
- data/tests/drivers/gogrid/realms_test.rb +2 -2
- data/tests/drivers/mock/images_test.rb +4 -4
- data/tests/drivers/mock/instances_test.rb +9 -9
- data/tests/drivers/mock/keys_test.rb +3 -3
- data/tests/drivers/mock/realms_test.rb +2 -2
- data/tests/drivers/mock/storage_snapshots_test.rb +2 -2
- data/tests/drivers/mock/storage_volumes_test.rb +4 -4
- data/tests/drivers/models/instance_test.rb +2 -2
- data/tests/drivers/openstack/images_test.rb +2 -2
- data/tests/drivers/openstack/instances_test.rb +2 -3
- data/tests/drivers/openstack/keys_test.rb +1 -1
- data/tests/drivers/openstack/realms_test.rb +2 -11
- data/tests/drivers/rhevm/common.rb +33 -12
- data/tests/drivers/rhevm/images_test.rb +20 -12
- data/tests/drivers/rhevm/instance_test.rb +62 -46
- data/tests/drivers/rhevm/provider_test.rb +12 -6
- data/tests/drivers/rhevm/realms_test.rb +15 -9
- data/tests/ec2/query_parser_test.rb +1 -1
- data/tests/test_helper.rb +68 -12
- data/views/addresses/show.html.haml +1 -1
- data/views/buckets/show.html.haml +1 -1
- data/views/errors/{500.html.haml → common.html.haml} +0 -0
- data/views/errors/common.xml.haml +17 -0
- data/views/firewalls/index.xml.haml +2 -2
- data/views/firewalls/new.html.haml +2 -2
- data/views/images/show.html.haml +1 -1
- data/views/instances/run_command.html.haml +1 -1
- data/views/instances/show.html.haml +3 -3
- data/views/keys/index.html.haml +1 -0
- data/views/keys/show.html.haml +8 -4
- data/views/keys/show.xml.haml +3 -2
- data/views/load_balancers/new.html.haml +1 -1
- data/views/load_balancers/show.html.haml +2 -2
- data/views/metrics/show.html.haml +1 -1
- data/views/realms/index.html.haml +0 -2
- data/views/realms/show.html.haml +0 -4
- data/views/realms/show.xml.haml +0 -3
- data/views/storage_snapshots/index.html.haml +1 -1
- data/views/storage_snapshots/new.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +3 -3
- metadata +90 -41
- data/views/errors/400.html.haml +0 -41
- data/views/errors/400.xml.haml +0 -3
- data/views/errors/401.html.haml +0 -26
- data/views/errors/401.xml.haml +0 -3
- data/views/errors/403.html.haml +0 -42
- data/views/errors/403.xml.haml +0 -9
- data/views/errors/404.html.haml +0 -28
- data/views/errors/404.xml.haml +0 -3
- data/views/errors/405.html.haml +0 -29
- data/views/errors/405.xml.haml +0 -5
- data/views/errors/409.html.haml +0 -47
- data/views/errors/409.xml.haml +0 -11
- data/views/errors/500.xml.haml +0 -13
- data/views/errors/501.html.haml +0 -44
- data/views/errors/501.xml.haml +0 -1
- data/views/errors/502.html.haml +0 -44
- data/views/errors/502.xml.haml +0 -1
- data/views/errors/504.html.haml +0 -43
- data/views/errors/504.xml.haml +0 -1
@@ -35,16 +35,20 @@ module Deltacloud
|
|
35
35
|
module Ec2
|
36
36
|
class Ec2Driver < Deltacloud::BaseDriver
|
37
37
|
|
38
|
-
feature :instances,
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
38
|
+
feature :instances,
|
39
|
+
:user_data,
|
40
|
+
:authentication_key,
|
41
|
+
:firewalls,
|
42
|
+
:instance_count,
|
43
|
+
:metrics,
|
44
|
+
:attach_snapshot
|
45
|
+
|
46
|
+
feature :images,
|
47
|
+
:owner_id,
|
48
|
+
:image_name,
|
49
|
+
:image_description
|
50
|
+
|
46
51
|
feature :buckets, :bucket_location
|
47
|
-
feature :instances, :attach_snapshot
|
48
52
|
|
49
53
|
DEFAULT_REGION = 'us-east-1'
|
50
54
|
|
@@ -274,6 +274,44 @@ eoidxml
|
|
274
274
|
request('DestroyVDiskBackup', {'vsysId' => vsys_id, 'backupId' => backup_id})
|
275
275
|
end
|
276
276
|
|
277
|
+
def get_vdisk_backup_copy_key(vsys_id, backup_id)
|
278
|
+
@version = '2012-07-20'
|
279
|
+
request('GetVDiskBackupCopyKey', {'vsysId' => vsys_id, 'backupId' => backup_id})
|
280
|
+
end
|
281
|
+
|
282
|
+
def set_vdisk_backup_copy_key(vsys_id, backup_id, contracts)
|
283
|
+
@version = '2012-07-20'
|
284
|
+
contracts_xml = <<-"eoctxml"
|
285
|
+
<?xml version="1.0" encoding ="UTF-8"?>
|
286
|
+
<Request>
|
287
|
+
<contracts>
|
288
|
+
<contract>
|
289
|
+
#{contracts.collect { |c| " <number>#{c}</number>" }.join("\n")}
|
290
|
+
</contract>
|
291
|
+
</contracts>
|
292
|
+
</Request>
|
293
|
+
eoctxml
|
294
|
+
request('SetVDiskBackupCopyKey',
|
295
|
+
{
|
296
|
+
'vsysId' => vsys_id,
|
297
|
+
'backupId' => backup_id
|
298
|
+
},
|
299
|
+
contracts_xml,
|
300
|
+
'contractsXMLFilePath'
|
301
|
+
)
|
302
|
+
end
|
303
|
+
|
304
|
+
def external_restore_vdisk(src_vsys_id, src_backup_id, dst_vsys_id, dst_vdisk_id, key)
|
305
|
+
@version = '2012-07-20'
|
306
|
+
request('ExternalRestoreVDisk', {
|
307
|
+
'srcVsysId' => src_vsys_id,
|
308
|
+
'srcBackupId' => src_backup_id,
|
309
|
+
'dstVsysId' => dst_vsys_id,
|
310
|
+
'dstVdiskId' => dst_vdisk_id,
|
311
|
+
'key' => key}
|
312
|
+
)
|
313
|
+
end
|
314
|
+
|
277
315
|
def list_public_ips(vsys_id=nil)
|
278
316
|
if vsys_id.nil?
|
279
317
|
request('ListPublicIP')
|
@@ -321,6 +359,12 @@ eoidxml
|
|
321
359
|
$1
|
322
360
|
end
|
323
361
|
|
362
|
+
#extract contract id from vserverId, efmId or networkId
|
363
|
+
def extract_contract_id(id)
|
364
|
+
/^(\w+)-\w+\b.*/ =~ id
|
365
|
+
$1
|
366
|
+
end
|
367
|
+
|
324
368
|
private
|
325
369
|
|
326
370
|
# params hash is of the form :vserverId => 'ABC123', etc.
|
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
require_relative 'fgcp_client'
|
19
19
|
require_relative '../../runner'
|
20
|
+
require_relative 'fgcp_driver_cimi_methods'
|
20
21
|
require 'openssl'
|
21
22
|
require 'xmlsimple'
|
22
23
|
|
@@ -109,8 +110,11 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
109
110
|
if xml['diskimages'] # not likely to not be so, but just in case
|
110
111
|
xml['diskimages'][0]['diskimage'].each do |img|
|
111
112
|
|
112
|
-
#
|
113
|
+
# This will determine image architecture using OS name.
|
114
|
+
# Usually the OS name includes '64bit' or '32bit'. If not,
|
115
|
+
# it will fall back to 64 bit.
|
113
116
|
os_arch = img['osName'][0].to_s =~ /.*32.?bit.*/ ? 'i386' : 'x86_64'
|
117
|
+
# 32bit CentOS/RHEL images are refused on hwps > 16GB (i.e. w_high, quad_high)
|
114
118
|
os_centos_rhel = img['osName'][0] =~ /(CentOS|Red Hat).*/
|
115
119
|
allowed_hwps = hwps.select do |hwp|
|
116
120
|
hwp.memory.default.to_i < 16000 or os_arch == 'x86_64' or not os_centos_rhel
|
@@ -122,9 +126,6 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
122
126
|
:description => img['description'][0].to_s,
|
123
127
|
:owner_id => img['registrant'][0].to_s, # or 'creatorName'?
|
124
128
|
:state => 'AVAILABLE', #server keeps no particular state. If it's listed, it's available for use.
|
125
|
-
# This will determine image architecture using OS name.
|
126
|
-
# Usually the OS name includes '64bit' or '32bit'. If not,
|
127
|
-
# it will fall back to 64 bit.
|
128
129
|
:architecture => os_arch,
|
129
130
|
:hardware_profiles => allowed_hwps
|
130
131
|
) if opts[:id].nil? or opts[:id] == img['diskimageId'][0]
|
@@ -183,7 +184,13 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
183
184
|
|
184
185
|
# determine id belongs to system or network
|
185
186
|
vsys_id = client.extract_vsys_id(opts[:id])
|
186
|
-
|
187
|
+
begin
|
188
|
+
vsys = client.get_vsys_attributes(vsys_id)['vsys'][0]
|
189
|
+
rescue Exception => ex
|
190
|
+
return [] if ex.message =~ /VALIDATION_ERROR.*A wrong value is set/
|
191
|
+
raise
|
192
|
+
end
|
193
|
+
|
187
194
|
realm_name = vsys['vsysName'][0]
|
188
195
|
limit = '[System]'
|
189
196
|
if opts[:id] != vsys_id # network id specified
|
@@ -210,18 +217,24 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
210
217
|
:limit => '[System]',
|
211
218
|
:state => 'AVAILABLE' # map to state of FW/VSYS (reconfiguring = unavailable)?
|
212
219
|
)
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
220
|
+
begin
|
221
|
+
# then retrieve and add list of network segments
|
222
|
+
client.get_vsys_configuration(vsys['vsysId'][0])['vsys'][0]['vnets'][0]['vnet'].each do |vnet|
|
223
|
+
|
224
|
+
vnet['networkId'][0] =~ /^.*\b(\w+)$/
|
225
|
+
realm_name = vsys['vsysName'][0].to_s + ' [' + $1 + ']' # vsys name or vsys name + network [DMZ/SECURE1/SECURE2]
|
226
|
+
realms << Realm::new(
|
227
|
+
:id => vnet['networkId'][0], # vsysId or networkId
|
228
|
+
:name => realm_name,
|
229
|
+
#:limit => :unlimited,
|
230
|
+
:limit => '[Network]',
|
231
|
+
:state => 'AVAILABLE' # map to state of FW/VSYS (reconfiguring = unavailable)?
|
232
|
+
)
|
233
|
+
end
|
234
|
+
rescue Exception => ex # cater for case where vsys was just destroyed since list_vsys call
|
235
|
+
raise ex if not ex.message =~ /RESOURCE_NOT_FOUND.*/
|
236
|
+
# remove earlier added vsys
|
237
|
+
realms.pop
|
225
238
|
end
|
226
239
|
end
|
227
240
|
end
|
@@ -266,20 +279,24 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
266
279
|
xml[0]['vsys'].each do |vsys|
|
267
280
|
|
268
281
|
# use get_vsys_configuration (instead of get_vserver_configuration) to retrieve all vservers in one call
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
282
|
+
begin
|
283
|
+
vsys_config = client.get_vsys_configuration(vsys['vsysId'][0])
|
284
|
+
vsys_config['vsys'][0]['vservers'][0]['vserver'].each do |vserver|
|
285
|
+
|
286
|
+
# skip firewalls - they probably don't belong here and their new type ('firewall' instead of
|
287
|
+
# 'economy') causes errors when trying to map to available profiles)
|
288
|
+
unless determine_server_type(vserver) == 'FW'
|
289
|
+
# to keep the response time of this method acceptable, retrieve state
|
290
|
+
# only if required because state is filtered on
|
291
|
+
state_data = opts[:state] ? instance_state_data(vserver, client) : nil
|
292
|
+
# filter on state
|
293
|
+
if opts[:state].nil? or opts[:state] == state_data[:state]
|
294
|
+
instances << convert_to_instance(client, vserver, state_data)
|
295
|
+
end
|
281
296
|
end
|
282
297
|
end
|
298
|
+
rescue Exception => ex # cater for case where vsys was just destroyed since list_vsys call
|
299
|
+
raise ex if not ex.message =~ /RESOURCE_NOT_FOUND.*/
|
283
300
|
end
|
284
301
|
end
|
285
302
|
end
|
@@ -452,7 +469,10 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
452
469
|
begin
|
453
470
|
vdisk = client.get_vdisk_attributes(opts[:id])['vdisk'][0]
|
454
471
|
rescue Exception => ex
|
472
|
+
# vdisk doesn't exist
|
455
473
|
return [] if ex.message =~ /VALIDATION_ERROR.*t exist./
|
474
|
+
# vsys_id extracted from :id doesn't exist
|
475
|
+
return [] if ex.message =~ /VALIDATION_ERROR.*A wrong value is set/
|
456
476
|
raise
|
457
477
|
end
|
458
478
|
state = client.get_vdisk_status(opts[:id])['vdiskStatus'][0]
|
@@ -489,24 +509,28 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
489
509
|
return [] if xml.nil?
|
490
510
|
xml[0]['vsys'].each do |vsys|
|
491
511
|
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
vdisks['vdisk']
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
512
|
+
begin
|
513
|
+
vdisks = client.list_vdisk(vsys['vsysId'][0])['vdisks'][0]
|
514
|
+
|
515
|
+
if vdisks['vdisk']
|
516
|
+
vdisks['vdisk'].each do |vdisk|
|
517
|
+
|
518
|
+
#state requires an additional call per volume. Only set if attached.
|
519
|
+
#exclude system disks as they are not detachable?
|
520
|
+
volumes << StorageVolume.new(
|
521
|
+
:id => vdisk['vdiskId'][0],
|
522
|
+
:name => vdisk['vdiskName'][0],
|
523
|
+
:capacity => vdisk['size'][0],
|
524
|
+
:instance_id => vdisk['attachedTo'].nil? ? nil : vdisk['attachedTo'][0],
|
525
|
+
:realm_id => client.extract_vsys_id(vdisk['vdiskId'][0]),
|
526
|
+
# aligning with rhevm, which returns 'system' or 'data'
|
527
|
+
:kind => determine_storage_type(vdisk['vdiskId'][0]),
|
528
|
+
:state => vdisk['attachedTo'].nil? ? 'AVAILABLE' : 'IN-USE'
|
529
|
+
)
|
530
|
+
end
|
509
531
|
end
|
532
|
+
rescue Exception => ex # cater for case where vsys was just destroyed since list_vsys call
|
533
|
+
raise ex if not ex.message =~ /RESOURCE_NOT_FOUND.*/
|
510
534
|
end
|
511
535
|
end
|
512
536
|
end
|
@@ -533,7 +557,43 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
533
557
|
opts[:realm_id] = xml[0]['vsys'][0]['vsysId'][0] if xml
|
534
558
|
end
|
535
559
|
|
536
|
-
|
560
|
+
if not opts[:snapshot_id]
|
561
|
+
vdisk_id = client.create_vdisk(opts[:realm_id], opts[:name], opts[:capacity])['vdiskId'][0]
|
562
|
+
else
|
563
|
+
orig_vdisk_id, backup_id = split_snapshot_id(opts[:snapshot_id])
|
564
|
+
orig_vsys_id = client.extract_vsys_id(orig_vdisk_id)
|
565
|
+
# check snapshot size
|
566
|
+
size = client.get_vdisk_attributes(orig_vdisk_id)['vdisk'][0]['size'][0]
|
567
|
+
#set and retrieve key
|
568
|
+
contract_id = client.extract_contract_id(opts[:realm_id])
|
569
|
+
client.set_vdisk_backup_copy_key(orig_vsys_id, backup_id, [contract_id])
|
570
|
+
key = client.get_vdisk_backup_copy_key(opts[:realm_id], backup_id)['keyInfo'][0]['key'][0]
|
571
|
+
# create vdisk with same size as snapshot
|
572
|
+
size = client.get_vdisk_attributes(orig_vdisk_id)['vdisk'][0]['size'][0]
|
573
|
+
vdisk_id = client.create_vdisk(opts[:realm_id], opts[:name], size)['vdiskId'][0]
|
574
|
+
# try a restore straight away. It will likely fail (as the vdisk creation has not
|
575
|
+
# completed yet), but at least the parameters will be validated straight away.
|
576
|
+
begin
|
577
|
+
client.external_restore_vdisk(orig_vsys_id, backup_id, opts[:realm_id], vdisk_id, key)
|
578
|
+
rescue Exception => ex
|
579
|
+
# ignore expected error that destination vdisk is not ready yet
|
580
|
+
raise unless ex.message =~ /ILLEGAL_STATE_DST.*/
|
581
|
+
end
|
582
|
+
#wait until creation completes in a separate thread
|
583
|
+
Thread.new {
|
584
|
+
attempts = 0
|
585
|
+
begin
|
586
|
+
sleep 10
|
587
|
+
# this fails if the destination vdisk is still being deployed
|
588
|
+
client.external_restore_vdisk(orig_vsys_id, backup_id, opts[:realm_id], vdisk_id, key)
|
589
|
+
rescue Exception => ex
|
590
|
+
raise unless attempts < 30 and ex.message =~ /ILLEGAL_STATE_DST.*/
|
591
|
+
# Deployment takes a few minutes, so keep trying for a while
|
592
|
+
attempts += 1
|
593
|
+
retry
|
594
|
+
end
|
595
|
+
}
|
596
|
+
end
|
537
597
|
|
538
598
|
StorageVolume.new(
|
539
599
|
:id => vdisk_id,
|
@@ -608,23 +668,27 @@ class FgcpDriver < Deltacloud::BaseDriver
|
|
608
668
|
return [] if xml.nil?
|
609
669
|
xml[0]['vsys'].each do |vsys|
|
610
670
|
|
611
|
-
|
612
|
-
|
613
|
-
vdisks['vdisk']
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
backups['backups'][0]['backup']
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
671
|
+
begin
|
672
|
+
vdisks = client.list_vdisk(vsys['vsysId'][0])['vdisks'][0]
|
673
|
+
if vdisks['vdisk']
|
674
|
+
vdisks['vdisk'].each do |vdisk|
|
675
|
+
|
676
|
+
backups = client.list_vdisk_backup(vdisk['vdiskId'][0])
|
677
|
+
if backups['backups'] and backups['backups'][0]['backup']
|
678
|
+
backups['backups'][0]['backup'].each do |backup|
|
679
|
+
|
680
|
+
snapshots << StorageSnapshot.new(
|
681
|
+
:id => generate_snapshot_id(vdisk['vdiskId'][0], backup['backupId'][0]),
|
682
|
+
:state => 'AVAILABLE',
|
683
|
+
:storage_volume_id => vdisk['vdiskId'][0],
|
684
|
+
:created => backup['backupTime'][0]
|
685
|
+
)
|
686
|
+
end
|
625
687
|
end
|
626
688
|
end
|
627
689
|
end
|
690
|
+
rescue Exception => ex # cater for case where vsys was just destroyed since list_vsys call
|
691
|
+
raise ex if not ex.message =~ /(RESOURCE_NOT_FOUND|ERROR).*/
|
628
692
|
end
|
629
693
|
end
|
630
694
|
end
|
@@ -1168,31 +1232,35 @@ eofwopxml
|
|
1168
1232
|
xml = client.list_vsys['vsyss']
|
1169
1233
|
return [] if xml.nil?
|
1170
1234
|
|
1171
|
-
|
1235
|
+
begin
|
1236
|
+
xml[0]['vsys'].each do |vsys|
|
1172
1237
|
|
1173
|
-
|
1174
|
-
|
1175
|
-
|
1238
|
+
# use get_vsys_configuration (instead of list_efm) to retrieve all SLBs incl. realms in one call
|
1239
|
+
vsys_config = client.get_vsys_configuration(vsys['vsysId'][0])
|
1240
|
+
vsys_config['vsys'][0]['vservers'][0]['vserver'].each do |vserver|
|
1176
1241
|
|
1177
|
-
|
1178
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
1183
|
-
|
1184
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
1190
|
-
|
1191
|
-
|
1192
|
-
|
1193
|
-
|
1242
|
+
if determine_server_type(vserver) == 'SLB'
|
1243
|
+
vserver['vnics'][0]['vnic'][0]['networkId'][0] =~ /^.*\b(\w+)$/
|
1244
|
+
realm_name = vsys['vsysId'][0] + ' [' + $1 + ']' # vsys name + network [DMZ/SECURE1/SECURE2]
|
1245
|
+
realm = Realm::new(
|
1246
|
+
:id => vserver['vnics'][0]['vnic'][0]['networkId'][0],
|
1247
|
+
:name => realm_name,
|
1248
|
+
:limit => '[Network]',
|
1249
|
+
:state => 'AVAILABLE' # map to state of FW/VSYS (reconfiguring = unavailable)?
|
1250
|
+
)
|
1251
|
+
balancer = LoadBalancer.new({
|
1252
|
+
:id => vserver['vserverId'][0],
|
1253
|
+
:realms => [realm],
|
1254
|
+
:listeners => [],
|
1255
|
+
:instances => [],
|
1256
|
+
:public_addresses => []
|
1257
|
+
})
|
1258
|
+
balancers << balancer
|
1259
|
+
end
|
1194
1260
|
end
|
1195
1261
|
end
|
1262
|
+
rescue Exception => ex # cater for case where vsys was just destroyed since list_vsys call
|
1263
|
+
raise ex if not ex.message =~ /(RESOURCE_NOT_FOUND).*/
|
1196
1264
|
end
|
1197
1265
|
end
|
1198
1266
|
balancers
|
@@ -1327,18 +1395,22 @@ eofwopxml
|
|
1327
1395
|
# list all vservers
|
1328
1396
|
realms.each do |realm_id|
|
1329
1397
|
|
1330
|
-
|
1398
|
+
begin
|
1399
|
+
xml = client.list_vservers(client.extract_vsys_id(realm_id))['vservers']
|
1331
1400
|
|
1332
|
-
|
1401
|
+
if xml and xml[0]['vserver']
|
1333
1402
|
|
1334
|
-
|
1403
|
+
xml[0]['vserver'].each do |vserver|
|
1335
1404
|
|
1336
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
1405
|
+
# should check whether vserver is actually in opts[:realm_id] if network segment?
|
1406
|
+
metrics_arr << Metric.new(
|
1407
|
+
:id => vserver['vserverId'][0],
|
1408
|
+
:entity => vserver['vserverName'][0]
|
1409
|
+
)
|
1410
|
+
end
|
1341
1411
|
end
|
1412
|
+
rescue Exception => ex # cater for case where vsys was just destroyed since list_vsys call
|
1413
|
+
raise ex if not ex.message =~ /(RESOURCE_NOT_FOUND).*/
|
1342
1414
|
end
|
1343
1415
|
end
|
1344
1416
|
|
@@ -1558,6 +1630,8 @@ eofwopxml
|
|
1558
1630
|
images['diskimages'][0]['diskimage'].each do |img|
|
1559
1631
|
if vserver['diskimageId'][0] == img['diskimageId'][0]
|
1560
1632
|
instance.username = img['osName'][0] =~ /Windows.*/ ? 'Administrator' : 'root'
|
1633
|
+
instance.instance_profile.storage = img['size'][0].to_s
|
1634
|
+
break
|
1561
1635
|
end
|
1562
1636
|
end
|
1563
1637
|
instance.password = client.get_vserver_initial_password(vserver['vserverId'][0])['initialPassword'][0]
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#
|
2
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
3
|
+
# contributor license agreements. See the NOTICE file distributed with
|
4
|
+
# this work for additional information regarding copyright ownership. The
|
5
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
6
|
+
# "License"); you may not use this file except in compliance with the
|
7
|
+
# License. You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
13
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
14
|
+
# License for the specific language governing permissions and limitations
|
15
|
+
# under the License.
|
16
|
+
#
|
17
|
+
#Definition of CIMI methods for the Fgcp driver - separation from deltacloud
|
18
|
+
#API Fgcp driver methods
|
19
|
+
|
20
|
+
module Deltacloud::Drivers::Fgcp
|
21
|
+
|
22
|
+
class FgcpDriver < Deltacloud::BaseDriver
|
23
|
+
|
24
|
+
#cimi features
|
25
|
+
feature :machines, :default_initial_state do
|
26
|
+
{ :values => ["STOPPED"] }
|
27
|
+
end
|
28
|
+
|
29
|
+
def systems(credentials, opts={})
|
30
|
+
safely do
|
31
|
+
client = new_client(credentials)
|
32
|
+
|
33
|
+
if opts and opts[:id]
|
34
|
+
vsys_ids = [opts[:id]]
|
35
|
+
else
|
36
|
+
xml = client.list_vsys['vsyss']
|
37
|
+
return [] if xml.nil?
|
38
|
+
vsys_ids = xml[0]['vsys'].collect { |vsys| vsys['vsysId'][0] }
|
39
|
+
end
|
40
|
+
|
41
|
+
vsys_ids.collect do |vsys_id|
|
42
|
+
vsys = client.get_vsys_configuration(vsys_id)['vsys'][0]
|
43
|
+
vsys_description_el = vsys['description']
|
44
|
+
CIMI::Model::System.new(
|
45
|
+
:id => vsys['vsysId'][0],
|
46
|
+
:name => vsys['vsysName'][0],
|
47
|
+
# :machines => "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/machines?realm_id=#{vsys['vsysId'][0]}",
|
48
|
+
# :volumes => "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/volumes?realm_id=#{vsys['vsysId'][0]}",
|
49
|
+
# :networks => "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/networks?realm_id=#{vsys['vsysId'][0]}",
|
50
|
+
# :addresses => "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/addresses?realm_id=#{vsys['vsysId'][0]}",
|
51
|
+
:description => vsys_description_el ? vsys_description_el[0] : nil
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def system_templates(credentials, opts={})
|
58
|
+
safely do
|
59
|
+
client = new_client(credentials)
|
60
|
+
templates = client.list_vsys_descriptor['vsysdescriptors'][0]['vsysdescriptor'].collect do |desc|
|
61
|
+
CIMI::Model::SystemTemplate.new(
|
62
|
+
:id => desc['vsysdescriptorId'][0],
|
63
|
+
:name => desc['vsysdescriptorName'][0],
|
64
|
+
:description => desc['description'][0]
|
65
|
+
)
|
66
|
+
end
|
67
|
+
templates = templates.select { |t| opts[:id] == t[:id] } if opts[:id]
|
68
|
+
templates
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|