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 @@ -132,6 +132,11 @@ terraform/azure/kconfigs/Kconfig.location.generated
terraform/azure/kconfigs/Kconfig.size.generated
terraform/azure/scripts/__pycache__/

terraform/gce/kconfigs/Kconfig.image.generated
terraform/gce/kconfigs/Kconfig.location.generated
terraform/gce/kconfigs/Kconfig.machine.generated
terraform/gce/scripts/__pycache__/

terraform/oci/kconfigs/Kconfig.image.generated
terraform/oci/kconfigs/Kconfig.location.generated
terraform/oci/kconfigs/Kconfig.shape.generated
Expand Down
40 changes: 35 additions & 5 deletions scripts/dynamic-cloud-kconfig.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ AZURE_KCONFIG_SIZE_DEFAULT := $(AZURE_KCONFIG_DIR)/Kconfig.size.default

AZURE_KCONFIGS := $(AZURE_KCONFIG_LOCATION) $(AZURE_KCONFIG_SIZE) $(AZURE_KCONFIG_IMAGE)

# GCE dynamic configuration
GCE_KCONFIG_DIR := terraform/gce/kconfigs
GCE_KCONFIG_IMAGE := $(GCE_KCONFIG_DIR)/Kconfig.image.generated
GCE_KCONFIG_LOCATION := $(GCE_KCONFIG_DIR)/Kconfig.location.generated
GCE_KCONFIG_MACHINE := $(GCE_KCONFIG_DIR)/Kconfig.machine.generated

# GCE default files (tracked in git, provide sensible defaults)
GCE_KCONFIG_IMAGE_DEFAULT := $(GCE_KCONFIG_DIR)/Kconfig.image.default
GCE_KCONFIG_LOCATION_DEFAULT := $(GCE_KCONFIG_DIR)/Kconfig.location.default
GCE_KCONFIG_MACHINE_DEFAULT := $(GCE_KCONFIG_DIR)/Kconfig.machine.default

GCE_KCONFIGS := $(GCE_KCONFIG_IMAGE) $(GCE_KCONFIG_LOCATION) $(GCE_KCONFIG_MACHINE)

# OCI dynamic configuration
OCI_KCONFIG_DIR := terraform/oci/kconfigs
OCI_KCONFIG_IMAGE := $(OCI_KCONFIG_DIR)/Kconfig.image.generated
Expand Down Expand Up @@ -70,7 +83,7 @@ DATACRUNCH_KCONFIG_LOCATION_DEFAULT := $(DATACRUNCH_KCONFIG_DIR)/Kconfig.locatio
DATACRUNCH_KCONFIGS := $(DATACRUNCH_KCONFIG_COMPUTE) $(DATACRUNCH_KCONFIG_IMAGES) $(DATACRUNCH_KCONFIG_LOCATION)

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

# Ensure Lambda Labs generated files exist with sensible defaults
# Copies from .default files if .generated files don't exist
Expand All @@ -93,6 +106,13 @@ dynamic_azure_kconfig_touch:
$(Q)test -f $(AZURE_KCONFIG_LOCATION) || cp $(AZURE_KCONFIG_LOCATION_DEFAULT) $(AZURE_KCONFIG_LOCATION)
$(Q)test -f $(AZURE_KCONFIG_SIZE) || cp $(AZURE_KCONFIG_SIZE_DEFAULT) $(AZURE_KCONFIG_SIZE)

# Ensure GCE generated files exist with sensible defaults
# Copies from .default files if .generated files don't exist
dynamic_gce_kconfig_touch:
$(Q)test -f $(GCE_KCONFIG_IMAGE) || cp $(GCE_KCONFIG_IMAGE_DEFAULT) $(GCE_KCONFIG_IMAGE)
$(Q)test -f $(GCE_KCONFIG_LOCATION) || cp $(GCE_KCONFIG_LOCATION_DEFAULT) $(GCE_KCONFIG_LOCATION)
$(Q)test -f $(GCE_KCONFIG_MACHINE) || cp $(GCE_KCONFIG_MACHINE_DEFAULT) $(GCE_KCONFIG_MACHINE)

# Ensure OCI generated files exist with sensible defaults
# Copies from .default files if .generated files don't exist
dynamic_oci_kconfig_touch:
Expand All @@ -107,11 +127,11 @@ dynamic_datacrunch_kconfig_touch:
$(Q)test -f $(DATACRUNCH_KCONFIG_IMAGES) || cp $(DATACRUNCH_KCONFIG_IMAGES_DEFAULT) $(DATACRUNCH_KCONFIG_IMAGES)
$(Q)test -f $(DATACRUNCH_KCONFIG_LOCATION) || cp $(DATACRUNCH_KCONFIG_LOCATION_DEFAULT) $(DATACRUNCH_KCONFIG_LOCATION)

DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_oci_kconfig_touch dynamic_datacrunch_kconfig_touch
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_gce_kconfig_touch dynamic_oci_kconfig_touch dynamic_datacrunch_kconfig_touch

# User-facing target to populate cloud kconfigs with defaults
# This is called automatically before menuconfig, but can be run manually
default-cloud-kconfigs: dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_oci_kconfig_touch dynamic_datacrunch_kconfig_touch
default-cloud-kconfigs: dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_gce_kconfig_touch dynamic_oci_kconfig_touch dynamic_datacrunch_kconfig_touch

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

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

# OCI targets use --provider argument for efficiency
cloud-config-oci:
$(Q)python3 scripts/generate_cloud_configs.py --provider oci
Expand All @@ -145,6 +169,10 @@ clean-cloud-config-aws:
clean-cloud-config-azure:
$(Q)rm -f $(AZURE_KCONFIGS)

# Clean GCE generated files
clean-cloud-config-gce:
$(Q)rm -f $(GCE_KCONFIGS)

# Clean OCI generated files
clean-cloud-config-oci:
$(Q)rm -f $(OCI_KCONFIGS)
Expand All @@ -153,7 +181,7 @@ clean-cloud-config-oci:
clean-cloud-config-datacrunch:
$(Q)rm -f $(DATACRUNCH_KCONFIGS)

DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-azure cloud-config-oci cloud-config-datacrunch
DYNAMIC_CLOUD_KCONFIG += cloud-config-lambdalabs cloud-config-aws cloud-config-azure cloud-config-gce cloud-config-oci cloud-config-datacrunch

cloud-config-help:
@echo "Cloud-specific dynamic kconfig targets:"
Expand All @@ -162,6 +190,7 @@ cloud-config-help:
@echo "cloud-config-lambdalabs - generates Lambda Labs dynamic kconfig content"
@echo "cloud-config-aws - generates AWS dynamic kconfig content"
@echo "cloud-config-azure - generates Azure dynamic kconfig content"
@echo "cloud-config-gce - generates GCE dynamic kconfig content"
@echo "cloud-config-oci - generates OCI dynamic kconfig content"
@echo "cloud-config-datacrunch - generates DataCrunch dynamic kconfig content"
@echo "clean-cloud-config - removes all generated cloud kconfig files"
Expand All @@ -172,7 +201,7 @@ HELP_TARGETS += cloud-config-help
cloud-config:
$(Q)python3 scripts/generate_cloud_configs.py

clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws clean-cloud-config-azure clean-cloud-config-oci clean-cloud-config-datacrunch
clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws clean-cloud-config-azure clean-cloud-config-gce clean-cloud-config-oci clean-cloud-config-datacrunch
$(Q)echo "Cleaned all cloud provider dynamic Kconfig files."

cloud-list-all:
Expand All @@ -182,6 +211,7 @@ cloud-list-all:
PHONY += cloud-config clean-cloud-config cloud-config-help cloud-list-all default-cloud-kconfigs
PHONY += cloud-config-aws clean-cloud-config-aws
PHONY += cloud-config-azure clean-cloud-config-azure
PHONY += cloud-config-gce clean-cloud-config-gce
PHONY += cloud-config-datacrunch clean-cloud-config-datacrunch
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 @@ -193,6 +193,52 @@ def generate_azure_kconfig() -> bool:
return all_success


def generate_gce_kconfig() -> bool:
"""
Generate GCE 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)
gce_scripts_dir = os.path.join(project_root, "terraform", "gce", "scripts")
gce_kconfigs_dir = os.path.join(project_root, "terraform", "gce", "kconfigs")

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

all_success = True

for script_name, kconfig_file in scripts_to_run:
script_path = os.path.join(gce_scripts_dir, script_name)
output_path = os.path.join(gce_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 generate_oci_kconfig() -> bool:
"""
Generate OCI Kconfig files.
Expand Down Expand Up @@ -278,8 +324,13 @@ def process_azure():


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


def process_oci():
Expand Down
7 changes: 5 additions & 2 deletions terraform/gce/Kconfig
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
if TERRAFORM_GCE

menu "Resource Location"
source "terraform/gce/kconfigs/Kconfig.location"
source "terraform/gce/kconfigs/Kconfig.location.generated"
endmenu
menu "Compute"
source "terraform/gce/kconfigs/Kconfig.compute"
comment "Machine selection"
source "terraform/gce/kconfigs/Kconfig.machine.generated"
comment "OS image selection"
source "terraform/gce/kconfigs/Kconfig.image.generated"
endmenu
menu "Storage"
source "terraform/gce/kconfigs/Kconfig.storage"
Expand Down
111 changes: 0 additions & 111 deletions terraform/gce/kconfigs/Kconfig.compute

This file was deleted.

Loading
Loading