This is an automated email from the ASF dual-hosted git repository. mykolabodnar pushed a commit to branch DLAB-1379 in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git
The following commit(s) were added to refs/heads/DLAB-1379 by this push: new da8f6d2 [DLAB-1379] - SSN creation fixed da8f6d2 is described below commit da8f6d2cf41e86c0f6dc92d272ffbd2fe70e3959 Author: Mykola_Bodnar1 <bodnarmyk...@gmail.com> AuthorDate: Mon Dec 16 16:48:29 2019 +0200 [DLAB-1379] - SSN creation fixed --- .../src/general/lib/gcp/actions_lib.py | 34 +++++++++------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py index 976a882..1c5a9eb 100644 --- a/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py +++ b/infrastructure-provisioning/src/general/lib/gcp/actions_lib.py @@ -553,33 +553,25 @@ class GCPActions: traceback.print_exc(file=sys.stdout) def set_role_to_service_account(self, service_account_name, role_name, role_type='custom'): - -# request = GCPActions().service_resource.projects().serviceAccounts().getIamPolicy(resource=resource) -# serviceAccounts_policy = request.execute() service_account_email = "{}@{}.iam.gserviceaccount.com".format(service_account_name, self.project) resource = "projects/{}/serviceAccounts/{}".format(self.project, service_account_email) -# params = { -# "role": "projects/{}/roles/{}".format(self.project, role_name.replace('-', '_')), -# "members": [ -# "serviceAccount:{}".format(service_account_email) -# ] -# } -# if role_type == 'predefined': -# params['role'] = "roles/{}".format(role_name) -# serviceAccounts_policy['bindings'].append(params) + request = GCPActions()self.service_iam.projects().serviceAccounts().getIamPolicy(resource=resource) + serviceAccounts_policy = request.execute() + + params = { + "role": "projects/{}/roles/{}".format(self.project, role_name.replace('-', '_')), + "members": [ + "serviceAccount:{}".format(service_account_email) + ] + } + if role_type == 'predefined': + params['role'] = "roles/{}".format(role_name) + serviceAccounts_policy['bindings'].append(params) params = { "policy": { - "bindings": [ - { - "role": "projects/{}/roles/{}".format(self.project, role_name.replace('-', '_')), - "members": [ - "serviceAccount:{}".format(service_account_email) - ] - } - ] + "bindings": serviceAccounts_policy['bindings'] } } - print(params) request = self.service_iam.projects().serviceAccounts().setIamPolicy(resource=resource, body=params) try: return request.execute() --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@dlab.apache.org For additional commands, e-mail: commits-h...@dlab.apache.org