summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorMichael Brown2021-05-01 22:33:38 +0200
committerMichael Brown2021-05-01 22:36:19 +0200
commite994237c0b7de6e4f17cc1a1c740043c553d2bdf (patch)
treec66f09ae5610e5613652acdbab16f0d794f768ac /contrib
parent[settings] Add --timeout option to "read" command (diff)
downloadipxe-e994237c0b7de6e4f17cc1a1c740043c553d2bdf.tar.gz
ipxe-e994237c0b7de6e4f17cc1a1c740043c553d2bdf.tar.xz
ipxe-e994237c0b7de6e4f17cc1a1c740043c553d2bdf.zip
[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>
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/cloud/aws-import20
1 files changed, 20 insertions, 0 deletions
diff --git a/contrib/cloud/aws-import b/contrib/cloud/aws-import
index 9ee53e70..a93a0084 100755
--- a/contrib/cloud/aws-import
+++ b/contrib/cloud/aws-import
@@ -65,6 +65,12 @@ def import_image(region, name, architecture, image, public):
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
parser = argparse.ArgumentParser(description="Import AWS EC2 image (AMI)")
parser.add_argument('--architecture', '-a', default='x86_64',
@@ -75,6 +81,8 @@ parser.add_argument('--public', '-p', action='store_true',
help="Make image public")
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")
args = parser.parse_args()
@@ -95,6 +103,18 @@ with ThreadPoolExecutor(max_workers=len(args.region)) as executor:
results = {futures[future]: future.result()
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
for region in args.region:
print("%s: %s" % (region, results[region]))