occi 3.0.0.beta.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. data/Gemfile +3 -26
  2. data/Gemfile.lock +43 -35
  3. data/README.md +40 -4
  4. data/bin/occi +67 -64
  5. data/ext/mkrf_conf.rb +25 -0
  6. data/features/cassettes/Create_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
  7. data/features/cassettes/Delete_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
  8. 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
  9. 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
  10. 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
  11. data/features/cassettes/Miscellaneous_operation_on_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
  12. data/features/cassettes/Read_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
  13. data/features/cassettes/Update_an_OCCI_Resource/_http_http___141_5_99_69__text_plain_201_.yml +186 -0
  14. data/features/occi/core/create/create.feature +3 -2
  15. data/features/occi/core/delete/delete.feature +6 -2
  16. data/features/occi/core/discovery_interface/discovery_interface.feature +4 -2
  17. data/features/occi/core/miscellaneous/miscellaneous.feature +6 -2
  18. data/features/occi/core/read/read.feature +6 -2
  19. data/features/occi/core/update/update.feature +6 -2
  20. data/features/occi/infrastructure/create/create.feature +6 -2
  21. data/features/support/env.rb +13 -1
  22. data/lib/occi/api/client/client_http.rb +914 -820
  23. data/lib/occi/api/client/http/net_http_fix.rb +7 -36
  24. data/lib/occi/api/dsl.rb +32 -2
  25. data/lib/occi/bin/occi_opts.rb +15 -1
  26. data/lib/occi/collection.rb +26 -15
  27. data/lib/occi/core/categories.rb +9 -1
  28. data/lib/occi/core/category.rb +20 -11
  29. data/lib/occi/core/link.rb +4 -5
  30. data/lib/occi/model.rb +2 -2
  31. data/lib/occi/parser.rb +51 -49
  32. data/lib/occi/version.rb +1 -1
  33. data/occi.gemspec +16 -3
  34. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_compute_resource.yml +222 -0
  35. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_network_resource.yml +222 -0
  36. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/creates_a_new_storage_resource.yml +222 -0
  37. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_compute_resource.yml +222 -0
  38. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_network_resource.yml +222 -0
  39. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deletes_a_storage_resource.yml +222 -0
  40. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/deploys_an_instance_based_on_OVF_OVA_file.yml +222 -0
  41. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_all_available_mixins.yml +222 -0
  42. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_compute_resources.yml +324 -0
  43. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_network_resources.yml +326 -0
  44. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_os_tpl_mixins.yml +222 -0
  45. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_resource_tpl_mixins.yml +222 -0
  46. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_storage_resources.yml +386 -0
  47. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/establishes_connection.yml +222 -0
  48. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_identifier.yml +222 -0
  49. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_compute_resource_using_type_name.yml +222 -0
  50. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_identifier.yml +222 -0
  51. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_network_resource_using_type_name.yml +222 -0
  52. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_identifier.yml +222 -0
  53. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/instantiates_a_storage_resource_using_type_name.yml +222 -0
  54. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_type_identifiers.yml +222 -0
  55. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_entity_types.yml +222 -0
  56. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_type_identifiers.yml +222 -0
  57. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_link_types.yml +222 -0
  58. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_type_identifiers.yml +222 -0
  59. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixin_types.yml +222 -0
  60. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_mixins.yml +222 -0
  61. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_type_identifiers.yml +222 -0
  62. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_all_available_resource_types.yml +222 -0
  63. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_compute_resources.yml +264 -0
  64. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_network_resources.yml +264 -0
  65. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_os_tpl_mixins.yml +222 -0
  66. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_resource_tpl_mixins.yml +222 -0
  67. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/lists_storage_resources.yml +266 -0
  68. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/refreshes_its_model.yml +397 -0
  69. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_compute_resource.yml +222 -0
  70. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_network_resource.yml +222 -0
  71. data/spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/triggers_an_action_on_a_storage_resource.yml +222 -0
  72. data/spec/occi/api/client/client_amqp_spec.rb +10 -2
  73. data/spec/occi/api/client/client_http_spec.rb +111 -117
  74. data/spec/occi/api/dsl_spec.rb +22 -0
  75. data/spec/occi/collection_spec.rb +11 -2
  76. data/spec/occi/core/resource_spec.rb +1 -1
  77. data/spec/occi/infrastructure/compute_spec.rb +3 -3
  78. data/spec/occi/log_spec.rb +1 -1
  79. data/spec/occi/model_spec.rb +4 -8
  80. data/spec/occi/parser_spec.rb +4 -4
  81. data/spec/spec_helper.rb +3 -2
  82. metadata +264 -12
  83. data/spec/cassettes/client_http_text_plain.yml +0 -1066
  84. 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
