Skip to content

Commit 418ddf1

Browse files
committed
scripts: Add --provider argument to generate_cloud_configs.py
This adds command-line argument support to allow generating Kconfig menus for specific cloud providers instead of always processing all providers. The script now accepts an optional --provider argument that can be set to lambdalabs, aws, azure, gce, or oci to generate configuration for only that provider. When no --provider argument is specified, the script maintains backward compatibility by generating configs for all providers. This improves the user experience when working with a specific cloud provider and reduces unnecessary API calls and processing time. Generated-by: Claude AI Signed-off-by: Chuck Lever <[email protected]>
1 parent 4342500 commit 418ddf1

File tree

1 file changed

+70
-12
lines changed

1 file changed

+70
-12
lines changed

scripts/generate_cloud_configs.py

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111
import subprocess
1212
import json
13+
import argparse
1314

1415

1516
def generate_lambdalabs_kconfig() -> bool:
@@ -146,16 +147,12 @@ def generate_aws_kconfig() -> bool:
146147
return all_success
147148

148149

149-
def main():
150-
"""Main function to generate cloud configurations."""
151-
print("Cloud Provider Configuration Summary")
152-
print("=" * 60)
153-
print()
154-
155-
# Lambda Labs - Generate Kconfig files first
150+
def process_lambdalabs():
151+
"""Process Lambda Labs configuration."""
152+
# Generate Kconfig files first
156153
kconfig_generated = generate_lambdalabs_kconfig()
157154

158-
# Lambda Labs - Get summary
155+
# Get summary
159156
success, summary = get_lambdalabs_summary()
160157
if success:
161158
print(f"✓ {summary}")
@@ -167,23 +164,84 @@ def main():
167164
print(f"⚠ {summary}")
168165
print()
169166

170-
# AWS - Generate Kconfig files
167+
168+
def process_aws():
169+
"""Process AWS configuration."""
171170
kconfig_generated = generate_aws_kconfig()
172171
if kconfig_generated:
173172
print("✓ AWS: Kconfig files generated successfully")
174173
else:
175174
print("⚠ AWS: Failed to generate Kconfig files - using defaults")
176175
print()
177176

178-
# Azure (placeholder - not implemented)
177+
178+
def process_azure():
179+
"""Process Azure configuration (placeholder)."""
179180
print("⚠ Azure: Dynamic configuration not yet implemented")
180181

181-
# GCE (placeholder - not implemented)
182+
183+
def process_gce():
184+
"""Process GCE configuration (placeholder)."""
182185
print("⚠ GCE: Dynamic configuration not yet implemented")
183186

184-
# OCI (placeholder - not implemented)
187+
188+
def process_oci():
189+
"""Process OCI configuration (placeholder)."""
185190
print("⚠ OCI: Dynamic configuration not yet implemented")
186191

192+
193+
def main():
194+
"""Main function to generate cloud configurations."""
195+
parser = argparse.ArgumentParser(
196+
description="Generate dynamic cloud configurations for supported providers",
197+
formatter_class=argparse.RawDescriptionHelpFormatter,
198+
epilog="""
199+
Examples:
200+
%(prog)s # Generate configs for all providers
201+
%(prog)s --provider lambdalabs # Generate configs for Lambda Labs only
202+
%(prog)s --provider aws # Generate configs for AWS only
203+
%(prog)s --provider azure # Generate configs for Azure only
204+
205+
Supported providers: lambdalabs, aws, azure, gce, oci
206+
""",
207+
)
208+
209+
parser.add_argument(
210+
"--provider",
211+
choices=["lambdalabs", "aws", "azure", "gce", "oci"],
212+
help="Generate configuration for a specific cloud provider only",
213+
)
214+
215+
args = parser.parse_args()
216+
217+
# Provider dispatch table
218+
providers = {
219+
"lambdalabs": process_lambdalabs,
220+
"aws": process_aws,
221+
"azure": process_azure,
222+
"gce": process_gce,
223+
"oci": process_oci,
224+
}
225+
226+
print("Cloud Provider Configuration Summary")
227+
print("=" * 60)
228+
print()
229+
230+
# If a specific provider is requested, only process that one
231+
if args.provider:
232+
if args.provider in providers:
233+
providers[args.provider]()
234+
else:
235+
print(f"Error: Unknown provider '{args.provider}'", file=sys.stderr)
236+
sys.exit(1)
237+
else:
238+
# Process all providers
239+
process_lambdalabs()
240+
process_aws()
241+
process_azure()
242+
process_gce()
243+
process_oci()
244+
187245
print()
188246
print("Note: Dynamic configurations query real-time availability")
189247
print("Run 'make menuconfig' to configure your cloud provider")

0 commit comments

Comments
 (0)