|
2 | 2 | import json |
3 | 3 | import logging |
4 | 4 | import oci |
| 5 | +from threading import Thread |
5 | 6 | from fdk import response |
6 | 7 |
|
7 | 8 | # Get Resource Principal Credentials |
@@ -48,7 +49,7 @@ def process_users(user,identity_domains_client,tag_namespace,manage_capability,e |
48 | 49 | ) |
49 | 50 | ) |
50 | 51 | patch_ops.operations = patch_ops_operations |
51 | | - identity_domains_client.patch_user(user_id=user_ocid, patch_op=patch_ops) |
| 52 | + identity_domains_client.patch_user(user_id=user_ocid, patch_op=patch_ops,retry_strategy=oci.retry.DEFAULT_RETRY_STRATEGY) |
52 | 53 |
|
53 | 54 |
|
54 | 55 | def handler(ctx, data: io.BytesIO=None): |
@@ -95,12 +96,25 @@ def handler(ctx, data: io.BytesIO=None): |
95 | 96 | list_users_response = identity_domains_client.list_users(page=list_users_response.next_page) |
96 | 97 | users.extend(list_users_response.data.resources) |
97 | 98 | count = 0 |
| 99 | + jobs = [] |
98 | 100 |
|
99 | 101 | for user in users: |
100 | | - process_users(user, identity_domains_client,tag_namespace,manage_capability,execution_mode) |
| 102 | + #process_users(user, identity_domains_client, tag_namespace, manage_capability, execution_mode) |
| 103 | + |
| 104 | + thread = Thread(target=process_users, args=(user, identity_domains_client, tag_namespace, manage_capability, execution_mode)) |
| 105 | + jobs.append(thread) |
101 | 106 | count += 1 |
102 | 107 |
|
103 | | - logging.getLogger().info(f'Processed {str(count)} users....') |
| 108 | + # start threads |
| 109 | + for job in jobs: |
| 110 | + job.start() |
| 111 | + |
| 112 | + # join threads,so we don't quit until all threads have finished |
| 113 | + for job in jobs: |
| 114 | + job.join() |
| 115 | + |
| 116 | + |
| 117 | + logging.getLogger().info(f'Processed {str(count)} users for domain - {str(domain_endpoint)}....') |
104 | 118 |
|
105 | 119 |
|
106 | 120 | except (Exception, ValueError) as ex: |
|
0 commit comments