-
Notifications
You must be signed in to change notification settings - Fork 547
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OCI] Support reuse existing VCN for SkyServe (#4530)
* Support reuse existing VCN for SkyServe * fix * remove unused import * format
- Loading branch information
Showing
3 changed files
with
29 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,8 @@ | |
from ubuntu 20.04 to ubuntu 22.04, including: | ||
- GPU: skypilot:gpu-ubuntu-2004 -> skypilot:gpu-ubuntu-2204 | ||
- CPU: skypilot:cpu-ubuntu-2004 -> skypilot:cpu-ubuntu-2204 | ||
- Hysun He ([email protected]) @ Jan.01, 2025: Support reuse existing | ||
VCN for SkyServe. | ||
""" | ||
import os | ||
|
||
|
@@ -109,8 +111,15 @@ def get_compartment(cls, region): | |
('oci', region, 'compartment_ocid'), default_compartment_ocid) | ||
return compartment | ||
|
||
@classmethod | ||
def get_vcn_ocid(cls, region): | ||
# Will reuse the regional VCN if specified. | ||
vcn = skypilot_config.get_nested(('oci', region, 'vcn_ocid'), None) | ||
return vcn | ||
|
||
@classmethod | ||
def get_vcn_subnet(cls, region): | ||
# Will reuse the subnet if specified. | ||
vcn = skypilot_config.get_nested(('oci', region, 'vcn_subnet'), None) | ||
return vcn | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
find_compartment: allow search subtree when find a compartment. | ||
- Hysun He ([email protected]) @ Nov.12, 2024: Add methods to | ||
Add/remove security rules: create_nsg_rules & remove_nsg | ||
- Hysun He ([email protected]) @ Jan.01, 2025: Support reuse existing | ||
VCN for SkyServe. | ||
""" | ||
from datetime import datetime | ||
import functools | ||
|
@@ -17,7 +19,6 @@ | |
import typing | ||
from typing import List, Optional, Tuple | ||
|
||
from sky import exceptions | ||
from sky import sky_logging | ||
from sky.adaptors import common as adaptors_common | ||
from sky.adaptors import oci as oci_adaptor | ||
|
@@ -496,26 +497,25 @@ def find_nsg(cls, region: str, nsg_name: str, | |
|
||
compartment = cls.find_compartment(region) | ||
|
||
list_vcns_resp = net_client.list_vcns( | ||
compartment_id=compartment, | ||
display_name=oci_utils.oci_config.VCN_NAME, | ||
lifecycle_state='AVAILABLE', | ||
) | ||
|
||
if not list_vcns_resp: | ||
raise exceptions.ResourcesUnavailableError( | ||
'The VCN is not available') | ||
vcn_id = oci_utils.oci_config.get_vcn_ocid(region) | ||
if vcn_id is None: | ||
list_vcns_resp = net_client.list_vcns( | ||
compartment_id=compartment, | ||
display_name=oci_utils.oci_config.VCN_NAME, | ||
lifecycle_state='AVAILABLE', | ||
) | ||
|
||
# Get the primary vnic. The vnic might be an empty list for the | ||
# corner case when the cluster was exited during provision. | ||
if not list_vcns_resp.data: | ||
return None | ||
# Get the primary vnic. The vnic might be an empty list for the | ||
# corner case when the cluster was exited during provision. | ||
if not list_vcns_resp.data: | ||
return None | ||
|
||
vcn = list_vcns_resp.data[0] | ||
vcn = list_vcns_resp.data[0] | ||
vcn_id = vcn.id | ||
|
||
list_nsg_resp = net_client.list_network_security_groups( | ||
compartment_id=compartment, | ||
vcn_id=vcn.id, | ||
vcn_id=vcn_id, | ||
limit=1, | ||
display_name=nsg_name, | ||
) | ||
|
@@ -532,7 +532,7 @@ def find_nsg(cls, region: str, nsg_name: str, | |
create_network_security_group_details=oci_adaptor.oci.core.models. | ||
CreateNetworkSecurityGroupDetails( | ||
compartment_id=compartment, | ||
vcn_id=vcn.id, | ||
vcn_id=vcn_id, | ||
display_name=nsg_name, | ||
)) | ||
get_nsg_resp = net_client.get_network_security_group( | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters