|
21 | 21 | LOCK_PATH = os.path.join(tempfile.gettempdir(), "sagemaker_test_vpc_lock") |
22 | 22 |
|
23 | 23 |
|
24 | | -def _subnet_ids_by_name(ec2_client, name): |
| 24 | +def _get_subnet_ids_by_name(ec2_client, name): |
25 | 25 | desc = ec2_client.describe_subnets(Filters=[{"Name": "tag-value", "Values": [name]}]) |
26 | 26 | if len(desc["Subnets"]) == 0: |
27 | 27 | return None |
28 | 28 | else: |
29 | 29 | return [subnet["SubnetId"] for subnet in desc["Subnets"]] |
30 | 30 |
|
31 | 31 |
|
32 | | -def _security_id_by_name(ec2_client, name): |
| 32 | +def _get_security_id_by_name(ec2_client, name): |
33 | 33 | desc = ec2_client.describe_security_groups(Filters=[{"Name": "tag-value", "Values": [name]}]) |
34 | 34 | if len(desc["SecurityGroups"]) == 0: |
35 | 35 | return None |
@@ -70,7 +70,7 @@ def check_or_create_vpc_resources_efs_fsx(sagemaker_session, region, name=VPC_NA |
70 | 70 | if _vpc_exists(ec2_client, name): |
71 | 71 | vpc_id = _vpc_id_by_name(ec2_client, name) |
72 | 72 | return ( |
73 | | - _subnet_ids_by_name(ec2_client, name), |
| 73 | + _get_subnet_ids_by_name(ec2_client, name), |
74 | 74 | _security_group_ids_by_vpc_id(sagemaker_session, vpc_id), |
75 | 75 | ) |
76 | 76 | else: |
@@ -184,7 +184,10 @@ def get_or_create_vpc_resources(ec2_client, region, name=VPC_NAME): |
184 | 184 | with lock.lock(LOCK_PATH): |
185 | 185 | if _vpc_exists(ec2_client, name): |
186 | 186 | print("using existing vpc: {}".format(name)) |
187 | | - return (_subnet_ids_by_name(ec2_client, name), _security_id_by_name(ec2_client, name)) |
| 187 | + return ( |
| 188 | + _get_subnet_ids_by_name(ec2_client, name), |
| 189 | + _get_security_id_by_name(ec2_client, name), |
| 190 | + ) |
188 | 191 | else: |
189 | 192 | print("creating new vpc: {}".format(name)) |
190 | 193 | return _create_vpc_with_name(ec2_client, region, name) |
|
0 commit comments