diff options
author | Michael Brown <mcb30@ipxe.org> | 2021-05-02 12:23:00 +0100 |
---|---|---|
committer | Michael Brown <mcb30@ipxe.org> | 2021-05-02 12:38:03 +0100 |
commit | 106f4c539182b4a92b8a427b637497e6da19bd85 (patch) | |
tree | c88f124f121de4e3f6ac31678cc4d59f5f4e781e | |
parent | 1dfc05622d183213c55b49c3ea4f4fd5c7bd6253 (diff) | |
download | ipxe-106f4c539182b4a92b8a427b637497e6da19bd85.tar.gz |
[cloud] Allow multiple images to be imported simultaneously
Allow both x86_64 and arm64 images to be imported in a single import
command, thereby allowing for e.g.
make CONFIG=cloud EMBED=config/cloud/aws.ipxe bin/ipxe.usb
make CONFIG=cloud EMBED=config/cloud/aws.ipxe \
CROSS=aarch64-linux-gnu- bin-arm64-efi/ipxe.usb
../contrib/cloud/aws-import -w amilist.txt -p \
bin/ipxe.usb bin-arm64-efi/ipxe.usb
This simplifies the process of generating a single amilist.txt file
for inclusion in the documentation at https://ipxe.org/howto/ec2
Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rwxr-xr-x | contrib/cloud/aws-import | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/contrib/cloud/aws-import b/contrib/cloud/aws-import index 4e0fafd66..eef4302d5 100755 --- a/contrib/cloud/aws-import +++ b/contrib/cloud/aws-import @@ -92,33 +92,31 @@ parser.add_argument('--region', '-r', action='append', help="AWS region(s)") parser.add_argument('--wiki', '-w', metavar='FILE', help="Generate Dokuwiki table") -parser.add_argument('image', help="iPXE disk image") +parser.add_argument('image', nargs='+', help="iPXE disk image") args = parser.parse_args() -# Detect CPU architecture -architecture = detect_architecture(args.image) +# Detect CPU architectures +architectures = {image: detect_architecture(image) for image in args.image} # Use default name if none specified if not args.name: - args.name = 'iPXE (%s %s)' % ( - date.today().strftime('%Y-%m-%d'), - architecture, - ) + args.name = 'iPXE (%s)' % date.today().strftime('%Y-%m-%d') # Use all regions if none specified if not args.region: args.region = sorted(x['RegionName'] for x in boto3.client('ec2').describe_regions()['Regions']) -# Use one thread per region to maximise parallelism -with ThreadPoolExecutor(max_workers=len(args.region)) as executor: +# Use one thread per import to maximise parallelism +imports = [(region, image) for region in args.region for image in args.image] +with ThreadPoolExecutor(max_workers=len(imports)) as executor: futures = {executor.submit(import_image, region=region, name=args.name, - architecture=architecture, - image=args.image, - public=args.public): region - for region in args.region} + architecture=architectures[image], + image=image, + public=args.public): (region, image) + for region, image in imports} results = {futures[future]: future.result() for future in as_completed(futures)} @@ -126,14 +124,16 @@ with ThreadPoolExecutor(max_workers=len(args.region)) as executor: wikitab = ["^ AWS region ^ CPU architecture ^ AMI ID ^\n"] + list( "| ''%s'' | ''%s'' | ''[[%s|%s]]'' |\n" % ( region, - architecture, - launch_link(region, results[region]), - results[region], - ) for region in args.region) + architectures[image], + launch_link(region, results[(region, image)]), + results[(region, image)], + ) for region, image in imports) if args.wiki: with open(args.wiki, 'wt') as fh: fh.writelines(wikitab) # Show created images -for region in args.region: - print("%s %s %s" % (region, architecture, results[region])) +for region, image in imports: + print("%s %s %s %s" % ( + region, image, architectures[image], results[(region, image)] + )) |