mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Fix PUT/DELETE in s3.query
Was broken in 8ed7c92
during move to requests.
- PUT now uploads data
- Fixes AttributeError
This commit is contained in:
parent
91edd75a03
commit
8a885fc38f
@ -150,6 +150,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
|
||||
try:
|
||||
result = requests.request(method, requesturl, headers=headers,
|
||||
data=data,
|
||||
verify=verify_ssl)
|
||||
response = result.content
|
||||
except requests.exceptions.HTTPError as exc:
|
||||
@ -162,7 +163,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
log.debug('S3 Response Status Code: {0}'.format(result.status_code))
|
||||
|
||||
if method == 'PUT':
|
||||
if result.getcode() == 200:
|
||||
if result.status_code == 200:
|
||||
if local_file:
|
||||
log.debug('Uploaded from {0} to {1}'.format(local_file, path))
|
||||
else:
|
||||
@ -172,14 +173,14 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
log.debug('Failed to upload from {0} to {1}: {2}'.format(
|
||||
local_file,
|
||||
path,
|
||||
result.getcode(),
|
||||
result.status_code,
|
||||
))
|
||||
else:
|
||||
log.debug('Failed to create bucket {0}'.format(bucket))
|
||||
return
|
||||
|
||||
if method == 'DELETE':
|
||||
if str(result.getcode()).startswith('2'):
|
||||
if str(result.status_code).startswith('2'):
|
||||
if path:
|
||||
log.debug('Deleted {0} from bucket {1}'.format(path, bucket))
|
||||
else:
|
||||
@ -189,7 +190,7 @@ def query(key, keyid, method='GET', params=None, headers=None,
|
||||
log.debug('Failed to delete {0} from bucket {1}: {2}'.format(
|
||||
path,
|
||||
bucket,
|
||||
result.getcode(),
|
||||
result.status_code,
|
||||
))
|
||||
else:
|
||||
log.debug('Failed to delete bucket {0}'.format(bucket))
|
||||
|
Loading…
Reference in New Issue
Block a user