mirror of https://github.com/ipxe/ipxe.git
[cloud] Add ability to generate Dokuwiki table of AMI images
Add an option to generate the amilist.txt list of current AMI images as included in the EC2 documentation at https://ipxe.org/howto/ec2 Signed-off-by: Michael Brown <mcb30@ipxe.org>pull/373/head
parent
323af9ee84
commit
e994237c0b
|
@ -65,6 +65,12 @@ def import_image(region, name, architecture, image, public):
|
||||||
return image_id
|
return image_id
|
||||||
|
|
||||||
|
|
||||||
|
def launch_link(region, image_id):
|
||||||
|
"""Construct a web console launch link"""
|
||||||
|
return ("https://console.aws.amazon.com/ec2/v2/home?"
|
||||||
|
"region=%s#LaunchInstanceWizard:ami=%s" % (region, image_id))
|
||||||
|
|
||||||
|
|
||||||
# Parse command-line arguments
|
# Parse command-line arguments
|
||||||
parser = argparse.ArgumentParser(description="Import AWS EC2 image (AMI)")
|
parser = argparse.ArgumentParser(description="Import AWS EC2 image (AMI)")
|
||||||
parser.add_argument('--architecture', '-a', default='x86_64',
|
parser.add_argument('--architecture', '-a', default='x86_64',
|
||||||
|
@ -75,6 +81,8 @@ parser.add_argument('--public', '-p', action='store_true',
|
||||||
help="Make image public")
|
help="Make image public")
|
||||||
parser.add_argument('--region', '-r', action='append',
|
parser.add_argument('--region', '-r', action='append',
|
||||||
help="AWS region(s)")
|
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', help="iPXE disk image")
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
@ -95,6 +103,18 @@ with ThreadPoolExecutor(max_workers=len(args.region)) as executor:
|
||||||
results = {futures[future]: future.result()
|
results = {futures[future]: future.result()
|
||||||
for future in as_completed(futures)}
|
for future in as_completed(futures)}
|
||||||
|
|
||||||
|
# Construct Dokuwiki table
|
||||||
|
wikitab = ["^ AWS region ^ CPU architecture ^ AMI ID ^\n"] + list(
|
||||||
|
"| ''%s'' | ''%s'' | ''[[%s|%s]]'' |\n" % (
|
||||||
|
region,
|
||||||
|
args.architecture,
|
||||||
|
launch_link(region, results[region]),
|
||||||
|
results[region],
|
||||||
|
) for region in args.region)
|
||||||
|
if args.wiki:
|
||||||
|
with open(args.wiki, 'wt') as fh:
|
||||||
|
fh.writelines(wikitab)
|
||||||
|
|
||||||
# Show created images
|
# Show created images
|
||||||
for region in args.region:
|
for region in args.region:
|
||||||
print("%s: %s" % (region, results[region]))
|
print("%s: %s" % (region, results[region]))
|
||||||
|
|
Loading…
Reference in New Issue