Skip to content

Commit f752039

Browse files
authored
Merge pull request #76 from linux-kdevops/cel/gce-dynamic-kconfig
Add "make cloud-config-gce"
2 parents dd6a35d + e7a39eb commit f752039

58 files changed

Lines changed: 8297 additions & 1830 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ terraform/azure/kconfigs/Kconfig.location.generated
132132
terraform/azure/kconfigs/Kconfig.size.generated
133133
terraform/azure/scripts/__pycache__/
134134

135+
terraform/gce/kconfigs/Kconfig.image.generated
136+
terraform/gce/kconfigs/Kconfig.location.generated
137+
terraform/gce/kconfigs/Kconfig.machine.generated
138+
terraform/gce/scripts/__pycache__/
139+
135140
terraform/oci/kconfigs/Kconfig.image.generated
136141
terraform/oci/kconfigs/Kconfig.location.generated
137142
terraform/oci/kconfigs/Kconfig.shape.generated

scripts/dynamic-cloud-kconfig.Makefile

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,19 @@ AZURE_KCONFIG_SIZE_DEFAULT := $(AZURE_KCONFIG_DIR)/Kconfig.size.default
4343

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

46+
# GCE dynamic configuration
47+
GCE_KCONFIG_DIR := terraform/gce/kconfigs
48+
GCE_KCONFIG_IMAGE := $(GCE_KCONFIG_DIR)/Kconfig.image.generated
49+
GCE_KCONFIG_LOCATION := $(GCE_KCONFIG_DIR)/Kconfig.location.generated
50+
GCE_KCONFIG_MACHINE := $(GCE_KCONFIG_DIR)/Kconfig.machine.generated
51+
52+
# GCE default files (tracked in git, provide sensible defaults)
53+
GCE_KCONFIG_IMAGE_DEFAULT := $(GCE_KCONFIG_DIR)/Kconfig.image.default
54+
GCE_KCONFIG_LOCATION_DEFAULT := $(GCE_KCONFIG_DIR)/Kconfig.location.default
55+
GCE_KCONFIG_MACHINE_DEFAULT := $(GCE_KCONFIG_DIR)/Kconfig.machine.default
56+
57+
GCE_KCONFIGS := $(GCE_KCONFIG_IMAGE) $(GCE_KCONFIG_LOCATION) $(GCE_KCONFIG_MACHINE)
58+
4659
# OCI dynamic configuration
4760
OCI_KCONFIG_DIR := terraform/oci/kconfigs
4861
OCI_KCONFIG_IMAGE := $(OCI_KCONFIG_DIR)/Kconfig.image.generated
@@ -70,7 +83,7 @@ DATACRUNCH_KCONFIG_LOCATION_DEFAULT := $(DATACRUNCH_KCONFIG_DIR)/Kconfig.locatio
7083
DATACRUNCH_KCONFIGS := $(DATACRUNCH_KCONFIG_COMPUTE) $(DATACRUNCH_KCONFIG_IMAGES) $(DATACRUNCH_KCONFIG_LOCATION)
7184

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

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

109+
# Ensure GCE generated files exist with sensible defaults
110+
# Copies from .default files if .generated files don't exist
111+
dynamic_gce_kconfig_touch:
112+
$(Q)test -f $(GCE_KCONFIG_IMAGE) || cp $(GCE_KCONFIG_IMAGE_DEFAULT) $(GCE_KCONFIG_IMAGE)
113+
$(Q)test -f $(GCE_KCONFIG_LOCATION) || cp $(GCE_KCONFIG_LOCATION_DEFAULT) $(GCE_KCONFIG_LOCATION)
114+
$(Q)test -f $(GCE_KCONFIG_MACHINE) || cp $(GCE_KCONFIG_MACHINE_DEFAULT) $(GCE_KCONFIG_MACHINE)
115+
96116
# Ensure OCI generated files exist with sensible defaults
97117
# Copies from .default files if .generated files don't exist
98118
dynamic_oci_kconfig_touch:
@@ -107,11 +127,11 @@ dynamic_datacrunch_kconfig_touch:
107127
$(Q)test -f $(DATACRUNCH_KCONFIG_IMAGES) || cp $(DATACRUNCH_KCONFIG_IMAGES_DEFAULT) $(DATACRUNCH_KCONFIG_IMAGES)
108128
$(Q)test -f $(DATACRUNCH_KCONFIG_LOCATION) || cp $(DATACRUNCH_KCONFIG_LOCATION_DEFAULT) $(DATACRUNCH_KCONFIG_LOCATION)
109129

110-
DYNAMIC_KCONFIG += dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_oci_kconfig_touch dynamic_datacrunch_kconfig_touch
130+
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
111131

112132
# User-facing target to populate cloud kconfigs with defaults
113133
# This is called automatically before menuconfig, but can be run manually
114-
default-cloud-kconfigs: dynamic_lambdalabs_kconfig_touch dynamic_aws_kconfig_touch dynamic_azure_kconfig_touch dynamic_oci_kconfig_touch dynamic_datacrunch_kconfig_touch
134+
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
115135

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

148+
# GCE targets use --provider argument for efficiency
149+
cloud-config-gce:
150+
$(Q)python3 scripts/generate_cloud_configs.py --provider gce
151+
128152
# OCI targets use --provider argument for efficiency
129153
cloud-config-oci:
130154
$(Q)python3 scripts/generate_cloud_configs.py --provider oci
@@ -145,6 +169,10 @@ clean-cloud-config-aws:
145169
clean-cloud-config-azure:
146170
$(Q)rm -f $(AZURE_KCONFIGS)
147171

