Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ terraform/aws/kconfigs/Kconfig.instance.generated
terraform/aws/kconfigs/Kconfig.location.generated
terraform/aws/scripts/__pycache__/

terraform/oci/kconfigs/Kconfig.image.generated
terraform/oci/kconfigs/Kconfig.location.generated
terraform/oci/kconfigs/Kconfig.shape.generated
terraform/oci/scripts/__pycache__/

.cloud.initialized

scripts/__pycache__/
Expand Down
31 changes: 27 additions & 4 deletions scripts/dynamic-cloud-kconfig.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,16 @@ AWS_KCONFIG_LOCATION := $(AWS_KCONFIG_DIR)/Kconfig.location.generated

AWS_KCONFIGS := $(AWS_KCONFIG_AMI) $(AWS_KCONFIG_INSTANCE) $(AWS_KCONFIG_LOCATION)

# OCI dynamic configuration
OCI_KCONFIG_DIR := terraform/oci/kconfigs
OCI_KCONFIG_IMAGE := $(OCI_KCONFIG_DIR)/Kconfig.image.generated
OCI_KCONFIG_LOCATION := $(OCI_KCONFIG_DIR)/Kconfig.location.generated
OCI_KCONFIG_SHAPE := $(OCI_KCONFIG_DIR)/Kconfig.shape.generated

OCI_KCONFIGS := $(OCI_KCONFIG_IMAGE) $(OCI_KCONFIG_LOCATION) $(OCI_KCONFIG_SHAPE)

# Add generated files to mrproper clean list
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS)
KDEVOPS_MRPROPER += $(LAMBDALABS_KCONFIGS) $(AWS_KCONFIGS) $(OCI_KCONFIGS)

# Touch Lambda Labs generated files so Kconfig can source them
# This ensures the files exist (even if empty) before Kconfig runs
Expand All @@ -32,7 +40,11 @@ dynamic_lambdalabs_kconfig_touch:
dynamic_aws_kconfig_touch:
$(Q)touch $(AWS_KCONFIGS)

DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch
# Touch OCI generated files so Kconfig can source them
dynamic_oci_kconfig_touch:
$(Q)touch $(OCI_KCONFIGS)

DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_oci_kconfig_touch

# Lambda Labs targets use --provider argument for efficiency
cloud-config-lambdalabs:
Expand All @@ -42,6 +54,10 @@ cloud-config-lambdalabs:
cloud-config-aws:
$(Q)python3 scripts/generate_cloud_configs.py --provider aws

# OCI targets use --provider argument for efficiency
cloud-config-oci:
$(Q)python3 scripts/generate_cloud_configs.py --provider oci

# Clean Lambda Labs generated files
clean-cloud-config-lambdalabs:
$(Q)rm -f $(LAMBDALABS_KCONFIGS)
Expand All @@ -50,7 +66,11 @@ clean-cloud-config-lambdalabs:
clean-cloud-config-aws:
$(Q)rm -f $(AWS_KCONFIGS)

DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws
# Clean OCI generated files
clean-cloud-config-oci:
$(Q)rm -f $(OCI_KCONFIGS)

DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-oci

cloud-config-help:
@echo "Cloud-specific dynamic kconfig targets:"
Expand All @@ -72,4 +92,7 @@ cloud-list-all:
$(Q)chmod +x scripts/cloud_list_all.sh
$(Q)scripts/cloud_list_all.sh

PHONY += cloud-config cloud-config-lambdalabs cloud-config-aws clean-cloud-config clean-cloud-config-lambdalabs clean-cloud-config-aws cloud-config-help cloud-list-all
PHONY += cloud-config clean-cloud-config cloud-config-help cloud-list-all
PHONY += cloud-config-aws clean-cloud-config-aws
PHONY += cloud-config-lambdalabs clean-cloud-config-lambdalabs
PHONY += cloud-config-oci clean-cloud-config-oci
55 changes: 53 additions & 2 deletions scripts/generate_cloud_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,52 @@ def generate_aws_kconfig() -> bool:
return all_success


def generate_oci_kconfig() -> bool:
"""
Generate OCI Kconfig files.
Returns True on success, False on failure.
"""
script_dir = os.path.dirname(os.path.abspath(__file__))
project_root = os.path.dirname(script_dir)
oci_scripts_dir = os.path.join(project_root, "terraform", "oci", "scripts")
oci_kconfigs_dir = os.path.join(project_root, "terraform", "oci", "kconfigs")

# Define the script-to-output mapping
scripts_to_run = [
("gen_kconfig_image", "Kconfig.image.generated"),
("gen_kconfig_location", "Kconfig.location.generated"),
("gen_kconfig_shape", "Kconfig.shape.generated"),
]

all_success = True

for script_name, kconfig_file in scripts_to_run:
script_path = os.path.join(oci_scripts_dir, script_name)
output_path = os.path.join(oci_kconfigs_dir, kconfig_file)

# Run the script and capture its output
result = subprocess.run(
[script_path],
capture_output=True,
text=True,
check=False,
)

if result.returncode == 0:
# Write the output to the corresponding Kconfig file
try:
with open(output_path, "w") as f:
f.write(result.stdout)
except IOError as e:
print(f"Error writing {kconfig_file}: {e}", file=sys.stderr)
all_success = False
else:
print(f"Error running {script_name}: {result.stderr}", file=sys.stderr)
all_success = False

return all_success


def process_lambdalabs():
"""Process Lambda Labs configuration."""
# Generate Kconfig files first
Expand Down Expand Up @@ -186,8 +232,13 @@ def process_gce():


def process_oci():
"""Process OCI configuration (placeholder)."""
print("⚠ OCI: Dynamic configuration not yet implemented")
"""Process OCI configuration."""
kconfig_generated = generate_oci_kconfig()
if kconfig_generated:
print("✓ OCI: Kconfig files generated successfully")
else:
print("⚠ OCI: Failed to generate Kconfig files - using defaults")
print()


def main():
Expand Down
13 changes: 11 additions & 2 deletions terraform/oci/Kconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# OCI provider configuration
#
# This file sources dynamically Kconfig menus. Run
# 'make cloud-config-oci' to populate the .generated files
# with current OCI resource information.

if TERRAFORM_OCI

menu "Resource location"
source "terraform/oci/kconfigs/Kconfig.location"
source "terraform/oci/kconfigs/Kconfig.location.generated"
endmenu
menu "Compute"
source "terraform/oci/kconfigs/Kconfig.compute"
comment "Shape selection"
source "terraform/oci/kconfigs/Kconfig.shape.generated"
comment "OS image selection"
source "terraform/oci/kconfigs/Kconfig.image.generated"
endmenu
menu "Storage"
source "terraform/oci/kconfigs/Kconfig.storage"
Expand Down
79 changes: 0 additions & 79 deletions terraform/oci/kconfigs/Kconfig.compute

This file was deleted.

Loading
Loading