Moved region update to beginning of auth function

So it'll work without auth params as well
This commit is contained in:
Shay Nehmad 2019-04-16 21:55:36 +03:00
parent 6216ac0e9e
commit 9c38d8e72a
2 changed files with 7 additions and 11 deletions

View File

@ -45,13 +45,9 @@ class RemoteRun(flask_restful.Resource):
body = json.loads(request.data)
resp = {}
if body.get('type') == 'aws':
#is_auth = RemoteRunAwsService.update_aws_auth_params()
#resp['auth'] = is_auth
#if is_auth:
# result = self.run_aws_monkeys(body)
# resp['result'] = result
#else:
RemoteRunAwsService.update_aws_region_authless()
is_auth = RemoteRunAwsService.update_aws_auth_params()
resp['auth'] = is_auth
if is_auth:
result = self.run_aws_monkeys(body)
resp['result'] = result
return jsonify(resp)

View File

@ -51,6 +51,8 @@ class RemoteRunAwsService:
Updates the AWS authentication parameters according to config
:return: True if new params allow successful authentication. False otherwise
"""
AwsService.set_region(RemoteRunAwsService.aws_instance.region)
access_key_id = ConfigService.get_config_value(['cnc', 'aws_config', 'aws_access_key_id'], False, True)
secret_access_key = ConfigService.get_config_value(['cnc', 'aws_config', 'aws_secret_access_key'], False, True)
@ -58,8 +60,6 @@ class RemoteRunAwsService:
AwsService.set_auth_params(access_key_id, secret_access_key)
RemoteRunAwsService.is_auth = AwsService.test_client()
AwsService.set_region(RemoteRunAwsService.aws_instance.region)
return RemoteRunAwsService.is_auth
@staticmethod