172+
# Clean GCE generated files
173+
clean-cloud-config-gce:
174+
$(Q)rm -f $(GCE_KCONFIGS)
175+
148176
# Clean OCI generated files
149177
clean-cloud-config-oci:
150178
$(Q)rm -f $(OCI_KCONFIGS)
@@ -153,7 +181,7 @@ clean-cloud-config-oci:
153181
clean-cloud-config-datacrunch:
154182
$(Q)rm -f $(DATACRUNCH_KCONFIGS)
155183

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

158186
cloud-config-help:
159187
@echo "Cloud-specific dynamic kconfig targets:"
@@ -162,6 +190,7 @@ cloud-config-help:
162190
@echo "cloud-config-lambdalabs - generates Lambda Labs dynamic kconfig content"
163191
@echo "cloud-config-aws - generates AWS dynamic kconfig content"
164192
@echo "cloud-config-azure - generates Azure dynamic kconfig content"
193+
@echo "cloud-config-gce - generates GCE dynamic kconfig content"
165194
@echo "cloud-config-oci - generates OCI dynamic kconfig content"
166195
@echo "cloud-config-datacrunch - generates DataCrunch dynamic kconfig content"
167196
@echo "clean-cloud-config - removes all generated cloud kconfig files"
@@ -172,7 +201,7 @@ HELP_TARGETS += cloud-config-help
172201
cloud-config:
173202
$(Q)python3 scripts/generate_cloud_configs.py
174203

175-
clean-cloud-config: clean-cloud-config-lambdalabs clean-cloud-config-aws clean-cloud-config-azure clean-cloud-config-oci clean-cloud-config-datacrunch
204+
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
176205
$(Q)echo "Cleaned all cloud provider dynamic Kconfig files."
177206

178207
cloud-list-all:
@@ -182,6 +211,7 @@ cloud-list-all:
182211
PHONY += cloud-config clean-cloud-config cloud-config-help cloud-list-all default-cloud-kconfigs
183212
PHONY += cloud-config-aws clean-cloud-config-aws
184213
PHONY += cloud-config-azure clean-cloud-config-azure
214+
PHONY += cloud-config-gce clean-cloud-config-gce
185215
PHONY += cloud-config-datacrunch clean-cloud-config-datacrunch
186216
PHONY += cloud-config-lambdalabs clean-cloud-config-lambdalabs
187217
PHONY += cloud-config-oci clean-cloud-config-oci

scripts/generate_cloud_configs.py

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,52 @@ def generate_azure_kconfig() -> bool:
193193
return all_success
194194

195195

196+
def generate_gce_kconfig() -> bool:
197+
"""
198+
Generate GCE Kconfig files.
199+
Returns True on success, False on failure.
200+
"""
201+
script_dir = os.path.dirname(os.path.abspath(__file__))
202+
project_root = os.path.dirname(script_dir)
203+
gce_scripts_dir = os.path.join(project_root, "terraform", "gce", "scripts")
204+
gce_kconfigs_dir = os.path.join(project_root, "terraform", "gce", "kconfigs")
205+
206+
# Define the script-to-output mapping
207+
scripts_to_run = [
208+
("gen_kconfig_image", "Kconfig.image.generated"),
209+
("gen_kconfig_location", "Kconfig.location.generated"),
210+
("gen_kconfig_machine", "Kconfig.machine.generated"),
211+
]
212+
213+
all_success = True
214+
215+
for script_name, kconfig_file in scripts_to_run:
216+
script_path = os.path.join(gce_scripts_dir, script_name)
217+
output_path = os.path.join(gce_kconfigs_dir, kconfig_file)
218+
219+
# Run the script and capture its output
220+
result = subprocess.run(
221+
[script_path],
222+
capture_output=True,
223+
text=True,
224+
check=False,
225+
)
226+
227+
if result.returncode == 0:
228+
# Write the output to the corresponding Kconfig file
229+
try:
230+
with open(output_path, "w") as f:
231+
f.write(result.stdout)
232+
except IOError as e:
233+
print(f"Error writing {kconfig_file}: {e}", file=sys.stderr)
234+
all_success = False
235+
else:
236+
print(f"Error running {script_name}: {result.stderr}", file=sys.stderr)
237+
all_success = False
238+
239+
return all_success
240+
241+
196242
def generate_oci_kconfig() -> bool:
197243
"""
198244
Generate OCI Kconfig files.
@@ -278,8 +324,13 @@ def process_azure():
278324

279325

280326
def process_gce():
281-
"""Process GCE configuration (placeholder)."""
282-
print("⚠ GCE: Dynamic configuration not yet implemented")
327+
"""Process GCE configuration."""
328+
kconfig_generated = generate_gce_kconfig()
329+
if kconfig_generated:
330+
print("✓ GCE: Kconfig files generated successfully")
331+
else:
332+
print("⚠ GCE: Failed to generate Kconfig files - using defaults")
333+
print()
283334

284335

285336
def process_oci():

terraform/gce/Kconfig

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
if TERRAFORM_GCE
22

33
menu "Resource Location"
4-
source "terraform/gce/kconfigs/Kconfig.location"
4+
source "terraform/gce/kconfigs/Kconfig.location.generated"
55
endmenu
66
menu "Compute"
7-
source "terraform/gce/kconfigs/Kconfig.compute"
7+
comment "Machine selection"
8+
source "terraform/gce/kconfigs/Kconfig.machine.generated"
9+
comment "OS image selection"
10+
source "terraform/gce/kconfigs/Kconfig.image.generated"
811
endmenu
912
menu "Storage"
1013
source "terraform/gce/kconfigs/Kconfig.storage"

terraform/gce/kconfigs/Kconfig.compute

Lines changed: 0 additions & 111 deletions
This file was deleted.

0 commit comments

Comments
 (0)