deltacloud-core 0.1.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/DISCLAIMER +8 -0
- data/{COPYING → LICENSE} +0 -0
- data/NOTICE +13 -0
- data/Rakefile +50 -51
- data/bin/deltacloudd +8 -1
- data/config.ru +0 -2
- data/config/drivers.yaml +48 -0
- data/deltacloud-core.gemspec +75 -0
- data/deltacloud.rb +3 -2
- data/lib/deltacloud/backend_capability.rb +15 -3
- data/lib/deltacloud/base_driver.rb +0 -2
- data/lib/deltacloud/base_driver/base_driver.rb +85 -89
- data/lib/deltacloud/base_driver/features.rb +61 -7
- data/lib/deltacloud/base_driver/mock_driver.rb +42 -43
- data/lib/deltacloud/core_ext.rb +18 -0
- data/lib/deltacloud/core_ext/integer.rb +31 -0
- data/lib/deltacloud/core_ext/string.rb +50 -0
- data/lib/deltacloud/drivers/azure/azure_driver.rb +71 -22
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +641 -584
- data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +0 -2
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +167 -0
- data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +39 -1
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +41 -25
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob1.yml +6 -3
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob2.yml +6 -3
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob3.yml +4 -2
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob4.yml +5 -2
- data/lib/deltacloud/drivers/mock/data/buckets/blobs/blob5.yml +4 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol1.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol2.yml +1 -0
- data/lib/deltacloud/drivers/mock/data/storage_volumes/vol3.yml +1 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +138 -30
- data/lib/deltacloud/drivers/opennebula/cloud_client.rb +13 -15
- data/lib/deltacloud/drivers/opennebula/occi_client.rb +13 -15
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +13 -15
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +224 -113
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +332 -0
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +221 -170
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +0 -1
- data/lib/deltacloud/drivers/sbc/sbc_client.rb +247 -0
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +297 -0
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +0 -2
- data/lib/deltacloud/hardware_profile.rb +1 -3
- data/lib/deltacloud/helpers.rb +0 -2
- data/lib/deltacloud/helpers/application_helper.rb +86 -12
- data/lib/deltacloud/helpers/blob_stream.rb +19 -2
- data/lib/deltacloud/helpers/conversion_helper.rb +0 -2
- data/lib/deltacloud/helpers/hardware_profiles_helper.rb +0 -2
- data/lib/deltacloud/method_serializer.rb +0 -2
- data/lib/deltacloud/models/base_model.rb +0 -2
- data/lib/deltacloud/models/blob.rb +1 -2
- data/lib/deltacloud/models/bucket.rb +0 -2
- data/lib/deltacloud/models/image.rb +0 -2
- data/lib/deltacloud/models/instance.rb +19 -2
- data/lib/deltacloud/models/instance_profile.rb +4 -2
- data/lib/deltacloud/models/key.rb +0 -2
- data/lib/deltacloud/models/load_balancer.rb +0 -2
- data/lib/deltacloud/models/realm.rb +0 -2
- data/lib/deltacloud/models/storage_snapshot.rb +0 -2
- data/lib/deltacloud/models/storage_volume.rb +4 -2
- data/lib/deltacloud/runner.rb +132 -0
- data/lib/deltacloud/state_machine.rb +0 -2
- data/lib/deltacloud/validation.rb +9 -7
- data/lib/drivers.rb +36 -48
- data/lib/sinatra/accept_media_types.rb +26 -0
- data/lib/sinatra/lazy_auth.rb +16 -0
- data/lib/sinatra/rabbit.rb +112 -54
- data/lib/sinatra/rack_driver_select.rb +50 -16
- data/lib/sinatra/rack_etag.rb +79 -0
- data/lib/sinatra/rack_matrix_params.rb +84 -0
- data/lib/sinatra/rack_runtime.rb +47 -0
- data/lib/sinatra/static_assets.rb +16 -0
- data/lib/sinatra/url_for.rb +31 -4
- data/public/favicon.ico +0 -0
- data/public/images/bread-bg.png +0 -0
- data/public/images/error.png +0 -0
- data/public/images/pending.png +0 -0
- data/public/images/running.png +0 -0
- data/public/images/stopped.png +0 -0
- data/public/javascripts/application.js +35 -0
- data/public/stylesheets/compiled/application.css +59 -5
- data/public/stylesheets/compiled/screen.css +1 -1
- data/server.rb +293 -29
- data/support/fedora/deltacloud-core +78 -0
- data/support/fedora/deltacloud-core.spec +143 -0
- data/support/fedora/deltacloudd +78 -18
- data/support/fedora/rubygem-deltacloud-core.spec +76 -40
- data/tests/common.rb +172 -0
- data/tests/drivers/mock/api_test.rb +133 -0
- data/tests/drivers/mock/hardware_profiles_test.rb +134 -0
- data/tests/drivers/mock/images_test.rb +126 -0
- data/tests/drivers/mock/instance_states_test.rb +71 -0
- data/tests/drivers/mock/instances_test.rb +236 -0
- data/tests/drivers/mock/realms_test.rb +93 -0
- data/tests/drivers/mock/setup.rb +3 -0
- data/tests/drivers/mock/url_for_test.rb +67 -0
- data/tests/drivers/rackspace/api_test.rb +41 -0
- data/tests/drivers/rackspace/hardware_profiles_test.rb +53 -0
- data/tests/drivers/rackspace/images_test.rb +40 -0
- data/tests/drivers/rackspace/instances_test.rb +161 -0
- data/tests/drivers/rackspace/realms_test.rb +36 -0
- data/tests/drivers/rackspace/setup.rb +14 -0
- data/tests/drivers/rhevm/api_test.rb +39 -0
- data/tests/drivers/rhevm/hardware_profiles_test.rb +53 -0
- data/tests/drivers/rhevm/images_test.rb +42 -0
- data/tests/drivers/rhevm/instances_test.rb +179 -0
- data/tests/drivers/rhevm/realms_test.rb +35 -0
- data/tests/drivers/rhevm/setup.rb +14 -0
- data/tests/rabbit_test.rb +52 -0
- data/views/api/show.html.haml +2 -5
- data/views/blobs/new.html.haml +17 -1
- data/views/blobs/show.html.haml +6 -0
- data/views/blobs/show.xml.haml +5 -1
- data/views/buckets/index.html.haml +1 -12
- data/views/buckets/index.xml.haml +3 -5
- data/views/docs/operation.html.haml +23 -11
- data/views/drivers/index.html.haml +15 -0
- data/views/drivers/index.xml.haml +7 -0
- data/views/drivers/show.html.haml +20 -0
- data/views/drivers/show.xml.haml +7 -0
- data/views/error.html.haml +31 -0
- data/views/errors/auth_exception.xml.haml +2 -1
- data/views/errors/backend_capability_failure.xml.haml +2 -1
- data/views/errors/backend_error.html.haml +3 -0
- data/views/errors/backend_error.xml.haml +2 -2
- data/views/errors/validation_failure.xml.haml +3 -2
- data/views/images/index.html.haml +1 -6
- data/views/images/index.xml.haml +2 -0
- data/views/images/new.html.haml +14 -0
- data/views/images/show.xml.haml +2 -0
- data/views/instances/index.html.haml +8 -6
- data/views/instances/index.xml.haml +4 -0
- data/views/instances/new.html.haml +40 -11
- data/views/instances/run.html.haml +9 -0
- data/views/instances/run.xml.haml +7 -0
- data/views/instances/run_command.html.haml +16 -0
- data/views/instances/show.html.haml +14 -0
- data/views/instances/show.xml.haml +12 -4
- data/views/layout.html.haml +7 -2
- data/views/load_balancers/index.html.haml +1 -1
- data/views/load_balancers/new.html.haml +2 -2
- data/views/load_balancers/show.html.haml +1 -1
- data/views/storage_snapshots/index.html.haml +3 -0
- data/views/storage_snapshots/new.html.haml +9 -0
- data/views/storage_volumes/attach.html.haml +20 -0
- data/views/storage_volumes/index.html.haml +16 -1
- data/views/storage_volumes/index.xml.haml +1 -10
- data/views/storage_volumes/new.html.haml +17 -0
- data/views/storage_volumes/show.html.haml +8 -0
- data/views/storage_volumes/show.xml.haml +25 -3
- metadata +197 -127
- data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +0 -130
- data/parse.rb +0 -7
- data/test.rb +0 -3
- data/views/api/drivers.xml.haml +0 -6
@@ -1,130 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2009, 2010 Red Hat, Inc.
|
3
|
-
#
|
4
|
-
# Licensed to the Apache Software Foundation (ASF) under one or more
|
5
|
-
# contributor license agreements. See the NOTICE file distributed with
|
6
|
-
# this work for additional information regarding copyright ownership. The
|
7
|
-
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
8
|
-
# "License"); you may not use this file except in compliance with the
|
9
|
-
# License. You may obtain a copy of the License at
|
10
|
-
#
|
11
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
-
#
|
13
|
-
# Unless required by applicable law or agreed to in writing, software
|
14
|
-
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
15
|
-
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
16
|
-
# License for the specific language governing permissions and limitations
|
17
|
-
# under the License.
|
18
|
-
|
19
|
-
require "net/http"
|
20
|
-
require "net/https"
|
21
|
-
require 'rubygems'
|
22
|
-
require 'json'
|
23
|
-
|
24
|
-
#
|
25
|
-
# author: Michael Neale
|
26
|
-
# TODO: catch generic errors in JSON response and throw (probably)
|
27
|
-
#
|
28
|
-
module Deltacloud
|
29
|
-
module Drivers
|
30
|
-
module Rackspace
|
31
|
-
|
32
|
-
class RackspaceClient
|
33
|
-
|
34
|
-
@@AUTH_API = URI.parse('https://auth.api.rackspacecloud.com/v1.0')
|
35
|
-
|
36
|
-
def initialize(username, auth_key)
|
37
|
-
http = Net::HTTP.new(@@AUTH_API.host,@@AUTH_API.port)
|
38
|
-
http.use_ssl = true
|
39
|
-
authed = http.get(@@AUTH_API.path, {'X-Auth-User' => username, 'X-Auth-Key' => auth_key})
|
40
|
-
if authed.is_a?(Net::HTTPUnauthorized)
|
41
|
-
raise Deltacloud::AuthException, "Failed to authenticate to Rackspace"
|
42
|
-
elsif !authed.is_a?(Net::HTTPSuccess)
|
43
|
-
backend_error!(resp)
|
44
|
-
end
|
45
|
-
@auth_token = authed.header['X-Auth-Token']
|
46
|
-
@service_uri = URI.parse(authed.header['X-Server-Management-Url'])
|
47
|
-
@service = Net::HTTP.new(@service_uri.host, @service_uri.port)
|
48
|
-
@service.use_ssl = true
|
49
|
-
end
|
50
|
-
|
51
|
-
def list_flavors
|
52
|
-
JSON.parse(get('/flavors/detail'))['flavors']
|
53
|
-
end
|
54
|
-
|
55
|
-
def list_images
|
56
|
-
JSON.parse(get('/images/detail'))['images']
|
57
|
-
end
|
58
|
-
|
59
|
-
def list_servers
|
60
|
-
JSON.parse(get('/servers/detail'))['servers']
|
61
|
-
end
|
62
|
-
|
63
|
-
|
64
|
-
def load_server_details( server_id )
|
65
|
-
JSON.parse(get("/servers/#{server_id}"))['server']
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
def start_server(image_id, flavor_id, name)
|
70
|
-
json = { :server => { :name => name,
|
71
|
-
:imageId => image_id.to_i,
|
72
|
-
:flavorId => flavor_id.to_i }}.to_json
|
73
|
-
# FIXME: The response has the root password in 'adminPass'; we somehow
|
74
|
-
# need to communicate this back since it's the only place where we can
|
75
|
-
# get it from
|
76
|
-
JSON.parse(post("/servers", json, headers).body)["server"]
|
77
|
-
end
|
78
|
-
|
79
|
-
def delete_server(server_id)
|
80
|
-
delete("/servers/#{server_id}", headers)
|
81
|
-
end
|
82
|
-
|
83
|
-
def reboot_server(server_id)
|
84
|
-
json = { :reboot => { :type => :SOFT }}.to_json
|
85
|
-
post("/servers/#{server_id}/action", json, headers)
|
86
|
-
end
|
87
|
-
|
88
|
-
|
89
|
-
def headers
|
90
|
-
{"Accept" => "application/json", "X-Auth-Token" => @auth_token, "Content-Type" => "application/json"}
|
91
|
-
end
|
92
|
-
|
93
|
-
private
|
94
|
-
def get(path)
|
95
|
-
resp = @service.get(@service_uri.path + path, {"Accept" => "application/json", "X-Auth-Token" => @auth_token})
|
96
|
-
unless resp.is_a?(Net::HTTPSuccess)
|
97
|
-
backend_error!(resp)
|
98
|
-
end
|
99
|
-
resp.body
|
100
|
-
end
|
101
|
-
|
102
|
-
def post(path, json, headers)
|
103
|
-
resp = @service.post(@service_uri.path + path, json, headers)
|
104
|
-
unless resp.is_a?(Net::HTTPSuccess)
|
105
|
-
backend_error!(resp)
|
106
|
-
end
|
107
|
-
resp
|
108
|
-
end
|
109
|
-
|
110
|
-
def delete(path, headers)
|
111
|
-
resp = @service.delete(@service_uri.path + path, headers)
|
112
|
-
unless resp.is_a?(Net::HTTPSuccess)
|
113
|
-
backend_error!(resp)
|
114
|
-
end
|
115
|
-
resp
|
116
|
-
end
|
117
|
-
|
118
|
-
def backend_error!(resp)
|
119
|
-
json = JSON.parse(resp.body)
|
120
|
-
cause = json.keys[0]
|
121
|
-
code = json[cause]["code"]
|
122
|
-
message = json[cause]["message"]
|
123
|
-
details = json[cause]["details"]
|
124
|
-
raise Deltacloud::BackendError.new(code, cause, message, details)
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|
130
|
-
end
|
data/parse.rb
DELETED
data/test.rb
DELETED