bbrowning-deltacloud-core 0.0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. data/COPYING +502 -0
  2. data/Rakefile +85 -0
  3. data/bin/deltacloudd +88 -0
  4. data/config.ru +5 -0
  5. data/deltacloud.rb +14 -0
  6. data/lib/deltacloud/base_driver.rb +19 -0
  7. data/lib/deltacloud/base_driver/base_driver.rb +189 -0
  8. data/lib/deltacloud/base_driver/features.rb +159 -0
  9. data/lib/deltacloud/base_driver/mock_driver.rb +37 -0
  10. data/lib/deltacloud/drivers/ec2/ec2_driver.rb +340 -0
  11. data/lib/deltacloud/drivers/ec2/ec2_mock_driver.rb +170 -0
  12. data/lib/deltacloud/drivers/gogrid/gogrid_client.rb +45 -0
  13. data/lib/deltacloud/drivers/gogrid/gogrid_driver.rb +322 -0
  14. data/lib/deltacloud/drivers/mock/mock_driver.rb +275 -0
  15. data/lib/deltacloud/drivers/opennebula/cloud_client.rb +116 -0
  16. data/lib/deltacloud/drivers/opennebula/occi_client.rb +204 -0
  17. data/lib/deltacloud/drivers/opennebula/opennebula_driver.rb +241 -0
  18. data/lib/deltacloud/drivers/rackspace/rackspace_client.rb +129 -0
  19. data/lib/deltacloud/drivers/rackspace/rackspace_driver.rb +150 -0
  20. data/lib/deltacloud/drivers/rhevm/rhevm_driver.rb +254 -0
  21. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb +84 -0
  22. data/lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb +144 -0
  23. data/lib/deltacloud/drivers/terremark/terremark_driver.rb +261 -0
  24. data/lib/deltacloud/hardware_profile.rb +153 -0
  25. data/lib/deltacloud/helpers.rb +5 -0
  26. data/lib/deltacloud/helpers/application_helper.rb +56 -0
  27. data/lib/deltacloud/helpers/conversion_helper.rb +38 -0
  28. data/lib/deltacloud/helpers/hardware_profiles_helper.rb +35 -0
  29. data/lib/deltacloud/method_serializer.rb +84 -0
  30. data/lib/deltacloud/models/base_model.rb +58 -0
  31. data/lib/deltacloud/models/image.rb +26 -0
  32. data/lib/deltacloud/models/instance.rb +37 -0
  33. data/lib/deltacloud/models/instance_profile.rb +47 -0
  34. data/lib/deltacloud/models/realm.rb +25 -0
  35. data/lib/deltacloud/models/storage_snapshot.rb +26 -0
  36. data/lib/deltacloud/models/storage_volume.rb +27 -0
  37. data/lib/deltacloud/state_machine.rb +84 -0
  38. data/lib/deltacloud/validation.rb +70 -0
  39. data/lib/drivers.rb +38 -0
  40. data/lib/sinatra/accept_media_types.rb +128 -0
  41. data/lib/sinatra/lazy_auth.rb +56 -0
  42. data/lib/sinatra/rabbit.rb +272 -0
  43. data/lib/sinatra/respond_to.rb +269 -0
  44. data/lib/sinatra/static_assets.rb +83 -0
  45. data/lib/sinatra/url_for.rb +51 -0
  46. data/public/favicon.ico +0 -0
  47. data/public/images/grid.png +0 -0
  48. data/public/images/logo-wide.png +0 -0
  49. data/public/images/rails.png +0 -0
  50. data/public/images/topbar-bg.png +0 -0
  51. data/public/javascripts/application.js +32 -0
  52. data/public/javascripts/jquery-1.4.2.min.js +154 -0
  53. data/public/stylesheets/compiled/application.css +613 -0
  54. data/public/stylesheets/compiled/ie.css +31 -0
  55. data/public/stylesheets/compiled/print.css +27 -0
  56. data/public/stylesheets/compiled/screen.css +456 -0
  57. data/server.rb +342 -0
  58. data/support/fedora/deltacloudd +68 -0
  59. data/support/fedora/rubygem-deltacloud-core.spec +91 -0
  60. data/tests/deltacloud_test.rb +60 -0
  61. data/tests/images_test.rb +94 -0
  62. data/tests/instances_test.rb +136 -0
  63. data/tests/realms_test.rb +56 -0
  64. data/tests/storage_snapshots_test.rb +48 -0
  65. data/tests/storage_volumes_test.rb +48 -0
  66. data/torquebox-ec2-config.ru +8 -0
  67. data/views/accounts/index.html.haml +11 -0
  68. data/views/accounts/show.html.haml +30 -0
  69. data/views/api/show.html.haml +15 -0
  70. data/views/api/show.xml.haml +5 -0
  71. data/views/docs/collection.html.haml +37 -0
  72. data/views/docs/collection.xml.haml +14 -0
  73. data/views/docs/index.html.haml +15 -0
  74. data/views/docs/index.xml.haml +5 -0
  75. data/views/docs/operation.html.haml +31 -0
  76. data/views/docs/operation.xml.haml +10 -0
  77. data/views/errors/auth_exception.html.haml +8 -0
  78. data/views/errors/auth_exception.xml.haml +2 -0
  79. data/views/errors/backend_error.html.haml +17 -0
  80. data/views/errors/backend_error.xml.haml +8 -0
  81. data/views/errors/validation_failure.html.haml +11 -0
  82. data/views/errors/validation_failure.xml.haml +7 -0
  83. data/views/hardware_profiles/index.html.haml +25 -0
  84. data/views/hardware_profiles/index.xml.haml +4 -0
  85. data/views/hardware_profiles/show.html.haml +19 -0
  86. data/views/hardware_profiles/show.xml.haml +17 -0
  87. data/views/images/index.html.haml +30 -0
  88. data/views/images/index.xml.haml +7 -0
  89. data/views/images/show.html.haml +21 -0
  90. data/views/images/show.xml.haml +5 -0
  91. data/views/instance_states/show.gv.erb +45 -0
  92. data/views/instance_states/show.html.haml +31 -0
  93. data/views/instance_states/show.xml.haml +8 -0
  94. data/views/instances/index.html.haml +30 -0
  95. data/views/instances/index.xml.haml +23 -0
  96. data/views/instances/new.html.haml +55 -0
  97. data/views/instances/show.html.haml +43 -0
  98. data/views/instances/show.xml.haml +41 -0
  99. data/views/layout.html.haml +26 -0
  100. data/views/realms/index.html.haml +29 -0
  101. data/views/realms/index.xml.haml +12 -0
  102. data/views/realms/show.html.haml +15 -0
  103. data/views/realms/show.xml.haml +10 -0
  104. data/views/root/index.html.haml +4 -0
  105. data/views/storage_snapshots/index.html.haml +20 -0
  106. data/views/storage_snapshots/index.xml.haml +11 -0
  107. data/views/storage_snapshots/show.html.haml +14 -0
  108. data/views/storage_snapshots/show.xml.haml +9 -0
  109. data/views/storage_volumes/index.html.haml +21 -0
  110. data/views/storage_volumes/index.xml.haml +13 -0
  111. data/views/storage_volumes/show.html.haml +20 -0
  112. data/views/storage_volumes/show.xml.haml +13 -0
  113. metadata +361 -0
