occi-api 4.2.0.beta.14 → 4.2.0.beta.15

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8a7610d847f41dcce7d386c39adab48066bac4ae
4
- data.tar.gz: 503e8cb17de12da525ab24be836295a05992780f
3
+ metadata.gz: 1fd9d35cc6faff4bdad01821af58fce357fafa38
4
+ data.tar.gz: f68dc05a6b11820607275059fc4bc7435be03c4a
5
5
  SHA512:
6
- metadata.gz: 0197ee150d6c92cea361c2d913848a5c4def90375e3c3efc64a2f747cdad73fe523bcaf84eb17449e9859894a026aea98fdd1d566240d6499a86c44ad9787dd2
7
- data.tar.gz: ec1ac07e7ed42c66b5b70bfe8da18632c0c72f609e3cdfde0addd214732b1541137a3ef65df0870cce8cbd540b81c898fef66d680a7482ce5be253ec3a43549b
6
+ metadata.gz: 995087000d3f6802fbce5d2ab8bfc0525d5e7d0ee0ad4be24db7af897e28d82d9faabbf17443d5e626dc7944cdd86803f50dc3915f5805bee4cd2f6563b8af03
7
+ data.tar.gz: 1466c82b129a9cf4c9bf70b30dbb914040f2c43ee8b74103c57d450d0acd9e5d2d9c4b61f6e555d1420d1e1147914e61e7d032a00dcf1687c16d06a3c0fa7b78
data/README.md CHANGED
@@ -132,7 +132,7 @@ To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
132
132
  options = {
133
133
  :endpoint => "http://localhost:3300/",
134
134
  :auth => {:type => "none"},
135
- :log => {:out => STDERR, :level => Occi::Log::WARN, :logger => nil},
135
+ :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil},
136
136
  :auto_connect => "value", auto_connect => true,
137
137
  :media_type => nil
138
138
  }
@@ -209,7 +209,7 @@ To connect to an OCCI endpoint/server (e.g. running on http://localhost:3300/ )
209
209
  options = {
210
210
  :endpoint => "http://localhost:3300/",
211
211
  :auth => {:type => "none"},
212
- :log => {:out => STDERR, :level => Occi::Log::WARN, :logger => nil},
212
+ :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil},
213
213
  :auto_connect => "value", auto_connect => true,
214
214
  :media_type => nil
215
215
  }
@@ -286,14 +286,14 @@ The OCCI gem includes its own logging mechanism using a message queue. By defaul
286
286
  A new OCCI Logger can be initialized by specifying the log destination (either a filename or an IO object like
287
287
  STDOUT) and the log level.
288
288
 
289
- logger = Occi::Log.new STDOUT
290
- logger.level = Occi::Log::INFO
289
+ logger = Occi::Api::Log.new STDOUT
290
+ logger.level = Occi::Api::Log::INFO
291
291
 
292
292
  You can create multiple Loggers to receive the log output.
293
293
 
294
- You can always, even if there is no logger defined, log output using the class methods of OCCI::Log e.g.
294
+ You can always, even if there is no logger defined, log output using the class methods of OCCI::Api::Log e.g.
295
295
 
296
- Occi::Log.info("Test message")
296
+ Occi::Api::Log.info("Test message")
297
297
 
298
298
  Changelog
299
299
  ---------
@@ -29,7 +29,7 @@ connect(
29
29
  },
30
30
  :log => {
31
31
  :out => STDERR,
32
- :level => Occi::Log::DEBUG
32
+ :level => Occi::Api::Log::DEBUG
33
33
  }
34
34
  }
35
35
  )
@@ -24,7 +24,7 @@ client = Occi::Api::Client::ClientHttp.new({
24
24
  },
25
25
  :log => {
26
26
  :out => STDERR,
27
- :level => Occi::Log::DEBUG
27
+ :level => Occi::Api::Log::DEBUG
28
28
  }
29
29
  })
30
30
 
data/lib/occi-api.rb CHANGED
@@ -9,6 +9,7 @@ module Occi::Api::Dsl; end
9
9
  module Occi::Api::Client::Errors; end
10
10
 
11
11
  require 'occi/api/version'
12
+ require 'occi/api/log'
12
13
  require 'occi/api/client/authn_utils'
13
14
  require 'occi/api/client/errors'
14
15
  require 'occi/api/client/client_base'
