mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 17:33:54 +00:00
parent
55d5e6c6fe
commit
29702a3397
@ -90,6 +90,7 @@ import decimal
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.utils
|
||||
import salt.utils.hashutils
|
||||
from salt._compat import ElementTree as ET
|
||||
import salt.utils.http as http
|
||||
import salt.utils.aws as aws
|
||||
@ -342,7 +343,7 @@ def query(params=None, setname=None, requesturl=None, location=None,
|
||||
canonical_headers = 'host:' + host + '\n' + 'x-amz-date:' + amz_date + '\n'
|
||||
signed_headers = 'host;x-amz-date'
|
||||
|
||||
payload_hash = hashlib.sha256('').hexdigest()
|
||||
payload_hash = salt.utils.hashutils.sha256_digest('')
|
||||
|
||||
ec2_api_version = provider.get(
|
||||
'ec2_api_version',
|
||||
@ -351,7 +352,7 @@ def query(params=None, setname=None, requesturl=None, location=None,
|
||||
|
||||
params_with_headers['Version'] = ec2_api_version
|
||||
|
||||
keys = sorted(params_with_headers.keys())
|
||||
keys = sorted(list(params_with_headers))
|
||||
values = map(params_with_headers.get, keys)
|
||||
querystring = _urlencode(list(zip(keys, values)))
|
||||
querystring = querystring.replace('+', '%20')
|
||||
@ -365,7 +366,7 @@ def query(params=None, setname=None, requesturl=None, location=None,
|
||||
|
||||
string_to_sign = algorithm + '\n' + amz_date + '\n' + \
|
||||
credential_scope + '\n' + \
|
||||
hashlib.sha256(canonical_request).hexdigest()
|
||||
salt.utils.hashutils.sha256_digest(canonical_request)
|
||||
|
||||
kDate = sign(('AWS4' + provider['key']).encode('utf-8'), datestamp)
|
||||
kRegion = sign(kDate, region)
|
||||
@ -2000,7 +2001,7 @@ def request_instance(vm_=None, call=None):
|
||||
'salt/cloud/{0}/requesting'.format(vm_['name']),
|
||||
args={
|
||||
'kwargs': __utils__['cloud.filter_event'](
|
||||
'requesting', params, params.keys()
|
||||
'requesting', params, list(params)
|
||||
),
|
||||
'location': location,
|
||||
},
|
||||
@ -2786,7 +2787,7 @@ def create(vm_=None, call=None):
|
||||
'event',
|
||||
'created instance',
|
||||
'salt/cloud/{0}/created'.format(vm_['name']),
|
||||
args=__utils__['cloud.filter_event']('created', event_data, event_data.keys()),
|
||||
args=__utils__['cloud.filter_event']('created', event_data, list(event_data)),
|
||||
sock_dir=__opts__['sock_dir'],
|
||||
transport=__opts__['transport']
|
||||
)
|
||||
@ -3394,7 +3395,8 @@ def _get_node(name=None, instance_id=None, location=None):
|
||||
provider=provider,
|
||||
opts=__opts__,
|
||||
sigver='4')
|
||||
return _extract_instance_info(instances).values()[0]
|
||||
instance_info = _extract_instance_info(instances).values()
|
||||
return next(iter(instance_info))
|
||||
except IndexError:
|
||||
attempts -= 1
|
||||
log.debug(
|
||||
|
@ -22,6 +22,7 @@ import salt.config
|
||||
import re
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.hashutils
|
||||
import salt.utils.xmlutil as xml
|
||||
from salt._compat import ElementTree as ET
|
||||
|
||||
@ -244,7 +245,7 @@ def sig4(method, endpoint, params, prov_dict,
|
||||
# Create payload hash (hash of the request body content). For GET
|
||||
# requests, the payload is an empty string ('').
|
||||
if not payload_hash:
|
||||
payload_hash = hashlib.sha256(data).hexdigest()
|
||||
payload_hash = salt.utils.hashutils.sha256_digest(data)
|
||||
|
||||
new_headers['X-Amz-date'] = amzdate
|
||||
new_headers['host'] = endpoint
|
||||
@ -280,7 +281,7 @@ def sig4(method, endpoint, params, prov_dict,
|
||||
algorithm,
|
||||
amzdate,
|
||||
credential_scope,
|
||||
hashlib.sha256(canonical_request).hexdigest()
|
||||
salt.utils.hashutils.sha256_digest(canonical_request)
|
||||
))
|
||||
|
||||
# Create the signing key using the function defined above.
|
||||
|
@ -2536,7 +2536,8 @@ def cachedir_index_add(minion_id, profile, driver, provider, base=None):
|
||||
lock_file(index_file)
|
||||
|
||||
if os.path.exists(index_file):
|
||||
with salt.utils.fopen(index_file, 'r') as fh_:
|
||||
mode = 'rb' if six.PY3 else 'r'
|
||||
with salt.utils.fopen(index_file, mode) as fh_:
|
||||
index = msgpack.load(fh_)
|
||||
else:
|
||||
index = {}
|
||||
@ -2552,7 +2553,8 @@ def cachedir_index_add(minion_id, profile, driver, provider, base=None):
|
||||
}
|
||||
})
|
||||
|
||||
with salt.utils.fopen(index_file, 'w') as fh_:
|
||||
mode = 'wb' if six.PY3 else 'w'
|
||||
with salt.utils.fopen(index_file, mode) as fh_:
|
||||
msgpack.dump(index, fh_)
|
||||
|
||||
unlock_file(index_file)
|
||||
@ -2568,7 +2570,8 @@ def cachedir_index_del(minion_id, base=None):
|
||||
lock_file(index_file)
|
||||
|
||||
if os.path.exists(index_file):
|
||||
with salt.utils.fopen(index_file, 'r') as fh_:
|
||||
mode = 'rb' if six.PY3 else 'r'
|
||||
with salt.utils.fopen(index_file, mode) as fh_:
|
||||
index = msgpack.load(fh_)
|
||||
else:
|
||||
return
|
||||
@ -2576,7 +2579,8 @@ def cachedir_index_del(minion_id, base=None):
|
||||
if minion_id in index:
|
||||
del index[minion_id]
|
||||
|
||||
with salt.utils.fopen(index_file, 'w') as fh_:
|
||||
mode = 'wb' if six.PY3 else 'w'
|
||||
with salt.utils.fopen(index_file, mode) as fh_:
|
||||
msgpack.dump(index, fh_)
|
||||
|
||||
unlock_file(index_file)
|
||||
|
Loading…
Reference in New Issue
Block a user