@@ -0,0 +1,116 @@
1
+ #--------------------------------------------------------------------------- #
2
+ # Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
3
+ # Complutense de Madrid (dsa-research.org)
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #--------------------------------------------------------------------------- #
19
+
20
+ require 'rubygems'
21
+ require 'uri'
22
+
23
+ require 'net/https'
24
+
25
+ begin
26
+ require 'net/http/post/multipart'
27
+ rescue LoadError
28
+ end
29
+
30
+ ###############################################################################
31
+ # The CloudClient module contains general functionality to implement a
32
+ # Cloud Client
33
+ ###############################################################################
34
+ module CloudClient
35
+ # #########################################################################
36
+ # Default location for the authentication file
37
+ # #########################################################################
38
+ DEFAULT_AUTH_FILE = ENV["HOME"]+"/.one/one_auth"
39
+
40
+ # #########################################################################
41
+ # Gets authorization credentials from ONE_AUTH or default
42
+ # auth file.
43
+ #
44
+ # Raises an error if authorization is not found
45
+ # #########################################################################
46
+ def self.get_one_auth
47
+ if ENV["ONE_AUTH"] and !ENV["ONE_AUTH"].empty? and
48
+ File.file?(ENV["ONE_AUTH"])
49
+ one_auth=File.read(ENV["ONE_AUTH"]).strip.split(':')
50
+ elsif File.file?(DEFAULT_AUTH_FILE)
51
+ one_auth=File.read(DEFAULT_AUTH_FILE).strip.split(':')
52
+ else
53
+ raise "No authorization data present"
54
+ end
55
+
56
+ raise "Authorization data malformed" if one_auth.length < 2
57
+
58
+ one_auth
59
+ end
60
+
61
+ # #########################################################################
62
+ # Starts an http connection and calls the block provided. SSL flag
63
+ # is set if needed.
64
+ # #########################################################################
65
+ def self.http_start(url, &block)
66
+ http = Net::HTTP.new(url.host, url.port)
67
+ if url.scheme=='https'
68
+ http.use_ssl = true
69
+ http.verify_mode=OpenSSL::SSL::VERIFY_NONE
70
+ end
71
+
72
+ begin
73
+ http.start do |connection|
74
+ block.call(connection)
75
+ end
76
+ rescue Errno::ECONNREFUSED => e
77
+ str = "Error connecting to server (#{e.to_s})."
78
+ str << "Server: #{url.host}:#{url.port}"
79
+
80
+ return CloudClient::Error.new(str)
81
+ end
82
+ end
83
+
84
+ # #########################################################################
85
+ # The Error Class represents a generic error in the Cloud Client
86
+ # library. It contains a readable representation of the error.
87
+ # #########################################################################
88
+ class Error
89
+ attr_reader :message
90
+
91
+ # +message+ a description of the error
92
+ def initialize(message=nil)
93
+ @message=message
94
+ end
95
+
96
+ def to_s()
97
+ @message
98
+ end
99
+ end
100
+
101
+ # #########################################################################
102
+ # Returns true if the object returned by a method of the OpenNebula
103
+ # library is an Error
104
+ # #########################################################################
105
+ def self.is_error?(value)
106
+ value.class==CloudClient::Error
107
+ end
108
+ end
109
+
110
+ # Command line help functions
111
+ module CloudCLI
112
+ # Returns the command name
113
+ def cmd_name
114
+ File.basename($0)
115
+ end
116
+ end
@@ -0,0 +1,204 @@
1
+ #--------------------------------------------------------------------------- #
2
+ # Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
3
+ # Complutense de Madrid (dsa-research.org)
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #--------------------------------------------------------------------------- #
19
+
20
+ require 'rubygems'
21
+ require 'uri'
22
+ require 'rexml/document'
23
+
24
+ require 'deltacloud/drivers/opennebula/cloud_client'
25
+
26
+
27
+ module OCCIClient
28
+
29
+ #####################################################################
30
+ # Client Library to interface with the OpenNebula OCCI Service
31
+ #####################################################################
32
+ class Client
33
+
34
+ ######################################################################
35
+ # Initialize client library
36
+ ######################################################################
37
+ def initialize(endpoint_str=nil, user=nil, pass=nil, debug_flag=true)
38
+ @debug = debug_flag
39
+
40
+ # Server location
41
+ if endpoint_str
42
+ @endpoint = endpoint_str
43
+ elsif ENV["OCCI_URL"]
44
+ @endpoint = ENV["OCCI_URL"]
45
+ else
46
+ @endpoint = "http://localhost:4567"
47
+ end
48
+
49
+ # Autentication
50
+ if user && pass
51
+ @occiauth = [user, pass]
52
+ else
53
+ @occiauth = CloudClient::get_one_auth
54
+ end
55
+
56
+ if !@occiauth
57
+ raise "No authorization data present"
58
+ end
59
+
60
+ @occiauth[1] = Digest::SHA1.hexdigest(@occiauth[1])
61
+ end
62
+
63
+ #################################
64
+ # Pool Resource Request Methods #
65
+ #################################
66
+
67
+ ######################################################################
68
+ # Post a new VM to the VM Pool
69
+ # :instance_type
70
+ # :xmlfile
71
+ ######################################################################
72
+ def post_vms(xmlfile)
73
+ xml=File.read(xmlfile)
74
+
75
+ url = URI.parse(@endpoint+"/compute")
76
+
77
+ req = Net::HTTP::Post.new(url.path)
78
+ req.body=xml
79
+
80
+ req.basic_auth @occiauth[0], @occiauth[1]
81
+
82
+ res = CloudClient::http_start(url) do |http|
83
+ http.request(req)
84
+ end
85
+
86
+ if CloudClient::is_error?(res)
87
+ return res
88
+ else
89
+ return res.body
90
+ end
91
+ end
92
+
93
+ ######################################################################
94
+ # Retieves the pool of Virtual Machines
95
+ ######################################################################
96
+ def get_vms
97
+ url = URI.parse(@endpoint+"/compute")
98
+ req = Net::HTTP::Get.new(url.path)
99
+
100
+ req.basic_auth @occiauth[0], @occiauth[1]
101
+
102
+ res = CloudClient::http_start(url) {|http|
103
+ http.request(req)
104
+ }
105
+
106
+ if CloudClient::is_error?(res)
107
+ return res
108
+ else
109
+ return res.body
110
+ end
111
+ end
112
+
113
+ ######################################################################
114
+ # Retieves the pool of Images owned by the user
115
+ ######################################################################
116
+ def get_images
117
+ url = URI.parse(@endpoint+"/storage")
118
+ req = Net::HTTP::Get.new(url.path)
119
+
120
+ req.basic_auth @occiauth[0], @occiauth[1]
121
+
122
+ res = CloudClient::http_start(url) {|http|
123
+ http.request(req)
124
+ }
125
+
126
+ if CloudClient::is_error?(res)
127
+ return res
128
+ else
129
+ return res.body
130
+ end
131
+ end
132
+
133
+ ####################################
134
+ # Entity Resource Request Methods #
135
+ ####################################
136
+
137
+ ######################################################################
138
+ # :id VM identifier
139
+ ######################################################################
140
+ def get_vm(id)
141
+ url = URI.parse(@endpoint+"/compute/" + id.to_s)
142
+ req = Net::HTTP::Get.new(url.path)
143
+
144
+ req.basic_auth @occiauth[0], @occiauth[1]
145
+
146
+ res = CloudClient::http_start(url) {|http|
147
+ http.request(req)
148
+ }
149
+
150
+ if CloudClient::is_error?(res)
151
+ return res
152
+ else
153
+ return res.body
154
+ end
155
+ end
156
+
157
+ ######################################################################
158
+ # Puts a new Compute representation in order to change its state
159
+ # :xmlfile Compute OCCI xml representation
160
+ ######################################################################
161
+ def put_vm(xmlfile)
162
+ xml=File.read(xmlfile)
163
+ vm_info=REXML::Document.new(xml).root.elements
164
+
165
+ url = URI.parse(@endpoint+'/compute/' + vm_info['ID'].text)
166
+
167
+ req = Net::HTTP::Put.new(url.path)
168
+ req.body = xml
169
+
170
+ req.basic_auth @occiauth[0], @occiauth[1]
171
+
172
+ res = CloudClient::http_start(url) do |http|
173
+ http.request(req)
174
+ end
175
+
176
+ if CloudClient::is_error?(res)
177
+ return res
178
+ else
179
+ return res.body
180
+ end
181
+ end
182
+
183
+ #######################################################################
184
+ # Retieves an Image
185
+ # :image_uuid Image identifier
186
+ ######################################################################
187
+ def get_image(image_uuid)
188
+ url = URI.parse(@endpoint+"/storage/"+image_uuid)
189
+ req = Net::HTTP::Get.new(url.path)
190
+
191
+ req.basic_auth @occiauth[0], @occiauth[1]
192
+
193
+ res = CloudClient::http_start(url) {|http|
194
+ http.request(req)
195
+ }
196
+
197
+ if CloudClient::is_error?(res)
198
+ return res
199
+ else
200
+ return res.body
201
+ end
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,241 @@
1
+ #--------------------------------------------------------------------------- #
2
+ # Copyright 2002-2009, Distributed Systems Architecture Group, Universidad
3
+ # Complutense de Madrid (dsa-research.org)
4
+ #
5
+ # This library is free software; you can redistribute it and/or
6
+ # modify it under the terms of the GNU Lesser General Public
7
+ # License as published by the Free Software Foundation; either
8
+ # version 2.1 of the License, or (at your option) any later version.
9
+ #
10
+ # This library is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
+ # Lesser General Public License for more details.
14
+ #
15
+ # You should have received a copy of the GNU Lesser General Public
16
+ # License along with this library; if not, write to the Free Software
17
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
+ #--------------------------------------------------------------------------- #
19
+
20
+ require 'deltacloud/base_driver'
21
+
22
+ require 'erb'
23
+ require 'rexml/document'
24
+
25
+ path = File.dirname(__FILE__)
26
+ $: << path
27
+
28
+ require 'occi_client'
29
+
30
+ module Deltacloud
31
+ module Drivers
32
+ module Opennebula
33
+
34
+ class OpennebulaDriver < Deltacloud::BaseDriver
35
+
36
+ ######################################################################
37
+ # Hardware profiles
38
+ ######################################################################
39
+
40
+ define_hardware_profile 'small'
41
+
42
+ define_hardware_profile 'medium'
43
+
44
+ define_hardware_profile 'large'
45
+
46
+ ######################################################################
47
+ # Realms
48
+ ######################################################################
49
+
50
+ (REALMS = [
51
+ Realm.new( {
52
+ :id=>'Any id',
53
+ :name=>'Any name',
54
+ :limit=>:unlimited,
55
+ :state=>'Any state',
56
+ } ),
57
+ ] ) unless defined?( REALMS )
58
+
59
+
60
+ def realms(credentials, opts=nil)
61
+ return REALMS if ( opts.nil? )
62
+ results = REALMS
63
+ results = filter_on( results, :id, opts )
64
+ results
65
+ end
66
+
67
+
68
+ ######################################################################
69
+ # Images
70
+ ######################################################################
71
+
72
+ def images(credentials, opts=nil)
73
+ occi_client = new_client(credentials)
74
+
75
+ images = []
76
+ imagesxml = occi_client.get_images
77
+
78
+ storage = REXML::Document.new(imagesxml)
79
+ storage.root.elements.each do |d|
80
+ id = d.attributes['href'].split("/").last
81
+
82
+ diskxml = occi_client.get_image(id)
83
+
84
+ images << convert_image(diskxml.to_s(), credentials)
85
+ end
86
+ images
87
+ end
88
+
89
+
90
+ ######################################################################
91
+ # Instances
92
+ ######################################################################
93
+
94
+ define_instance_states do
95
+ start.to( :pending ) .on( :create )
96
+
97
+ pending.to( :running ) .automatically
98
+
99
+ running.to( :stopped ) .on( :stop )
100
+
101
+ stopped.to( :running ) .on( :start )
102
+ stopped.to( :finish ) .on( :destroy )
103
+ end
104
+
105
+
106
+ def instances(credentials, opts=nil)
107
+ occi_client = new_client(credentials)
108
+
109
+ instances = []
110
+ instancesxml = occi_client.get_vms
111
+
112
+ computes = REXML::Document.new(instancesxml)
113
+ computes.root.elements.each do |d|
114
+ vm_id = d.attributes['href'].split("/").last
115
+
116
+ computexml = occi_client.get_vm(vm_id)
117
+
118
+ instances << convert_instance(computexml.to_s(), credentials)
119
+ end
120
+ instances = filter_on( instances, :id, opts )
121
+ instances = filter_on( instances, :state, opts )
122
+ instances
123
+ end
124
+
125
+
126
+ def create_instance(credentials, image_id, opts=nil)
127
+ occi_client = new_client(credentials)
128
+
129
+ hwp_id = opts[:hwp_id] || 'small'
130
+
131
+ instancexml = ERB.new(OCCI_VM).result(binding)
132
+ instancefile = "|echo '#{instancexml}'"
133
+
134
+ xmlvm = occi_client.post_vms(instancefile)
135
+
136
+ convert_instance(xmlvm.to_s(), credentials)
137
+ end
138
+
139
+
140
+ def start_instance(credentials, id)
141
+ occi_action(credentials, id, 'RESUME')
142
+ end
143
+
144
+
145
+ def stop_instance(credentials, id)
146
+ occi_action(credentials, id, 'STOPPED')
147
+ end
148
+
149
+
150
+ def destroy_instance(credentials, id)
151
+ occi_action(credentials, id, 'DONE')
152
+ end
153
+
154
+
155
+
156
+ private
157
+
158
+ def new_client(credentials)
159
+ OCCIClient::Client.new(nil, credentials.user, credentials.password, false)
160
+ end
161
+
162
+
163
+ def convert_image(diskxml, credentials)
164
+ disk = REXML::Document.new(diskxml)
165
+ diskhash = disk.root.elements
166
+
167
+ Image.new( {
168
+ :id=>diskhash['ID'].text,
169
+ :name=>diskhash['NAME'].text,
170
+ :description=>diskhash['NAME'].text,
171
+ :owner_id=>credentials.user,
172
+ :architecture=>'Any architecture',
173
+ } )
174
+ end
175
+
176
+
177
+ def convert_instance(computexml, credentials)
178
+ compute = REXML::Document.new(computexml)
179
+ computehash = compute.root.elements
180
+
181
+ imageid = computehash['STORAGE/DISK[@type="disk"]'].attributes['href'].split("/").last
182
+
183
+ state = (computehash['STATE'].text == 'ACTIVE') ? 'RUNNING' : computehash['STATE'].text
184
+
185
+ hwp_name = computehash['INSTANCE_TYPE'] || 'small'
186
+
187
+ networks = []
188
+ (computehash['NETWORK'].each do |n|
189
+ networks << n.attributes['ip']
190
+ end) unless computehash['NETWORK'].nil?
191
+
192
+ Instance.new( {
193
+ :id=>computehash['ID'].text,
194
+ :owner_id=>credentials.user,
195
+ :name=>computehash['NAME'].text,
196
+ :image_id=>imageid,
197
+ :instance_profile=>InstanceProfile.new(hwp_name),
198
+ :realm_id=>'Any realm',
199
+ :state=>state,
200
+ :public_addreses=>networks,
201
+ :private_addreses=>networks,
202
+ :actions=> instance_actions_for( state )
203
+ } )
204
+ end
205
+
206
+
207
+ def occi_action(credentials, id, strstate)
208
+ occi_client = new_client(credentials)
209
+
210
+ actionxml = ERB.new(OCCI_ACTION).result(binding)
211
+ actionfile = "|echo '#{actionxml}'"
212
+
213
+ xmlvm = occi_client.put_vm(actionfile)
214
+
215
+ convert_instance(xmlvm.to_s(), credentials)
216
+ end
217
+
218
+
219
+ (OCCI_VM = %q{
220
+ <COMPUTE>
221
+ <NAME><%=opts[:name]%></NAME>
222
+ <INSTANCE_TYPE><%= hwp_id %></INSTANCE_TYPE>
223
+ <STORAGE>
224
+ <DISK image="<%= image_id %>" dev="sda1" />
225
+ </STORAGE>
226
+ </COMPUTE>
227
+ }.gsub(/^ /, '') ) unless defined?( OCCI_VM )
228
+
229
+
230
+ (OCCI_ACTION = %q{
231
+ <COMPUTE>
232
+ <ID><%= id %></ID>
233
+ <STATE><%= strstate %></STATE>
234
+ </COMPUTE>
235
+ }.gsub(/^ /, '') ) unless defined?( OCCI_ACTION )
236
+
237
+ end
238
+
239
+ end
240
+ end
241
+ end