@@ -15,7 +15,7 @@ module Occi::Api::Client
15
15
  # @param resource_type [String] resource name or resource identifier
16
16
  # @return [Occi::Core::Resource] new resource instance
17
17
  def get_resource(resource_type)
18
- Occi::Log.debug("Instantiating #{resource_type.inspect}")
18
+ Occi::Api::Log.debug("Instantiating #{resource_type.inspect}")
19
19
 
20
20
  type_id = get_resource_type_identifier(resource_type)
21
21
  raise "Unknown resource type! #{resource_type.inspect}" unless type_id
@@ -14,7 +14,7 @@ module Occi::Api::Client
14
14
  # @return [Array<String>] list of available kind type identifiers related to
15
15
  # the given type identifier
16
16
  def get_kind_type_identifiers_related_to(type_identifier)
17
- Occi::Log.debug("Getting kind type identifiers related to #{type_identifier.inspect}")
17
+ Occi::Api::Log.debug("Getting kind type identifiers related to #{type_identifier.inspect}")
18
18
  collection = @model.get(type_identifier)
19
19
  collection.kinds.to_a.collect { |kind| kind.type_identifier }
20
20
  end
@@ -21,7 +21,7 @@ module Occi::Api::Client
21
21
  # @return [String, Occi::Core::Mixin, nil] link, mixin description or nothing found
22
22
  def get_mixin(name, type = nil, describe = false)
23
23
  # TODO: mixin fix
24
- Occi::Log.debug "Looking for mixin #{name.inspect} #{type.inspect} " \
24
+ Occi::Api::Log.debug "Looking for mixin #{name.inspect} #{type.inspect} " \
25
25
  "#{describe.inspect}"
26
26
 
27
27
  # TODO: extend this code to support multiple matches and regex filters
@@ -7,13 +7,13 @@ module Occi::Api::Client
7
7
  # instances to the rOCCI client.
8
8
  #
9
9
  # @example
10
- # get_logger { :out => STDERR, :level => Occi::Log::WARN, :logger => nil }
10
+ # get_logger { :out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil }
11
11
  #
12
12
  # @param log_options [Hash] logger options
13
- # @return [Occi::Log] instance of the logger
13
+ # @return [Occi::Api::Log] instance of the logger
14
14
  def get_logger(log_options)
15
- unless log_options[:logger].kind_of?(Occi::Log)
16
- logger = Occi::Log.new(log_options[:out])
15
+ unless log_options[:logger].kind_of?(Occi::Api::Log)
16
+ logger = Occi::Api::Log.new(log_options[:out])
17
17
  logger.level = log_options[:level]
18
18
  else
19
19
  logger = log_options[:logger]
@@ -15,7 +15,7 @@ module Occi::Api::Client
15
15
  defaults = Hashie::Mash.new({
16
16
  :endpoint => "http://localhost:3000/",
17
17
  :auth => {:type => "none"},
18
- :log => {:out => STDERR, :level => Occi::Log::WARN, :logger => nil},
18
+ :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil},
19
19
  :auto_connect => true,
20
20
  :media_type => nil
21
21
  })
@@ -25,7 +25,7 @@ module Occi::Api::Client
25
25
 
26
26
  @options = defaults.merge(options)
27
27
 
28
- # set Occi::Log
28
+ # set Occi::Api::Log
29
29
  @logger = get_logger(@options[:log])
30
30
 
31
31
  # check the validity and canonize the endpoint URI
@@ -28,7 +28,7 @@ module Occi::Api::Client
28
28
  # :endpoint => "http://localhost:3000/",
29
29
  # :timeout => 15
30
30
  # :auth => {:type => "none"},
31
- # :log => {:out => STDERR, :level => Occi::Log::WARN, :logger => nil},
31
+ # :log => {:out => STDERR, :level => Occi::Api::Log::WARN, :logger => nil},
32
32
  # :auto_connect => true,
33
33
  # :media_type => nil
34
34
  # }
@@ -110,7 +110,7 @@ module Occi::Api::Client
110
110
  def create(entity)
111
111
  raise "#{entity.class.name.inspect} not an entity!" unless entity.kind_of? Occi::Core::Entity
112
112
 
