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
=== modified file 'bin/duplicity.1'
--- bin/duplicity.1 2017-05-04 15:06:41 +0000
+++ bin/duplicity.1 2017-05-12 22:39:46 +0000
@@ -927,6 +927,13 @@
927.BR "A NOTE ON SSL CERTIFICATE VERIFICATION" .927.BR "A NOTE ON SSL CERTIFICATE VERIFICATION" .
928928
929.TP929.TP
930.BI --swift-storage-policy
931Use this storage policy when operating on Swift containers.
932.br
933See also
934.BR "A NOTE ON SWIFT (OPENSTACK OBJECT STORAGE) ACCESS" .
935
936.TP
930.BI "--tempdir " directory937.BI "--tempdir " directory
931Use this existing directory for duplicity temporary files instead of938Use this existing directory for duplicity temporary files instead of
932the system default, which is usually the /tmp directory. This option939the system default, which is usually the /tmp directory. This option
933940
=== modified file 'duplicity/backends/swiftbackend.py'
--- duplicity/backends/swiftbackend.py 2017-05-05 20:59:45 +0000
+++ duplicity/backends/swiftbackend.py 2017-05-12 22:39:46 +0000
@@ -21,6 +21,7 @@
21import os21import os
2222
23import duplicity.backend23import duplicity.backend
24from duplicity import globals
24from duplicity import log25from duplicity import log
25from duplicity import util26from duplicity import util
26from duplicity.errors import BackendException27from duplicity.errors import BackendException
@@ -108,6 +109,9 @@
108 else:109 else:
109 self.prefix = ''110 self.prefix = ''
110111
112 policy = globals.swift_storage_policy
113 policy_header = 'X-Storage-Policy'
114
111 container_metadata = None115 container_metadata = None
112 try:116 try:
113 self.conn = Connection(**conn_kwargs)117 self.conn = Connection(**conn_kwargs)
@@ -122,11 +126,15 @@
122 if container_metadata is None:126 if container_metadata is None:
123 log.Info("Creating container %s" % self.container)127 log.Info("Creating container %s" % self.container)
124 try:128 try:
125 self.conn.put_container(self.container)129 headers = dict([[policy_header, policy]]) if policy else None
130 self.conn.put_container(self.container, headers=headers)
126 except Exception as e:131 except Exception as e:
127 log.FatalError("Container creation failed: %s %s"132 log.FatalError("Container creation failed: %s %s"
128 % (e.__class__.__name__, str(e)),133 % (e.__class__.__name__, str(e)),
129 log.ErrorCode.connection_failed)134 log.ErrorCode.connection_failed)
135 elif policy and container_metadata[policy_header.lower()] != policy:
136 log.FatalError("Container '%s' exists but its storage policy is '%s' not '%s'."
137 % (self.container, container_metadata[policy_header.lower()], policy))
130138
131 def _error_code(self, operation, e):139 def _error_code(self, operation, e):
132 if isinstance(e, self.resp_exc):140 if isinstance(e, self.resp_exc):
133141
=== modified file 'duplicity/commandline.py'
--- duplicity/commandline.py 2017-05-04 15:52:42 +0000
+++ duplicity/commandline.py 2017-05-12 22:39:46 +0000
@@ -563,6 +563,9 @@
563 # Option to allow use of server side encryption in s3563 # Option to allow use of server side encryption in s3
564 parser.add_option("--s3-use-server-side-encryption", action="store_true", dest="s3_use_sse")564 parser.add_option("--s3-use-server-side-encryption", action="store_true", dest="s3_use_sse")
565565
566 # Option to specify a Swift container storage policy.
567 parser.add_option("--swift-storage-policy", type="string", metavar=_("policy"))
568
566 # Number of the largest supported upload size where the Azure library makes only one put call.569 # Number of the largest supported upload size where the Azure library makes only one put call.
567 # This is used to upload a single block if the content length is known and is less than this value.570 # This is used to upload a single block if the content length is known and is less than this value.
568 # The default is 67108864 (64MiB)571 # The default is 67108864 (64MiB)
569572
=== modified file 'duplicity/globals.py'
--- duplicity/globals.py 2017-05-11 10:45:03 +0000
+++ duplicity/globals.py 2017-05-12 22:39:46 +0000
@@ -216,6 +216,9 @@
216# Use server side encryption in s3216# Use server side encryption in s3
217s3_use_sse = False217s3_use_sse = False
218218
219# Which storage policy to use for Swift containers
220swift_storage_policy = ""
221
219# The largest size upload supported in a single put call for azure222# The largest size upload supported in a single put call for azure
220azure_max_single_put_size = None223azure_max_single_put_size = None
221224

Subscribers

People subscribed via source and target branches