deltacloud-core 0.5.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/NOTICE +1 -1
- data/Rakefile +63 -21
- data/bin/deltacloudd +10 -6
- data/config.ru +62 -6
- data/config/drivers/ec2.yaml +8 -0
- data/config/drivers/fgcp.yaml +13 -0
- data/deltacloud-core.gemspec +10 -2
- data/lib/cimi/collections.rb +58 -0
- data/lib/cimi/collections/address_templates.rb +49 -0
- data/lib/cimi/collections/addresses.rb +74 -0
- data/lib/cimi/collections/cloud_entry_point.rb +37 -0
- data/lib/{deltacloud/helpers/conversion_helper.rb → cimi/collections/entity_metadata.rb} +24 -16
- data/lib/cimi/collections/machine_admins.rb +74 -0
- data/lib/cimi/collections/machine_configurations.rb +49 -0
- data/lib/cimi/collections/machine_images.rb +50 -0
- data/lib/cimi/collections/machines.rb +157 -0
- data/lib/cimi/collections/network_configurations.rb +47 -0
- data/lib/cimi/collections/network_templates.rb +48 -0
- data/lib/cimi/collections/networks.rb +125 -0
- data/lib/cimi/collections/routing_group_templates.rb +47 -0
- data/lib/cimi/collections/routing_groups.rb +48 -0
- data/lib/cimi/collections/volume_configurations.rb +48 -0
- data/lib/cimi/collections/volume_images.rb +50 -0
- data/lib/cimi/collections/volumes.rb +80 -0
- data/lib/cimi/collections/vsp_configurations.rb +48 -0
- data/lib/cimi/collections/vsp_templates.rb +50 -0
- data/lib/cimi/collections/vsps.rb +108 -0
- data/lib/cimi/dependencies.rb +1 -0
- data/lib/cimi/helpers.rb +116 -0
- data/lib/cimi/helpers/cimi_helper.rb +6 -2
- data/lib/cimi/models.rb +72 -0
- data/lib/cimi/{model → models}/action.rb +1 -1
- data/lib/cimi/models/address.rb +72 -0
- data/lib/cimi/models/address_collection.rb +34 -0
- data/lib/cimi/models/address_template.rb +54 -0
- data/lib/cimi/models/address_template_collection.rb +34 -0
- data/lib/cimi/{model → models}/base.rb +2 -2
- data/lib/cimi/{model → models}/cloud_entry_point.rb +3 -5
- data/lib/cimi/{model → models}/entity_metadata.rb +7 -6
- data/lib/cimi/{model → models}/entity_metadata_collection.rb +2 -2
- data/lib/cimi/{model → models}/errors.rb +8 -0
- data/lib/cimi/{model → models}/machine.rb +10 -10
- data/lib/cimi/{model → models}/machine_admin.rb +1 -1
- data/lib/cimi/{model → models}/machine_admin_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_configuration.rb +9 -6
- data/lib/cimi/{model → models}/machine_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_image.rb +1 -1
- data/lib/cimi/{model → models}/machine_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/machine_template.rb +0 -0
- data/lib/cimi/{model → models}/machine_template_collection.rb +2 -2
- data/lib/cimi/models/network.rb +109 -0
- data/lib/cimi/{model → models}/network_collection.rb +2 -2
- data/lib/cimi/{model → models}/network_configuration.rb +3 -4
- data/lib/cimi/{model → models}/network_configuration_collection.rb +2 -2
- data/lib/cimi/models/network_template.rb +36 -0
- data/lib/cimi/models/network_template_collection.rb +35 -0
- data/lib/cimi/models/routing_group.rb +34 -0
- data/lib/cimi/models/routing_group_collection.rb +34 -0
- data/lib/cimi/models/routing_group_template.rb +34 -0
- data/lib/cimi/models/routing_group_template_collection.rb +35 -0
- data/lib/cimi/{model → models}/schema.rb +0 -0
- data/lib/cimi/{model → models}/volume.rb +4 -4
- data/lib/cimi/{model → models}/volume_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_configuration.rb +1 -1
- data/lib/cimi/{model → models}/volume_configuration_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_image.rb +1 -1
- data/lib/cimi/{model → models}/volume_image_collection.rb +2 -2
- data/lib/cimi/{model → models}/volume_template.rb +0 -0
- data/lib/cimi/{model → models}/volume_template_collection.rb +2 -2
- data/lib/cimi/models/vsp.rb +102 -0
- data/lib/cimi/models/vsp_collection.rb +34 -0
- data/lib/cimi/models/vsp_configuration.rb +40 -0
- data/lib/cimi/models/vsp_configuration_collection.rb +34 -0
- data/lib/cimi/models/vsp_template.rb +34 -0
- data/lib/cimi/models/vsp_template_collection.rb +34 -0
- data/lib/cimi/server.rb +27 -549
- data/lib/deltacloud/api.rb +79 -0
- data/lib/deltacloud/collections.rb +54 -0
- data/lib/deltacloud/collections/addresses.rb +91 -0
- data/lib/deltacloud/collections/buckets.rb +273 -0
- data/lib/deltacloud/collections/drivers.rb +51 -0
- data/lib/deltacloud/collections/firewalls.rb +116 -0
- data/lib/deltacloud/collections/hardware_profiles.rb +29 -0
- data/lib/deltacloud/collections/images.rb +73 -0
- data/lib/deltacloud/collections/instance_states.rb +59 -0
- data/lib/deltacloud/collections/instances.rb +113 -0
- data/lib/deltacloud/collections/keys.rb +61 -0
- data/lib/deltacloud/collections/load_balancers.rb +102 -0
- data/lib/deltacloud/collections/metrics.rb +28 -0
- data/lib/deltacloud/collections/realms.rb +28 -0
- data/lib/deltacloud/collections/storage_snapshots.rb +51 -0
- data/lib/deltacloud/collections/storage_volumes.rb +99 -0
- data/lib/deltacloud/core_ext.rb +14 -6
- data/lib/deltacloud/core_ext/string.rb +17 -5
- data/lib/deltacloud/drivers.rb +6 -42
- data/lib/deltacloud/drivers/azure/azure_driver.rb +0 -4
- data/lib/deltacloud/{base_driver → drivers}/base_driver.rb +56 -18
- data/lib/deltacloud/drivers/condor/condor_driver.rb +1 -8
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +142 -33
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +2 -6
- data/lib/deltacloud/{base_driver → drivers}/exceptions.rb +25 -2
- data/lib/deltacloud/drivers/features.rb +154 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_client.rb +387 -0
- data/lib/deltacloud/drivers/fgcp/fgcp_driver.rb +1435 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +8 -11
- data/lib/deltacloud/drivers/google/google_driver.rb +2 -5
- data/lib/deltacloud/drivers/mock/data/keys/test-key.yml +28 -0
- data/lib/deltacloud/drivers/mock/mock_client.rb +2 -2
- data/lib/deltacloud/drivers/mock/mock_driver.rb +58 -40
- data/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb +145 -0
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +107 -73
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +285 -145
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +189 -126
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +427 -8
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +7 -9
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +48 -66
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +44 -51
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +7 -8
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -3
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +8 -8
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +39 -13
- data/lib/deltacloud/drivers/vsphere/vsphere_filemanager.rb +1 -0
- data/lib/deltacloud/helpers.rb +79 -7
- data/lib/{sinatra/lazy_auth.rb → deltacloud/helpers/auth_helper.rb} +5 -9
- data/lib/deltacloud/helpers/{blob_stream.rb → blob_stream_helper.rb} +7 -7
- data/lib/deltacloud/helpers/deltacloud_helper.rb +286 -0
- data/lib/deltacloud/helpers/driver_helper.rb +58 -0
- data/lib/deltacloud/helpers/rabbit_helper.rb +34 -0
- data/lib/{sinatra/url_for.rb → deltacloud/helpers/url_helper.rb} +31 -9
- data/lib/deltacloud/models.rb +19 -17
- data/lib/deltacloud/models/bucket.rb +4 -0
- data/lib/deltacloud/{hardware_profile.rb → models/hardware_profile.rb} +4 -2
- data/lib/deltacloud/models/image.rb +1 -0
- data/lib/deltacloud/models/instance.rb +4 -2
- data/lib/deltacloud/models/instance_address.rb +4 -0
- data/lib/deltacloud/models/key.rb +4 -0
- data/lib/deltacloud/models/metric.rb +40 -0
- data/lib/deltacloud/{state_machine.rb → models/state_machine.rb} +18 -1
- data/lib/deltacloud/server.rb +41 -1222
- data/lib/deltacloud_rack.rb +79 -0
- data/lib/{cimi/model/network_template.rb → ec2/helpers.rb} +7 -10
- data/lib/{deltacloud/backend_capability.rb → ec2/helpers/errors.rb} +24 -29
- data/lib/ec2/helpers/result.rb +31 -0
- data/lib/ec2/query_parser.rb +152 -0
- data/lib/ec2/server.rb +70 -0
- data/lib/{deltacloud.rb → sinatra.rb} +7 -12
- data/lib/sinatra/rack_accept.rb +13 -7
- data/lib/sinatra/rack_driver_select.rb +1 -1
- data/lib/sinatra/rack_matrix_params.rb +1 -3
- data/public/images/metric.png +0 -0
- data/public/javascripts/jquery.mobile-1.0.1.min.js +177 -0
- data/public/stylesheets/jquery.mobile-1.0.1.min.css +2 -0
- data/public/stylesheets/new.css +10 -0
- data/support/fedora/deltacloud-core.spec +1 -1
- data/tests/api/common.rb +1 -0
- data/tests/api/driver_test.rb +79 -0
- data/tests/api/library_test.rb +48 -0
- data/tests/cimi/features/step_definitions/common_steps.rb +2 -2
- data/tests/cimi/features/step_definitions/machines_steps.rb +5 -4
- data/tests/cimi/features/step_definitions/volumes_steps.rb +8 -8
- data/tests/cimi/features/support/env.rb +33 -11
- data/tests/common.rb +7 -8
- data/tests/drivers/ec2/api_test.rb +19 -0
- data/tests/drivers/ec2/common.rb +23 -0
- data/tests/drivers/ec2/drivers_test.rb +120 -0
- data/tests/drivers/ec2/hardware_profiles_test.rb +224 -0
- data/tests/drivers/ec2/images_test.rb +230 -0
- data/tests/drivers/ec2/instances_test.rb +356 -0
- data/tests/drivers/ec2/keys_test.rb +181 -0
- data/tests/drivers/ec2/realms_test.rb +146 -0
- data/tests/drivers/fgcp/api_test.rb +47 -0
- data/tests/drivers/fgcp/hardware_profiles_test.rb +54 -0
- data/tests/drivers/fgcp/realms_test.rb +42 -0
- data/tests/drivers/{rackspace → fgcp}/setup.rb +5 -6
- data/tests/drivers/google/api_test.rb +10 -26
- data/tests/drivers/google/buckets_test.rb +79 -95
- data/tests/drivers/google/common.rb +54 -0
- data/tests/drivers/mock/api_test.rb +4 -127
- data/tests/drivers/mock/buckets_test.rb +195 -0
- data/tests/drivers/mock/common.rb +7 -0
- data/tests/drivers/mock/drivers_test.rb +123 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +190 -100
- data/tests/drivers/mock/images_test.rb +162 -103
- data/tests/drivers/mock/instances_test.rb +310 -220
- data/tests/drivers/mock/keys_test.rb +161 -0
- data/tests/drivers/mock/realms_test.rb +109 -70
- data/tests/drivers/mock/storage_snapshots_test.rb +114 -0
- data/tests/drivers/mock/storage_volumes_test.rb +122 -0
- data/tests/drivers/openstack/api_test.rb +8 -3
- data/tests/drivers/openstack/common.rb +21 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +20 -9
- data/tests/drivers/openstack/images_test.rb +11 -5
- data/tests/drivers/openstack/instances_test.rb +61 -16
- data/tests/drivers/openstack/realms_test.rb +11 -7
- data/tests/drivers/rackspace/api_test.rb +7 -2
- data/tests/drivers/rackspace/buckets_test.rb +7 -2
- data/tests/drivers/rackspace/common.rb +16 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rackspace/images_test.rb +7 -2
- data/tests/drivers/rackspace/instances_test.rb +10 -5
- data/tests/drivers/rackspace/realms_test.rb +7 -2
- data/tests/drivers/rhevm/api_test.rb +12 -6
- data/tests/drivers/rhevm/{setup.rb → common.rb} +8 -1
- data/tests/drivers/rhevm/hardware_profiles_test.rb +7 -2
- data/tests/drivers/rhevm/images_test.rb +8 -2
- data/tests/drivers/rhevm/instances_test.rb +7 -2
- data/tests/drivers/rhevm/realms_test.rb +7 -2
- data/tests/minitest_common.rb +58 -0
- data/tests/minitest_common_api_test.rb +115 -0
- data/views/addresses/associate.html.haml +1 -1
- data/views/addresses/index.html.haml +1 -1
- data/views/addresses/show.html.haml +2 -3
- data/views/api/show.html.haml +22 -9
- data/views/api/show.xml.haml +8 -7
- data/views/blobs/show.xml.haml +7 -4
- data/views/buckets/new.html.haml +2 -2
- data/views/cimi/errors/401.xml.haml +1 -1
- data/views/error.html.haml +3 -3
- data/views/errors/400.html.haml +1 -1
- data/views/errors/400.xml.haml +1 -2
- data/views/errors/401.html.haml +8 -7
- data/views/errors/401.xml.haml +1 -1
- data/views/errors/404.xml.haml +1 -0
- data/views/errors/500.xml.haml +4 -2
- data/views/{cimi/errors/403.html.haml → errors/501.html.haml} +4 -2
- data/views/errors/501.xml.haml +1 -0
- data/views/errors/502.xml.haml +1 -7
- data/views/{cimi/errors/500.html.haml → errors/504.html.haml} +0 -0
- data/views/errors/504.xml.haml +1 -0
- data/views/firewalls/new.html.haml +2 -2
- data/views/firewalls/new_rule.html.haml +1 -1
- data/views/firewalls/show.html.haml +1 -1
- data/views/hardware_profiles/index.html.haml +3 -1
- data/views/hardware_profiles/index.xml.haml +2 -2
- data/views/hardware_profiles/show.html.haml +3 -3
- data/views/hardware_profiles/show.xml.haml +3 -3
- data/views/images/show.html.haml +5 -0
- data/views/images/show.xml.haml +6 -1
- data/views/instance_states/show.html.haml +1 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +54 -39
- data/views/instances/run_command.html.haml +24 -15
- data/views/instances/show.html.haml +7 -3
- data/views/instances/show.xml.haml +2 -2
- data/views/keys/show.xml.haml +1 -0
- data/views/layout.html.haml +5 -9
- data/views/load_balancers/show.html.haml +12 -6
- data/views/metrics/index.html.haml +13 -0
- data/views/metrics/index.xml.haml +5 -0
- data/views/metrics/show.html.haml +23 -0
- data/views/metrics/show.xml.haml +9 -0
- data/views/realms/show.xml.haml +2 -1
- data/views/root/index.html.haml +1 -1
- data/views/storage_snapshots/show.html.haml +1 -1
- data/views/storage_snapshots/show.xml.haml +1 -0
- data/views/storage_volumes/attach.html.haml +1 -2
- data/views/storage_volumes/index.html.haml +1 -1
- data/views/storage_volumes/new.html.haml +22 -16
- data/views/storage_volumes/show.html.haml +10 -4
- data/views/storage_volumes/show.xml.haml +3 -4
- metadata +547 -519
- data/DISCLAIMER +0 -8
- data/lib/cimi/model.rb +0 -52
- data/lib/cimi/model/network.rb +0 -69
- data/lib/deltacloud/base_driver.rb +0 -18
- data/lib/deltacloud/base_driver/features.rb +0 -262
- data/lib/deltacloud/base_driver/mock_driver.rb +0 -78
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -186
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +0 -521
- data/lib/deltacloud/helpers/application_helper.rb +0 -267
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -50
- data/lib/deltacloud/helpers/json_helper.rb +0 -31
- data/lib/deltacloud/method_serializer.rb +0 -83
- data/lib/deltacloud/validation.rb +0 -107
- data/lib/sinatra/rabbit.rb +0 -441
- data/lib/sinatra/rack_runtime.rb +0 -47
- data/lib/sinatra/rack_syslog.rb +0 -86
- data/lib/sinatra/sinatra_verbose.rb +0 -73
- data/lib/sinatra/static_assets.rb +0 -99
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +0 -170
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +0 -12
- data/tests/drivers/google/setup.rb +0 -38
- data/tests/drivers/mock/instance_states_test.rb +0 -71
- data/tests/drivers/mock/setup.rb +0 -3
- data/tests/drivers/mock/url_for_test.rb +0 -67
- data/tests/drivers/openstack/setup.rb +0 -20
- data/views/cimi/errors/400.html.haml +0 -41
- data/views/cimi/errors/401.html.haml +0 -41
- data/views/cimi/errors/404.html.haml +0 -29
- data/views/cimi/errors/405.html.haml +0 -29
- data/views/cimi/errors/502.html.haml +0 -43
- data/views/cimi/errors/backend_capability_failure.html.haml +0 -29
@@ -14,7 +14,6 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
require 'deltacloud/base_driver'
|
18
17
|
require 'cloudfiles'
|
19
18
|
require 'cloudservers'
|
20
19
|
require 'base64'
|
@@ -28,10 +27,9 @@ class RackspaceDriver < Deltacloud::BaseDriver
|
|
28
27
|
feature :instances, :user_name
|
29
28
|
feature :instances, :authentication_password
|
30
29
|
feature :instances, :user_files
|
30
|
+
feature :images, :user_name
|
31
31
|
|
32
|
-
|
33
|
-
DEFAULT_COLLECTIONS + [ :buckets ] - [ :storage_snapshots, :storage_volumes ]
|
34
|
-
end
|
32
|
+
define_hardware_profile('default')
|
35
33
|
|
36
34
|
def hardware_profiles(credentials, opts = {})
|
37
35
|
rs = new_client( credentials )
|
@@ -100,8 +98,8 @@ class RackspaceDriver < Deltacloud::BaseDriver
|
|
100
98
|
image = server.create_image(opts[:name])
|
101
99
|
Image.new(
|
102
100
|
:id => image.id.to_s,
|
103
|
-
:name => image.name,
|
104
|
-
:description => image.
|
101
|
+
:name => opts[:name] || image.name,
|
102
|
+
:description => opts[:description] || image.description,
|
105
103
|
:owner_id => credentials.user,
|
106
104
|
:state => image.status,
|
107
105
|
:architecture => 'x86_64'
|
@@ -127,7 +125,7 @@ class RackspaceDriver < Deltacloud::BaseDriver
|
|
127
125
|
:password => opts[:password]
|
128
126
|
}
|
129
127
|
param[:port] = opts[:port] || '22'
|
130
|
-
param[:ip] = target.public_addresses.first
|
128
|
+
param[:ip] = opts[:ip] || target.public_addresses.first.address
|
131
129
|
safely do
|
132
130
|
Deltacloud::Runner.execute(opts[:cmd], param)
|
133
131
|
end
|
@@ -193,8 +191,8 @@ class RackspaceDriver < Deltacloud::BaseDriver
|
|
193
191
|
start.to( :pending ) .on( :create )
|
194
192
|
pending.to( :running ) .automatically
|
195
193
|
running.to( :running ) .on( :reboot )
|
196
|
-
running.to( :
|
197
|
-
|
194
|
+
running.to( :stopping ) .on( :stop )
|
195
|
+
stopping.to( :stopped ) .automatically
|
198
196
|
stopped.to( :finish ) .automatically
|
199
197
|
end
|
200
198
|
|
@@ -14,36 +14,20 @@
|
|
14
14
|
# License for the specific language governing permissions and limitations
|
15
15
|
# under the License.
|
16
16
|
|
17
|
-
|
18
|
-
#
|
19
|
-
# 1. Setup RHEV-M server
|
20
|
-
# 2. Setup RHEV-M API (git://git.fedorahosted.org/rhevm-api.git - follow README)
|
21
|
-
# 3. Set URL to API using shell variable (or HTTP header, see comment on provider_url)
|
22
|
-
# export API_PROVIDER="https://x.x.x.x/rhevm-api-powershell"
|
23
|
-
# 4. Start Deltacloud using: deltacloudd -i rhevm
|
24
|
-
# 5. Use RHEV-M credentials + append Windows Domain
|
25
|
-
# like: admin@rhevm.example.com
|
26
|
-
|
27
|
-
require 'deltacloud/base_driver'
|
28
|
-
require 'deltacloud/drivers/rhevm/rhevm_client'
|
17
|
+
require 'rbovirt'
|
29
18
|
|
30
19
|
module Deltacloud
|
31
20
|
module Drivers
|
32
|
-
module
|
33
|
-
|
34
|
-
class RHEVMDriver < Deltacloud::BaseDriver
|
21
|
+
module Rhevm
|
35
22
|
|
36
|
-
|
37
|
-
DEFAULT_COLLECTIONS - [:storage_snapshots]
|
38
|
-
end
|
23
|
+
class RhevmDriver < Deltacloud::BaseDriver
|
39
24
|
|
25
|
+
feature :instances, :user_data
|
40
26
|
feature :instances, :user_name do
|
41
|
-
|
27
|
+
{ :max_length => 50 }
|
42
28
|
end
|
43
29
|
|
44
|
-
|
45
|
-
|
46
|
-
USER_NAME_MAX = feature(:instances, :user_name).constraints[:max_length]
|
30
|
+
USER_NAME_MAX = constraints(:collection => :instances, :feature => :user_name)[:max_length]
|
47
31
|
|
48
32
|
# FIXME: These values are just for ilustration
|
49
33
|
# Also I choosed 'SERVER' and 'DESKTOP' names
|
@@ -119,8 +103,8 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
119
103
|
template_name = "#{instance.first.name}-template"
|
120
104
|
end
|
121
105
|
safely do
|
122
|
-
new_image = client.create_template(opts[:id], :name => (opts[:name] || template_name),
|
123
|
-
:description => opts[:description])
|
106
|
+
new_image = client.create_template(:vm => opts[:id], :name => (opts[:name] || template_name),
|
107
|
+
:description => opts[:description] || template_name)
|
124
108
|
convert_image(client, new_image)
|
125
109
|
end
|
126
110
|
end
|
@@ -161,14 +145,14 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
161
145
|
def stop_instance(credentials, id)
|
162
146
|
client = new_client(credentials)
|
163
147
|
safely do
|
164
|
-
raise "ERROR: Operation
|
148
|
+
raise "ERROR: Operation stop failed" unless client.vm_action(id, :shutdown)
|
165
149
|
end
|
166
150
|
end
|
167
151
|
|
168
152
|
def destroy_instance(credentials, id)
|
169
153
|
client = new_client(credentials)
|
170
154
|
safely do
|
171
|
-
raise "ERROR: Operation
|
155
|
+
raise "ERROR: Operation destroy failed" unless client.destroy_vm(id)
|
172
156
|
end
|
173
157
|
end
|
174
158
|
|
@@ -187,42 +171,39 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
187
171
|
def create_instance(credentials, image_id, opts={})
|
188
172
|
client = new_client(credentials)
|
189
173
|
params = {}
|
190
|
-
name = opts[:name]
|
191
|
-
if not name
|
192
|
-
name = Time.now.to_i.to_s
|
193
|
-
end
|
194
|
-
if name.length > USER_NAME_MAX
|
195
|
-
raise "Parameter name must be #{USER_NAME_MAX} characters or less"
|
196
|
-
end
|
197
174
|
safely do
|
198
|
-
|
199
|
-
|
200
|
-
params[:hwp_id] = opts[:hwp_id] if opts[:hwp_id]
|
201
|
-
params[:hwp_memory] = opts[:hwp_memory] if opts[:hwp_memory]
|
202
|
-
params[:hwp_cpu] = opts[:hwp_cpu] if opts[:hwp_cpu]
|
203
|
-
if opts[:user_data]
|
204
|
-
params[:user_data] = opts[:user_data].gsub(/\n/,'')
|
175
|
+
if opts[:name]
|
176
|
+
raise "Parameter name must be #{USER_NAME_MAX} characters or less" if opts[:name].length > USER_NAME_MAX
|
205
177
|
end
|
206
|
-
|
178
|
+
params[:name] = opts[:name]
|
179
|
+
params[:template] = opts[:image_id]
|
180
|
+
params[:cluster] = opts[:realm_id] if opts[:realm_id]
|
181
|
+
params[:hwp_id] = opts[:hwp_id] if opts[:hwp_id]
|
182
|
+
params[:memory] = (opts[:hwp_memory].to_i * 1024 * 1024) if opts[:hwp_memory]
|
183
|
+
params[:cores] = opts[:hwp_cpu] if opts[:hwp_cpu]
|
184
|
+
params[:user_data] = opts[:user_data].gsub(/\n/,'') if opts[:user_data]
|
185
|
+
params[:fileinject_path] = "deltacloud-user-data.txt"
|
186
|
+
convert_instance(client, client.create_vm(params))
|
207
187
|
end
|
208
188
|
end
|
209
189
|
|
210
190
|
def valid_credentials?(credentials)
|
211
|
-
retval = true
|
212
191
|
begin
|
213
|
-
realms(credentials)
|
214
|
-
rescue
|
215
|
-
|
192
|
+
realms(credentials) && true
|
193
|
+
rescue => e
|
194
|
+
safely do
|
195
|
+
raise e
|
196
|
+
end
|
216
197
|
end
|
217
|
-
retval
|
218
198
|
end
|
219
199
|
|
220
200
|
private
|
221
201
|
|
222
202
|
def new_client(credentials)
|
223
|
-
url, datacenter = api_provider.split(';')
|
224
203
|
safely do
|
225
|
-
|
204
|
+
raise 'No API provider set for this request.' unless api_provider
|
205
|
+
url, datacenter = api_provider.split(';')
|
206
|
+
OVIRT::Client.new(credentials.user, credentials.password, url, datacenter)
|
226
207
|
end
|
227
208
|
end
|
228
209
|
|
@@ -247,10 +228,11 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
247
228
|
:hwp_cpu => inst.cores,
|
248
229
|
:hwp_storage => "#{storage_size}"
|
249
230
|
)
|
250
|
-
|
231
|
+
|
251
232
|
# First try to get IP address from RHEV-M. This require rhev-agent package
|
252
233
|
# installed on guest
|
253
|
-
public_addresses
|
234
|
+
public_addresses = inst.ips.map { |ip| InstanceAddress.new(ip, :type => :ipv4) }
|
235
|
+
|
254
236
|
# ConfServer will overide the IP address returned by RHEV-M guest agent
|
255
237
|
if ENV['CONFIG_SERVER_ADDRESS']
|
256
238
|
ip = confserver_ip(inst.id)
|
@@ -258,7 +240,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
258
240
|
end
|
259
241
|
# If IP retrieval failed, fallback to VNC and MAC address
|
260
242
|
if public_addresses.empty?
|
261
|
-
public_addresses = inst.
|
243
|
+
public_addresses = inst.interfaces.map { |interface| InstanceAddress.new(interface.mac, :type => :mac) }
|
262
244
|
end
|
263
245
|
if inst.vnc
|
264
246
|
public_addresses << InstanceAddress.new(inst.vnc[:address], :port => inst.vnc[:port], :type => :vnc)
|
@@ -269,7 +251,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
269
251
|
:state => state,
|
270
252
|
:image_id => inst.template.id,
|
271
253
|
:realm_id => inst.cluster.id,
|
272
|
-
:owner_id =>
|
254
|
+
:owner_id => client.credentials[:username],
|
273
255
|
:launch_time => inst.creation_time,
|
274
256
|
:instance_profile => profile,
|
275
257
|
:hardware_profile_id => profile.id,
|
@@ -293,8 +275,10 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
293
275
|
end
|
294
276
|
case state.strip.upcase
|
295
277
|
when 'WAIT_FOR_LAUNCH', 'REBOOT_IN_PROGRESS', 'SAVING_STATE',
|
296
|
-
'RESTORING_STATE', '
|
278
|
+
'RESTORING_STATE', 'POWERING_UP', 'IMAGE_LOCKED', 'SAVING_STATE' then
|
297
279
|
'PENDING'
|
280
|
+
when 'POWERING_DOWN' then
|
281
|
+
'STOPPING'
|
298
282
|
when 'UNASSIGNED', 'DOWN', 'PAUSED', 'NOT_RESPONDING', 'SUSPENDED', 'IMAGE_ILLEGAL', 'UNKNOWN' then
|
299
283
|
'STOPPED'
|
300
284
|
when 'UP', 'MIGRATING_TO', 'MIGRATING_FROM'
|
@@ -323,6 +307,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
323
307
|
:description => img.description,
|
324
308
|
:owner_id => client.credentials[:username],
|
325
309
|
:architecture => 'x86_64', # All RHEV-M VMs are x86_64
|
310
|
+
:hardware_profiles => hardware_profiles(nil),
|
326
311
|
:state => img.status
|
327
312
|
)
|
328
313
|
end
|
@@ -338,31 +323,28 @@ class RHEVMDriver < Deltacloud::BaseDriver
|
|
338
323
|
|
339
324
|
exceptions do
|
340
325
|
|
341
|
-
on /
|
342
|
-
status 400
|
343
|
-
end
|
344
|
-
|
345
|
-
on /RestClient::Unauthorized/ do
|
326
|
+
on /Unauthorized/ do
|
346
327
|
status 401
|
347
328
|
end
|
348
329
|
|
349
|
-
on /
|
350
|
-
|
330
|
+
on /(not supported|custom properties are not configured)/ do
|
331
|
+
message "The user_data, require the floppyinject hook installed in your RHEV-M deployment"
|
332
|
+
status 501
|
351
333
|
end
|
352
334
|
|
353
|
-
on /
|
335
|
+
on /(InternalServerError|nodename nor servname provided|no available running Hosts)/ do
|
354
336
|
status 502
|
355
337
|
end
|
356
338
|
|
357
|
-
on /(
|
358
|
-
status
|
339
|
+
on /(404|ResourceNotFound)/ do
|
340
|
+
status 404
|
359
341
|
end
|
360
342
|
|
361
|
-
on /(
|
362
|
-
status
|
343
|
+
on /(RestClient|RHEVM|OVIRT)/ do
|
344
|
+
status 500
|
363
345
|
end
|
364
346
|
|
365
|
-
on /Parameter name/ do
|
347
|
+
on /(Bad Request|Parameter name|No API provider)/ do
|
366
348
|
status 400
|
367
349
|
end
|
368
350
|
|
@@ -19,68 +19,61 @@
|
|
19
19
|
|
20
20
|
require "net/http"
|
21
21
|
require "net/https"
|
22
|
-
require "rubygems"
|
23
|
-
require "json"
|
24
|
-
require "deltacloud/base_driver"
|
25
22
|
|
26
|
-
module Deltacloud
|
27
|
-
module Drivers
|
28
|
-
module RimuHosting
|
23
|
+
module Deltacloud::Drivers::RimuHosting
|
29
24
|
|
30
|
-
class RimuHostingClient
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
end
|
37
|
-
|
38
|
-
def request(resource, data='', method='GET')
|
39
|
-
headers = {"Accept" => "application/json", "Content-Type" => "application/json"}
|
40
|
-
if(!@auth.nil?)
|
41
|
-
headers["Authorization"] = @auth
|
25
|
+
class RimuHostingClient
|
26
|
+
def initialize(credentials ,baseuri = 'https://rimuhosting.com/r')
|
27
|
+
@uri = URI.parse(baseuri)
|
28
|
+
@service = Net::HTTP.new(@uri.host, @uri.port)
|
29
|
+
@service.use_ssl = true
|
30
|
+
@auth = "rimuhosting apikey=#{credentials.password}"
|
42
31
|
end
|
43
|
-
safely do
|
44
|
-
r = @service.send_request(method, @uri.path + resource, data, headers)
|
45
|
-
puts r.body
|
46
|
-
res = JSON.parse(r.body)
|
47
|
-
res = res[res.keys[0]]
|
48
32
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
33
|
+
def request(resource, data='', method='GET')
|
34
|
+
headers = {"Accept" => "application/json", "Content-Type" => "application/json"}
|
35
|
+
if(!@auth.nil?)
|
36
|
+
headers["Authorization"] = @auth
|
37
|
+
end
|
38
|
+
safely do
|
39
|
+
r = @service.send_request(method, @uri.path + resource, data, headers)
|
40
|
+
res = JSON.parse(r.body)
|
41
|
+
res = res[res.keys[0]]
|
55
42
|
|
56
|
-
|
57
|
-
|
58
|
-
|
43
|
+
if(res['response_type'] == "ERROR" and ( (res['error_info']['error_class'] == "PermissionException") or
|
44
|
+
(res['error_info']['error_class'] == "LoginRequired") ))
|
45
|
+
raise "AuthFailure"
|
46
|
+
end
|
47
|
+
res
|
48
|
+
end
|
59
49
|
|
60
|
-
|
61
|
-
|
62
|
-
|
50
|
+
def list_images
|
51
|
+
request('/distributions')["distro_infos"]
|
52
|
+
end
|
63
53
|
|
64
|
-
|
65
|
-
|
66
|
-
|
54
|
+
def list_plans
|
55
|
+
request('/pricing-plans;server-type=VPS')["pricing_plan_infos"]
|
56
|
+
end
|
67
57
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
end
|
58
|
+
def list_nodes
|
59
|
+
request('/orders;include_inactive=N')["about_orders"]
|
60
|
+
end
|
72
61
|
|
73
|
-
|
74
|
-
|
75
|
-
|
62
|
+
def set_server_state(id, state)
|
63
|
+
json = {"reboot_request" => {"running_state" => state}}.to_json
|
64
|
+
request("/orders/order-#{id}-a/vps/running-state", json, 'PUT')
|
65
|
+
end
|
76
66
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
request('/orders/new-vps',json, 'POST')[:about_order]
|
81
|
-
end
|
82
|
-
end
|
67
|
+
def delete_server(id)
|
68
|
+
request("/orders/order-#{id}-a/vps",'', 'DELETE')
|
69
|
+
end
|
83
70
|
|
71
|
+
def create_server(image_id, plan_code, name)
|
72
|
+
json = {:new_vps => {:instantiation_options => {:domain_name => name, :distro => image_id},
|
73
|
+
:pricing_plan_code => plan_code}}.to_json
|
74
|
+
request('/orders/new-vps',json, 'POST')[:about_order]
|
75
|
+
end
|
84
76
|
end
|
77
|
+
|
85
78
|
end
|
86
79
|
end
|
@@ -16,14 +16,13 @@
|
|
16
16
|
# License for the specific language governing permissions and limitations
|
17
17
|
# under the License.
|
18
18
|
|
19
|
-
require "deltacloud/base_driver"
|
20
19
|
require "deltacloud/drivers/rimuhosting/rimuhosting_client"
|
21
20
|
|
22
21
|
module Deltacloud
|
23
22
|
module Drivers
|
24
|
-
module
|
23
|
+
module Rimuhosting
|
25
24
|
|
26
|
-
class
|
25
|
+
class RimuhostingDriver < Deltacloud::BaseDriver
|
27
26
|
|
28
27
|
feature :instances, :user_name
|
29
28
|
|
@@ -131,9 +130,9 @@ class RimuHostingDriver < Deltacloud::BaseDriver
|
|
131
130
|
:owner_id => "root",
|
132
131
|
:instance_profile => InstanceProfile.new("none"),
|
133
132
|
:actions => instance_actions_for("RUNNING"),
|
134
|
-
:public_addresses => [ InstanceAddress.new(inst["allocated_ips"]["primary_ip"] ),
|
135
|
-
:launch_time => inst["billing_info"]["order_date"]["iso_format"]
|
136
|
-
|
133
|
+
:public_addresses => [ InstanceAddress.new(inst["allocated_ips"]["primary_ip"] )],
|
134
|
+
:launch_time => inst["billing_info"]["order_date"]["iso_format"]}
|
135
|
+
)
|
137
136
|
end
|
138
137
|
|
139
138
|
define_instance_states do
|
@@ -142,9 +141,9 @@ class RimuHostingDriver < Deltacloud::BaseDriver
|
|
142
141
|
pending.to( :running ) .automatically
|
143
142
|
|
144
143
|
running.to( :running ) .on(:reboot)
|
145
|
-
running.to( :
|
144
|
+
running.to( :stopping ) .on(:stop)
|
146
145
|
|
147
|
-
|
146
|
+
stopping.to( :stopped ) .automatically
|
148
147
|
|
149
148
|
stopped.to( :finish ) .automatically
|
150
149
|
end
|
@@ -15,17 +15,17 @@
|
|
15
15
|
# under the License.
|
16
16
|
|
17
17
|
require 'nokogiri'
|
18
|
-
|
18
|
+
require_relative './sbc_client'
|
19
19
|
|
20
20
|
module Deltacloud
|
21
21
|
module Drivers
|
22
|
-
module
|
22
|
+
module Sbc
|
23
23
|
#
|
24
24
|
# Driver for the IBM Smart Business Cloud (SBC).
|
25
25
|
#
|
26
26
|
# 31 January 2011
|
27
27
|
#
|
28
|
-
class
|
28
|
+
class SbcDriver < Deltacloud::BaseDriver
|
29
29
|
#
|
30
30
|
# Retrieves images
|
31
31
|
#
|