occi 3.0.0.beta.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +3 -26
- data/Gemfile.lock +43 -35
- data/README.md +40 -4
- data/bin/occi +67 -64
- data/ext/mkrf_conf.rb +25 -0
- data/features/cassettes/Create_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
- data/features/cassettes/Delete_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
- data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__application_json_200_.yml +173 -0
- data/features/cassettes/Discovery_Interface/Retrieving_all_OCCI_Categories_supported_by_the_OCCI_Server/_http_http___141_5_99_69__text_plain_200_.yml +325 -0
- 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 +186 -0
- data/features/cassettes/Miscellaneous_operation_on_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
- data/features/cassettes/Read_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
- data/features/cassettes/Update_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
- data/features/occi/core/create/create.feature +3 -2
- data/features/occi/core/delete/delete.feature +6 -2
- data/features/occi/core/discovery_interface/discovery_interface.feature +4 -2
- data/features/occi/core/miscellaneous/miscellaneous.feature +6 -2
- data/features/occi/core/read/read.feature +6 -2
- data/features/occi/core/update/update.feature +6 -2
- data/features/occi/infrastructure/create/create.feature +6 -2
- data/features/support/env.rb +13 -1
- data/lib/occi/api/client/client_http.rb +914 -820
- data/lib/occi/api/client/http/net_http_fix.rb +7 -36
- data/lib/occi/api/dsl.rb +32 -2
- data/lib/occi/bin/occi_opts.rb +15 -1
- data/lib/occi/collection.rb +26 -15
- data/lib/occi/core/categories.rb +9 -1
- data/lib/occi/core/category.rb +20 -11
- data/lib/occi/core/link.rb +4 -5
- data/lib/occi/model.rb +2 -2
- data/lib/occi/parser.rb +51 -49
- data/lib/occi/version.rb +1 -1
- data/occi.gemspec +16 -3
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_compute_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_network_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_storage_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_compute_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_network_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_storage_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deploys_an_instance_based_on_OVF_OVA_file.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_all_available_mixins.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_compute_resources.yml +324 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_network_resources.yml +326 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_os_tpl_mixins.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_resource_tpl_mixins.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_storage_resources.yml +386 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/establishes_connection.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_identifier.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_name.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_identifier.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_name.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_identifier.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_name.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_type_identifiers.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_types.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_type_identifiers.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_types.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_type_identifiers.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_types.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixins.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_type_identifiers.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_types.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_compute_resources.yml +264 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_network_resources.yml +264 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_os_tpl_mixins.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_resource_tpl_mixins.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_storage_resources.yml +266 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/refreshes_its_model.yml +397 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_compute_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_network_resource.yml +222 -0
- data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_storage_resource.yml +222 -0
- data/spec/occi/api/client/client_amqp_spec.rb +10 -2
- data/spec/occi/api/client/client_http_spec.rb +111 -117
- data/spec/occi/api/dsl_spec.rb +22 -0
- data/spec/occi/collection_spec.rb +11 -2
- data/spec/occi/core/resource_spec.rb +1 -1
- data/spec/occi/infrastructure/compute_spec.rb +3 -3
- data/spec/occi/log_spec.rb +1 -1
- data/spec/occi/model_spec.rb +4 -8
- data/spec/occi/parser_spec.rb +4 -4
- data/spec/spec_helper.rb +3 -2
- metadata +264 -12
- data/spec/cassettes/client_http_text_plain.yml +0 -1066
- data/spec/occi/api/client/client_http_0.5_spec.rb +0 -292
data/Gemfile
CHANGED
@@ -1,32 +1,9 @@
|
|
1
1
|
source :rubygems
|
2
2
|
|
3
|
-
|
4
|
-
gem "json"
|
5
|
-
gem "antlr3"
|
6
|
-
gem "hashie"
|
7
|
-
gem "uuidtools", ">=2.1.3"
|
8
|
-
gem "nokogiri"
|
9
|
-
gem "builder"
|
10
|
-
gem "activesupport"
|
11
|
-
gem "rake"
|
12
|
-
gem "httparty"
|
13
|
-
gem "highline"
|
14
|
-
gem "i18n"
|
15
|
-
gem "amqp"
|
3
|
+
gemspec
|
16
4
|
|
17
|
-
|
18
|
-
group :development do
|
19
|
-
gem "rspec"
|
20
|
-
gem "simplecov"
|
21
|
-
gem "yard"
|
22
|
-
gem "yard-sinatra"
|
23
|
-
gem "yard-rspec"
|
24
|
-
gem "yard-cucumber"
|
25
|
-
gem "rspec-http"
|
26
|
-
gem "vcr"
|
27
|
-
gem "webmock", "=1.8.11"
|
28
|
-
end
|
5
|
+
gem 'vcr', :git => 'git://github.com/arax/vcr.git', :branch => 'test_framework_patches'
|
29
6
|
|
30
7
|
platforms :jruby do
|
31
|
-
gem 'jruby-openssl'
|
8
|
+
gem 'jruby-openssl' if ((defined? JRUBY_VERSION) && (JRUBY_VERSION.split('.')[1].to_i < 7))
|
32
9
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,22 +1,43 @@
|
|
1
|
+
GIT
|
2
|
+
remote: git://github.com/arax/vcr.git
|
3
|
+
revision: e82e843ceddd8822acea59846b015bcabf1906df
|
4
|
+
branch: test_framework_patches
|
5
|
+
specs:
|
6
|
+
vcr (2.4.0)
|
7
|
+
|
8
|
+
PATH
|
9
|
+
remote: .
|
10
|
+
specs:
|
11
|
+
occi (3.0.0.beta.1)
|
12
|
+
activesupport
|
13
|
+
amqp
|
14
|
+
antlr3
|
15
|
+
hashie
|
16
|
+
highline
|
17
|
+
httparty
|
18
|
+
i18n
|
19
|
+
json
|
20
|
+
nokogiri
|
21
|
+
uuidtools (>= 2.1.3)
|
22
|
+
|
1
23
|
GEM
|
2
24
|
remote: http://rubygems.org/
|
3
25
|
specs:
|
4
|
-
activesupport (3.2.
|
26
|
+
activesupport (3.2.11)
|
5
27
|
i18n (~> 0.6)
|
6
28
|
multi_json (~> 1.0)
|
7
29
|
addressable (2.3.2)
|
8
|
-
amq-client (0.9.
|
30
|
+
amq-client (0.9.10)
|
9
31
|
amq-protocol (>= 0.9.4)
|
10
32
|
eventmachine
|
11
|
-
amq-protocol (0.
|
33
|
+
amq-protocol (1.0.1)
|
12
34
|
amqp (0.9.8)
|
13
35
|
amq-client (~> 0.9.5)
|
14
36
|
amq-protocol (>= 0.9.4)
|
15
37
|
eventmachine
|
16
38
|
antlr3 (1.8.12)
|
17
|
-
bouncy-castle-java (1.5.0146.1)
|
18
39
|
builder (3.1.4)
|
19
|
-
crack (0.3.
|
40
|
+
crack (0.3.2)
|
20
41
|
cucumber (1.2.1)
|
21
42
|
builder (>= 2.1.2)
|
22
43
|
diff-lcs (>= 1.1.3)
|
@@ -35,32 +56,29 @@ GEM
|
|
35
56
|
multi_json (~> 1.0)
|
36
57
|
multi_xml
|
37
58
|
i18n (0.6.1)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
json (1.7.5-java)
|
42
|
-
multi_json (1.3.7)
|
59
|
+
json (1.7.6)
|
60
|
+
json (1.7.6-java)
|
61
|
+
multi_json (1.5.0)
|
43
62
|
multi_xml (0.5.1)
|
44
|
-
nokogiri (1.5.
|
45
|
-
nokogiri (1.5.
|
46
|
-
rake (0.
|
47
|
-
rspec (2.
|
48
|
-
rspec-core (~> 2.
|
49
|
-
rspec-expectations (~> 2.
|
50
|
-
rspec-mocks (~> 2.
|
51
|
-
rspec-core (2.
|
52
|
-
rspec-expectations (2.
|
63
|
+
nokogiri (1.5.6)
|
64
|
+
nokogiri (1.5.6-java)
|
65
|
+
rake (10.0.3)
|
66
|
+
rspec (2.12.0)
|
67
|
+
rspec-core (~> 2.12.0)
|
68
|
+
rspec-expectations (~> 2.12.0)
|
69
|
+
rspec-mocks (~> 2.12.0)
|
70
|
+
rspec-core (2.12.2)
|
71
|
+
rspec-expectations (2.12.1)
|
53
72
|
diff-lcs (~> 1.1.3)
|
54
73
|
rspec-http (0.10.0)
|
55
74
|
rspec (~> 2.0)
|
56
|
-
rspec-mocks (2.
|
75
|
+
rspec-mocks (2.12.1)
|
57
76
|
simplecov (0.7.1)
|
58
77
|
multi_json (~> 1.0)
|
59
78
|
simplecov-html (~> 0.7.1)
|
60
79
|
simplecov-html (0.7.1)
|
61
80
|
uuidtools (2.1.3)
|
62
|
-
|
63
|
-
webmock (1.8.11)
|
81
|
+
webmock (1.9.0)
|
64
82
|
addressable (>= 2.2.7)
|
65
83
|
crack (>= 0.1.7)
|
66
84
|
yard (0.8.3)
|
@@ -78,24 +96,14 @@ PLATFORMS
|
|
78
96
|
ruby
|
79
97
|
|
80
98
|
DEPENDENCIES
|
81
|
-
activesupport
|
82
|
-
amqp
|
83
|
-
antlr3
|
84
99
|
builder
|
85
|
-
|
86
|
-
highline
|
87
|
-
httparty
|
88
|
-
i18n
|
89
|
-
jruby-openssl
|
90
|
-
json
|
91
|
-
nokogiri
|
100
|
+
occi!
|
92
101
|
rake
|
93
102
|
rspec
|
94
103
|
rspec-http
|
95
104
|
simplecov
|
96
|
-
|
97
|
-
|
98
|
-
webmock (= 1.8.11)
|
105
|
+
vcr!
|
106
|
+
webmock
|
99
107
|
yard
|
100
108
|
yard-cucumber
|
101
109
|
yard-rspec
|
data/README.md
CHANGED
@@ -1,7 +1,9 @@
|
|
1
1
|
rOCCI - A Ruby OCCI Framework
|
2
2
|
=================================
|
3
3
|
|
4
|
-
[![Build Status](https://secure.travis-ci.org/gwdg/rOCCI.png)](http://travis-ci.org/gwdg/rOCCI)
|
4
|
+
[![Build Status](https://secure.travis-ci.org/gwdg/rOCCI.png)](http://travis-ci.org/gwdg/rOCCI)
|
5
|
+
[![Dependency Status](https://gemnasium.com/gwdg/rOCCI.png)](https://gemnasium.com/gwdg/rOCCI)
|
6
|
+
[![Gem Version](https://fury-badge.herokuapp.com/rb/occi.png)](https://badge.fury.io/rb/occi)
|
5
7
|
|
6
8
|
Requirements
|
7
9
|
------------
|
@@ -14,9 +16,20 @@ The following setup is recommended
|
|
14
16
|
|
15
17
|
Installation
|
16
18
|
------------
|
19
|
+
To install the most recent stable version
|
17
20
|
|
18
21
|
gem install occi
|
19
22
|
|
23
|
+
To install the most recent beta version
|
24
|
+
|
25
|
+
gem install occi --pre
|
26
|
+
|
27
|
+
To build and install the bleeding edge version from master
|
28
|
+
|
29
|
+
git clone git://github.com/gwdg/rOCCI.git
|
30
|
+
cd rOCCI
|
31
|
+
rake install
|
32
|
+
|
20
33
|
Usage
|
21
34
|
-----
|
22
35
|
### Client
|
@@ -30,6 +43,7 @@ To run the client in an interactive mode use
|
|
30
43
|
|
31
44
|
occi --interactive
|
32
45
|
occi --interactive --endpoint https://<ENDPOINT>:<PORT>/
|
46
|
+
occi --interactive --endpoint https://<ENDPOINT>:<PORT>/ --auth x509
|
33
47
|
|
34
48
|
To list available resources use
|
35
49
|
|
@@ -93,6 +107,12 @@ For X.509 auth use
|
|
93
107
|
auth.user_cert_password = 'MyPassword'
|
94
108
|
auth.ca_path = '/Path/To/root-certificates'
|
95
109
|
|
110
|
+
For keystone auth use
|
111
|
+
|
112
|
+
auth = Hashie::Mash.new
|
113
|
+
auth.type = 'keystone'
|
114
|
+
auth.token = '887665443383838'
|
115
|
+
|
96
116
|
#### DSL
|
97
117
|
In your scripts, you can use the OCCI client DSL.
|
98
118
|
|
@@ -104,10 +124,12 @@ To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
|
|
104
124
|
|
105
125
|
connect(:http, 'http://localhost:3300',auth||=nil)
|
106
126
|
|
107
|
-
To get the list of available resource
|
127
|
+
To get the list of available resource, mixin, entity or link types use
|
108
128
|
|
109
129
|
resource_types
|
110
130
|
mixin_types
|
131
|
+
entity_types
|
132
|
+
link_types
|
111
133
|
|
112
134
|
To get compute, storage or network descriptions use
|
113
135
|
|
@@ -174,10 +196,12 @@ All available categories are automatically registered to the OCCI model during c
|
|
174
196
|
|
175
197
|
client.model
|
176
198
|
|
177
|
-
To get the list of available resource
|
199
|
+
To get the list of available resource, mixin, entity or link types use
|
178
200
|
|
179
201
|
client.get_resource_types
|
180
202
|
client.get_mixin_types
|
203
|
+
client.get_entity_types
|
204
|
+
client.get_link_types
|
181
205
|
|
182
206
|
To get compute, storage or network descriptions use
|
183
207
|
|
@@ -303,7 +327,19 @@ The OCCI gem includes all OCCI Core classes necessary to handly arbitrary OCCI o
|
|
303
327
|
Changelog
|
304
328
|
---------
|
305
329
|
|
306
|
-
###
|
330
|
+
### Version 3.0
|
331
|
+
|
332
|
+
* many bugfixes
|
333
|
+
* rewrote Core classes to use metaprogramming techniques
|
334
|
+
* added VCR cassettes for reliable testing against prerecorded server responses
|
335
|
+
* several updates to the OCCI Client
|
336
|
+
* started work on an OCCI Client using AMQP as transport protocol
|
337
|
+
* added support for keystone authentication to be used with the OpenStack OCCI server
|
338
|
+
* updated dependencies
|
339
|
+
* updated rspec tests
|
340
|
+
* started work on cucumber features
|
341
|
+
|
342
|
+
### Version 2.5
|
307
343
|
|
308
344
|
* improved OCCI Client
|
309
345
|
* improved documentation
|
data/bin/occi
CHANGED
@@ -41,37 +41,38 @@ output = Occi::Bin::ResourceOutputFactory.new options.output_format
|
|
41
41
|
Occi::Log.info "Starting OCCI client ..."
|
42
42
|
Occi::Log.debug "Options: #{options}"
|
43
43
|
|
44
|
+
# TODO: this part isn't necessary, just annoying
|
44
45
|
# to make the interactive mode completely self-sufficient
|
45
46
|
# ask for endpoint and auth method (provide defaults)
|
46
|
-
if options.interactive
|
47
|
-
Occi::Log.debug "Checking for endpoint and auth changes ..."
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
47
|
+
#if options.interactive
|
48
|
+
# Occi::Log.debug "Checking for endpoint and auth changes ..."
|
49
|
+
#
|
50
|
+
# options.endpoint = ask("What endpoint should I use? ") {
|
51
|
+
# |q| q.default = options.endpoint
|
52
|
+
# }
|
53
|
+
#
|
54
|
+
# # separate menus
|
55
|
+
# say "\n"
|
56
|
+
#
|
57
|
+
# choose do |menu|
|
58
|
+
# menu.prompt = "Which auth method should I use? "
|
59
|
+
#
|
60
|
+
# Occi::Bin::OcciOpts::AUTH_METHODS.each do |auth_m|
|
61
|
+
# menu.choice(auth_m) { options.auth[:type] = auth_m.to_s }
|
62
|
+
# end
|
63
|
+
# end
|
64
|
+
#end
|
64
65
|
|
65
66
|
# running with an empty password, we should ask the user for one
|
66
67
|
# if auth method is not "none"
|
67
|
-
if options.auth[:password].nil?
|
68
|
+
if options.auth[:password].nil? || options.auth[:user_cert_password].nil? || options.auth[:token].nil?
|
68
69
|
Occi::Log.debug "Password or token is not set, asking for it now ..."
|
69
70
|
|
70
71
|
say("\n")
|
71
72
|
|
72
73
|
options.auth[:user_cert_password] = ask("Enter a password or an auth. token: ") {
|
73
|
-
|
74
|
-
} unless options.auth[:type] == "none"
|
74
|
+
|q| q.echo = false
|
75
|
+
} unless options.auth[:type] == "none" || (options.auth[:proxy_ca] && options.auth[:type] == "x509")
|
75
76
|
|
76
77
|
options.auth[:token] = options.auth[:password] = options.auth[:user_cert_password]
|
77
78
|
end
|
@@ -102,7 +103,7 @@ rescue OpenSSL::PKey::RSAError => key_ex
|
|
102
103
|
rescue Errno::ECONNREFUSED
|
103
104
|
# the remote server has refused our connection attempt(s)
|
104
105
|
# there is nothing we can do ...
|
105
|
-
Occi::Log.error "Connection refused!"
|
106
|
+
Occi::Log.error "Connection refused by #{options.endpoint}!"
|
106
107
|
exit!
|
107
108
|
rescue Exception => ex
|
108
109
|
# something went wrong during the execution
|
@@ -121,12 +122,14 @@ if options.dump_model
|
|
121
122
|
exit!
|
122
123
|
end
|
123
124
|
|
125
|
+
collection = model.get options.filter
|
126
|
+
|
124
127
|
# iterate through available instance variables
|
125
|
-
|
128
|
+
collection.instance_variables.each do |inst_var_sym|
|
126
129
|
puts "#"*79
|
127
130
|
puts "Dumping #{inst_var_sym.to_s}:"
|
128
131
|
|
129
|
-
inst_var =
|
132
|
+
inst_var = collection.instance_variable_get(inst_var_sym)
|
130
133
|
next unless inst_var.respond_to? :each
|
131
134
|
|
132
135
|
# iterate through collection elements
|
@@ -195,7 +198,7 @@ begin
|
|
195
198
|
}
|
196
199
|
|
197
200
|
# describe action requires a resource type or a resource location
|
198
|
-
menu.choice(:describe) {
|
201
|
+
menu.choice(:describe) {
|
199
202
|
options.action = :describe
|
200
203
|
|
201
204
|
# separate menus from each other
|
@@ -260,7 +263,7 @@ begin
|
|
260
263
|
if options.action == :create
|
261
264
|
options.resource_title = ask("What name should I give to the new resource? ")
|
262
265
|
number_of_mixins = ask("How many mixins do you wish me to mix into this resource? ",
|
263
|
-
|
266
|
+
Integer) { |q| q.in = 0..2 }
|
264
267
|
|
265
268
|
options.mixin = {}
|
266
269
|
(1..number_of_mixins).each do |mixin_number|
|
@@ -336,59 +339,59 @@ begin
|
|
336
339
|
|
337
340
|
# call the appropriate helper and then format its output
|
338
341
|
case options.action
|
339
|
-
|
340
|
-
|
342
|
+
when :list
|
343
|
+
found = helper_list options
|
341
344
|
|
342
|
-
|
343
|
-
|
345
|
+
valid = Occi::Bin::ResourceOutputFactory.allowed_resource_types.include? options.resource.to_sym
|
346
|
+
Occi::Log.error "Not printing, the resource type is not supported!" unless valid
|
344
347
|
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
+
puts output.format(found, :locations, options.resource.to_sym) if valid
|
349
|
+
when :describe
|
350
|
+
found = helper_describe options
|
348
351
|
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
352
|
+
if options.resource.start_with? options.endpoint
|
353
|
+
resource_type = options.resource.split("/")[3].to_sym
|
354
|
+
elsif mixin_types.include? options.resource.split('#').first
|
355
|
+
resource_type = options.resource.split('#').first.to_sym
|
356
|
+
else
|
357
|
+
resource_type = options.resource.to_sym
|
358
|
+
end
|
359
|
+
|
360
|
+
valid = Occi::Bin::ResourceOutputFactory.allowed_resource_types.include? resource_type
|
361
|
+
Occi::Log.error "Not printing, the resource type is not supported!" unless valid
|
362
|
+
|
363
|
+
puts output.format(found, :resources, resource_type) if valid
|
364
|
+
when :create
|
365
|
+
location = helper_create options
|
366
|
+
puts location
|
367
|
+
when :delete
|
368
|
+
result = helper_delete options
|
356
369
|
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
puts "Resource #{options.resource} successfully removed!"
|
370
|
+
if result
|
371
|
+
puts "Resource #{options.resource} successfully removed!"
|
372
|
+
else
|
373
|
+
puts "Failed to remove resource #{options.resource}!"
|
374
|
+
end
|
375
|
+
when :trigger
|
376
|
+
helper_trigger options
|
377
|
+
when :refresh
|
378
|
+
refresh
|
379
|
+
when :skip
|
380
|
+
Occi::Log.info "Skipping this action, probably not implemented yet!"
|
369
381
|
else
|
370
|
-
|
371
|
-
end
|
372
|
-
when :trigger
|
373
|
-
helper_trigger options
|
374
|
-
when :refresh
|
375
|
-
refresh
|
376
|
-
when :skip
|
377
|
-
Occi::Log.info "Skipping this action, probably not implemented yet!"
|
378
|
-
else
|
379
|
-
raise "Unknown action [#{options.action}]!"
|
382
|
+
raise "Unknown action [#{options.action}]!"
|
380
383
|
end
|
381
384
|
|
382
385
|
rescue Errno::ECONNREFUSED
|
383
386
|
# remote server refused our connection attempt(s)
|
384
387
|
# even though initial connect was successful
|
385
|
-
Occi::Log.error "Connection refused!"
|
388
|
+
Occi::Log.error "Connection refused by #{options.endpoint}!"
|
386
389
|
exit!
|
387
390
|
rescue Exception => ex
|
388
391
|
# something went wrong during the execution
|
389
392
|
# hide the stack trace in non-debug modes
|
390
393
|
Occi::Log.error "An error occurred! Message: #{ex.message}"
|
391
|
-
|
394
|
+
|
392
395
|
raise ex if options.debug
|
393
396
|
exit!
|
394
397
|
end while options.interactive
|