Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: boto/provider.py

Issue 8386013: Merging in latest boto. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: Redoing vendor drop by deleting and then merging. Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « boto/mturk/question.py ('k') | boto/pyami/bootstrap.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/ 1 # Copyright (c) 2010 Mitch Garnaat http://garnaat.org/
2 # Copyright 2010 Google Inc. 2 # Copyright 2010 Google Inc.
3 # Copyright (c) 2010, Eucalyptus Systems, Inc. 3 # Copyright (c) 2010, Eucalyptus Systems, Inc.
4 # Copyright (c) 2011, Nexenta Systems Inc.
4 # All rights reserved. 5 # All rights reserved.
5 # 6 #
6 # Permission is hereby granted, free of charge, to any person obtaining a 7 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the 8 # copy of this software and associated documentation files (the
8 # "Software"), to deal in the Software without restriction, including 9 # "Software"), to deal in the Software without restriction, including
9 # without limitation the rights to use, copy, modify, merge, publish, dis- 10 # without limitation the rights to use, copy, modify, merge, publish, dis-
10 # tribute, sublicense, and/or sell copies of the Software, and to permit 11 # tribute, sublicense, and/or sell copies of the Software, and to permit
11 # persons to whom the Software is furnished to do so, subject to the fol- 12 # persons to whom the Software is furnished to do so, subject to the fol-
12 # lowing conditions: 13 # lowing conditions:
13 # 14 #
(...skipping 29 matching lines...) Expand all
43 AUTH_HEADER_KEY = 'auth-header' 44 AUTH_HEADER_KEY = 'auth-header'
44 COPY_SOURCE_HEADER_KEY = 'copy-source-header' 45 COPY_SOURCE_HEADER_KEY = 'copy-source-header'
45 COPY_SOURCE_VERSION_ID_HEADER_KEY = 'copy-source-version-id-header' 46 COPY_SOURCE_VERSION_ID_HEADER_KEY = 'copy-source-version-id-header'
46 DELETE_MARKER_HEADER_KEY = 'delete-marker-header' 47 DELETE_MARKER_HEADER_KEY = 'delete-marker-header'
47 DATE_HEADER_KEY = 'date-header' 48 DATE_HEADER_KEY = 'date-header'
48 METADATA_DIRECTIVE_HEADER_KEY = 'metadata-directive-header' 49 METADATA_DIRECTIVE_HEADER_KEY = 'metadata-directive-header'
49 RESUMABLE_UPLOAD_HEADER_KEY = 'resumable-upload-header' 50 RESUMABLE_UPLOAD_HEADER_KEY = 'resumable-upload-header'
50 SECURITY_TOKEN_HEADER_KEY = 'security-token-header' 51 SECURITY_TOKEN_HEADER_KEY = 'security-token-header'
51 STORAGE_CLASS_HEADER_KEY = 'storage-class' 52 STORAGE_CLASS_HEADER_KEY = 'storage-class'
52 MFA_HEADER_KEY = 'mfa-header' 53 MFA_HEADER_KEY = 'mfa-header'
54 SERVER_SIDE_ENCRYPTION_KEY = 'server-side-encryption-header'
53 VERSION_ID_HEADER_KEY = 'version-id-header' 55 VERSION_ID_HEADER_KEY = 'version-id-header'
54 56
55 STORAGE_COPY_ERROR = 'StorageCopyError' 57 STORAGE_COPY_ERROR = 'StorageCopyError'
56 STORAGE_CREATE_ERROR = 'StorageCreateError' 58 STORAGE_CREATE_ERROR = 'StorageCreateError'
57 STORAGE_DATA_ERROR = 'StorageDataError' 59 STORAGE_DATA_ERROR = 'StorageDataError'
58 STORAGE_PERMISSIONS_ERROR = 'StoragePermissionsError' 60 STORAGE_PERMISSIONS_ERROR = 'StoragePermissionsError'
59 STORAGE_RESPONSE_ERROR = 'StorageResponseError' 61 STORAGE_RESPONSE_ERROR = 'StorageResponseError'
60 62
61 63
62 class Provider(object): 64 class Provider(object):
(...skipping 11 matching lines...) Expand all
74 CannedAclsMap = { 76 CannedAclsMap = {
75 'aws' : CannedS3ACLStrings, 77 'aws' : CannedS3ACLStrings,
76 'google' : CannedGSACLStrings 78 'google' : CannedGSACLStrings
77 } 79 }
78 80
79 HostKeyMap = { 81 HostKeyMap = {
80 'aws' : 's3', 82 'aws' : 's3',
81 'google' : 'gs' 83 'google' : 'gs'
82 } 84 }
83 85
86 ChunkedTransferSupport = {
87 'aws' : False,
88 'google' : True
89 }
90
91 # If you update this map please make sure to put "None" for the
92 # right-hand-side for any headers that don't apply to a provider, rather
93 # than simply leaving that header out (which would cause KeyErrors).
84 HeaderInfoMap = { 94 HeaderInfoMap = {
85 'aws' : { 95 'aws' : {
86 HEADER_PREFIX_KEY : AWS_HEADER_PREFIX, 96 HEADER_PREFIX_KEY : AWS_HEADER_PREFIX,
87 METADATA_PREFIX_KEY : AWS_HEADER_PREFIX + 'meta-', 97 METADATA_PREFIX_KEY : AWS_HEADER_PREFIX + 'meta-',
88 ACL_HEADER_KEY : AWS_HEADER_PREFIX + 'acl', 98 ACL_HEADER_KEY : AWS_HEADER_PREFIX + 'acl',
89 AUTH_HEADER_KEY : 'AWS', 99 AUTH_HEADER_KEY : 'AWS',
90 COPY_SOURCE_HEADER_KEY : AWS_HEADER_PREFIX + 'copy-source', 100 COPY_SOURCE_HEADER_KEY : AWS_HEADER_PREFIX + 'copy-source',
91 COPY_SOURCE_VERSION_ID_HEADER_KEY : AWS_HEADER_PREFIX + 101 COPY_SOURCE_VERSION_ID_HEADER_KEY : AWS_HEADER_PREFIX +
92 'copy-source-version-id', 102 'copy-source-version-id',
93 DATE_HEADER_KEY : AWS_HEADER_PREFIX + 'date', 103 DATE_HEADER_KEY : AWS_HEADER_PREFIX + 'date',
94 DELETE_MARKER_HEADER_KEY : AWS_HEADER_PREFIX + 'delete-marker', 104 DELETE_MARKER_HEADER_KEY : AWS_HEADER_PREFIX + 'delete-marker',
95 METADATA_DIRECTIVE_HEADER_KEY : AWS_HEADER_PREFIX + 105 METADATA_DIRECTIVE_HEADER_KEY : AWS_HEADER_PREFIX +
96 'metadata-directive', 106 'metadata-directive',
97 RESUMABLE_UPLOAD_HEADER_KEY : None, 107 RESUMABLE_UPLOAD_HEADER_KEY : None,
98 SECURITY_TOKEN_HEADER_KEY : AWS_HEADER_PREFIX + 'security-token', 108 SECURITY_TOKEN_HEADER_KEY : AWS_HEADER_PREFIX + 'security-token',
109 SERVER_SIDE_ENCRYPTION_KEY : AWS_HEADER_PREFIX + 'server-side-encryp tion',
99 VERSION_ID_HEADER_KEY : AWS_HEADER_PREFIX + 'version-id', 110 VERSION_ID_HEADER_KEY : AWS_HEADER_PREFIX + 'version-id',
100 STORAGE_CLASS_HEADER_KEY : AWS_HEADER_PREFIX + 'storage-class', 111 STORAGE_CLASS_HEADER_KEY : AWS_HEADER_PREFIX + 'storage-class',
101 MFA_HEADER_KEY : AWS_HEADER_PREFIX + 'mfa', 112 MFA_HEADER_KEY : AWS_HEADER_PREFIX + 'mfa',
102 }, 113 },
103 'google' : { 114 'google' : {
104 HEADER_PREFIX_KEY : GOOG_HEADER_PREFIX, 115 HEADER_PREFIX_KEY : GOOG_HEADER_PREFIX,
105 METADATA_PREFIX_KEY : GOOG_HEADER_PREFIX + 'meta-', 116 METADATA_PREFIX_KEY : GOOG_HEADER_PREFIX + 'meta-',
106 ACL_HEADER_KEY : GOOG_HEADER_PREFIX + 'acl', 117 ACL_HEADER_KEY : GOOG_HEADER_PREFIX + 'acl',
107 AUTH_HEADER_KEY : 'GOOG1', 118 AUTH_HEADER_KEY : 'GOOG1',
108 COPY_SOURCE_HEADER_KEY : GOOG_HEADER_PREFIX + 'copy-source', 119 COPY_SOURCE_HEADER_KEY : GOOG_HEADER_PREFIX + 'copy-source',
109 COPY_SOURCE_VERSION_ID_HEADER_KEY : GOOG_HEADER_PREFIX + 120 COPY_SOURCE_VERSION_ID_HEADER_KEY : GOOG_HEADER_PREFIX +
110 'copy-source-version-id', 121 'copy-source-version-id',
111 DATE_HEADER_KEY : GOOG_HEADER_PREFIX + 'date', 122 DATE_HEADER_KEY : GOOG_HEADER_PREFIX + 'date',
112 DELETE_MARKER_HEADER_KEY : GOOG_HEADER_PREFIX + 'delete-marker', 123 DELETE_MARKER_HEADER_KEY : GOOG_HEADER_PREFIX + 'delete-marker',
113 METADATA_DIRECTIVE_HEADER_KEY : GOOG_HEADER_PREFIX + 124 METADATA_DIRECTIVE_HEADER_KEY : GOOG_HEADER_PREFIX +
114 'metadata-directive', 125 'metadata-directive',
115 RESUMABLE_UPLOAD_HEADER_KEY : GOOG_HEADER_PREFIX + 'resumable', 126 RESUMABLE_UPLOAD_HEADER_KEY : GOOG_HEADER_PREFIX + 'resumable',
116 SECURITY_TOKEN_HEADER_KEY : GOOG_HEADER_PREFIX + 'security-token', 127 SECURITY_TOKEN_HEADER_KEY : GOOG_HEADER_PREFIX + 'security-token',
128 SERVER_SIDE_ENCRYPTION_KEY : None,
129 # Note that this version header is not to be confused with
130 # the Google Cloud Storage 'x-goog-api-version' header.
117 VERSION_ID_HEADER_KEY : GOOG_HEADER_PREFIX + 'version-id', 131 VERSION_ID_HEADER_KEY : GOOG_HEADER_PREFIX + 'version-id',
118 STORAGE_CLASS_HEADER_KEY : None, 132 STORAGE_CLASS_HEADER_KEY : None,
119 MFA_HEADER_KEY : None, 133 MFA_HEADER_KEY : None,
120 } 134 }
121 } 135 }
122 136
123 ErrorMap = { 137 ErrorMap = {
124 'aws' : { 138 'aws' : {
125 STORAGE_COPY_ERROR : boto.exception.S3CopyError, 139 STORAGE_COPY_ERROR : boto.exception.S3CopyError,
126 STORAGE_CREATE_ERROR : boto.exception.S3CreateError, 140 STORAGE_CREATE_ERROR : boto.exception.S3CreateError,
127 STORAGE_DATA_ERROR : boto.exception.S3DataError, 141 STORAGE_DATA_ERROR : boto.exception.S3DataError,
128 STORAGE_PERMISSIONS_ERROR : boto.exception.S3PermissionsError, 142 STORAGE_PERMISSIONS_ERROR : boto.exception.S3PermissionsError,
129 STORAGE_RESPONSE_ERROR : boto.exception.S3ResponseError, 143 STORAGE_RESPONSE_ERROR : boto.exception.S3ResponseError,
130 }, 144 },
131 'google' : { 145 'google' : {
132 STORAGE_COPY_ERROR : boto.exception.GSCopyError, 146 STORAGE_COPY_ERROR : boto.exception.GSCopyError,
133 STORAGE_CREATE_ERROR : boto.exception.GSCreateError, 147 STORAGE_CREATE_ERROR : boto.exception.GSCreateError,
134 STORAGE_DATA_ERROR : boto.exception.GSDataError, 148 STORAGE_DATA_ERROR : boto.exception.GSDataError,
135 STORAGE_PERMISSIONS_ERROR : boto.exception.GSPermissionsError, 149 STORAGE_PERMISSIONS_ERROR : boto.exception.GSPermissionsError,
136 STORAGE_RESPONSE_ERROR : boto.exception.GSResponseError, 150 STORAGE_RESPONSE_ERROR : boto.exception.GSResponseError,
137 } 151 }
138 } 152 }
139 153
140 def __init__(self, name, access_key=None, secret_key=None): 154 def __init__(self, name, access_key=None, secret_key=None,
155 security_token=None):
141 self.host = None 156 self.host = None
142 self.access_key = access_key 157 self.access_key = access_key
143 self.secret_key = secret_key 158 self.secret_key = secret_key
159 self.security_token = security_token
144 self.name = name 160 self.name = name
145 self.acl_class = self.AclClassMap[self.name] 161 self.acl_class = self.AclClassMap[self.name]
146 self.canned_acls = self.CannedAclsMap[self.name] 162 self.canned_acls = self.CannedAclsMap[self.name]
147 self.get_credentials(access_key, secret_key) 163 self.get_credentials(access_key, secret_key)
148 self.configure_headers() 164 self.configure_headers()
149 self.configure_errors() 165 self.configure_errors()
150 # allow config file to override default host 166 # allow config file to override default host
151 host_opt_name = '%s_host' % self.HostKeyMap[self.name] 167 host_opt_name = '%s_host' % self.HostKeyMap[self.name]
152 if config.has_option('Credentials', host_opt_name): 168 if config.has_option('Credentials', host_opt_name):
153 self.host = config.get('Credentials', host_opt_name) 169 self.host = config.get('Credentials', host_opt_name)
(...skipping 27 matching lines...) Expand all
181 self.copy_source_header = header_info_map[COPY_SOURCE_HEADER_KEY] 197 self.copy_source_header = header_info_map[COPY_SOURCE_HEADER_KEY]
182 self.copy_source_version_id = header_info_map[ 198 self.copy_source_version_id = header_info_map[
183 COPY_SOURCE_VERSION_ID_HEADER_KEY] 199 COPY_SOURCE_VERSION_ID_HEADER_KEY]
184 self.date_header = header_info_map[DATE_HEADER_KEY] 200 self.date_header = header_info_map[DATE_HEADER_KEY]
185 self.delete_marker = header_info_map[DELETE_MARKER_HEADER_KEY] 201 self.delete_marker = header_info_map[DELETE_MARKER_HEADER_KEY]
186 self.metadata_directive_header = ( 202 self.metadata_directive_header = (
187 header_info_map[METADATA_DIRECTIVE_HEADER_KEY]) 203 header_info_map[METADATA_DIRECTIVE_HEADER_KEY])
188 self.security_token_header = header_info_map[SECURITY_TOKEN_HEADER_KEY] 204 self.security_token_header = header_info_map[SECURITY_TOKEN_HEADER_KEY]
189 self.resumable_upload_header = ( 205 self.resumable_upload_header = (
190 header_info_map[RESUMABLE_UPLOAD_HEADER_KEY]) 206 header_info_map[RESUMABLE_UPLOAD_HEADER_KEY])
207 self.server_side_encryption_header = header_info_map[SERVER_SIDE_ENCRYPT ION_KEY]
191 self.storage_class_header = header_info_map[STORAGE_CLASS_HEADER_KEY] 208 self.storage_class_header = header_info_map[STORAGE_CLASS_HEADER_KEY]
192 self.version_id = header_info_map[VERSION_ID_HEADER_KEY] 209 self.version_id = header_info_map[VERSION_ID_HEADER_KEY]
193 self.mfa_header = header_info_map[MFA_HEADER_KEY] 210 self.mfa_header = header_info_map[MFA_HEADER_KEY]
194 211
195 def configure_errors(self): 212 def configure_errors(self):
196 error_map = self.ErrorMap[self.name] 213 error_map = self.ErrorMap[self.name]
197 self.storage_copy_error = error_map[STORAGE_COPY_ERROR] 214 self.storage_copy_error = error_map[STORAGE_COPY_ERROR]
198 self.storage_create_error = error_map[STORAGE_CREATE_ERROR] 215 self.storage_create_error = error_map[STORAGE_CREATE_ERROR]
199 self.storage_data_error = error_map[STORAGE_DATA_ERROR] 216 self.storage_data_error = error_map[STORAGE_DATA_ERROR]
200 self.storage_permissions_error = error_map[STORAGE_PERMISSIONS_ERROR] 217 self.storage_permissions_error = error_map[STORAGE_PERMISSIONS_ERROR]
201 self.storage_response_error = error_map[STORAGE_RESPONSE_ERROR] 218 self.storage_response_error = error_map[STORAGE_RESPONSE_ERROR]
202 219
203 def get_provider_name(self): 220 def get_provider_name(self):
204 return self.HostKeyMap[self.name] 221 return self.HostKeyMap[self.name]
205 222
223 def supports_chunked_transfer(self):
224 return self.ChunkedTransferSupport[self.name]
225
206 # Static utility method for getting default Provider. 226 # Static utility method for getting default Provider.
207 def get_default(): 227 def get_default():
208 return Provider('aws') 228 return Provider('aws')
OLDNEW
« no previous file with comments | « boto/mturk/question.py ('k') | boto/pyami/bootstrap.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698