Mercurial > public > mercurial-scm > hg-stable
comparison contrib/automation/hgautomation/aws.py @ 42648:d80edcb0b30c stable
automation: make Windows base image name configurable
Since automation broke in the middle of the 5.0 release cycle,
there's a good chance it will break again in the future. While
a robust solution might be to search for all available images and
choose the newest one, it does seem useful to be able to explicitly
choose the name of the image to find and use so users can opt in
to using a different image.
This commit implements that functionality.
Differential Revision: https://phab.mercurial-scm.org/D6673
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 22 Jul 2019 19:06:20 -0700 |
parents | 8804aa6c07a0 |
children | 3e3fb15bfeea |
comparison
equal
deleted
inserted
replaced
42647:8804aa6c07a0 | 42648:d80edcb0b30c |
---|---|
1030 finally: | 1030 finally: |
1031 for instance in instances: | 1031 for instance in instances: |
1032 instance.ssh_client.close() | 1032 instance.ssh_client.close() |
1033 | 1033 |
1034 | 1034 |
1035 def ensure_windows_dev_ami(c: AWSConnection, prefix='hg-'): | 1035 def ensure_windows_dev_ami(c: AWSConnection, prefix='hg-', |
1036 base_image_name=WINDOWS_BASE_IMAGE_NAME): | |
1036 """Ensure Windows Development AMI is available and up-to-date. | 1037 """Ensure Windows Development AMI is available and up-to-date. |
1037 | 1038 |
1038 If necessary, a modern AMI will be built by starting a temporary EC2 | 1039 If necessary, a modern AMI will be built by starting a temporary EC2 |
1039 instance and bootstrapping it. | 1040 instance and bootstrapping it. |
1040 | 1041 |
1048 ec2resource = c.ec2resource | 1049 ec2resource = c.ec2resource |
1049 ssmclient = c.session.client('ssm') | 1050 ssmclient = c.session.client('ssm') |
1050 | 1051 |
1051 name = '%s%s' % (prefix, 'windows-dev') | 1052 name = '%s%s' % (prefix, 'windows-dev') |
1052 | 1053 |
1053 image = find_image(ec2resource, AMAZON_ACCOUNT_ID, WINDOWS_BASE_IMAGE_NAME) | 1054 image = find_image(ec2resource, AMAZON_ACCOUNT_ID, base_image_name) |
1054 | 1055 |
1055 config = { | 1056 config = { |
1056 'BlockDeviceMappings': [ | 1057 'BlockDeviceMappings': [ |
1057 { | 1058 { |
1058 'DeviceName': '/dev/sda1', | 1059 'DeviceName': '/dev/sda1', |
1101 fingerprint = resolve_fingerprint({ | 1102 fingerprint = resolve_fingerprint({ |
1102 'instance_config': config, | 1103 'instance_config': config, |
1103 'user_data': WINDOWS_USER_DATA, | 1104 'user_data': WINDOWS_USER_DATA, |
1104 'initial_bootstrap': WINDOWS_BOOTSTRAP_POWERSHELL, | 1105 'initial_bootstrap': WINDOWS_BOOTSTRAP_POWERSHELL, |
1105 'bootstrap_commands': commands, | 1106 'bootstrap_commands': commands, |
1107 'base_image_name': base_image_name, | |
1106 }) | 1108 }) |
1107 | 1109 |
1108 existing_image = find_and_reconcile_image(ec2resource, name, fingerprint) | 1110 existing_image = find_and_reconcile_image(ec2resource, name, fingerprint) |
1109 | 1111 |
1110 if existing_image: | 1112 if existing_image: |