Merge lp:~xlucas/duplicity/swift-storage-policies into lp:~duplicity-team/duplicity/0.8-series

Proposed by Xavier Lucas
Status: Merged
Merged at revision: 1225
Proposed branch: lp:~xlucas/duplicity/swift-storage-policies
Merge into: lp:~duplicity-team/duplicity/0.8-series
Diff against target: 83 lines (+22/-1)
4 files modified
bin/duplicity.1 (+7/-0)
duplicity/backends/swiftbackend.py (+9/-1)
duplicity/commandline.py (+3/-0)
duplicity/globals.py (+3/-0)
To merge this branch: bzr merge lp:~xlucas/duplicity/swift-storage-policies
Reviewer Review Type Date Requested Status
duplicity-team Pending
Review via email: mp+324008@code.launchpad.net

Description of the change

This brings support for Swift storage policies: when using a Swift backend, you can specify the policy containers should be operating on. This is similar to the idea of AWS Cloud Storage classes (ia, rrs, glacier and so on).

For instance at OVH we built solutions for hot/cold storage atop Swift that typically differentiate for the user, when manipulating the Swift API, by the storage policy in use.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bin/duplicity.1'
2--- bin/duplicity.1 2017-05-04 15:06:41 +0000
3+++ bin/duplicity.1 2017-05-12 22:39:46 +0000
4@@ -927,6 +927,13 @@
5 .BR "A NOTE ON SSL CERTIFICATE VERIFICATION" .
6
7 .TP
8+.BI --swift-storage-policy
9+Use this storage policy when operating on Swift containers.
10+.br
11+See also
12+.BR "A NOTE ON SWIFT (OPENSTACK OBJECT STORAGE) ACCESS" .
13+
14+.TP
15 .BI "--tempdir " directory
16 Use this existing directory for duplicity temporary files instead of
17 the system default, which is usually the /tmp directory. This option
18
19=== modified file 'duplicity/backends/swiftbackend.py'
20--- duplicity/backends/swiftbackend.py 2017-05-05 20:59:45 +0000
21+++ duplicity/backends/swiftbackend.py 2017-05-12 22:39:46 +0000
22@@ -21,6 +21,7 @@
23 import os
24
25 import duplicity.backend
26+from duplicity import globals
27 from duplicity import log
28 from duplicity import util
29 from duplicity.errors import BackendException
30@@ -108,6 +109,9 @@
31 else:
32 self.prefix = ''
33
34+ policy = globals.swift_storage_policy
35+ policy_header = 'X-Storage-Policy'
36+
37 container_metadata = None
38 try:
39 self.conn = Connection(**conn_kwargs)
40@@ -122,11 +126,15 @@
41 if container_metadata is None:
42 log.Info("Creating container %s" % self.container)
43 try:
44- self.conn.put_container(self.container)
45+ headers = dict([[policy_header, policy]]) if policy else None
46+ self.conn.put_container(self.container, headers=headers)
47 except Exception as e:
48 log.FatalError("Container creation failed: %s %s"
49 % (e.__class__.__name__, str(e)),
50 log.ErrorCode.connection_failed)
51+ elif policy and container_metadata[policy_header.lower()] != policy:
52+ log.FatalError("Container '%s' exists but its storage policy is '%s' not '%s'."
53+ % (self.container, container_metadata[policy_header.lower()], policy))
54
55 def _error_code(self, operation, e):
56 if isinstance(e, self.resp_exc):
57
58=== modified file 'duplicity/commandline.py'
59--- duplicity/commandline.py 2017-05-04 15:52:42 +0000
60+++ duplicity/commandline.py 2017-05-12 22:39:46 +0000
61@@ -563,6 +563,9 @@
62 # Option to allow use of server side encryption in s3
63 parser.add_option("--s3-use-server-side-encryption", action="store_true", dest="s3_use_sse")
64
65+ # Option to specify a Swift container storage policy.
66+ parser.add_option("--swift-storage-policy", type="string", metavar=_("policy"))
67+
68 # Number of the largest supported upload size where the Azure library makes only one put call.
69 # This is used to upload a single block if the content length is known and is less than this value.
70 # The default is 67108864 (64MiB)
71
72=== modified file 'duplicity/globals.py'
73--- duplicity/globals.py 2017-05-11 10:45:03 +0000
74+++ duplicity/globals.py 2017-05-12 22:39:46 +0000
75@@ -216,6 +216,9 @@
76 # Use server side encryption in s3
77 s3_use_sse = False
78
79+# Which storage policy to use for Swift containers
80+swift_storage_policy = ""
81+
82 # The largest size upload supported in a single put call for azure
83 azure_max_single_put_size = None
84

Subscribers

People subscribed via source and target branches