113
- Occi::Log.debug "Entity kind: #{entity.kind.type_identifier.inspect}"
113
+ Occi::Api::Log.debug "Entity kind: #{entity.kind.type_identifier.inspect}"
114
114
  raise "No kind found for #{entity.inspect}" unless entity.kind
115
115
 
116
116
  # get location for this kind of entity
@@ -118,7 +118,7 @@ module Occi::Api::Client
118
118
  collection = Occi::Collection.new
119
119
 
120
120
  # is this entity a Resource or a Link?
121
- Occi::Log.debug "Entity class: #{entity.class.name.inspect}"
121
+ Occi::Api::Log.debug "Entity class: #{entity.class.name.inspect}"
122
122
  collection.resources << entity if entity.kind_of? Occi::Core::Resource
123
123
  collection.links << entity if entity.kind_of? Occi::Core::Link
124
124
 
@@ -178,7 +178,7 @@ module Occi::Api::Client
178
178
  raise 'Resource not provided!' if resource_type_identifier.blank?
179
179
  path = path_for_kind_type_identifier(resource_type_identifier)
180
180
 
181
- Occi::Log.debug("Deleting #{path.inspect} for #{resource_type_identifier.inspect}")
181
+ Occi::Api::Log.debug("Deleting #{path.inspect} for #{resource_type_identifier.inspect}")
182
182
  del path
183
183
  end
184
184
 
@@ -27,7 +27,7 @@ module Occi::Api::Client
27
27
 
28
28
  def set_keystone_base_url
29
29
  response = @env_ref.class.head "#{@env_ref.endpoint.to_s}/-/"
30
- Occi::Log.debug response.inspect
30
+ Occi::Api::Log.debug response.inspect
31
31
 
32
32
  return if response.success?
33
33
  raise ::Occi::Api::Client::Errors::AuthnError,
@@ -61,7 +61,7 @@ module Occi::Api::Client
61
61
  :body => get_keystone_req(tenant),
62
62
  :headers => headers
63
63
  )
64
- Occi::Log.debug response.inspect
64
+ Occi::Api::Log.debug response.inspect
65
65
 
66
66
  if response.success?
67
67
  @env_ref.class.headers['X-Auth-Token'] = response['access']['token']['id']
@@ -101,7 +101,7 @@ module Occi::Api::Client
101
101
  "#{@keystone_url}/v2.0/tenants",
102
102
  :headers => headers
103
103
  )
104
- Occi::Log.debug response.inspect
104
+ Occi::Api::Log.debug response.inspect
105
105
 
106
106
  # TODO: impl match with regexp in case of multiple tenants?
107
107
  raise ::Occi::Api::Client::Errors::AuthnError,
@@ -6,7 +6,7 @@ module Occi::Api::Client
6
6
  # @see Occi::Api::Client::ClientBase
7
7
  def get_logger(log_options)
8
8
  logger = super(log_options)
9
- self.class.debug_output $stderr if logger.level == Occi::Log::DEBUG
9
+ self.class.debug_output $stderr if logger.level == Occi::Api::Log::DEBUG
10
10
 
11
11
  logger
12
12
  end
@@ -40,7 +40,7 @@ module Occi::Api::Client
40
40
  begin
41
41
  @authn_plugin.authenticate
42
42
  rescue ::Occi::Api::Client::Errors::AuthnError => e
43
- Occi::Log.debug e.message
43
+ Occi::Api::Log.debug e.message
44
44
 
45
45
  if @authn_plugin.fallbacks.any?
46
46
  # TODO: multiple fallbacks
@@ -64,7 +64,7 @@ module Occi::Api::Client
64
64
  else
65
65
  media_types = self.class.head(@endpoint.to_s).headers['accept']
66
66
 
67
- Occi::Log.debug("Available media types: #{media_types.inspect}")
67
+ Occi::Api::Log.debug("Available media types: #{media_types.inspect}")
68
68
  media_type = case media_types
69
69
  when /application\/occi\+json/
70
70
  'application/occi+json'
@@ -104,24 +104,24 @@ module Occi::Api::Client
104
104
  private
105
105
 
106
106
  def get_process_response(path, response)
107
- Occi::Log.debug "Response from location: #{path.inspect}"
107
+ Occi::Api::Log.debug "Response from location: #{path.inspect}"
108
108
  kind = @model.get_by_location(path) if @model
109
109
 
