deltacloud-core 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -24
- data/lib/deltacloud/base_driver/features.rb +15 -0
- data/lib/deltacloud/base_driver/mock_driver.rb +37 -0
- data/lib/deltacloud/drivers/ec2/ec2_driver.rb +70 -48
- data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +97 -14
- data/lib/deltacloud/drivers/{rimu/rimu_hosting_client.rb → rimuhosting/rimuhosting_client.rb} +5 -8
- data/lib/deltacloud/drivers/{rimu/rimu_hosting_driver.rb → rimuhosting/rimuhosting_driver.rb} +6 -5
- data/lib/deltacloud/drivers/terremark/terremark_driver.rb +261 -0
- data/lib/deltacloud/hardware_profile.rb +22 -0
- data/lib/deltacloud/helpers/application_helper.rb +18 -0
- data/lib/deltacloud/helpers/conversion_helper.rb +2 -3
- data/lib/deltacloud/method_serializer.rb +84 -0
- data/lib/drivers.rb +4 -3
- data/lib/sinatra/accept_media_types.rb +128 -0
- data/lib/sinatra/respond_to.rb +23 -16
- data/public/javascripts/application.js +30 -0
- data/public/javascripts/jquery-1.4.2.min.js +154 -0
- data/server.rb +23 -21
- data/support/fedora/deltacloudd +68 -0
- data/support/fedora/rubygem-deltacloud-core.spec +91 -0
- data/views/instances/index.html.haml +2 -1
- data/views/instances/index.xml.haml +3 -3
- data/views/instances/new.html.haml +9 -3
- data/views/instances/show.html.haml +2 -1
- data/views/instances/show.xml.haml +16 -3
- data/views/layout.html.haml +2 -0
- metadata +19 -37
- data/lib/converters/xml_converter.rb +0 -133
- data/public/javascripts/controls.js +0 -963
- data/public/javascripts/dragdrop.js +0 -973
- data/public/javascripts/effects.js +0 -1128
- data/public/javascripts/prototype.js +0 -4320
@@ -0,0 +1,68 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'optparse'
|
5
|
+
require 'thin'
|
6
|
+
|
7
|
+
options = {
|
8
|
+
:env => 'production'
|
9
|
+
}
|
10
|
+
optparse = OptionParser.new do |opts|
|
11
|
+
|
12
|
+
opts.banner = <<BANNER
|
13
|
+
Usage:
|
14
|
+
deltacloudd -i <driver> [options]
|
15
|
+
|
16
|
+
Options:
|
17
|
+
BANNER
|
18
|
+
opts.on( '-i', '--driver DRIVER', 'Driver to use') do |driver|
|
19
|
+
ENV["API_DRIVER"] = driver
|
20
|
+
end
|
21
|
+
opts.on( '-r', '--hostname HOSTNAME',
|
22
|
+
'Bind to HOST address (default: localhost)') do |host|
|
23
|
+
ENV["API_HOST"] = host
|
24
|
+
end
|
25
|
+
opts.on( '-p', '--port PORT', 'Use PORT (default: 3001)') do |port|
|
26
|
+
ENV["API_PORT"] = port
|
27
|
+
end
|
28
|
+
opts.on( '-e', '--env ENV', 'Environment (default: "development")') { |env| options[:env] = env }
|
29
|
+
opts.on( '-h', '--help', '') { options[:help] = true }
|
30
|
+
end
|
31
|
+
|
32
|
+
optparse.parse!
|
33
|
+
|
34
|
+
if options[:help]
|
35
|
+
puts optparse
|
36
|
+
exit(0)
|
37
|
+
end
|
38
|
+
|
39
|
+
unless ENV["API_DRIVER"]
|
40
|
+
puts "You need to specify a driver to use (-i <driver>)"
|
41
|
+
exit(1)
|
42
|
+
end
|
43
|
+
|
44
|
+
ENV["API_HOST"] = "localhost" unless ENV["API_HOST"]
|
45
|
+
ENV["API_PORT"] = "3001" unless ENV["API_PORT"]
|
46
|
+
|
47
|
+
dirname="#{File.dirname(__FILE__)}/.."
|
48
|
+
|
49
|
+
argv_opts = ARGV.clone
|
50
|
+
argv_opts << ['start'] unless Thin::Runner.commands.include?(options[0])
|
51
|
+
argv_opts << ['--address', ENV["API_HOST"] ]
|
52
|
+
argv_opts << ['--port', ENV["API_PORT"] ]
|
53
|
+
argv_opts << ['--rackup', 'config.ru' ]
|
54
|
+
argv_opts << ['--chdir', dirname ]
|
55
|
+
argv_opts << ['-e', options[:env] ]
|
56
|
+
argv_opts << ['--threaded', '-D', '--stats', '/stats']
|
57
|
+
|
58
|
+
argv_opts.flatten!
|
59
|
+
|
60
|
+
puts "Starting Deltacloud API :: #{ENV["API_DRIVER"]} :: http://#{ENV["API_HOST"]}:#{ENV["API_PORT"]}/api"
|
61
|
+
puts
|
62
|
+
|
63
|
+
thin = Thin::Runner.new(argv_opts)
|
64
|
+
begin
|
65
|
+
thin.run!
|
66
|
+
rescue Exception => e
|
67
|
+
puts "ERROR: #{e.message}"
|
68
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
%global ruby_sitelib %(ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
|
2
|
+
%global gemdir %(ruby -rubygems -e 'puts Gem::dir' 2>/dev/null)
|
3
|
+
%global gemname deltacloud-core
|
4
|
+
%global geminstdir %{gemdir}/gems/%{gemname}-%{version}
|
5
|
+
|
6
|
+
Summary: Deltacloud REST API
|
7
|
+
Name: rubygem-%{gemname}
|
8
|
+
Version: 0.0.1
|
9
|
+
Release: 2%{?dist}
|
10
|
+
Group: Development/Languages
|
11
|
+
License: ASL 2.0 and MIT
|
12
|
+
URL: http://www.deltacloud.org
|
13
|
+
Source0: http://gems.rubyforge.org/gems/%{gemname}-%{version}.gem
|
14
|
+
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
15
|
+
Requires: rubygems
|
16
|
+
Requires: ruby(abi) = 1.8
|
17
|
+
Requires: rubygem(eventmachine) >= 0.12.10
|
18
|
+
Requires: rubygem(haml) >= 2.2.17
|
19
|
+
Requires: rubygem(sinatra) >= 0.9.4
|
20
|
+
Requires: rubygem(rack) >= 1.0.0
|
21
|
+
Requires: rubygem(thin) >= 1.2.5
|
22
|
+
Requires: rubygem(builder) >= 2.1.2
|
23
|
+
Requires: rubygem(json) >= 1.2.3
|
24
|
+
BuildRequires: ruby-json >= 1.1.9
|
25
|
+
BuildRequires: rubygem(rake) >= 0.8.7
|
26
|
+
BuildRequires: rubygem(rack-test) >= 0.4.0
|
27
|
+
BuildRequires: rubygem(cucumber) >= 0.4.0
|
28
|
+
BuildRequires: rubygem(rcov) >= 0.9.6
|
29
|
+
BuildRequires: rubygems
|
30
|
+
BuildRequires: ruby(abi) = 1.8
|
31
|
+
BuildArch: noarch
|
32
|
+
Provides: rubygem(%{gemname}) = %{version}
|
33
|
+
|
34
|
+
%description
|
35
|
+
The Deltacloud API is built as a service-based REST API.
|
36
|
+
You do not directly link a Deltacloud library into your program to use it.
|
37
|
+
Instead, a client speaks the Deltacloud API over HTTP to a server
|
38
|
+
which implements the REST interface.
|
39
|
+
|
40
|
+
%prep
|
41
|
+
|
42
|
+
%build
|
43
|
+
|
44
|
+
%install
|
45
|
+
rm -rf %{buildroot}
|
46
|
+
mkdir -p %{buildroot}%{gemdir}
|
47
|
+
gem install --local --install-dir %{buildroot}%{gemdir} \
|
48
|
+
--force --rdoc %{SOURCE0}
|
49
|
+
mkdir -p %{buildroot}/%{_bindir}
|
50
|
+
mv %{buildroot}%{geminstdir}/support/fedora/deltacloudd %{buildroot}/%{geminstdir}/bin
|
51
|
+
mv %{buildroot}%{gemdir}/bin/* %{buildroot}/%{_bindir}
|
52
|
+
rmdir %{buildroot}%{gemdir}/bin
|
53
|
+
find %{buildroot}%{geminstdir}/bin -type f | xargs chmod a+x
|
54
|
+
|
55
|
+
# Needs json_pure gem / not available in Fedora yet
|
56
|
+
#%check
|
57
|
+
#pushd %{buildroot}%{geminstdir}
|
58
|
+
#cucumber features/*.feature
|
59
|
+
#popd
|
60
|
+
|
61
|
+
%clean
|
62
|
+
rm -rf %{buildroot}
|
63
|
+
|
64
|
+
%files
|
65
|
+
%defattr(-, root, root, -)
|
66
|
+
%{_bindir}/deltacloudd
|
67
|
+
%{gemdir}/gems/%{gemname}-%{version}/bin
|
68
|
+
%{gemdir}/gems/%{gemname}-%{version}/lib
|
69
|
+
%{gemdir}/gems/%{gemname}-%{version}/public/favicon.ico
|
70
|
+
%{gemdir}/gems/%{gemname}-%{version}/public/images
|
71
|
+
%{gemdir}/gems/%{gemname}-%{version}/public/stylesheets
|
72
|
+
%{gemdir}/gems/%{gemname}-%{version}/tests
|
73
|
+
%{gemdir}/gems/%{gemname}-%{version}/views
|
74
|
+
%{gemdir}/gems/%{gemname}-%{version}/Rakefile
|
75
|
+
%{gemdir}/gems/%{gemname}-%{version}/*.rb
|
76
|
+
%{gemdir}/gems/%{gemname}-%{version}/config.ru
|
77
|
+
%doc %{gemdir}/gems/%{gemname}-%{version}/support/fedora
|
78
|
+
%doc %{gemdir}/gems/%{gemname}-%{version}/COPYING
|
79
|
+
%doc %{gemdir}/doc/%{gemname}-%{version}
|
80
|
+
%{gemdir}/cache/%{gemname}-%{version}.gem
|
81
|
+
%{gemdir}/specifications/%{gemname}-%{version}.gemspec
|
82
|
+
# MIT
|
83
|
+
%{gemdir}/gems/%{gemname}-%{version}/public/javascripts
|
84
|
+
|
85
|
+
%changelog
|
86
|
+
* Mon Apr 26 2010 Michal Fojtik <mfojtik@packager> - 0.0.1-1
|
87
|
+
- Initial package
|
88
|
+
|
89
|
+
* Mon Apr 26 2010 Michal Fojtik <mfojtik@packager> - 0.0.1-2
|
90
|
+
- Fixed broken dependencies
|
91
|
+
- Added new launcher for Fedora
|
@@ -26,4 +26,5 @@
|
|
26
26
|
%td
|
27
27
|
= instance.state
|
28
28
|
%td
|
29
|
-
|
29
|
+
-instance.actions.each do |action|
|
30
|
+
=link_to action, self.send(:"#{action}_instance_url", instance.id), :class => instance_action_method(action)
|
@@ -14,10 +14,10 @@
|
|
14
14
|
%property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)}
|
15
15
|
%actions
|
16
16
|
- instance.actions.compact.each do |action|
|
17
|
-
%link{:rel => action, :href => self.send("#{action}_instance_url", instance.id)}
|
18
|
-
|
17
|
+
%link{:rel => action, :href => self.send("#{action}_instance_url", instance.id), :method => instance_action_method(action)}
|
18
|
+
%public-addresses
|
19
19
|
- instance.public_addresses.each do |address|
|
20
20
|
%address #{address}
|
21
|
-
|
21
|
+
%private-addresses
|
22
22
|
- instance.private_addresses.each do |address|
|
23
23
|
%address #{address}
|
@@ -5,9 +5,15 @@
|
|
5
5
|
|
6
6
|
%form{ :action => instances_url, :method => :post }
|
7
7
|
%input{ :name => :image_id, :type => :hidden, :value => @instance.image_id }/
|
8
|
-
%
|
9
|
-
|
10
|
-
|
8
|
+
%p
|
9
|
+
%label
|
10
|
+
Instance Name:
|
11
|
+
%input{ :name => 'name', :size => 30 }/
|
12
|
+
-if driver_has_feature?(:authentication_key)
|
13
|
+
%p
|
14
|
+
%label
|
15
|
+
Instance Keyname:
|
16
|
+
%input{:name => 'keyname', :size => 30 }
|
11
17
|
- if !@hardware_profiles.empty?
|
12
18
|
%h3 What size machine?
|
13
19
|
- for hwp in @hardware_profiles
|
@@ -39,4 +39,5 @@
|
|
39
39
|
%di
|
40
40
|
%dt
|
41
41
|
%dd
|
42
|
-
|
42
|
+
-@instance.actions.each do |action|
|
43
|
+
=link_to action, self.send(:"#{action}_instance_url", @instance.id), :class => instance_action_method(action)
|
@@ -17,12 +17,25 @@
|
|
17
17
|
%property{:kind => 'fixed', :name => p, :value => v, :unit => Deltacloud::HardwareProfile::unit(p)}
|
18
18
|
%actions
|
19
19
|
- @instance.actions.compact.each do |instance_action|
|
20
|
-
%link{:rel => instance_action, :href => self.send("#{instance_action}_instance_url", @instance.id)}
|
21
|
-
|
20
|
+
%link{:rel => instance_action, :method => instance_action_method(instance_action), :href => self.send("#{instance_action}_instance_url", @instance.id)}
|
21
|
+
%public-addresses
|
22
22
|
- @instance.public_addresses.each do |address|
|
23
23
|
%address<
|
24
24
|
=address
|
25
|
-
|
25
|
+
%private-addresses
|
26
26
|
- @instance.private_addresses.each do |address|
|
27
27
|
%address<
|
28
28
|
=address
|
29
|
+
- if driver_has_auth_features?
|
30
|
+
%authentication{ :type => driver_auth_feature_name }
|
31
|
+
- if @instance.authn_feature_failed?
|
32
|
+
%error #{@instance.authn_error}
|
33
|
+
- else
|
34
|
+
- if driver_auth_feature_name == 'password'
|
35
|
+
%login
|
36
|
+
%username #{@instance.username}
|
37
|
+
%password #{@instance.password}
|
38
|
+
- if driver_auth_feature_name == 'key'
|
39
|
+
%login
|
40
|
+
%keyname #{@instance.keyname}
|
41
|
+
|
data/views/layout.html.haml
CHANGED
@@ -8,6 +8,8 @@
|
|
8
8
|
/[if lt IE 8]
|
9
9
|
= stylesheet_link_tag '/stylesheets/compiled/ie.css', :media => 'screen, projection'
|
10
10
|
= stylesheet_link_tag '/stylesheets/compiled/application.css', :media => 'screen, projection'
|
11
|
+
%script{:type => "text/javascript", :src => "/javascripts/jquery-1.4.2.min.js" }
|
12
|
+
%script{:type => "text/javascript", :src => "/javascripts/application.js" }
|
11
13
|
%body
|
12
14
|
#wrapper
|
13
15
|
#header
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deltacloud-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Red Hat, Inc.
|
@@ -9,19 +9,9 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-06-09 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
|
-
- !ruby/object:Gem::Dependency
|
16
|
-
name: rake
|
17
|
-
type: :runtime
|
18
|
-
version_requirement:
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.8.7
|
24
|
-
version:
|
25
15
|
- !ruby/object:Gem::Dependency
|
26
16
|
name: eventmachine
|
27
17
|
type: :runtime
|
@@ -73,44 +63,34 @@ dependencies:
|
|
73
63
|
version: 1.2.5
|
74
64
|
version:
|
75
65
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
77
|
-
type: :runtime
|
78
|
-
version_requirement:
|
79
|
-
version_requirements: !ruby/object:Gem::Requirement
|
80
|
-
requirements:
|
81
|
-
- - ">="
|
82
|
-
- !ruby/object:Gem::Version
|
83
|
-
version: 0.5.2
|
84
|
-
version:
|
85
|
-
- !ruby/object:Gem::Dependency
|
86
|
-
name: builder
|
66
|
+
name: json
|
87
67
|
type: :runtime
|
88
68
|
version_requirement:
|
89
69
|
version_requirements: !ruby/object:Gem::Requirement
|
90
70
|
requirements:
|
91
71
|
- - ">="
|
92
72
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
73
|
+
version: 1.2.3
|
94
74
|
version:
|
95
75
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
76
|
+
name: rerun
|
97
77
|
type: :runtime
|
98
78
|
version_requirement:
|
99
79
|
version_requirements: !ruby/object:Gem::Requirement
|
100
80
|
requirements:
|
101
81
|
- - ">="
|
102
82
|
- !ruby/object:Gem::Version
|
103
|
-
version:
|
83
|
+
version: 0.5.2
|
104
84
|
version:
|
105
85
|
- !ruby/object:Gem::Dependency
|
106
|
-
name:
|
107
|
-
type: :
|
86
|
+
name: rake
|
87
|
+
type: :development
|
108
88
|
version_requirement:
|
109
89
|
version_requirements: !ruby/object:Gem::Requirement
|
110
90
|
requirements:
|
111
91
|
- - ">="
|
112
92
|
- !ruby/object:Gem::Version
|
113
|
-
version:
|
93
|
+
version: 0.8.7
|
114
94
|
version:
|
115
95
|
- !ruby/object:Gem::Dependency
|
116
96
|
name: compass
|
@@ -175,10 +155,13 @@ files:
|
|
175
155
|
- config.ru
|
176
156
|
- server.rb
|
177
157
|
- deltacloud.rb
|
178
|
-
-
|
158
|
+
- support/fedora/deltacloudd
|
159
|
+
- support/fedora/rubygem-deltacloud-core.spec
|
160
|
+
- lib/drivers.rb
|
179
161
|
- lib/deltacloud/base_driver.rb
|
180
162
|
- lib/deltacloud/base_driver/base_driver.rb
|
181
163
|
- lib/deltacloud/base_driver/features.rb
|
164
|
+
- lib/deltacloud/base_driver/mock_driver.rb
|
182
165
|
- lib/deltacloud/drivers/ec2/ec2_driver.rb
|
183
166
|
- lib/deltacloud/drivers/ec2/ec2_mock_driver.rb
|
184
167
|
- lib/deltacloud/drivers/gogrid/gogrid_client.rb
|
@@ -190,8 +173,9 @@ files:
|
|
190
173
|
- lib/deltacloud/drivers/rackspace/rackspace_client.rb
|
191
174
|
- lib/deltacloud/drivers/rackspace/rackspace_driver.rb
|
192
175
|
- lib/deltacloud/drivers/rhevm/rhevm_driver.rb
|
193
|
-
- lib/deltacloud/drivers/
|
194
|
-
- lib/deltacloud/drivers/
|
176
|
+
- lib/deltacloud/drivers/terremark/terremark_driver.rb
|
177
|
+
- lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb
|
178
|
+
- lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb
|
195
179
|
- lib/deltacloud/hardware_profile.rb
|
196
180
|
- lib/deltacloud/helpers.rb
|
197
181
|
- lib/deltacloud/helpers/application_helper.rb
|
@@ -206,12 +190,13 @@ files:
|
|
206
190
|
- lib/deltacloud/models/instance_profile.rb
|
207
191
|
- lib/deltacloud/state_machine.rb
|
208
192
|
- lib/deltacloud/validation.rb
|
193
|
+
- lib/deltacloud/method_serializer.rb
|
209
194
|
- lib/sinatra/lazy_auth.rb
|
210
195
|
- lib/sinatra/rabbit.rb
|
211
196
|
- lib/sinatra/respond_to.rb
|
212
197
|
- lib/sinatra/static_assets.rb
|
213
198
|
- lib/sinatra/url_for.rb
|
214
|
-
- lib/
|
199
|
+
- lib/sinatra/accept_media_types.rb
|
215
200
|
- views/accounts/index.html.haml
|
216
201
|
- views/accounts/show.html.haml
|
217
202
|
- views/api/show.html.haml
|
@@ -264,10 +249,7 @@ files:
|
|
264
249
|
- public/images/rails.png
|
265
250
|
- public/images/topbar-bg.png
|
266
251
|
- public/javascripts/application.js
|
267
|
-
- public/javascripts/
|
268
|
-
- public/javascripts/dragdrop.js
|
269
|
-
- public/javascripts/effects.js
|
270
|
-
- public/javascripts/prototype.js
|
252
|
+
- public/javascripts/jquery-1.4.2.min.js
|
271
253
|
- public/stylesheets/compiled/application.css
|
272
254
|
- public/stylesheets/compiled/ie.css
|
273
255
|
- public/stylesheets/compiled/print.css
|
@@ -1,133 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2009 Red Hat, Inc.
|
3
|
-
#
|
4
|
-
# This library is free software; you can redistribute it and/or
|
5
|
-
# modify it under the terms of the GNU Lesser General Public
|
6
|
-
# License as published by the Free Software Foundation; either
|
7
|
-
# version 2.1 of the License, or (at your option) any later version.
|
8
|
-
#
|
9
|
-
# This library is distributed in the hope that it will be useful,
|
10
|
-
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
12
|
-
# Lesser General Public License for more details.
|
13
|
-
#
|
14
|
-
# You should have received a copy of the GNU Lesser General Public
|
15
|
-
# License along with this library; if not, write to the Free Software
|
16
|
-
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
17
|
-
|
18
|
-
module Converters
|
19
|
-
|
20
|
-
( ALIASES = {
|
21
|
-
:owner=>nil,
|
22
|
-
:volume=>:storage_volume,
|
23
|
-
} ) unless defined?( ALIASES )
|
24
|
-
|
25
|
-
def self.url_type(type)
|
26
|
-
type = type.to_sym
|
27
|
-
return ALIASES[type] if ( ALIASES.keys.include?( type ) )
|
28
|
-
type
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.tag_name(type)
|
32
|
-
tag_name = type.to_s
|
33
|
-
tag_name.gsub( /_/, '-' )
|
34
|
-
end
|
35
|
-
|
36
|
-
class XMLConverter
|
37
|
-
def initialize(link_builder, type)
|
38
|
-
@link_builder = link_builder
|
39
|
-
@type = type
|
40
|
-
end
|
41
|
-
|
42
|
-
def convert(obj, builder=nil)
|
43
|
-
builder ||= Builder::XmlMarkup.new( :indent=>2 )
|
44
|
-
if ( obj.is_a?( Array ) )
|
45
|
-
builder.__send__( @type.to_s.pluralize.gsub( /_/, '-' ).to_sym ) do
|
46
|
-
obj.each do |e|
|
47
|
-
convert( e, builder )
|
48
|
-
end
|
49
|
-
end
|
50
|
-
else
|
51
|
-
case ( obj )
|
52
|
-
when Image
|
53
|
-
builder.image( :href=>@link_builder.send( :image_url, obj.id ) ) {
|
54
|
-
builder.id( obj.id )
|
55
|
-
builder.owner_id( obj.owner_id )
|
56
|
-
builder.name( obj.name )
|
57
|
-
builder.description( obj.description )
|
58
|
-
builder.architecture( obj.architecture )
|
59
|
-
}
|
60
|
-
when Realm
|
61
|
-
builder.realm( :href=>@link_builder.send( :realm_url, obj.id ) ) {
|
62
|
-
builder.id( obj.id )
|
63
|
-
builder.name( obj.name )
|
64
|
-
builder.state( obj.state )
|
65
|
-
if ( obj.limit == :unlimited )
|
66
|
-
builder.limit()
|
67
|
-
else
|
68
|
-
builder.limit( obj.limit )
|
69
|
-
end
|
70
|
-
}
|
71
|
-
when Instance
|
72
|
-
builder.instance( :href=>@link_builder.send( :instance_url, obj.id ) ) {
|
73
|
-
builder.id( obj.id )
|
74
|
-
builder.name( obj.name )
|
75
|
-
builder.owner_id( obj.owner_id )
|
76
|
-
builder.image( :href=>@link_builder.send( :image_url, obj.image_id ) )
|
77
|
-
builder.__send__( 'hardware-profile', :href=>@link_builder.send( :hardware_profile_url, obj.instance_profile.name) ) do
|
78
|
-
builder.id( obj.instance_profile.name )
|
79
|
-
obj.instance_profile.overrides.each do |p, v|
|
80
|
-
u = ::Deltacloud::HardwareProfile::unit(p)
|
81
|
-
builder.property( :kind=>:fixed, :name=>p, :unit=>u, :value=>v )
|
82
|
-
end
|
83
|
-
end
|
84
|
-
builder.realm( :href=>@link_builder.send( :realm_url, obj.realm_id ) ) if obj.realm_id
|
85
|
-
builder.state( obj.state )
|
86
|
-
builder.actions {
|
87
|
-
if ( obj.actions )
|
88
|
-
obj.actions.each do |action|
|
89
|
-
builder.link( :rel=>action, :href=>@link_builder.send( "#{action}_instance_url", obj.id ) )
|
90
|
-
end
|
91
|
-
end
|
92
|
-
}
|
93
|
-
builder.__send__( 'public-addresses' ) {
|
94
|
-
obj.public_addresses.each do |address|
|
95
|
-
builder.address( address )
|
96
|
-
end
|
97
|
-
}
|
98
|
-
builder.__send__( 'private-addresses' ) {
|
99
|
-
obj.private_addresses.each do |address|
|
100
|
-
builder.address( address )
|
101
|
-
end
|
102
|
-
}
|
103
|
-
}
|
104
|
-
when StorageVolume
|
105
|
-
builder.__send__('storage-volume', :href=>@link_builder.send( :storage_volume_url, obj.id )) {
|
106
|
-
builder.id( obj.id )
|
107
|
-
builder.created( obj.created )
|
108
|
-
builder.state( obj.state )
|
109
|
-
builder.capacity( obj.capacity )
|
110
|
-
builder.device( obj.device )
|
111
|
-
if ( obj.instance_id )
|
112
|
-
builder.instance( :href=>@link_builder.send( :instance_url, obj.instance_id ) )
|
113
|
-
else
|
114
|
-
builder.instance()
|
115
|
-
end
|
116
|
-
}
|
117
|
-
when StorageSnapshot
|
118
|
-
builder.__send__('storage-snapshot', :href=>@link_builder.send( :storage_snapshot_url, obj.id )) {
|
119
|
-
builder.id( obj.id )
|
120
|
-
builder.created( obj.created )
|
121
|
-
builder.state( obj.state )
|
122
|
-
if ( obj.storage_volume_id )
|
123
|
-
builder.__send__('storage-volume', :href=>@link_builder.send( :storage_volume_url, obj.storage_volume_id ) )
|
124
|
-
else
|
125
|
-
builder.__send( 'storage-volume' )
|
126
|
-
end
|
127
|
-
}
|
128
|
-
end
|
129
|
-
end
|
130
|
-
return builder.target!
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|