Class: Bosh::Blobstore::SwiftBlobstoreClient

Inherits:
BaseClient show all
Defined in:
lib/blobstore_client/swift_blobstore_client.rb

Constant Summary

Constants inherited from Client

Client::PROVIDER_NAMES, Client::VERSION

Instance Method Summary collapse

Methods inherited from BaseClient

#create, #delete, #exists?, #get

Methods inherited from Client

create, safe_create

Constructor Details

#initialize(options) ⇒ SwiftBlobstoreClient

Blobstore client for OpenStack Swift

Parameters:

  • options (Hash)

    Swift BlobStore options

Options Hash (options):

  • container_name (Symbol)
  • swift_provider (Symbol)


18
19
20
21
# File 'lib/blobstore_client/swift_blobstore_client.rb', line 18

def initialize(options)
  super(options)
  @http_client = HTTPClient.new
end

Instance Method Details

#containerObject

Raises:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/blobstore_client/swift_blobstore_client.rb', line 23

def container
  return @container if @container

  validate_options(@options)

  swift_provider = @options[:swift_provider]
  swift_options = { provider: swift_provider }
  swift_options.merge!(@options[swift_provider.to_sym])

  if swift_options.has_key?(:openstack_auth_url)
    unless swift_options[:openstack_auth_url].match(/\/tokens$/)
      swift_options[:openstack_auth_url] = swift_options[:openstack_auth_url] + '/tokens'
    end
  end

  swift = Fog::Storage.new(swift_options)

  container_name = @options[:container_name]
  @container = swift.directories.get(container_name)
  raise NotFound, "Swift container '#{container_name}' not found" if @container.nil?

  @container
end