cloud_files_transfer 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -9
- data/lib/cloud_files_transfer/client.rb +6 -9
- data/lib/cloud_files_transfer/transfer.rb +7 -1
- data/lib/cloud_files_transfer/version.rb +1 -1
- data/lib/tasks/cloud_files_assets.rake +15 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 356cd5bc6fd194469f9562ddd87c3d5b36064f3e
|
4
|
+
data.tar.gz: e25d1224aa740f0d72b90ab9c53713ada43f3f30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6151c334ea081670d8d2afc55cf8a3c5641f9632ffa2021d47edb63479693e05a9f1fb354d2340a59cb110e3a4c87031338c6baa864f0eae0016185de500fbe1
|
7
|
+
data.tar.gz: c9284dd36d6e6d502a5ab5ee238e792af2477c384bb509a9d4141137c466ffc03f43b469d9cc481551b9d3a6a6dd32837a41e72e26338105940cb5a4a9e51d0e
|
data/README.md
CHANGED
@@ -21,15 +21,20 @@ Or install it yourself as:
|
|
21
21
|
Have Rackspace username, api key and container name ready for both origin and destination folders.
|
22
22
|
Or add a config yaml file to automatically pick the info from:
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
24
|
+
```yaml
|
25
|
+
# config/cloudfiles.yml
|
26
|
+
origin:
|
27
|
+
username: rackspace_username
|
28
|
+
api_key: 1234567890abcdefghijklmnopqrstuv
|
29
|
+
container: container_name
|
30
|
+
|
31
|
+
destination:
|
32
|
+
username: rackspace_username
|
33
|
+
api_key: 1234567890abcdefghijklmnopqrstuv
|
34
|
+
container: container_name
|
35
|
+
```
|
36
|
+
|
37
|
+
Then launch the rake task to start the transfer. It doesn't matter where you do it from. It could be faster though if done from a Rackspace instance using service net (snet).
|
33
38
|
|
34
39
|
$ rake cloud_files_assets:transfer
|
35
40
|
|
@@ -1,12 +1,13 @@
|
|
1
1
|
module CloudFilesTransfer
|
2
2
|
class Client
|
3
3
|
|
4
|
-
attr_accessor :username, :api_key, :container_name, :connection
|
4
|
+
attr_accessor :username, :api_key, :container_name, :snet, :connection
|
5
5
|
|
6
6
|
def initialize(args={})
|
7
|
-
@username = args.fetch(:username
|
8
|
-
@api_key = args.fetch(:api_key
|
9
|
-
@container_name = args.fetch(:container
|
7
|
+
@username = args.fetch(:username) { raise 'Missing username'}
|
8
|
+
@api_key = args.fetch(:api_key) { raise 'Missing api_key'}
|
9
|
+
@container_name = args.fetch(:container) { raise 'Missing container'}
|
10
|
+
@snet = args.fetch(:snet, false)
|
10
11
|
@connection = args.fetch(:connection, create_connection)
|
11
12
|
end
|
12
13
|
|
@@ -17,14 +18,10 @@ module CloudFilesTransfer
|
|
17
18
|
private
|
18
19
|
|
19
20
|
def create_connection
|
20
|
-
c = CloudFiles::Connection.new(username: username, api_key: api_key)
|
21
|
+
c = CloudFiles::Connection.new(username: username, api_key: api_key, snet: snet)
|
21
22
|
puts "Connection established."
|
22
23
|
c
|
23
24
|
end
|
24
25
|
|
25
|
-
def credentials
|
26
|
-
@credentials ||= CarrierWave::Uploader::Base.fog_credentials
|
27
|
-
end
|
28
|
-
|
29
26
|
end
|
30
27
|
end
|
@@ -10,7 +10,7 @@ module CloudFilesTransfer
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.copy!(origin, destination, path, args={})
|
13
|
-
return if destination.object_exists?(path)
|
13
|
+
return skip_message(path) if destination.object_exists?(path)
|
14
14
|
new(origin, destination, path, args).copy
|
15
15
|
end
|
16
16
|
|
@@ -32,5 +32,11 @@ module CloudFilesTransfer
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
def skip_message path
|
38
|
+
puts "#{path} skipped."
|
39
|
+
end
|
40
|
+
|
35
41
|
end
|
36
42
|
end
|
@@ -3,30 +3,38 @@ namespace :cloud_files_assets do
|
|
3
3
|
desc "Copy assets from one container to another container"
|
4
4
|
task transfer: :environment do
|
5
5
|
|
6
|
-
config
|
6
|
+
config = YAML.load_file("config/cloudfiles.yml")
|
7
|
+
config = HashWithIndifferentAccess.new(config)
|
7
8
|
|
8
|
-
username = config[
|
9
|
-
api_key = config[
|
10
|
-
container = config[
|
9
|
+
username = config[:origin][:username] rescue ask("Origin username:")
|
10
|
+
api_key = config[:origin][:api_key] rescue ask("Origin API key:")
|
11
|
+
container = config[:origin][:container] rescue ask("Origin container name:")
|
12
|
+
snet = config[:origin][:snet] rescue false
|
11
13
|
@client_from = CloudFilesTransfer::Client.new(
|
12
14
|
username: username,
|
13
15
|
api_key: api_key,
|
14
|
-
container: container
|
16
|
+
container: container,
|
17
|
+
snet: snet
|
15
18
|
)
|
16
19
|
|
17
20
|
username = config["destination"]["username"] rescue ask("Destination username:")
|
18
21
|
api_key = config["destination"]["api_key"] rescue ask("Destination API key:")
|
19
22
|
container = config["destination"]["container"] rescue ask("Destination container name:")
|
23
|
+
snet = config["destination"]["snet"] rescue false
|
20
24
|
@client_to = CloudFilesTransfer::Client.new(
|
21
25
|
username: username,
|
22
26
|
api_key: api_key,
|
23
|
-
container: container
|
27
|
+
container: container,
|
28
|
+
snet: snet
|
24
29
|
)
|
25
30
|
|
26
31
|
@container_from = @client_from.container
|
27
32
|
@container_to = CloudFilesTransfer::Container.new(@client_to.container)
|
33
|
+
@assets = @container_from.objects
|
28
34
|
|
29
|
-
@
|
35
|
+
puts "Starting transfer. #{@assets.size} files to copy."
|
36
|
+
|
37
|
+
@assets.each do |path|
|
30
38
|
CloudFilesTransfer::Transfer.copy!(@container_from, @container_to, path)
|
31
39
|
end
|
32
40
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloud_files_transfer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mathieu Gagné
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cloudfiles
|