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
@@ -20,6 +20,35 @@
|
|
20
20
|
module Deltacloud::Drivers::Mock
|
21
21
|
|
22
22
|
class MockDriver < Deltacloud::BaseDriver
|
23
|
+
|
24
|
+
def systems(credentials, opts={})
|
25
|
+
check_credentials(credentials)
|
26
|
+
if opts[:id].nil?
|
27
|
+
systems = @client.load_all_cimi(:system).map{|sys| CIMI::Model::System.from_json(sys)}
|
28
|
+
else
|
29
|
+
begin
|
30
|
+
systems = [CIMI::Model::System.from_json(@client.load_cimi(:system, opts[:id]))]
|
31
|
+
rescue Errno::ENOENT
|
32
|
+
return []
|
33
|
+
end
|
34
|
+
end
|
35
|
+
systems.map{|sys|convert_cimi_mock_urls(:system, sys ,opts[:env])}.flatten
|
36
|
+
end
|
37
|
+
|
38
|
+
def system_templates(credentials, opts={})
|
39
|
+
check_credentials(credentials)
|
40
|
+
if opts[:id].nil?
|
41
|
+
system_templates = @client.load_all_cimi(:system_template).map{|sys_templ| CIMI::Model::SystemTemplate.from_json(sys_templ)}
|
42
|
+
else
|
43
|
+
begin
|
44
|
+
system_templates = [CIMI::Model::SystemTemplate.from_json(@client.load_cimi(:system_template, opts[:id]))]
|
45
|
+
rescue Errno::ENOENT
|
46
|
+
return []
|
47
|
+
end
|
48
|
+
end
|
49
|
+
system_templates.map{|sys_templ|convert_cimi_mock_urls(:system_template, sys_templ, opts[:env])}.flatten
|
50
|
+
end
|
51
|
+
|
23
52
|
def networks(credentials, opts={})
|
24
53
|
check_credentials(credentials)
|
25
54
|
if opts[:id].nil?
|
@@ -31,6 +60,48 @@ module Deltacloud::Drivers::Mock
|
|
31
60
|
end
|
32
61
|
end
|
33
62
|
|
63
|
+
def create_network(credentials, opts={})
|
64
|
+
check_credentials(credentials)
|
65
|
+
id = "#{opts[:env].send("networks_url")}/#{opts[:name]}"
|
66
|
+
net_hsh = { "id"=> id,
|
67
|
+
"name" => opts[:name],
|
68
|
+
"description" => opts[:description],
|
69
|
+
"created" => Time.now,
|
70
|
+
"state" => "STARTED",
|
71
|
+
"networkType" => opts[:network_config].network_type,
|
72
|
+
"mtu" => opts[:network_config].mtu,
|
73
|
+
"classOfService" => opts[:network_config].class_of_service,
|
74
|
+
|
75
|
+
|
76
|
+
"forwardingGroup"=> { "href" => opts[:forwarding_group].id },
|
77
|
+
"operations" => [{"rel"=>"edit", "href"=> id},
|
78
|
+
{"rel"=>"delete", "href"=> id}] }
|
79
|
+
network = CIMI::Model::Network.from_json(JSON.generate(net_hsh))
|
80
|
+
|
81
|
+
@client.store_cimi(:network, network)
|
82
|
+
network
|
83
|
+
end
|
84
|
+
|
85
|
+
def delete_network(credentials, id)
|
86
|
+
check_credentials(credentials)
|
87
|
+
@client.destroy_cimi(:network, id)
|
88
|
+
end
|
89
|
+
|
90
|
+
def start_network(credentials, id)
|
91
|
+
check_credentials(credentials)
|
92
|
+
update_object_state(id, "Network", "STARTED")
|
93
|
+
end
|
94
|
+
|
95
|
+
def stop_network(credentials, id)
|
96
|
+
check_credentials(credentials)
|
97
|
+
update_object_state(id, "Network", "STOPPED")
|
98
|
+
end
|
99
|
+
|
100
|
+
def suspend_network(credentials, id)
|
101
|
+
check_credentials(credentials)
|
102
|
+
update_object_state(id, "Network", "SUSPENDED")
|
103
|
+
end
|
104
|
+
|
34
105
|
def network_configurations(credentials, opts={})
|
35
106
|
check_credentials(credentials)
|
36
107
|
if opts[:id].nil?
|
@@ -163,6 +234,15 @@ module Deltacloud::Drivers::Mock
|
|
163
234
|
end
|
164
235
|
end
|
165
236
|
|
237
|
+
def update_object_state(id, object, new_state)
|
238
|
+
klass = CIMI::Model.const_get("#{object}")
|
239
|
+
symbol = object.to_s.downcase.singularize.intern
|
240
|
+
obj = klass.from_json(@client.load_cimi(symbol, id))
|
241
|
+
obj.state = new_state
|
242
|
+
@client.store_cimi(symbol, obj)
|
243
|
+
obj
|
244
|
+
end
|
245
|
+
|
166
246
|
end
|
167
247
|
|
168
248
|
end
|
@@ -240,12 +240,17 @@ class OpennebulaDriver < Deltacloud::BaseDriver
|
|
240
240
|
if computehash['DISK/STORAGE']
|
241
241
|
image_id = computehash['DISK/STORAGE'].attributes['href'].split("/").last
|
242
242
|
end
|
243
|
+
if computehash['INSTANCE_TYPE']
|
244
|
+
instance_profile = computehash['INSTANCE_TYPE'].text
|
245
|
+
else
|
246
|
+
instance_profile = 'small'
|
247
|
+
end
|
243
248
|
Instance.new( {
|
244
249
|
:id=>computehash['ID'].text,
|
245
250
|
:owner_id=>credentials.user,
|
246
251
|
:name=>computehash['NAME'].text,
|
247
252
|
:image_id=>image_id,
|
248
|
-
:instance_profile=>InstanceProfile.new(
|
253
|
+
:instance_profile=>InstanceProfile.new(instance_profile),
|
249
254
|
:realm_id=>'ONE',
|
250
255
|
:state=>VM_STATES[computehash['STATE'].text],
|
251
256
|
:public_addresses=>network,
|
@@ -43,11 +43,25 @@ module Deltacloud
|
|
43
43
|
end
|
44
44
|
|
45
45
|
define_hardware_profile('default')
|
46
|
+
|
46
47
|
def supported_collections(credentials)
|
47
48
|
#get the collections as defined by 'capability' and 'respond_to?' blocks
|
48
49
|
super_collections = super
|
49
|
-
|
50
|
-
|
50
|
+
begin
|
51
|
+
new_client(credentials, "compute")
|
52
|
+
rescue Deltacloud::Exceptions::NotImplemented
|
53
|
+
super_collections = super_collections - [Deltacloud::Rabbit::ImagesCollection, Deltacloud::Rabbit::InstancesCollection, Deltacloud::Rabbit::InstanceStatesCollection,Deltacloud::Rabbit::KeysCollection,Deltacloud::Rabbit::RealmsCollection, Deltacloud::Rabbit::HardwareProfilesCollection]
|
54
|
+
end
|
55
|
+
begin
|
56
|
+
new_client(credentials, "object-store")
|
57
|
+
rescue Deltacloud::Exceptions::NotImplemented #OpenStack::Exception::NotImplemented...
|
58
|
+
super_collections = super_collections - [Deltacloud::Rabbit::BucketsCollection]
|
59
|
+
end
|
60
|
+
begin
|
61
|
+
new_client(credentials, "volume")
|
62
|
+
rescue Deltacloud::Exceptions::NotImplemented
|
63
|
+
super_collections = super_collections - [Deltacloud::Rabbit::StorageVolumesCollection, Deltacloud::Rabbit::StorageSnapshotsCollection]
|
64
|
+
end
|
51
65
|
super_collections
|
52
66
|
end
|
53
67
|
|
@@ -115,44 +129,35 @@ module Deltacloud
|
|
115
129
|
end
|
116
130
|
end
|
117
131
|
|
132
|
+
def providers(credentials, opts={})
|
133
|
+
os = new_client(credentials, "compute", true)
|
134
|
+
providers = []
|
135
|
+
os.connection.regions_list.each_pair do |region, services|
|
136
|
+
resource_types = services.inject([]){|res, cur| res << cur[:service] if ["compute", "volume", "object-store"].include?(cur[:service]); res }
|
137
|
+
next if resource_types.empty? #nothing here deltacloud manages
|
138
|
+
providers << convert_provider(region)
|
139
|
+
end
|
140
|
+
providers
|
141
|
+
end
|
142
|
+
|
118
143
|
def realms(credentials, opts={})
|
119
144
|
os = new_client(credentials)
|
120
145
|
realms = []
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
else
|
131
|
-
os.connection.regions_list.each_pair do |region, services|
|
132
|
-
resource_types = services.inject([]){|res, cur| res << cur[:service] if ["compute", "volume", "object-store"].include?(cur[:service]); res }
|
133
|
-
next if resource_types.empty? #nothing here deltacloud manages
|
134
|
-
realms << Realm.new( { :id => region,
|
135
|
-
:name => region,
|
136
|
-
:state =>'AVAILABLE',
|
137
|
-
:resource_types => resource_types})
|
138
|
-
end
|
146
|
+
limits = ""
|
147
|
+
safely do
|
148
|
+
lim = os.limits
|
149
|
+
limits << "ABSOLUTE >> Max. Instances: #{lim[:absolute][:maxTotalInstances]} Max. RAM: #{lim[:absolute][:maxTotalRAMSize]} || "
|
150
|
+
lim[:rate].each do |rate|
|
151
|
+
if rate[:regex] =~ /servers/
|
152
|
+
limits << "SERVERS >> Total: #{rate[:limit].first[:value]} Remaining: #{rate[:limit].first[:remaining]} Time Unit: per #{rate[:limit].first[:unit]}"
|
153
|
+
end
|
154
|
+
end
|
139
155
|
end
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
# lim[:rate].each do |rate|
|
146
|
-
# if rate[:regex] =~ /servers/
|
147
|
-
# limits << "SERVERS >> Total: #{rate[:limit].first[:value]} Remaining: #{rate[:limit].first[:remaining]} Time Unit: per #{rate[:limit].first[:unit]}"
|
148
|
-
# end
|
149
|
-
# end
|
150
|
-
# end
|
151
|
-
# return [] if opts[:id] and opts[:id] != 'default'
|
152
|
-
# [ Realm.new( { :id=>'default',
|
153
|
-
# :name=>'default',
|
154
|
-
# :limit => limits,
|
155
|
-
# :state=>'AVAILABLE' })]
|
156
|
+
return [] if opts[:id] and opts[:id] != 'default'
|
157
|
+
[ Realm.new( { :id=>'default',
|
158
|
+
:name=>'default',
|
159
|
+
:limit => limits,
|
160
|
+
:state=>'AVAILABLE' })]
|
156
161
|
end
|
157
162
|
|
158
163
|
def instances(credentials, opts={})
|
@@ -178,13 +183,7 @@ module Deltacloud
|
|
178
183
|
end
|
179
184
|
|
180
185
|
def create_instance(credentials, image_id, opts)
|
181
|
-
|
182
|
-
os = new_client( credentials, "compute", opts[:realm_id])
|
183
|
-
else
|
184
|
-
#choose a random realm:
|
185
|
-
available_realms = regions_for(credentials, "compute")
|
186
|
-
os = new_client(credentials, "compute", available_realms.sample.id)
|
187
|
-
end
|
186
|
+
os = new_client( credentials, "compute")
|
188
187
|
result = nil
|
189
188
|
#opts[:personality]: path1='server_path1'. content1='contents1', path2='server_path2', content2='contents2' etc
|
190
189
|
params = {}
|
@@ -204,7 +203,7 @@ module Deltacloud
|
|
204
203
|
end
|
205
204
|
safely do
|
206
205
|
server = os.create_server(params)
|
207
|
-
result = convert_from_server(server, os.connection.authuser, get_attachments(server.id, os)
|
206
|
+
result = convert_from_server(server, os.connection.authuser, get_attachments(server.id, os))
|
208
207
|
end
|
209
208
|
result
|
210
209
|
end
|
@@ -238,15 +237,6 @@ module Deltacloud
|
|
238
237
|
|
239
238
|
alias_method :stop_instance, :destroy_instance
|
240
239
|
|
241
|
-
def valid_credentials?(credentials)
|
242
|
-
begin
|
243
|
-
new_client(credentials)
|
244
|
-
rescue
|
245
|
-
return false
|
246
|
-
end
|
247
|
-
true
|
248
|
-
end
|
249
|
-
|
250
240
|
def buckets(credentials, opts={})
|
251
241
|
os = new_client(credentials, "object-store")
|
252
242
|
buckets = []
|
@@ -484,17 +474,8 @@ module Deltacloud
|
|
484
474
|
end
|
485
475
|
|
486
476
|
private
|
487
|
-
|
488
|
-
def region_specified?
|
489
|
-
api_provider.split(";").last
|
490
|
-
end
|
491
|
-
|
492
|
-
def regions_for(credentials, service="compute")
|
493
|
-
realms(credentials).select{|region| region.resource_types.include?(service)}
|
494
|
-
end
|
495
|
-
|
496
477
|
#for v2 authentication credentials.name == "username+tenant_name"
|
497
|
-
def new_client(credentials, type="compute",
|
478
|
+
def new_client(credentials, type="compute", ignore_provider=false)
|
498
479
|
tokens = credentials.user.split("+")
|
499
480
|
if credentials.user.empty?
|
500
481
|
raise AuthenticationFailure.new(Exception.new("Error: you must supply the username"))
|
@@ -506,12 +487,12 @@ private
|
|
506
487
|
end
|
507
488
|
#check if region specified with provider:
|
508
489
|
provider = api_provider
|
509
|
-
if (
|
510
|
-
region =
|
490
|
+
if (provider.include?(";"))
|
491
|
+
region = provider.split(";").last
|
511
492
|
provider = provider.chomp(";#{region}")
|
512
493
|
end
|
513
494
|
connection_params = {:username => user_name, :api_key => credentials.password, :authtenant => tenant_name, :auth_url => provider, :service_type => type}
|
514
|
-
connection_params.merge!({:region => region}) if region
|
495
|
+
connection_params.merge!({:region => region}) if region && !ignore_provider # hack needed for 'def providers'
|
515
496
|
safely do
|
516
497
|
raise ValidationFailure.new(Exception.new("Error: tried to initialise Openstack connection using" +
|
517
498
|
" an unknown service_type: #{type}")) unless ["volume", "compute", "object-store"].include? type
|
@@ -548,7 +529,7 @@ private
|
|
548
529
|
})
|
549
530
|
end
|
550
531
|
|
551
|
-
def convert_from_server(server, owner, attachments=[]
|
532
|
+
def convert_from_server(server, owner, attachments=[])
|
552
533
|
op = (server.class == Hash)? :fetch : :send
|
553
534
|
image = server.send(op, :image)
|
554
535
|
flavor = server.send(op, :flavor)
|
@@ -559,7 +540,7 @@ private
|
|
559
540
|
end
|
560
541
|
inst = Instance.new(
|
561
542
|
:id => server.send(op, :id).to_s,
|
562
|
-
:realm_id =>
|
543
|
+
:realm_id => "default",
|
563
544
|
:owner_id => owner,
|
564
545
|
:description => server.send(op, :name),
|
565
546
|
:name => server.send(op, :name),
|
@@ -667,6 +648,14 @@ private
|
|
667
648
|
)
|
668
649
|
end
|
669
650
|
|
651
|
+
def convert_provider(region)
|
652
|
+
Provider.new(
|
653
|
+
:id => region,
|
654
|
+
:name => region,
|
655
|
+
:url => [api_provider.split(';').first, region].join(';')
|
656
|
+
)
|
657
|
+
end
|
658
|
+
|
670
659
|
#IN: path1='server_path1'. content1='contents1', path2='server_path2', content2='contents2' etc
|
671
660
|
#OUT:{local_path=>server_path, local_path1=>server_path2 etc}
|
672
661
|
def extract_personality(opts)
|
@@ -705,6 +694,10 @@ private
|
|
705
694
|
status 401
|
706
695
|
end
|
707
696
|
|
697
|
+
on /No API endpoint for region/ do
|
698
|
+
status 501
|
699
|
+
end
|
700
|
+
|
708
701
|
on /OpenStack::Exception::Authentication/ do
|
709
702
|
status 401
|
710
703
|
end
|
@@ -181,15 +181,6 @@ class RackspaceDriver < Deltacloud::BaseDriver
|
|
181
181
|
insts
|
182
182
|
end
|
183
183
|
|
184
|
-
def valid_credentials?(credentials)
|
185
|
-
begin
|
186
|
-
new_client(credentials)
|
187
|
-
rescue
|
188
|
-
return false
|
189
|
-
end
|
190
|
-
true
|
191
|
-
end
|
192
|
-
|
193
184
|
define_instance_states do
|
194
185
|
start.to( :pending ) .on( :create )
|
195
186
|
pending.to( :running ) .automatically
|
@@ -127,12 +127,17 @@ class RhevmDriver < Deltacloud::BaseDriver
|
|
127
127
|
inst_arr = []
|
128
128
|
safely do
|
129
129
|
if opts[:id]
|
130
|
-
|
130
|
+
begin
|
131
|
+
vm = client.vm(opts[:id])
|
132
|
+
inst_arr << convert_instance(client, vm)
|
133
|
+
rescue => e
|
134
|
+
raise e unless e.message =~ /Resource Not Found/
|
135
|
+
end
|
131
136
|
else
|
132
137
|
vms = client.vms
|
133
|
-
|
134
|
-
|
135
|
-
|
138
|
+
vms.each do |vm|
|
139
|
+
inst_arr << convert_instance(client, vm)
|
140
|
+
end
|
136
141
|
end
|
137
142
|
end
|
138
143
|
inst_arr = filter_on( inst_arr, :id, opts )
|
@@ -286,7 +291,7 @@ class RhevmDriver < Deltacloud::BaseDriver
|
|
286
291
|
# UNASSIGNED, DOWN, UP, POWERING_UP, POWERED_DOWN, PAUSED, MIGRATING_FROM,
|
287
292
|
# MIGRATING_TO, UNKNOWN, NOT_RESPONDING, WAIT_FOR_LAUNCH, REBOOT_IN_PROGRESS,
|
288
293
|
# SAVING_STATE, RESTORING_STATE, SUSPENDED, IMAGE_ILLEGAL,
|
289
|
-
# IMAGE_LOCKED or POWERING_DOWN
|
294
|
+
# IMAGE_LOCKED, MIGRATING or POWERING_DOWN
|
290
295
|
#
|
291
296
|
def convert_state(state)
|
292
297
|
unless state.respond_to?(:upcase)
|
@@ -295,7 +300,7 @@ class RhevmDriver < Deltacloud::BaseDriver
|
|
295
300
|
state = state.gsub('\\', '').strip.upcase
|
296
301
|
return 'PENDING' if ['WAIT_FOR_LAUNCH', 'REBOOT_IN_PROGRESS', 'SAVING_STATE',
|
297
302
|
'RESTORING_STATE', 'POWERING_UP', 'IMAGE_LOCKED', 'SAVING_STATE'].include? state
|
298
|
-
return 'STOPPING' if
|
303
|
+
return 'STOPPING' if ['POWERING_DOWN', 'MIGRATING'].include? state
|
299
304
|
return 'STOPPED' if ['UNASSIGNED', 'DOWN', 'NOT_RESPONDING',
|
300
305
|
'IMAGE_ILLEGAL', 'UNKNOWN'].include? state
|
301
306
|
return 'RUNNING' if ['UP', 'MIGRATING_TO', 'MIGRATING_FROM'].include? state
|
@@ -97,10 +97,15 @@ module Deltacloud::Drivers::VSphere
|
|
97
97
|
rootFolder = vsphere.serviceInstance.content.rootFolder
|
98
98
|
rootFolder.childEntity.grep(RbVmomi::VIM::Datacenter).each do |dc|
|
99
99
|
list_datastores(dc.datastoreFolder).each do |datastore|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
100
|
+
if datastore.class == RbVmomi::VIM::StoragePod
|
101
|
+
storagepod_name = datastore.summary['name']
|
102
|
+
vms += datastore.childEntity.grep(RbVmomi::VIM::VirtualMachine).collect { |vm| { :instance => vm, :datastore => storagepod_name } }
|
103
|
+
else
|
104
|
+
vms += datastore.vm.collect { |vm| { :instance => vm, :datastore => datastore.name } unless vm.nil? }
|
105
|
+
stored_tasks(datastore, vsphere) do |task|
|
106
|
+
if task.info.entity.class == RbVmomi::VIM::VirtualMachine
|
107
|
+
vms << { :stored_instance => load_serialized_instance(datastore, task.info.key), :datastore => datastore.name }
|
108
|
+
end
|
104
109
|
end
|
105
110
|
end
|
106
111
|
end
|
@@ -116,6 +121,8 @@ module Deltacloud::Drivers::VSphere
|
|
116
121
|
df.childEntity.each do |object|
|
117
122
|
if object.class.to_s == 'Folder'
|
118
123
|
datastores += list_datastores(object)
|
124
|
+
elsif object.class.to_s == 'StoragePod'
|
125
|
+
datastores += list_datastores(object)
|
119
126
|
else
|
120
127
|
datastores << object
|
121
128
|
end
|
@@ -390,18 +390,6 @@ module Deltacloud::Drivers::Vsphere
|
|
390
390
|
|
391
391
|
end
|
392
392
|
|
393
|
-
def valid_credentials?(credentials)
|
394
|
-
begin
|
395
|
-
RbVmomi::VIM.connect(:host => host_endpoint, :user => credentials.user, :password => credentials.password, :insecure => true) && true
|
396
|
-
rescue RbVmomi::Fault::InvalidLogin
|
397
|
-
return false
|
398
|
-
rescue => e
|
399
|
-
safely do
|
400
|
-
raise e
|
401
|
-
end
|
402
|
-
end
|
403
|
-
end
|
404
|
-
|
405
393
|
#######
|
406
394
|
private
|
407
395
|
#######
|