utils.aws: use time lib to conver to epoch seconds

Fixes #30798.
This commit is contained in:
Justin Findlay 2016-02-02 21:49:20 -07:00
parent f1cf027308
commit 17ae74dab1

View File

@ -153,7 +153,9 @@ def sig2(method, endpoint, params, provider, aws_api_version):
def assumed_creds(prov_dict, role_arn, location=None):
valid_session_name_re = re.compile("[^a-z0-9A-Z+=,.@-]")
now = (datetime.utcnow() - datetime(1970, 1, 1)).total_seconds()
# current time in epoch seconds
now = time.mktime(datetime.utcnow().timetuple())
for key, creds in __AssumeCache__.items():
if (creds["Expiration"] - now) <= 120:
__AssumeCache__.delete(key)