110
- Occi::Log.debug "Response should contain kind: #{kind.inspect}"
110
+ Occi::Api::Log.debug "Response should contain kind: #{kind.inspect}"
111
111
  entity_type = nil
112
112
  if kind && kind.related_to?(Occi::Core::Link)
113
113
  entity_type = Occi::Core::Link
114
114
  end
115
115
  entity_type = Occi::Core::Resource unless entity_type
116
116
 
117
- Occi::Log.debug "Parser call: #{response.content_type.inspect} #{path.include?('/-/')} " \
117
+ Occi::Api::Log.debug "Parser call: #{response.content_type.inspect} #{path.include?('/-/')} " \
118
118
  "#{entity_type} #{response.headers.inspect}"
119
119
  collection = Occi::Parser.parse(
120
120
  response.content_type, response.body,
121
121
  path.include?('/-/'), entity_type, response.headers
122
122
  )
123
123
 
124
- Occi::Log.debug "Parsed collection: empty? #{collection.empty?}"
124
+ Occi::Api::Log.debug "Parsed collection: empty? #{collection.empty?}"
125
125
  collection
126
126
  end
127
127
 
@@ -0,0 +1,27 @@
1
+ require 'logger'
2
+
3
+ module Occi::Api
4
+ class Log < ::Occi::Log
5
+
6
+ SUBSCRIPTION_HANDLE = "rOCCI-api.log"
7
+
8
+ attr_reader :core_log
9
+
10
+ def initialize(log_dev, log_prefix = '[rOCCI-api]')
11
+ @core_log = ::Occi::Log.new(log_dev)
12
+ super
13
+ end
14
+
15
+ def close
16
+ super
17
+ @core_log.close
18
+ end
19
+
20
+ # @param severity [::Logger::Severity] severity
21
+ def level=(severity)
22
+ @core_log.level = severity
23
+ super
24
+ end
25
+
26
+ end
27
+ end
@@ -1,5 +1,5 @@
1
1
  module Occi
2
2
  module Api
3
- VERSION = "4.2.0.beta.14" unless defined?(::Occi::Api::VERSION)
3
+ VERSION = "4.2.0.beta.15" unless defined?(::Occi::Api::VERSION)
4
4
  end
5
5
  end
data/occi-api.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.test_files = `git ls-files -- {test,spec}/*`.split("\n")
19
19
  gem.require_paths = ["lib"]
20
20
 
21
- gem.add_dependency 'occi-core', '~> 4.2.7'
21
+ gem.add_dependency 'occi-core', '~> 4.2.9'
22
22
  gem.add_dependency 'httparty'
23
23
  gem.add_dependency 'json'
24
24
 
@@ -14,7 +14,7 @@ module Occi
14
14
  :endpoint => 'https://localhost:3300',
15
15
  :auth => { :type => "none" },
16
16
  :log => { :out => "/dev/null",
17
- :level => Occi::Log::DEBUG },
17
+ :level => Occi::Api::Log::DEBUG },
18
18
  :auto_connect => true,
19
19
  :media_type => "text/plain,text/occi"
20
20
  })
@@ -293,7 +293,7 @@ module Occi
293
293
  # :endpoint => 'https://localhost:3300',
294
294
  # :auth => { :type => "none" },
295
295
  # :log => { :out => "/dev/null",
296
- # :level => Occi::Log::DEBUG },
296
+ # :level => Occi::Api::Log::DEBUG },
297
297
  # :auto_connect => true,
298
298
  # :media_type => "application/occi+json"
299
299
  #})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: occi-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.2.0.beta.14
4
+ version: 4.2.0.beta.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Feldhaus
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-02-05 00:00:00.000000000 Z
13
+ date: 2014-02-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: occi-core
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 4.2.7
21
+ version: 4.2.9
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - ~>
27
27
  - !ruby/object:Gem::Version
28
- version: 4.2.7
28
+ version: 4.2.9
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: httparty
31
31
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - lib/occi/api/dsl/main_methods.rb
113
113
  - lib/occi/api/dsl/mixin_methods.rb
114
114
  - lib/occi/api/dsl/type_methods.rb
115
+ - lib/occi/api/log.rb
115
116
  - lib/occi/api/version.rb
116
117
  - occi-api.gemspec
117
118
  - spec/cassettes/Occi_Api_Client_ClientHttp/using_media_type_text_plain/describes_compute_resources.yml