deltacloud-core 0.4.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +63 -7
- data/bin/deltacloudd +29 -17
- data/config.ru +5 -3
- data/config/drivers/ec2.yaml +9 -0
- data/config/drivers/google.yaml +3 -0
- data/config/drivers/openstack.yaml +3 -0
- data/deltacloud-core.gemspec +1 -1
- data/lib/cimi/dependencies.rb +62 -0
- data/lib/cimi/helpers/cimi_helper.rb +50 -0
- data/lib/cimi/model.rb +52 -0
- data/lib/cimi/model/action.rb +24 -0
- data/lib/cimi/model/base.rb +249 -0
- data/lib/cimi/model/cloud_entry_point.rb +48 -0
- data/lib/cimi/model/entity_metadata.rb +83 -0
- data/lib/cimi/model/entity_metadata_collection.rb +31 -0
- data/lib/cimi/model/errors.rb +40 -0
- data/lib/cimi/model/machine.rb +227 -0
- data/lib/cimi/model/machine_admin.rb +59 -0
- data/lib/cimi/model/machine_admin_collection.rb +34 -0
- data/lib/cimi/model/machine_collection.rb +34 -0
- data/lib/cimi/model/machine_configuration.rb +67 -0
- data/lib/cimi/model/machine_configuration_collection.rb +34 -0
- data/lib/cimi/model/machine_image.rb +46 -0
- data/lib/cimi/model/machine_image_collection.rb +34 -0
- data/lib/cimi/model/machine_template.rb +41 -0
- data/lib/cimi/model/machine_template_collection.rb +34 -0
- data/lib/cimi/model/network.rb +69 -0
- data/lib/cimi/model/network_collection.rb +34 -0
- data/lib/cimi/model/network_configuration.rb +50 -0
- data/lib/cimi/model/network_configuration_collection.rb +34 -0
- data/lib/cimi/model/network_template.rb +26 -0
- data/lib/cimi/model/schema.rb +277 -0
- data/lib/cimi/model/volume.rb +103 -0
- data/lib/cimi/model/volume_collection.rb +34 -0
- data/lib/cimi/model/volume_configuration.rb +60 -0
- data/lib/cimi/model/volume_configuration_collection.rb +34 -0
- data/lib/cimi/model/volume_image.rb +49 -0
- data/lib/cimi/model/volume_image_collection.rb +34 -0
- data/lib/cimi/model/volume_template.rb +23 -0
- data/lib/cimi/model/volume_template_collection.rb +34 -0
- data/lib/cimi/server.rb +575 -0
- data/lib/deltacloud/base_driver/base_driver.rb +11 -1
- data/lib/deltacloud/core_ext.rb +2 -0
- data/lib/deltacloud/core_ext/array.rb +25 -0
- data/lib/deltacloud/core_ext/hash.rb +7 -0
- data/lib/deltacloud/core_ext/proc.rb +31 -0
- data/lib/deltacloud/core_ext/string.rb +15 -0
- data/lib/deltacloud/drivers/condor/condor_driver.rb +2 -1
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +32 -10
- data/lib/deltacloud/drivers/eucalyptus/eucalyptus_driver.rb +1 -1
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +1 -1
- data/lib/deltacloud/drivers/google/google_driver.rb +233 -0
- data/lib/deltacloud/drivers/mock/data/instances/inst0.yml +7 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst1.yml +7 -2
- data/lib/deltacloud/drivers/mock/data/instances/inst2.yml +7 -2
- data/lib/deltacloud/drivers/mock/mock_client.rb +17 -0
- data/lib/deltacloud/drivers/mock/mock_driver.rb +82 -8
- data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +1 -1
- data/lib/deltacloud/drivers/openstack/openstack_driver.rb +47 -0
- data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +8 -8
- data/lib/deltacloud/drivers/rhevm/rhevm_client.rb +122 -49
- data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +42 -22
- data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +1 -1
- data/lib/deltacloud/drivers/sbc/sbc_driver.rb +3 -2
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +2 -2
- data/lib/deltacloud/drivers/vsphere/vsphere_client.rb +25 -4
- data/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +35 -12
- data/lib/deltacloud/hardware_profile.rb +34 -10
- data/lib/deltacloud/helpers/application_helper.rb +3 -28
- data/lib/deltacloud/helpers/blob_stream.rb +2 -1
- data/lib/deltacloud/models.rb +2 -0
- data/lib/deltacloud/models/bucket.rb +1 -1
- data/lib/deltacloud/models/image.rb +1 -1
- data/lib/deltacloud/models/instance.rb +2 -1
- data/lib/deltacloud/models/instance_address.rb +56 -0
- data/lib/deltacloud/models/provider.rb +27 -0
- data/{server.rb → lib/deltacloud/server.rb} +72 -14
- data/lib/deltacloud/validation.rb +31 -10
- data/lib/sinatra/rabbit.rb +34 -26
- data/lib/sinatra/rack_accept.rb +5 -5
- data/lib/sinatra/rack_matrix_params.rb +6 -2
- data/lib/sinatra/rack_syslog.rb +3 -3
- data/lib/sinatra/static_assets.rb +1 -1
- data/lib/sinatra/url_for.rb +1 -7
- data/public/images/bread-bg.png +0 -0
- data/public/images/logo-wide.png +0 -0
- data/public/images/topbar-bg.png +0 -0
- data/public/javascripts/application.js +5 -0
- data/public/javascripts/cmwgapp.js +249 -0
- data/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/public/javascripts/jquery.mobile-1.0rc1.min.js +170 -0
- data/public/stylesheets/images/icons-18-black.png +0 -0
- data/public/stylesheets/images/icons-18-white.png +0 -0
- data/public/stylesheets/images/icons-36-black.png +0 -0
- data/public/stylesheets/images/icons-36-white.png +0 -0
- data/public/stylesheets/jquery.mobile-1.0rc1.min.css +12 -0
- data/public/stylesheets/new.css +4 -0
- data/support/fedora/deltacloud-core.init +20 -13
- data/tests/cimi/features/step_definitions/common_steps.rb +59 -0
- data/tests/cimi/features/step_definitions/machine_images_steps.rb +0 -0
- data/tests/cimi/features/step_definitions/machines_steps.rb +99 -0
- data/tests/cimi/features/step_definitions/volumes_steps.rb +115 -0
- data/tests/cimi/features/support/env.rb +53 -0
- data/tests/common.rb +89 -11
- data/tests/core_ext/string.rb +31 -0
- data/tests/drivers/google/api_test.rb +35 -0
- data/tests/drivers/google/buckets_test.rb +116 -0
- data/tests/drivers/google/setup.rb +38 -0
- data/tests/drivers/mock/instances_test.rb +20 -5
- data/tests/drivers/openstack/api_test.rb +41 -0
- data/tests/drivers/openstack/hardware_profiles_test.rb +53 -0
- data/tests/drivers/openstack/images_test.rb +40 -0
- data/tests/drivers/openstack/instances_test.rb +163 -0
- data/tests/drivers/openstack/realms_test.rb +36 -0
- data/tests/drivers/openstack/setup.rb +20 -0
- data/tests/drivers/rackspace/buckets_test.rb +145 -0
- data/tests/drivers/rackspace/setup.rb +3 -3
- data/tests/drivers/rhevm/api_test.rb +1 -1
- data/tests/drivers/rhevm/images_test.rb +2 -2
- data/tests/drivers/rhevm/instances_test.rb +10 -12
- data/tests/drivers/rhevm/realms_test.rb +4 -4
- data/tests/drivers/rhevm/setup.rb +3 -3
- data/tests/rabbit_test.rb +1 -1
- data/views/api/show.html.haml +13 -0
- data/views/cimi/cloudEntryPoint/index.html.haml +5 -0
- data/views/cimi/cloudEntryPoint/index.xml.haml +9 -0
- data/views/cimi/collection/index.html.haml +45 -0
- data/views/cimi/collection/response.xml.haml +3 -0
- data/views/cimi/error.html.haml +31 -0
- data/views/cimi/errors/400.html.haml +41 -0
- data/views/cimi/errors/400.xml.haml +3 -0
- data/views/cimi/errors/401.html.haml +41 -0
- data/views/cimi/errors/401.xml.haml +2 -0
- data/views/cimi/errors/403.html.haml +42 -0
- data/views/cimi/errors/403.xml.haml +2 -0
- data/views/cimi/errors/404.html.haml +29 -0
- data/views/cimi/errors/404.xml.haml +2 -0
- data/views/cimi/errors/405.html.haml +29 -0
- data/views/cimi/errors/405.xml.haml +5 -0
- data/views/cimi/errors/500.html.haml +43 -0
- data/views/cimi/errors/500.xml.haml +6 -0
- data/views/cimi/errors/502.html.haml +43 -0
- data/views/cimi/errors/502.xml.haml +7 -0
- data/views/cimi/errors/backend_capability_failure.html.haml +29 -0
- data/views/cimi/layout.html.haml +32 -0
- data/views/cimi/machine_configurations/show.html.haml +159 -0
- data/views/cimi/machine_configurations/show.xml.haml +27 -0
- data/views/cimi/machine_images/show.html.haml +79 -0
- data/views/cimi/machine_images/show.xml.haml +17 -0
- data/views/cimi/machines/show.html.haml +177 -0
- data/views/cimi/machines/show.xml.haml +28 -0
- data/views/cimi/volumes/show.html.haml +68 -0
- data/views/cimi/volumes/show.xml.haml +17 -0
- data/views/drivers/show.html.haml +10 -5
- data/views/drivers/show.xml.haml +9 -4
- data/views/error.html.haml +2 -2
- data/views/errors/500.xml.haml +7 -1
- data/views/instances/index.html.haml +1 -1
- data/views/instances/new.html.haml +19 -16
- data/views/instances/show.html.haml +7 -2
- data/views/instances/show.xml.haml +8 -7
- data/views/layout.html.haml +2 -2
- data/views/storage_volumes/show.html.haml +1 -1
- metadata +296 -204
- data/public/javascripts/jquery.mobile-1.0b1.min.js +0 -146
- data/public/stylesheets/jquery.mobile-1.0b1.min.css +0 -8
data/Rakefile
CHANGED
|
@@ -20,12 +20,16 @@
|
|
|
20
20
|
require 'rake'
|
|
21
21
|
require 'rake/testtask'
|
|
22
22
|
require 'rubygems/package_task'
|
|
23
|
+
require 'rspec/core/rake_task'
|
|
23
24
|
|
|
24
25
|
begin
|
|
25
26
|
require 'ci/reporter/rake/test_unit'
|
|
26
27
|
rescue LoadError
|
|
27
28
|
end
|
|
28
29
|
|
|
30
|
+
$top_srcdir = File.dirname(__FILE__)
|
|
31
|
+
$:.unshift File.join($top_srcdir, 'lib')
|
|
32
|
+
|
|
29
33
|
begin
|
|
30
34
|
require 'cucumber'
|
|
31
35
|
require 'cucumber/rake/task'
|
|
@@ -46,11 +50,29 @@ begin
|
|
|
46
50
|
end
|
|
47
51
|
end
|
|
48
52
|
end
|
|
53
|
+
Cucumber::Rake::Task.new(:cimi) do |t|
|
|
54
|
+
t.cucumber_opts = "tests/cimi/features --format pretty"
|
|
55
|
+
t.rcov = false
|
|
56
|
+
end
|
|
57
|
+
namespace :cimi do
|
|
58
|
+
Cucumber::Rake::Task.new(:machines) do |t|
|
|
59
|
+
t.cucumber_opts = "tests/cimi/features/machines.feature --format pretty"
|
|
60
|
+
t.rcov = false
|
|
61
|
+
end
|
|
62
|
+
Cucumber::Rake::Task.new(:machine_images) do |t|
|
|
63
|
+
t.cucumber_opts = "tests/cimi/features/machine_images.feature --format pretty"
|
|
64
|
+
t.rcov = false
|
|
65
|
+
end
|
|
66
|
+
Cucumber::Rake::Task.new(:volumes) do |t|
|
|
67
|
+
t.cucumber_opts = "tests/cimi/features/volumes.feature --format pretty"
|
|
68
|
+
t.rcov = false
|
|
69
|
+
end
|
|
70
|
+
end
|
|
49
71
|
rescue LoadError
|
|
50
72
|
end
|
|
51
73
|
|
|
52
74
|
namespace :test do
|
|
53
|
-
%w(mock rackspace rhevm).each do |driver|
|
|
75
|
+
%w(mock rackspace rhevm openstack google).each do |driver|
|
|
54
76
|
desc "Run #{driver} unit tests"
|
|
55
77
|
Rake::TestTask.new(driver) { |t|
|
|
56
78
|
t.test_files = ['tests/common.rb', "tests/drivers/#{driver}/setup.rb"] + FileList.new("tests/drivers/#{driver}/*_test.rb") + FileList.new('tests/rabbit_test.rb')
|
|
@@ -59,11 +81,20 @@ namespace :test do
|
|
|
59
81
|
t.warning = false
|
|
60
82
|
}
|
|
61
83
|
end
|
|
84
|
+
|
|
85
|
+
desc "Run CIMI frontend tests"
|
|
86
|
+
Rake::TestTask.new "cimi" do |t|
|
|
87
|
+
t.test_files = ["tests/cimi/cimi.rb", "tests/cimi/common/*_test.rb"]
|
|
88
|
+
t.options = "-v -v"
|
|
89
|
+
t.verbose = true
|
|
90
|
+
t.warning = false
|
|
91
|
+
end
|
|
92
|
+
|
|
62
93
|
end
|
|
63
94
|
|
|
64
95
|
desc "Call our Test::Unit suite"
|
|
65
96
|
task :test do
|
|
66
|
-
%w(mock rackspace rhevm).each do |driver|
|
|
97
|
+
%w(mock rackspace rhevm openstack google).each do |driver|
|
|
67
98
|
Rake::Task["test:#{driver}"].reenable
|
|
68
99
|
Rake::Task["test:#{driver}"].invoke
|
|
69
100
|
end
|
|
@@ -77,6 +108,20 @@ task :cucumber do
|
|
|
77
108
|
end
|
|
78
109
|
end
|
|
79
110
|
|
|
111
|
+
RSpec::Core::RakeTask.new do |t|
|
|
112
|
+
t.pattern = FileList['spec/**/*_spec.rb']
|
|
113
|
+
t.rspec_opts = [ "--format", "nested", "--color", "-r ./spec/spec_helper.rb"]
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
Dir['spec/**/*_spec.rb'].each do |file|
|
|
117
|
+
RSpec::Core::RakeTask.new("spec:#{File.basename(file).gsub(/_spec\.rb$/, '')}") do |t|
|
|
118
|
+
t.pattern = FileList[file]
|
|
119
|
+
t.rspec_opts = [ "--format", "nested", "--color", "-r ./spec/spec_helper.rb"]
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
80
125
|
begin
|
|
81
126
|
require 'yard'
|
|
82
127
|
YARD::Rake::YardocTask.new do |t|
|
|
@@ -91,14 +136,25 @@ Gem::PackageTask.new(spec) do |pkg|
|
|
|
91
136
|
pkg.need_tar = true
|
|
92
137
|
end
|
|
93
138
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
139
|
+
namespace :routes do
|
|
140
|
+
desc "List all REST routes for the Deltacloud API"
|
|
141
|
+
task :api do
|
|
142
|
+
require 'deltacloud/server.rb'
|
|
143
|
+
Sinatra::Rabbit::routes.each do |m, path|
|
|
144
|
+
puts sprintf("\033[1;30m%-8s\033[0m %s", m.to_s.upcase, path)
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
desc "List all REST routes for the CIMI API"
|
|
149
|
+
task :cimi do
|
|
150
|
+
require 'cimi/server.rb'
|
|
151
|
+
Sinatra::Rabbit::routes.each do |m, path|
|
|
152
|
+
puts sprintf("\033[1;30m%-8s\033[0m %s", m.to_s.upcase, path)
|
|
153
|
+
end
|
|
99
154
|
end
|
|
100
155
|
end
|
|
101
156
|
|
|
157
|
+
|
|
102
158
|
namespace :mock do
|
|
103
159
|
namespace :fixtures do
|
|
104
160
|
desc "Setup Mock driver fixtures"
|
data/bin/deltacloudd
CHANGED
|
@@ -16,6 +16,8 @@
|
|
|
16
16
|
# under the License.
|
|
17
17
|
#
|
|
18
18
|
|
|
19
|
+
$top_srcdir = File::expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
20
|
+
|
|
19
21
|
require 'rubygems'
|
|
20
22
|
require 'optparse'
|
|
21
23
|
require 'yaml'
|
|
@@ -33,6 +35,7 @@ def library_present?(name)
|
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
DEFAULT_CONFIG = "~/.deltacloud/config"
|
|
38
|
+
|
|
36
39
|
options = {
|
|
37
40
|
:env => 'development'
|
|
38
41
|
}
|
|
@@ -57,6 +60,9 @@ BANNER
|
|
|
57
60
|
opts.on( '-P', '--provider PROVIDER', 'Use PROVIDER (default is set in the driver)') do |provider|
|
|
58
61
|
ENV['API_PROVIDER'] = provider
|
|
59
62
|
end
|
|
63
|
+
opts.on('--cimi', 'USe the DMTF CIMI frontend, not the Deltacloud frontend') do
|
|
64
|
+
ENV['API_FRONTEND'] = 'cimi'
|
|
65
|
+
end
|
|
60
66
|
opts.on( '-c', '--config [FILE]', 'Read provider and other config from FILE (default: ~/.deltacloud/config)') do |config|
|
|
61
67
|
options[:config] = File::expand_path(config || DEFAULT_CONFIG)
|
|
62
68
|
end
|
|
@@ -65,7 +71,8 @@ BANNER
|
|
|
65
71
|
options[:daemon] = true
|
|
66
72
|
end
|
|
67
73
|
opts.on( '-u', '--user USER', 'User to run daemon as. Use with -d (default: "nobody")') { |user| options[:user] = user }
|
|
68
|
-
opts.on( '', '--
|
|
74
|
+
opts.on( '-g', '--group GROUP', 'Group to run daemon as. Use with -d (default: "nobody")') { |group| options[:group] = group }
|
|
75
|
+
opts.on( '-b', '--pid PID', 'File to store PID (default: tmp/pids/thin.pid)') { |pid| options[:pid] = pid }
|
|
69
76
|
opts.on( '-l', '--drivers', 'List available drivers') { |env| options[:drivers] = true }
|
|
70
77
|
opts.on( '-s', '--ssl', 'Enable SSL (default: disabled)') { |ssl| options[:ssl] = true }
|
|
71
78
|
opts.on( '-k', '--ssl-key KEY', 'SSL key file to use') { |key| options[:ssl_key] = key }
|
|
@@ -76,6 +83,9 @@ BANNER
|
|
|
76
83
|
opts.on( '-V', '--verbose', 'Set verbose logging on') do |verbose|
|
|
77
84
|
ENV["API_VERBOSE"] ||= 'true'
|
|
78
85
|
end
|
|
86
|
+
opts.on( nil, '--webrick', 'Force the use of WEBRick as a server') do |opt|
|
|
87
|
+
options[:webrick] = true
|
|
88
|
+
end
|
|
79
89
|
opts.on( '-h', '--help', '') { options[:help] = true }
|
|
80
90
|
|
|
81
91
|
opts.separator <<EOS
|
|
@@ -112,7 +122,9 @@ unless options[:drivers] or ENV["API_DRIVER"]
|
|
|
112
122
|
end
|
|
113
123
|
|
|
114
124
|
if options[:drivers]
|
|
115
|
-
|
|
125
|
+
$:.unshift File.join($top_srcdir, 'lib')
|
|
126
|
+
server_dir = ENV['API_FRONTEND'] == 'cimi' ? 'cimi' : 'deltacloud'
|
|
127
|
+
load File.join($top_srcdir, 'lib', server_dir, 'server.rb')
|
|
116
128
|
puts "Available drivers:\n\n"
|
|
117
129
|
puts "* " + driver_config.keys.map{ |d| d.to_s }.join("\n* ")
|
|
118
130
|
puts
|
|
@@ -146,10 +158,11 @@ ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
|
|
|
146
158
|
unless options[:daemon]
|
|
147
159
|
msg = "Starting Deltacloud API :: #{ENV["API_DRIVER"]} "
|
|
148
160
|
msg << ":: #{ENV['API_PROVIDER']} " if ENV['API_PROVIDER']
|
|
161
|
+
api_uri = ENV['API_FRONTEND'] == 'cimi' ? 'cimi/cloudEntryPoint' : 'api'
|
|
149
162
|
if options[:ssl]
|
|
150
|
-
msg << ":: https://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}
|
|
163
|
+
msg << ":: https://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/#{api_uri}"
|
|
151
164
|
else
|
|
152
|
-
msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}
|
|
165
|
+
msg << ":: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/#{api_uri}"
|
|
153
166
|
end
|
|
154
167
|
puts msg
|
|
155
168
|
puts
|
|
@@ -161,23 +174,21 @@ if ENV['API_USER'] && ENV['API_PASSWORD']
|
|
|
161
174
|
puts
|
|
162
175
|
end
|
|
163
176
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
have_thin = library_present?('thin')
|
|
177
|
+
have_thin = options[:webrick].nil? && library_present?('thin')
|
|
167
178
|
have_rerun = library_present?('rerun')
|
|
168
179
|
|
|
169
180
|
unless have_thin
|
|
170
181
|
require 'rack'
|
|
171
182
|
|
|
172
183
|
# Read in config.ru and convert it to an instance of Rack::Builder
|
|
173
|
-
cfgfile = File.read(File.join(
|
|
184
|
+
cfgfile = File.read(File.join($top_srcdir, 'config.ru'))
|
|
174
185
|
inner_app = eval("Rack::Builder.new {(" + cfgfile + "\n )}.to_app",
|
|
175
186
|
nil, 'config.ru')
|
|
176
187
|
|
|
177
188
|
app = Rack::Builder.new {
|
|
178
189
|
use Rack::CommonLogger # apache-like logging
|
|
179
190
|
use Rack::Reloader if options[:env] == "development"
|
|
180
|
-
set :root,
|
|
191
|
+
set :root, $top_srcdir # Set Sinatra root since we can't chdir to ../
|
|
181
192
|
run inner_app
|
|
182
193
|
}.to_app
|
|
183
194
|
|
|
@@ -186,16 +197,16 @@ unless have_thin
|
|
|
186
197
|
port = ENV["API_PORT"].to_i
|
|
187
198
|
|
|
188
199
|
puts "=> Ctrl-C to shutdown server"
|
|
189
|
-
Rack::
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
200
|
+
Rack::Server::start(:app => app,
|
|
201
|
+
:Host => ENV["API_HOST"],
|
|
202
|
+
:Port => port,
|
|
203
|
+
:AccessLog => [])
|
|
193
204
|
else
|
|
194
205
|
argv_opts = ARGV.clone
|
|
195
206
|
argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
|
|
196
207
|
argv_opts << ['--address', ENV["API_HOST"] ]
|
|
197
208
|
argv_opts << ['--port', ENV["API_PORT"] ]
|
|
198
|
-
argv_opts << ['--rackup', File.join(
|
|
209
|
+
argv_opts << ['--rackup', File.join($top_srcdir, 'config.ru') ]
|
|
199
210
|
argv_opts << ['-e', options[:env] ]
|
|
200
211
|
argv_opts << ['--timeout', ENV["API_TIMEOUT"] || '60']
|
|
201
212
|
argv_opts << ['--threaded', '-D' ]
|
|
@@ -207,18 +218,19 @@ else
|
|
|
207
218
|
options[:env] = "production"
|
|
208
219
|
argv_opts << [ "--daemonize", "--user", options[:user] || 'nobody', "--tag", "deltacloud-#{ENV['API_DRIVER']}"]
|
|
209
220
|
argv_opts << [ "--pid", options[:pid]] if options[:pid]
|
|
221
|
+
argv_opts << [ "--group", options[:group] || 'nobody' ]
|
|
222
|
+
argv_opts << [ "--log", File.join("/var/log/deltacloud-core", "#{ENV['API_DRIVER']}.log")]
|
|
210
223
|
end
|
|
211
224
|
argv_opts.flatten!
|
|
212
225
|
|
|
213
226
|
if have_rerun && options[:env] == "development"
|
|
214
227
|
argv_opts.unshift "thin"
|
|
215
228
|
command = argv_opts.join(" ")
|
|
216
|
-
|
|
217
|
-
rerun = Rerun::Runner.new(command, :dir =>
|
|
229
|
+
Dir::chdir($top_srcdir)
|
|
230
|
+
rerun = Rerun::Runner.new(command, :dir => $top_srcdir)
|
|
218
231
|
rerun.start
|
|
219
232
|
rerun.join
|
|
220
233
|
else
|
|
221
|
-
$:.unshift File.join(dirname)
|
|
222
234
|
thin = Thin::Runner.new(argv_opts)
|
|
223
235
|
thin.run!
|
|
224
236
|
end
|
data/config.ru
CHANGED
|
@@ -16,10 +16,12 @@
|
|
|
16
16
|
|
|
17
17
|
require 'rubygems'
|
|
18
18
|
|
|
19
|
-
top_srcdir
|
|
19
|
+
$top_srcdir ||= File::expand_path(File.dirname(__FILE__))
|
|
20
20
|
|
|
21
|
-
$:.unshift File.join(top_srcdir, 'lib')
|
|
21
|
+
$:.unshift File.join($top_srcdir, 'lib')
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
server_dir = ENV['API_FRONTEND'] == 'cimi' ? 'cimi' : 'deltacloud'
|
|
24
|
+
|
|
25
|
+
load File.join($top_srcdir, 'lib', server_dir, 'server.rb')
|
|
24
26
|
|
|
25
27
|
run Sinatra::Application
|
data/config/drivers/ec2.yaml
CHANGED
|
@@ -3,17 +3,26 @@
|
|
|
3
3
|
:entrypoints:
|
|
4
4
|
s3:
|
|
5
5
|
us-west-1: s3-us-west-1.amazonaws.com
|
|
6
|
+
us-west-2: s3-us-west-2.amazonaws.com
|
|
6
7
|
ap-southeast-1: s3-ap-southeast-1.amazonaws.com
|
|
8
|
+
ap-northeast-1: s3-ap-northeast-1.amazonaws.com
|
|
7
9
|
eu-west-1: s3-eu-west-1.amazonaws.com
|
|
8
10
|
us-east-1: s3.amazonaws.com
|
|
11
|
+
sa-east-1: s3-sa-east-1.amazonaws.com
|
|
9
12
|
elb:
|
|
10
13
|
us-west-1: elasticloadbalancing.us-west-1.amazonaws.com
|
|
14
|
+
us-west-2: elasticloadbalancing.us-west-2.amazonaws.com
|
|
11
15
|
ap-southeast-1: elasticloadbalancing.ap-southeast-1.amazonaws.com
|
|
16
|
+
ap-northeast-1: elasticloadbalancing.ap-northeast-1.amazonaws.com
|
|
12
17
|
eu-west-1: elasticloadbalancing.eu-west-1.amazonaws.com
|
|
13
18
|
us-east-1: elasticloadbalancing.us-east-1.amazonaws.com
|
|
19
|
+
sa-east-1: elasticloadbalancing.sa-east-1.amazonaws.com
|
|
14
20
|
ec2:
|
|
15
21
|
us-west-1: ec2.us-west-1.amazonaws.com
|
|
22
|
+
us-west-2: ec2.us-west-2.amazonaws.com
|
|
16
23
|
ap-southeast-1: ec2.ap-southeast-1.amazonaws.com
|
|
24
|
+
ap-northeast-1: ec2.ap-northeast-1.amazonaws.com
|
|
17
25
|
eu-west-1: ec2.eu-west-1.amazonaws.com
|
|
18
26
|
us-east-1: ec2.us-east-1.amazonaws.com
|
|
27
|
+
sa-east-1: ec2.sa-east-1.amazonaws.com
|
|
19
28
|
:name: EC2
|
data/deltacloud-core.gemspec
CHANGED
|
@@ -0,0 +1,62 @@
|
|
|
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
|
+
#this file defines all the required components for dmtf implementation.
|
|
18
|
+
#if new dependencies are needed, please make changes to this file.
|
|
19
|
+
|
|
20
|
+
require 'sinatra'
|
|
21
|
+
require 'deltacloud/drivers'
|
|
22
|
+
require 'deltacloud/core_ext'
|
|
23
|
+
require 'deltacloud/base_driver'
|
|
24
|
+
require 'deltacloud/hardware_profile'
|
|
25
|
+
require 'deltacloud/state_machine'
|
|
26
|
+
require 'deltacloud/helpers'
|
|
27
|
+
require 'deltacloud/models/base_model'
|
|
28
|
+
require 'deltacloud/models/realm'
|
|
29
|
+
require 'deltacloud/models/image'
|
|
30
|
+
require 'deltacloud/models/instance'
|
|
31
|
+
require 'deltacloud/models/key'
|
|
32
|
+
require 'deltacloud/models/address'
|
|
33
|
+
require 'deltacloud/models/instance_profile'
|
|
34
|
+
require 'deltacloud/models/storage_snapshot'
|
|
35
|
+
require 'deltacloud/models/storage_volume'
|
|
36
|
+
require 'deltacloud/models/bucket'
|
|
37
|
+
require 'deltacloud/models/blob'
|
|
38
|
+
require 'deltacloud/models/load_balancer'
|
|
39
|
+
require 'deltacloud/models/firewall'
|
|
40
|
+
require 'deltacloud/models/firewall_rule'
|
|
41
|
+
|
|
42
|
+
require 'json'
|
|
43
|
+
require 'sinatra/rack_accept'
|
|
44
|
+
require 'sinatra/static_assets'
|
|
45
|
+
require 'sinatra/rabbit'
|
|
46
|
+
require 'sinatra/lazy_auth'
|
|
47
|
+
require 'erb'
|
|
48
|
+
require 'haml'
|
|
49
|
+
require 'open3'
|
|
50
|
+
require 'uuidtools'
|
|
51
|
+
require 'xmlsimple'
|
|
52
|
+
require 'benchmark'
|
|
53
|
+
require 'deltacloud/helpers/blob_stream'
|
|
54
|
+
require 'sinatra/rack_driver_select'
|
|
55
|
+
require 'sinatra/rack_runtime'
|
|
56
|
+
require 'sinatra/rack_etag'
|
|
57
|
+
require 'sinatra/rack_date'
|
|
58
|
+
require 'sinatra/rack_matrix_params'
|
|
59
|
+
require 'sinatra/rack_syslog'
|
|
60
|
+
require 'sinatra/sinatra_verbose'
|
|
61
|
+
|
|
62
|
+
CMWG_NAMESPACE = "http://www.dmtf.org/cimi"
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
|
6
|
+
# License. You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations
|
|
14
|
+
# under the License.
|
|
15
|
+
|
|
16
|
+
module CIMIHelper
|
|
17
|
+
|
|
18
|
+
def no_content_with_status(code=200)
|
|
19
|
+
body ''
|
|
20
|
+
status code
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
helpers CIMIHelper
|
|
26
|
+
|
|
27
|
+
class Array
|
|
28
|
+
def to_xml_cimi_collection(_self)
|
|
29
|
+
model_name = first.class.xml_tag_name
|
|
30
|
+
XmlSimple.xml_out({
|
|
31
|
+
"xmlns" => "http://www.dmtf.org/cimi",
|
|
32
|
+
"uri" => [ _self.send(:"#{model_name.underscore.pluralize}_url") ],
|
|
33
|
+
"name" => [ "default" ],
|
|
34
|
+
"created" => [ Time.now.to_s ],
|
|
35
|
+
model_name => map { |model| { 'href' => model.uri } }
|
|
36
|
+
}, :root_name => "#{model_name}Collection")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def to_json_cimi_collection(_self)
|
|
40
|
+
model_name = first.class.xml_tag_name
|
|
41
|
+
{
|
|
42
|
+
"uri" => _self.send(:"#{model_name.underscore.pluralize}_url"),
|
|
43
|
+
"name" => "default",
|
|
44
|
+
"created" => Time.now.to_s,
|
|
45
|
+
model_name.pluralize.uncapitalize => map { |model| { 'href' => model.uri } }
|
|
46
|
+
}.to_json
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
end
|
|
50
|
+
|
data/lib/cimi/model.rb
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Licensed to the Apache Software Foundation (ASF) under one or more
|
|
2
|
+
# contributor license agreements. See the NOTICE file distributed with
|
|
3
|
+
# this work for additional information regarding copyright ownership. The
|
|
4
|
+
# ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
5
|
+
# "License"); you may not use this file except in compliance with the
|
|
6
|
+
# License. You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
12
|
+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
13
|
+
# License for the specific language governing permissions and limitations
|
|
14
|
+
# under the License.
|
|
15
|
+
#
|
|
16
|
+
|
|
17
|
+
# Declare namespace for CIMI model
|
|
18
|
+
#
|
|
19
|
+
module CIMI
|
|
20
|
+
module Model; end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
require 'cimi/model/schema'
|
|
24
|
+
require 'cimi/model/base'
|
|
25
|
+
require 'cimi/model/errors'
|
|
26
|
+
require 'cimi/model/cloud_entry_point'
|
|
27
|
+
require 'cimi/model/machine_template'
|
|
28
|
+
require 'cimi/model/machine_image'
|
|
29
|
+
require 'cimi/model/machine_configuration'
|
|
30
|
+
require 'cimi/model/action'
|
|
31
|
+
require 'cimi/model/machine'
|
|
32
|
+
require 'cimi/model/volume'
|
|
33
|
+
require 'cimi/model/machine_admin'
|
|
34
|
+
require 'cimi/model/volume_configuration'
|
|
35
|
+
require 'cimi/model/volume_image'
|
|
36
|
+
require 'cimi/model/volume_template'
|
|
37
|
+
require 'cimi/model/machine_template_collection'
|
|
38
|
+
require 'cimi/model/machine_image_collection'
|
|
39
|
+
require 'cimi/model/machine_configuration_collection'
|
|
40
|
+
require 'cimi/model/machine_collection'
|
|
41
|
+
require 'cimi/model/volume_collection'
|
|
42
|
+
require 'cimi/model/machine_admin_collection'
|
|
43
|
+
require 'cimi/model/volume_configuration_collection'
|
|
44
|
+
require 'cimi/model/volume_image_collection'
|
|
45
|
+
require 'cimi/model/volume_template_collection'
|
|
46
|
+
require 'cimi/model/entity_metadata'
|
|
47
|
+
require 'cimi/model/entity_metadata_collection'
|
|
48
|
+
require 'cimi/model/network'
|
|
49
|
+
require 'cimi/model/network_collection'
|
|
50
|
+
require 'cimi/model/network_configuration'
|
|
51
|
+
require 'cimi/model/network_configuration_collection'
|
|
52
|
+
require 'cimi/model/network_template'
|