blobstore_client 1.3112.0 → 1.3115.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.
- checksums.yaml +4 -4
- data/README.md +0 -50
- data/lib/blobstore_client.rb +0 -1
- data/lib/blobstore_client/client.rb +1 -1
- data/lib/blobstore_client/version.rb +1 -1
- metadata +4 -33
- data/lib/blobstore_client/swift_blobstore_client.rb +0 -153
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fe8c7a244450fab928073d12c1e3f3b59f445e7
|
4
|
+
data.tar.gz: 36f62486ca4cdf43bde43e150d76c5e1daa717a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a45399970f5fe1ee8eb9b50497b884721ae4af99075a21baa6d24c0a75903c6388d858ed7ddfdf88541e092786a9c120879462b658c208cd26b4f159fd35d0bb
|
7
|
+
data.tar.gz: 446510a5724436ef3efdd0bd1c7aee8ff10153c86f8380cef49da2b896362c9585a3aabe3ef346d7cb4c70b2b5fec82366ff6f9311babcb122db9e0c7f1aae95
|
data/README.md
CHANGED
@@ -68,53 +68,3 @@ These are the options for the Blobstore client when provider is `s3`:
|
|
68
68
|
S3 Access Key
|
69
69
|
* `secret_access_key` (optional, if not present and `credentials_source` is `static`, the blobstore client operates in read only mode)
|
70
70
|
S3 Secret Access Key
|
71
|
-
|
72
|
-
### OpenStack Swift provider
|
73
|
-
|
74
|
-
These are the options for the Blobstore client when provider is `swift`:
|
75
|
-
|
76
|
-
* `container_name` (required)
|
77
|
-
Name of the container
|
78
|
-
* `swift_provider` (required)
|
79
|
-
OpenStack Swift provider (supported: `hp`, `openstack` and `rackspace`)
|
80
|
-
|
81
|
-
#### HP Object Storage
|
82
|
-
|
83
|
-
These are the options for the Blobstore client when `swift_provider` is `hp`:
|
84
|
-
|
85
|
-
* `hp_access_key` (required)
|
86
|
-
HP Object Storage Access Key
|
87
|
-
* `hp_secret_key` (required)
|
88
|
-
HP Object Storage Secret Key
|
89
|
-
* `hp_tenant_id` (required)
|
90
|
-
HP Object Storage Project ID
|
91
|
-
* `hp_avl_zone` (required)
|
92
|
-
HP Object Storage Availability Zone (`region-a.geo-1` or `region-b.geo-1`)
|
93
|
-
|
94
|
-
#### OpenStack Object Storage
|
95
|
-
|
96
|
-
These are the options for the Blobstore client when `swift_provider` is `openstack`:
|
97
|
-
|
98
|
-
* `openstack_auth_url` (required)
|
99
|
-
URL of the OpenStack Identity endpoint to connect to
|
100
|
-
* `openstack_username` (required)
|
101
|
-
OpenStack user name
|
102
|
-
* `openstack_api_key` (required)
|
103
|
-
OpenStack API key
|
104
|
-
* `openstack_tenant` (required)
|
105
|
-
OpenStack tenant name
|
106
|
-
* `openstack_domain` (optional)
|
107
|
-
OpenStack domain
|
108
|
-
* `openstack_region` (optional)
|
109
|
-
OpenStack region
|
110
|
-
|
111
|
-
#### Rackspace Cloud Files
|
112
|
-
|
113
|
-
These are the options for the Blobstore client when `swift_provider` is `rackspace`:
|
114
|
-
|
115
|
-
* `rackspace_username` (required)
|
116
|
-
Rackspace Cloud Files Username
|
117
|
-
* `rackspace_api_key` (required)
|
118
|
-
Rackspace Cloud Files API Key
|
119
|
-
* `rackspace_region` (optional)
|
120
|
-
Rackspace Cloud Files Region (`dfw` or `ord`)
|
data/lib/blobstore_client.rb
CHANGED
@@ -9,6 +9,5 @@ require 'blobstore_client/sha1_verifiable_blobstore_client'
|
|
9
9
|
|
10
10
|
Bosh::Blobstore.autoload(:S3BlobstoreClient, 'blobstore_client/s3_blobstore_client')
|
11
11
|
Bosh::Blobstore.autoload(:SimpleBlobstoreClient, 'blobstore_client/simple_blobstore_client')
|
12
|
-
Bosh::Blobstore.autoload(:SwiftBlobstoreClient, 'blobstore_client/swift_blobstore_client')
|
13
12
|
Bosh::Blobstore.autoload(:LocalClient, 'blobstore_client/local_client')
|
14
13
|
Bosh::Blobstore.autoload(:DavBlobstoreClient, 'blobstore_client/dav_blobstore_client')
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blobstore_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3115.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VMware
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -24,34 +24,6 @@ dependencies:
|
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.60.2
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: fog
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: 1.34.0
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: 1.34.0
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: fog-aws
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.7.6
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.7.6
|
55
27
|
- !ruby/object:Gem::Dependency
|
56
28
|
name: httpclient
|
57
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +58,14 @@ dependencies:
|
|
86
58
|
requirements:
|
87
59
|
- - "~>"
|
88
60
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.
|
61
|
+
version: 1.3115.0
|
90
62
|
type: :runtime
|
91
63
|
prerelease: false
|
92
64
|
version_requirements: !ruby/object:Gem::Requirement
|
93
65
|
requirements:
|
94
66
|
- - "~>"
|
95
67
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.
|
68
|
+
version: 1.3115.0
|
97
69
|
- !ruby/object:Gem::Dependency
|
98
70
|
name: rspec
|
99
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +157,6 @@ files:
|
|
185
157
|
- lib/blobstore_client/s3_blobstore_client.rb
|
186
158
|
- lib/blobstore_client/sha1_verifiable_blobstore_client.rb
|
187
159
|
- lib/blobstore_client/simple_blobstore_client.rb
|
188
|
-
- lib/blobstore_client/swift_blobstore_client.rb
|
189
160
|
- lib/blobstore_client/version.rb
|
190
161
|
homepage: https://github.com/cloudfoundry/bosh
|
191
162
|
licenses:
|
@@ -1,153 +0,0 @@
|
|
1
|
-
# Copyright (c) 2009-2012 VMware, Inc.
|
2
|
-
|
3
|
-
require 'base64'
|
4
|
-
require 'fog'
|
5
|
-
require 'multi_json'
|
6
|
-
require 'uri'
|
7
|
-
require 'httpclient'
|
8
|
-
|
9
|
-
module Bosh
|
10
|
-
module Blobstore
|
11
|
-
|
12
|
-
class SwiftBlobstoreClient < BaseClient
|
13
|
-
|
14
|
-
# Blobstore client for OpenStack Swift
|
15
|
-
# @param [Hash] options Swift BlobStore options
|
16
|
-
# @option options [Symbol] container_name
|
17
|
-
# @option options [Symbol] swift_provider
|
18
|
-
def initialize(options)
|
19
|
-
super(options)
|
20
|
-
@http_client = HTTPClient.new
|
21
|
-
end
|
22
|
-
|
23
|
-
def container
|
24
|
-
return @container if @container
|
25
|
-
|
26
|
-
validate_options(@options)
|
27
|
-
|
28
|
-
swift_provider = @options[:swift_provider]
|
29
|
-
swift_options = { provider: swift_provider }
|
30
|
-
swift_options.merge!(@options[swift_provider.to_sym])
|
31
|
-
|
32
|
-
if swift_options.has_key?(:openstack_auth_url)
|
33
|
-
unless swift_options[:openstack_auth_url].match(/\/tokens$/)
|
34
|
-
swift_options[:openstack_auth_url] = swift_options[:openstack_auth_url] + '/tokens'
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
swift = Fog::Storage.new(swift_options)
|
39
|
-
|
40
|
-
container_name = @options[:container_name]
|
41
|
-
@container = swift.directories.get(container_name)
|
42
|
-
raise NotFound, "Swift container '#{container_name}' not found" if @container.nil?
|
43
|
-
|
44
|
-
@container
|
45
|
-
end
|
46
|
-
|
47
|
-
protected
|
48
|
-
|
49
|
-
def create_file(object_id, file)
|
50
|
-
object_id ||= generate_object_id
|
51
|
-
object = container.files.create(key: object_id, body: file)
|
52
|
-
begin
|
53
|
-
public_url = object.public_url
|
54
|
-
rescue NotImplementedError
|
55
|
-
public_url = nil
|
56
|
-
end
|
57
|
-
encode_object_id(object_id, public_url)
|
58
|
-
rescue Exception => e
|
59
|
-
raise BlobstoreError, "Failed to create object: #{e.message}"
|
60
|
-
end
|
61
|
-
|
62
|
-
def get_file(object_id, file)
|
63
|
-
object_info = decode_object_id(object_id)
|
64
|
-
if object_info['purl']
|
65
|
-
response = @http_client.get(object_info['purl']) do |block|
|
66
|
-
file.write(block)
|
67
|
-
end
|
68
|
-
if response.status != 200
|
69
|
-
raise BlobstoreError, "Could not fetch object, #{response.status} #{response.content}"
|
70
|
-
end
|
71
|
-
else
|
72
|
-
object = container.files.get(object_info['oid']) do |block|
|
73
|
-
file.write(block)
|
74
|
-
end
|
75
|
-
raise NotFound, "Swift object '#{object_info['oid']}' not found" if object.nil?
|
76
|
-
end
|
77
|
-
rescue Exception => e
|
78
|
-
raise BlobstoreError, "Failed to find object '#{object_id}': #{e.message}"
|
79
|
-
end
|
80
|
-
|
81
|
-
def delete_object(object_id)
|
82
|
-
object_info = decode_object_id(object_id)
|
83
|
-
object = container.files.get(object_info['oid'])
|
84
|
-
|
85
|
-
raise NotFound, "Swift object '#{object_id}' not found" if object.nil?
|
86
|
-
|
87
|
-
object.destroy
|
88
|
-
rescue NotFound => e
|
89
|
-
raise e
|
90
|
-
rescue Exception => e
|
91
|
-
raise BlobstoreError, "Failed to delete object '#{object_id}': #{e.message}"
|
92
|
-
end
|
93
|
-
|
94
|
-
def object_exists?(object_id)
|
95
|
-
object_info = decode_object_id(object_id)
|
96
|
-
object = container.files.head(object_info['oid'])
|
97
|
-
object.nil? ? false : true
|
98
|
-
rescue Exception => e
|
99
|
-
raise BlobstoreError, "Failed to find object '#{object_id}': #{e.message}"
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
|
104
|
-
def encode_object_id(object_id, public_url = nil)
|
105
|
-
json = MultiJson.encode({ oid: object_id, purl: public_url })
|
106
|
-
URI.escape(Base64.encode64(json))
|
107
|
-
end
|
108
|
-
|
109
|
-
def decode_object_id(object_id)
|
110
|
-
begin
|
111
|
-
object_info = MultiJson.decode(Base64.decode64(URI.unescape(object_id)))
|
112
|
-
rescue MultiJson::DecodeError
|
113
|
-
object_info = {}
|
114
|
-
object_info['oid'] = object_id
|
115
|
-
end
|
116
|
-
|
117
|
-
raise BlobstoreError, "Invalid object_id: #{object_info.inspect}" if !object_info.kind_of?(Hash) || object_info['oid'].nil?
|
118
|
-
|
119
|
-
object_info
|
120
|
-
end
|
121
|
-
|
122
|
-
def validate_options(options)
|
123
|
-
raise "Invalid options format, Hash expected, #{options.class} given" unless options.is_a?(Hash)
|
124
|
-
raise 'Swift container name is missing' unless options.has_key?(:container_name)
|
125
|
-
raise 'Swift provider is missing' unless options.has_key?(:swift_provider)
|
126
|
-
case options[:swift_provider]
|
127
|
-
when 'hp'
|
128
|
-
raise 'HP options are missing' unless options.has_key?(:hp)
|
129
|
-
raise "Invalid HP options, Hash expected, #{options[:hp].class} given" unless options[:hp].is_a?(Hash)
|
130
|
-
raise 'HP access key is missing' unless options[:hp].has_key?(:hp_access_key)
|
131
|
-
raise 'HP secret key is missing' unless options[:hp].has_key?(:hp_secret_key)
|
132
|
-
raise 'HP tenant ID is missing' unless options[:hp].has_key?(:hp_tenant_id)
|
133
|
-
raise 'HP availability zone is missing' unless options[:hp].has_key?(:hp_avl_zone)
|
134
|
-
when 'openstack'
|
135
|
-
raise 'OpenStack options are missing' unless options.has_key?(:openstack)
|
136
|
-
raise "Invalid OpenStack options, Hash expected, #{options[:openstack].class} given" unless options[:openstack].is_a?(Hash)
|
137
|
-
raise 'OpenStack authorization URL is missing' unless options[:openstack].has_key?(:openstack_auth_url)
|
138
|
-
raise 'OpenStack user name is missing' unless options[:openstack].has_key?(:openstack_username)
|
139
|
-
raise 'OpenStack API key is missing' unless options[:openstack].has_key?(:openstack_api_key)
|
140
|
-
raise 'OpenStack tenant is missing' unless options[:openstack].has_key?(:openstack_tenant)
|
141
|
-
when 'rackspace'
|
142
|
-
raise 'Rackspace options are missing' unless options.has_key?(:rackspace)
|
143
|
-
raise "Invalid Rackspace options, Hash expected, #{options[:rackspace].class} given" unless options[:rackspace].is_a?(Hash)
|
144
|
-
raise 'Rackspace username is missing' unless options[:rackspace].has_key?(:rackspace_username)
|
145
|
-
raise 'Rackspace API key is missing' unless options[:rackspace].has_key?(:rackspace_api_key)
|
146
|
-
else
|
147
|
-
raise "Swift provider #{options[:swift_provider]} not supported"
|
148
|
-
end
|
149
|
-
end
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|