- # external ruby libraries
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
- # development related gems
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
@@ -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.9)
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.5)
30
+ amq-client (0.9.10)
9
31
  amq-protocol (>= 0.9.4)
10
32
  eventmachine
11
- amq-protocol (0.9.5)
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.1)
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
- jruby-openssl (0.7.7)
39
- bouncy-castle-java (>= 1.5.0146.1)
40
- json (1.7.5)
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.5)
45
- nokogiri (1.5.5-java)
46
- rake (0.9.2.2)
47
- rspec (2.11.0)
48
- rspec-core (~> 2.11.0)
49
- rspec-expectations (~> 2.11.0)
50
- rspec-mocks (~> 2.11.0)
51
- rspec-core (2.11.1)
52
- rspec-expectations (2.11.3)
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.11.3)
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
- vcr (2.3.0)
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
- hashie
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
- uuidtools (>= 2.1.3)
97
- vcr
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) [![Dependency Status](https://gemnasium.com/gwdg/rOCCI.png)](https://gemnasium.com/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 types or mixin types use
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 types or mixin types use
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
- ### version 2.5
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
- options.endpoint = ask("What endpoint should I use? ") {
50
- |q| q.default = options.endpoint
51
- }
52
-
53
- # separate menus
54
- say "\n"
55
-
56
- choose do |menu|
57
- menu.prompt = "Which auth method should I use? "
58
-
59
- Occi::Bin::OcciOpts::AUTH_METHODS.each do |auth_m|
60
- menu.choice(auth_m) { options.auth[:type] = auth_m.to_s }
61
- end
62
- end
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? or options.auth[:user_cert_password].nil? or options.auth[:token].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
- |q| q.echo = false
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
- model.instance_variables.each do |inst_var_sym|
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 = model.instance_variable_get(inst_var_sym)
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
- Integer) { |q| q.in = 0..2 }
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
- when :list
340
- found = helper_list options
342
+ when :list
343
+ found = helper_list options
341
344
 
342
- valid = Occi::Bin::ResourceOutputFactory.allowed_resource_types.include? options.resource.to_sym
343
- Occi::Log.error "Not printing, the resource type is not supported!" unless valid
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
- puts output.format(found, :locations, options.resource.to_sym) if valid
346
- when :describe
347
- found = helper_describe options
348
+ puts output.format(found, :locations, options.resource.to_sym) if valid
349
+ when :describe
350
+ found = helper_describe options
348
351
 
349
- if options.resource.start_with? options.endpoint
350
- resource_type = options.resource.split("/")[3].to_sym
351
- elsif mixin_types.include? options.resource.split('#').first
352
- resource_type = options.resource.split('#').first.to_sym
353
- else
354
- resource_type = options.resource.to_sym
355
- end
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
- valid = Occi::Bin::ResourceOutputFactory.allowed_resource_types.include? resource_type
358
- Occi::Log.error "Not printing, the resource type is not supported!" unless valid
359
-
360
- puts output.format(found, :resources, resource_type) if valid
361
- when :create
362
- location = helper_create options
363
- puts location
364
- when :delete
365
- result = helper_delete options
366
-
367
- if result
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
- puts "Failed to remove resource #{options.resource}!"
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