occi-api 4.0.0.alpha.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. data/.gitignore +15 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +43 -0
  4. data/.yardopts +1 -0
  5. data/AUTHORS +9 -0
  6. data/Gemfile +16 -0
  7. data/LICENSE +13 -0
  8. data/README.md +344 -0
  9. data/Rakefile +37 -0
  10. data/examples/dsl_example.rb +167 -0
  11. data/examples/x509auth_example.rb +161 -0
  12. data/ext/mkrf_conf.rb +34 -0
  13. data/features/cassettes/Create_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
  14. data/features/cassettes/Delete_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
  15. data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__application_json_200_.yml +333 -0
  16. data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__text_plain_200_.yml +529 -0
  17. data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__text_plain_200_action_.yml +288 -0
  18. data/features/cassettes/Miscellaneous_operation_on_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
  19. data/features/cassettes/Read_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
  20. data/features/cassettes/Update_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +288 -0
  21. data/features/common/step_definitions/common_steps.rb +32 -0
  22. data/features/occi/core/create/create.feature +18 -0
  23. data/features/occi/core/create/step_definitions/create_steps.rb +0 -0
  24. data/features/occi/core/delete/delete.feature +18 -0
  25. data/features/occi/core/delete/step_definitions/delete_steps.rb +0 -0
  26. data/features/occi/core/discovery_interface/discovery_interface.feature +37 -0
  27. data/features/occi/core/discovery_interface/step_definitions/discovery_interface_steps.rb +19 -0
  28. data/features/occi/core/miscellaneous/miscellaneous.feature +18 -0
  29. data/features/occi/core/miscellaneous/step_definitions/miscellaneous_steps.rb +0 -0
  30. data/features/occi/core/read/read.feature +18 -0
  31. data/features/occi/core/read/step_definitions/read_steps.rb +0 -0
  32. data/features/occi/core/update/step_definitions/update_steps.rb +0 -0
  33. data/features/occi/core/update/update.feature +18 -0
  34. data/features/occi/infrastructure/create/create.feature +18 -0
  35. data/features/occi/infrastructure/create/step_definitions/create_steps.rb +0 -0
  36. data/features/support/env.rb +16 -0
  37. data/lib/occi/api/client/client_amqp.rb +766 -0
  38. data/lib/occi/api/client/client_base.rb +689 -0
  39. data/lib/occi/api/client/client_http.rb +541 -0
  40. data/lib/occi/api/client/errors/authn_error.rb +7 -0
  41. data/lib/occi/api/client/errors.rb +1 -0
  42. data/lib/occi/api/client/http/authn_plugins/base.rb +27 -0
  43. data/lib/occi/api/client/http/authn_plugins/basic.rb +22 -0
  44. data/lib/occi/api/client/http/authn_plugins/digest.rb +22 -0
  45. data/lib/occi/api/client/http/authn_plugins/dummy.rb +13 -0
  46. data/lib/occi/api/client/http/authn_plugins/keystone.rb +61 -0
  47. data/lib/occi/api/client/http/authn_plugins/x509.rb +46 -0
  48. data/lib/occi/api/client/http/authn_plugins.rb +6 -0
  49. data/lib/occi/api/client/http/authn_utils.rb +87 -0
  50. data/lib/occi/api/client/http/httparty_fix.rb +53 -0
  51. data/lib/occi/api/client/http/net_http_fix.rb +21 -0
  52. data/lib/occi/api/dsl.rb +146 -0
  53. data/lib/occi/api/version.rb +5 -0
  54. data/lib/occi-api.rb +14 -0
  55. data/occi-api.gemspec +38 -0
  56. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_compute_resource.yml +266 -0
  57. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_network_resource.yml +266 -0
  58. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_storage_resource.yml +266 -0
  59. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_compute_resource.yml +266 -0
  60. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_network_resource.yml +266 -0
  61. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_storage_resource.yml +266 -0
  62. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deploys_an_instance_based_on_OVF_OVA_file.yml +266 -0
  63. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_compute_resources.yml +368 -0
  64. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_network_resources.yml +370 -0
  65. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_storage_resources.yml +430 -0
  66. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/establishes_connection.yml +266 -0
  67. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/finds_and_describes_scoped_os_tpl_mixin.yml +266 -0
  68. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/finds_and_describes_scoped_resource_tpl_mixin.yml +266 -0
  69. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/finds_and_describes_unscoped_mixin.yml +266 -0
  70. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_identifier.yml +266 -0
  71. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_name.yml +266 -0
  72. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_identifier.yml +266 -0
  73. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_name.yml +266 -0
  74. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_identifier.yml +266 -0
  75. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_name.yml +266 -0
  76. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_type_identifiers.yml +266 -0
  77. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_types.yml +266 -0
  78. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_type_identifiers.yml +266 -0
  79. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_types.yml +266 -0
  80. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_type_identifiers.yml +266 -0
  81. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_types.yml +266 -0
  82. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixins.yml +266 -0
  83. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_type_identifiers.yml +266 -0
  84. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_types.yml +266 -0
  85. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_compute_resources.yml +308 -0
  86. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_network_resources.yml +308 -0
  87. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_os_tpl_mixins.yml +266 -0
  88. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_resource_tpl_mixins.yml +266 -0
  89. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_storage_resources.yml +310 -0
  90. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/refreshes_its_model.yml +485 -0
  91. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_compute_resource.yml +266 -0
  92. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_network_resource.yml +266 -0
  93. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_storage_resource.yml +266 -0
  94. data/spec/occi/api/client/client_amqp_spec.rb +158 -0
  95. data/spec/occi/api/client/client_http_spec.rb +292 -0
  96. data/spec/occi/api/client/http/authn_utils_spec.rb +55 -0
  97. data/spec/occi/api/client/http/httparty_fix_spec.rb +0 -0
  98. data/spec/occi/api/client/http/net_http_fix_spec.rb +0 -0
  99. data/spec/occi/api/client/http/rocci-cred-cert.pem +3 -0
  100. data/spec/occi/api/client/http/rocci-cred-key-jruby.pem +3 -0
  101. data/spec/occi/api/client/http/rocci-cred-key.pem +3 -0
  102. data/spec/occi/api/client/http/rocci-cred.p12 +0 -0
  103. data/spec/occi/api/dsl_spec.rb +21 -0
  104. data/spec/spec_helper.rb +38 -0
  105. metadata +379 -0
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ *.gem
2
+ *.swp
3
+ .project
4
+ .idea
5
+ .yardoc
6
+ .bundle
7
+ .rvmrc
8
+ lib/occiantlr/output/
9
+ pkg
10
+ tmp
11
+ log
12
+ coverage
13
+ vendor
14
+ collection
15
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper --color --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,43 @@
1
+ language: ruby
2
+
3
+ before_install:
4
+ - sudo apt-get install -qq libonig-dev
5
+
6
+ rvm:
7
+ - 1.8.7
8
+ - 1.9.3
9
+ - 2.0.0
10
+ - ruby-head
11
+ - jruby-19mode
12
+ - jruby-head
13
+
14
+ jdk:
15
+ - openjdk7
16
+ - oraclejdk7
17
+ - openjdk6
18
+
19
+ matrix:
20
+ allow_failures:
21
+ - rvm: ruby-head
22
+ - rvm: jruby-head
23
+ exclude:
24
+ - rvm: 1.8.7
25
+ jdk: openjdk7
26
+ - rvm: 1.8.7
27
+ jdk: oraclejdk7
28
+ - rvm: 1.9.3
29
+ jdk: openjdk7
30
+ - rvm: 1.9.3
31
+ jdk: oraclejdk7
32
+ - rvm: 2.0.0
33
+ jdk: openjdk7
34
+ - rvm: 2.0.0
35
+ jdk: oraclejdk7
36
+ - rvm: ruby-head
37
+ jdk: openjdk7
38
+ - rvm: ruby-head
39
+ jdk: oraclejdk7
40
+
41
+ branches:
42
+ only:
43
+ - master
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --title "Documentation of the OCCI gem" --markup markdown --private
data/AUTHORS ADDED
@@ -0,0 +1,9 @@
1
+ rOcci was designed and is mainly developed by Florian Feldhaus (GWDG) and Piotr Kasprzak (GWDG) in Germany.
2
+
3
+ Special thanks to the following extraordinary individuals, whithout whom rOcci would not be possible:
4
+
5
+ * Hayati Bice - who wrote the initial version of an Occi server rOcci is based on
6
+ * Max Günther - who wrote the EC2 backend
7
+ * Andre Thevapalan - for his input regarding the JSON rendering
8
+ * Boris Parak - especially for his input regarding the Client / Client DSL and CLI
9
+ * the OCCI Working Group - for developing OCCI
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "https://rubygems.org/"
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ gem 'vcr', :git => 'git://github.com/arax/vcr.git', :branch => 'test_framework_patches', :ref => 'e82e843ceddd8822acea59846b015bcabf1906df'
7
+ gem 'rubygems-tasks', :git => 'git://github.com/postmodern/rubygems-tasks.git'
8
+ end
9
+
10
+ platforms :jruby do
11
+ gem 'jruby-openssl' if ((defined? JRUBY_VERSION) && (JRUBY_VERSION.split('.')[1].to_i < 7))
12
+ end
13
+
14
+ platforms :ruby_18 do
15
+ gem 'oniguruma'
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012 GWDG
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,344 @@
1
+ rOCCI-api - A Ruby OCCI Framework
2
+ =================================
3
+
4
+ [![Build Status](https://secure.travis-ci.org/gwdg/rOCCI-api.png)](http://travis-ci.org/gwdg/rOCCI-api)
5
+ [![Dependency Status](https://gemnasium.com/gwdg/rOCCI-api.png)](https://gemnasium.com/gwdg/rOCCI-api)
6
+ [![Gem Version](https://fury-badge.herokuapp.com/rb/occi-api.png)](https://badge.fury.io/rb/occi-api)
7
+ [![Code Climate](https://codeclimate.com/github/gwdg/rOCCI-api.png)](https://codeclimate.com/github/gwdg/rOCCI-api)
8
+
9
+ Requirements
10
+ ------------
11
+
12
+ Ruby
13
+ * at least version 1.8.7 is required
14
+
15
+ The following setup is recommended
16
+
17
+ * usage of the Ruby Version Manager
18
+ * Ruby 1.9.3
19
+ * RubyGems installed
20
+
21
+ The following libraries / packages may be required to use rOCCI
22
+
23
+ * libxslt-dev
24
+ * libxml2-dev
25
+ * **only if using Ruby 1.8.7:** libonig-dev (Linux) or oniguruma (Mac)
26
+
27
+ Installation
28
+ ------------
29
+
30
+ To install the most recent stable version
31
+
32
+ gem install occi-api
33
+
34
+ To install the most recent beta version
35
+
36
+ gem install occi-api --pre
37
+
38
+ ### Installation from source
39
+
40
+ To use rOCCI-api from source it is very much recommended to use RVM. [Install RVM](https://rvm.io/rvm/install/) with
41
+
42
+ curl -L https://get.rvm.io | bash -s stable --ruby
43
+
44
+ #### Ruby
45
+
46
+ To build and install the bleeding edge version from master
47
+
48
+ git clone git://github.com/gwdg/rOCCI-api.git
49
+ cd rOCCI-api
50
+ rvm install ruby-1.9.3
51
+ rvm --create --ruby-version use 1.9.3@rOCCI-api
52
+ bundle install --deployment
53
+ rake install
54
+
55
+ Usage
56
+ -----
57
+ ### Auth
58
+
59
+ For Basic auth use
60
+
61
+ auth = Hashie::Mash.new
62
+ auth.type = 'basic'
63
+ auth.username = 'user'
64
+ auth.password = 'mypass'
65
+
66
+ For Digest auth use
67
+
68
+ auth = Hashie::Mash.new
69
+ auth.type = 'digest'
70
+ auth.username = 'user'
71
+ auth.password = 'mypass'
72
+
73
+ For X.509 auth use
74
+
75
+ auth = Hashie::Mash.new
76
+ auth.type = 'x509'
77
+ auth.user_cert = '/Path/To/My/usercert.pem'
78
+ auth.user_cert_password = 'MyPassword'
79
+ auth.ca_path = '/Path/To/root-certificates'
80
+
81
+ ### DSL
82
+ In your scripts, you can use the OCCI client DSL.
83
+
84
+ To include the DSL definitions in a script use
85
+
86
+ extend Occi::Api::Dsl
87
+
88
+ To include the DSL definitions in a class use
89
+
90
+ include Occi::Api::Dsl
91
+
92
+ To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
93
+
94
+ # defaults
95
+ options = {
96
+ :endpoint => "http://localhost:3300/",
97
+ :auth => {:type => "none"},
98
+ :log => {:out => STDERR, :level => Occi::Log::WARN, :logger => nil},
99
+ :auto_connect => "value", auto_connect => true,
100
+ :media_type => nil
101
+ }
102
+
103
+ connect(:http, options ||= {})
104
+
105
+ To get the list of available resource, mixin, entity or link types use
106
+
107
+ resource_types
108
+ mixin_types
109
+ entity_types
110
+ link_types
111
+
112
+ To get compute, storage or network descriptions use
113
+
114
+ describe "compute"
115
+ describe "storage"
116
+ describe "network"
117
+
118
+ To get the location of compute, storage or network resources use
119
+
120
+ list "compute"
121
+ list "storage"
122
+ list "network"
123
+
124
+ To get the identifiers of specific mixins in specific mixin types use
125
+
126
+ mixin "my_template", "os_tpl"
127
+ mixin "small", "resource_tpl"
128
+
129
+ To get the identifiers of specific mixins with unknown types use
130
+
131
+ mixin "medium"
132
+
133
+ To get mixin descriptions use
134
+
135
+ mixin "medium", nil, true
136
+ mixin "my_template", "os_tpl", true
137
+
138
+ To get a list of names of all / OS templates / Resource templates mixins use
139
+
140
+ mixins
141
+ mixins "os_tpl"
142
+ mixins "resource_tpl"
143
+
144
+ To create a new compute resource use
145
+
146
+ os = mixin 'my_os', 'os_tpl'
147
+ size = mixin 'large', 'resource_tpl'
148
+ cmpt = resource "compute"
149
+ cmpt.mixins << os << size
150
+ cmpt.title = "My VM"
151
+ create cmpt
152
+
153
+ To get a description of a specific resource use
154
+
155
+ describe "/compute/<OCCI_ID>"
156
+ describe "/storage/<OCCI_ID>"
157
+ describe "/network/<OCCI_ID>"
158
+
159
+ To delete a specific resource use
160
+
161
+ delete "/compute/<OCCI_ID>"
162
+ delete "/storage/<OCCI_ID>"
163
+ delete "/network/<OCCI_ID>"
164
+
165
+ ### API
166
+ If you need low level access to parts of the OCCI client or need to use more than one instance
167
+ at a time, you should use the OCCI client API directly.
168
+
169
+ To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
170
+
171
+ # defaults
172
+ options = {
173
+ :endpoint => "http://localhost:3300/",
174
+ :auth => {:type => "none"},
175
+ :log => {:out => STDERR, :level => Occi::Log::WARN, :logger => nil},
176
+ :auto_connect => "value", auto_connect => true,
177
+ :media_type => nil
178
+ }
179
+
180
+ client = Occi::Api::Client::ClientHttp.new(options ||= {})
181
+
182
+ All available categories are automatically registered to the OCCI model during client initialization. You can get them via
183
+
184
+ client.model
185
+
186
+ To get the list of available resource, mixin, entity or link types use
187
+
188
+ client.get_resource_types
189
+ client.get_mixin_types
190
+ client.get_entity_types
191
+ client.get_link_types
192
+
193
+ To get compute, storage or network descriptions use
194
+
195
+ client.describe "compute"
196
+ client.describe "storage"
197
+ client.describe "network"
198
+
199
+ To get the location of compute, storage or network resources use
200
+
201
+ client.list "compute"
202
+ client.list "storage"
203
+ client.list "network"
204
+
205
+ To get the identifiers of specific mixins in specific mixin types use
206
+
207
+ client.find_mixin "my_template", "os_tpl"
208
+ client.find_mixin "small", "resource_tpl"
209
+
210
+ To get the identifiers of specific mixins with unknown types use
211
+
212
+ client.find_mixin "medium"
213
+
214
+ To get mixin descriptions use
215
+
216
+ client.find_mixin "medium", nil, true
217
+ client.find_mixin "my_template", "os_tpl", true
218
+
219
+ To get a list of names of all / OS templates / Resource templates mixins use
220
+
221
+ client.get_mixins
222
+ client.get_mixins "os_tpl"
223
+ client.get_mixins "resource_tpl"
224
+
225
+ To create a new compute resource use
226
+
227
+ os = client.find_mixin 'my_os', 'os_tpl'
228
+ size = client.find_mixin 'large', 'resource_tpl'
229
+ cmpt = client.get_resource "compute"
230
+ cmpt.mixins << os << size
231
+ cmpt.title = "My VM"
232
+ client.create cmpt
233
+
234
+ To get a description of a specific resource use
235
+
236
+ client.describe "/compute/<OCCI_ID>"
237
+ client.describe "/storage/<OCCI_ID>"
238
+ client.describe "/network/<OCCI_ID>"
239
+
240
+ To delete a specific resource use
241
+
242
+ client.delete "/compute/<OCCI_ID>"
243
+ client.delete "/storage/<OCCI_ID>"
244
+ client.delete "/network/<OCCI_ID>"
245
+
246
+ ### Logging
247
+
248
+ The OCCI gem includes its own logging mechanism using a message queue. By default, no one is listening to that queue.
249
+ A new OCCI Logger can be initialized by specifying the log destination (either a filename or an IO object like
250
+ STDOUT) and the log level.
251
+
252
+ Occi::Log.new(STDOUT,Occi::Log::INFO)
253
+
254
+ You can create multiple Loggers to receive the log output.
255
+
256
+ You can always, even if there is no logger defined, log output using the class methods of OCCI::Log e.g.
257
+
258
+ Occi::Log.info("Test message")
259
+
260
+ Changelog
261
+ ---------
262
+
263
+ ### Version 3.1
264
+ * added basic OS Keystone support
265
+ * added support for PKCS12 credentials for X.509 authN
266
+ * updated templates for plain output formatting
267
+ * minor client API changes
268
+ * several bugfixes
269
+
270
+ ### Version 3.0
271
+
272
+ * many bugfixes
273
+ * rewrote Core classes to use metaprogramming techniques
274
+ * added VCR cassettes for reliable testing against prerecorded server responses
275
+ * several updates to the OCCI Client
276
+ * started work on an OCCI Client using AMQP as transport protocol
277
+ * added support for keystone authentication to be used with the OpenStack OCCI server
278
+ * updated dependencies
279
+ * updated rspec tests
280
+ * started work on cucumber features
281
+
282
+ ### Version 2.5
283
+
284
+ * improved OCCI Client
285
+ * improved documentation
286
+ * several bugfixes
287
+
288
+ ### Version 2.4
289
+
290
+ * Changed OCCI attribute properties from lowercase to first letter uppercase (e.g. type -> Type, default -> Default, ...)
291
+
292
+ ### Version 2.3
293
+
294
+ * OCCI objects are now initialized with a list of attributes instead of a hash. Thus it is easier to check which
295
+ attributes are expected by a class and helps prevent errors.
296
+ * Parsing of a subset of the OVF specification is supported. Further parts of the specification will be covered in
297
+ future versions of rOCCI.
298
+
299
+ ### Version 2.2
300
+
301
+ * OCCI Client added. The client simplifies the execution of OCCI commands and provides shortcuts for often used steps.
302
+
303
+ ### Version 2.1
304
+
305
+ * Several improvements to the gem structure and code documentation. First rSpec test were added. Readme has been extended to include instructions how the gem can be used.
306
+
307
+ ### Version 2.0
308
+
309
+ * Starting with version 2.0 Florian Feldhaus and Piotr Kasprzak took over the development of the OCCI gem. The codebase was taken from the rOCCI framework and improved to be bundled as a standalone gem.
310
+
311
+ ### Version 1.X
312
+
313
+ * Version 1.X of the OCCI gem has been developed by retr0h and served as a simple way to access the first OpenNebula OCCI implementation.
314
+
315
+ Development
316
+ -----------
317
+
318
+ Checkout latest version from GIT:
319
+
320
+ git clone git://github.com/gwdg/rOCCI-api.git
321
+
322
+ Change to rOCCI-api folder
323
+
324
+ cd rOCCI-api
325
+
326
+ Install dependencies for deployment
327
+
328
+ bundle install
329
+
330
+ ### Code Documentation
331
+
332
+ [Code Documentation for rOCCI-api by YARD](http://rubydoc.info/github/gwdg/rOCCI-api/)
333
+
334
+ ### Continuous integration
335
+
336
+ [Continuous integration for rOCCI-api by Travis-CI](http://travis-ci.org/gwdg/rOCCI-api/)
337
+
338
+ ### Contribute
339
+
340
+ 1. Fork it.
341
+ 2. Create a branch (git checkout -b my_markup)
342
+ 3. Commit your changes (git commit -am "My changes")
343
+ 4. Push to the branch (git push origin my_markup)
344
+ 5. Create an Issue with a link to your branch
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ require 'rubygems/tasks'
2
+
3
+ task :default => 'test'
4
+
5
+ desc "Run all tests; includes rspec, cucumber and coverage reports"
6
+ task :test => 'rcov:all'
7
+
8
+ Gem::Tasks.new(:build => {:tar => true, :zip => true}, :sign => {:checksum => true, :pgp => false})
9
+
10
+ namespace :rcov do
11
+
12
+ require 'rspec/core/rake_task'
13
+ require 'cucumber/rake/task'
14
+
15
+ Cucumber::Rake::Task.new(:cucumber) do |t|
16
+ t.cucumber_opts = "--format pretty"
17
+ ENV['COVERAGE'] = "true"
18
+ end
19
+
20
+ RSpec::Core::RakeTask.new(:rspec) do |t|
21
+ ENV['COVERAGE'] = "true"
22
+ end
23
+
24
+ desc "Run cucumber & rspec to generate aggregated coverage"
25
+ task :all do |t|
26
+ rm "coverage/coverage.data" if File.exist?("coverage/coverage.data")
27
+ Rake::Task['rcov:rspec'].invoke
28
+ Rake::Task["rcov:cucumber"].invoke
29
+ end
30
+
31
+ end
32
+
33
+ require 'yard'
34
+ YARD::Rake::YardocTask.new(:yard) do |t|
35
+ t.files = ['features/**/*.feature', 'features/**/*.rb']
36
+ t.options = ['--any', '--extra', '--opts'] # optional
37
+ end
@@ -0,0 +1,167 @@
1
+ require 'rubygems'
2
+ require 'pp'
3
+
4
+ # load and include rOCCI client DSL
5
+ require 'occi-api'
6
+ extend Occi::Api::Dsl
7
+
8
+ ## options
9
+ use_os_temlate = true # use OS_TEMPLATE or NETWORK + STORAGE + INSTANCE TYPE
10
+ OS_TEMPLATE = 'monitoring' # name of the VM template in ON
11
+
12
+ clean_up_compute = true # issue DELETE <RESOURCE> after we are done
13
+
14
+ USER_CERT = ENV['HOME'] + '/.globus/usercred.pem'
15
+ USER_CERT_PASSWORD = 'mypassphrase'
16
+ CA_PATH = '/etc/grid-security/certificates'
17
+ ENDPOINT = 'https://localhost:3300'
18
+
19
+ ## establish a connection
20
+ connect(
21
+ :http,
22
+ {
23
+ :endpoint => ENDPOINT,
24
+ :auth => {
25
+ :type => "x509",
26
+ :user_cert => USER_CERT,
27
+ :user_cert_password => USER_CERT_PASSWORD,
28
+ :ca_path => CA_PATH
29
+ },
30
+ :log => {
31
+ :out => STDERR,
32
+ :level => Occi::Log::DEBUG
33
+ }
34
+ }
35
+ )
36
+
37
+ puts "\n\nListing all available resource types:"
38
+ resource_types.each do |type|
39
+ puts "\n#{type}"
40
+ end
41
+
42
+ puts "\n\nListing all available resource type identifiers:"
43
+ resource_type_identifiers.each do |type_id|
44
+ puts "\n#{type_id}"
45
+ end
46
+
47
+ puts "\n\nListing all available mixin types:"
48
+ mixin_types.each do |mixin_type|
49
+ puts "\n#{mixin_type}"
50
+ end
51
+
52
+ puts "\n\nListing all available mixin type identifiers:"
53
+ mixin_type_identifiers.each do |mixin_typeid|
54
+ puts "\n#{mixin_typeid}"
55
+ end
56
+
57
+ puts "\n\nListing all available mixins:"
58
+ mixins.each do |mixin|
59
+ puts "\n#{mixin}"
60
+ end
61
+
62
+ samples = [OS_TEMPLATE, "medium", "large", "small"]
63
+
64
+ puts "\n\nFind mixins using their names:"
65
+ samples.each do |mxn|
66
+ puts "\n#{mxn}:\n"
67
+ pp mixin mxn
68
+ end
69
+
70
+ puts "\n\nFind mixins using their names and a type:"
71
+ samples.each do |mxn|
72
+ puts "\n#{mxn}:\n"
73
+ pp mixin(mxn, "os_tpl")
74
+ end
75
+
76
+ puts "\n\nFind mixins using their names and a type:"
77
+ samples.each do |mxn|
78
+ puts "\n#{mxn}:\n"
79
+ pp mixin(mxn, "resource_tpl")
80
+ end
81
+
82
+ puts "\n\nFind mixins using their names (showing detailed descriptions):"
83
+ samples.each do |mxn|
84
+ puts "\n#{mxn}:\n"
85
+ pp mixin(mxn, nil, true)
86
+ end
87
+
88
+ ## get links of all available resources
89
+ puts "\n\nListing storage resources"
90
+ pp list "storage"
91
+
92
+ puts "\n\nListing network resources"
93
+ pp list "network"
94
+
95
+ puts "\n\nListing compute resources"
96
+ pp list "compute"
97
+
98
+ ## get detailed information about all available resources
99
+ puts "\n\nDescribing storage resources"
100
+ pp describe "storage"
101
+
102
+ puts "\n\nDescribing compute resources"
103
+ pp describe "compute"
104
+
105
+ puts "\n\nDescribing network resources"
106
+ pp describe "network"
107
+
108
+ ## create a compute resource using the chosen method (os_tpl|strg+ntwrk)
109
+ puts "\n\nCreate compute resources"
110
+ cmpt = resource "compute"
111
+
112
+ unless use_os_temlate
113
+ ## without OS template, we have to manually select and attach
114
+ ## network, storage and resource template (instance type)
115
+
116
+ ## select instance type medium
117
+ cmpt.mixins << mixin('medium', "resource_tpl")
118
+
119
+ ## list network/storage locations and select the appropriate ones (the first ones in this case)
120
+ puts "\nUsing:"
121
+ pp storage_loc = list("storage")[0]
122
+ pp network_loc = list("network")[0]
123
+
124
+ ## create links and attach them to the compure resource
125
+ puts "\n Connecting to our compute:"
126
+ cmpt.storagelink storage_loc
127
+ cmpt.networkinterface network_loc
128
+ else
129
+ ## with OS template, we have to find the template by name
130
+ ## optionally we can change its "size" by choosing an instance type
131
+ puts "\nUsing:"
132
+ pp os = mixin(OS_TEMPLATE, "os_tpl")
133
+ pp size = mixin('medium', "resource_tpl")
134
+
135
+ ## attach chosen resources to the compute resource
136
+ cmpt.mixins << os << size
137
+ ## we can change some of the values manually
138
+ cmpt.title = "My rOCCI x509 VM"
139
+ end
140
+
141
+ ## create the compute resource and print its location
142
+ cmpt_loc = create cmpt
143
+ pp "Location of new compute resource: #{cmpt_loc}"
144
+
145
+ ## get links of all available compute resouces again
146
+ puts "\n\nListing locations of compute resources (should now contain #{cmpt_loc})"
147
+ pp list "compute"
148
+
149
+ ## get detailed information about the new compute resource
150
+ puts "\n\nListing information about compute resource #{cmpt_loc}"
151
+ cmpt_data = describe cmpt_loc
152
+ pp cmpt_data
153
+
154
+ ## wait until the resource is "active"
155
+ while cmpt_data[0].resources.first.attributes.occi.compute.state == "inactive"
156
+ puts "\nCompute resource #{cmpt_loc} is inactive, waiting ..."
157
+ sleep 1
158
+ cmpt_data = describe cmpt_loc
159
+ end
160
+
161
+ puts "\nCompute resource #{cmpt_loc} is #{cmpt_data[0].resources.first.attributes.occi.compute.state}"
162
+
163
+ ## delete the resource and exit
164
+ if clean_up_compute
165
+ puts "\n\nDeleting compute resource #{cmpt_loc}"
166
+ pp delete cmpt_loc
167
+ end