Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python3-ec2imgutils for openSUSE:Factory checked in at 2022-06-01 17:34:49 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python3-ec2imgutils (Old) and /work/SRC/openSUSE:Factory/.python3-ec2imgutils.new.1548 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python3-ec2imgutils" Wed Jun 1 17:34:49 2022 rev:18 rq:980185 version:10.0.1 Changes: -------- --- /work/SRC/openSUSE:Factory/python3-ec2imgutils/python3-ec2imgutils.changes 2021-12-18 20:30:47.802260892 +0100 +++ /work/SRC/openSUSE:Factory/.python3-ec2imgutils.new.1548/python3-ec2imgutils.changes 2022-06-01 17:35:09.662776180 +0200 @@ -1,0 +2,16 @@ +Tue May 24 20:28:24 UTC 2022 - Robert Schweikert <rjsch...@suse.com> + +- Update to version 10.0.1 + + Follow up fix to (bsc#1199722) allow the user a choice of 2.0 and v2.0 as + tpm versions on the command line + +------------------------------------------------------------------- +Thu May 19 14:19:38 UTC 2022 - Robert Schweikert <rjsch...@suse.com> + +- Update to version 10.0.0 (bsc#1199722) + + Add --tpm-support as command line option and tpm_support to the API + to register images that support NitroTPM + + API change for ec2deprecateimg. It is now possible to deprecate + an image without providing a successor image. + +------------------------------------------------------------------- Old: ---- ec2imgutils-9.0.4.tar.bz2 New: ---- ec2imgutils-10.0.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python3-ec2imgutils.spec ++++++ --- /var/tmp/diff_new_pack.usScbe/_old 2022-06-01 17:35:10.046776634 +0200 +++ /var/tmp/diff_new_pack.usScbe/_new 2022-06-01 17:35:10.050776639 +0200 @@ -19,7 +19,7 @@ %define upstream_name ec2imgutils Name: python3-ec2imgutils -Version: 9.0.4 +Version: 10.0.1 Release: 0 Summary: Image management utilities for AWS EC2 License: GPL-3.0+ @@ -27,10 +27,10 @@ Url: https://github.com/SUSE-Enceladus/ec2imgutils Source0: %{upstream_name}-%{version}.tar.bz2 Requires: python3 -Requires: python3-boto3 >= 1.18.7 +Requires: python3-boto3 >= 1.22.11 Requires: python3-dateutil Requires: python3-paramiko -BuildRequires: python3-boto3 >= 1.18.7 +BuildRequires: python3-boto3 >= 1.22.11 BuildRequires: python3-dateutil BuildRequires: python3-setuptools BuildRequires: python-rpm-macros ++++++ ec2imgutils-9.0.4.tar.bz2 -> ec2imgutils-10.0.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/README.md new/ec2imgutils-10.0.1/README.md --- old/ec2imgutils-9.0.4/README.md 2021-11-03 14:51:59.432617680 +0100 +++ new/ec2imgutils-10.0.1/README.md 2022-05-24 22:27:25.522310684 +0200 @@ -30,9 +30,10 @@ Images are tagged with: -- Deprecated on -> today's date in YYYYMMDD format -- Removal date -> today's date plus the deprecation period specified -- Replacement image -> The AMI ID and name of the replacement image +- Deprecated on -> provided deprecation date or today's date (if no deprecation + date is provided) in YYYYMMDD format +- Removal date -> deprecation date plus the deprecation period specified +- Replacement image -> The AMI ID and name of the replacement image (Optional) The image set as the replacement is removed from the list of potential images to be deprecated before any matching takes place. Therefore, the @@ -42,7 +43,8 @@ #### Usage ``` -> ec2deprecateimg --account example --image-name-match v15 --image-virt-type hvm --replacement-name exampleimage_v16 +> ec2deprecateimg --account example --image-name-match v15 --image-virt-type hvm \ +--replacement-name exampleimage_v16 --deprecation_date 20220510 ``` See the [man pages](man/man1/ec2deprecateimg.1) for more information. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/ec2deprecateimg new/ec2imgutils-10.0.1/ec2deprecateimg --- old/ec2imgutils-9.0.4/ec2deprecateimg 2021-11-03 14:51:59.432617680 +0100 +++ new/ec2imgutils-10.0.1/ec2deprecateimg 2022-05-24 22:27:25.522310684 +0200 @@ -18,6 +18,7 @@ # along with ec2deprecateimg. If not, see <http://www.gnu.org/licenses/>. import argparse +import datetime import os import sys @@ -29,6 +30,19 @@ ) +# ---------------------------------------------------------------------------- +# Argument format validation functions +def valid_YYYYMMDD_date(s): + try: + if s: + datetime.datetime.strptime(s, "%Y%m%d") + return s + except ValueError: + msg = "not a valid date: {0:!r}".format(s) + raise argparse.ArgumentTypeError(msg) + + +# ---------------------------------------------------------------------------- # Set up command line argument parsing argparse = argparse.ArgumentParser(description='Deprecate images in EC2') argparse.add_argument( @@ -43,9 +57,19 @@ help='AWS access key (Optional)', metavar='AWS_ACCESS_KEY' ) +help_msg = 'The deprecation date, the date the image is considered ' +help_msg += 'deprecated. The default value is today\'s date (Optional)' +argparse.add_argument( + '--deprecation-date', + default='', + dest='depDate', + help=help_msg, + metavar='DEPRECATION_DATE', + type=valid_YYYYMMDD_date +) help_msg = 'The deprecation period, image will be tagged for removal ' -help_msg += 'on "now + deprecation perion", specified in months, default ' -help_msg += ' is 6 month (Optional)' +help_msg += 'on "deprecation date + deprecation period", specified in months, ' +help_msg += 'default is 6 month (Optional)' argparse.add_argument( '-d', '--deprecation-period', default=6, @@ -209,19 +233,6 @@ logger.error(error_msg) sys.exit(1) -# Explicit check required to to the group issue, see comment above -if ( - not args.replImgID and not - args.replImgName and not - args.replImgNameFrag and not - args.replImgNameMatch): - error_msg = 'ec2deprecateimg: error: one of the arguments ' - error_msg += '--replacement-id --replacement-name ' - error_msg += '--replacement-name-frag --replacement-name-match is required' - logger.error(error_msg) - sys.exit(1) - - config_file = os.path.expanduser(args.configFilePath) config = None if not os.path.isfile(config_file): @@ -269,9 +280,10 @@ # Collect all the errors to be displayed later errors = {} - -deprecator = ec2depimg.EC2DeprecateImg( +try: + deprecator = ec2depimg.EC2DeprecateImg( access_key=access_key, + deprecation_date=args.depDate, deprecation_period=args.depTime, deprecation_image_id=args.depImgID, deprecation_image_name=args.depImgName, @@ -286,7 +298,10 @@ replacement_image_name_match=args.replImgNameMatch, secret_key=secret_key, log_callback=logger -) + ) +except EC2DeprecateImgException as e: + logger.exception(e) + sys.exit(1) for region in regions: deprecator.set_region(region) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/ec2uploadimg new/ec2imgutils-10.0.1/ec2uploadimg --- old/ec2imgutils-9.0.4/ec2uploadimg 2021-11-03 14:51:59.440617620 +0100 +++ new/ec2imgutils-10.0.1/ec2uploadimg 2022-05-24 22:27:25.522310684 +0200 @@ -1,7 +1,7 @@ #!/usr/bin/python3 -# Copyright 2021 SUSE LLC +# Copyright 2022 SUSE LLC # # This file is part of ec2imgutils # @@ -229,6 +229,13 @@ type=int ) argparse.add_argument( + '--tpm-support', + dest='tpm', + help='The image supports NitroTPM, supported value 2.0/v2.0 (Optional)', + choices=['', '2.0', 'v2.0'], + metavar='TPM_SUPPORT' +) +argparse.add_argument( '-t', '--type', dest='instType', help='Instance type to use to upload image (Optional)', @@ -408,6 +415,14 @@ ) sys.exit(1) +tpm_boot_options = ['uefi'] +if args.tpm and args.bootMode not in tpm_boot_options: + logger.error( + 'TPM can only be set with --boot-mode set to %s' % str( + tpm_boot_options) + ) + sys.exit(1) + root_volume_size = 10 if args.rootVolSize: root_volume_size = args.rootVolSize @@ -668,7 +683,8 @@ vpc_subnet_id=vpc_subnet_id, wait_count=args.waitCount, log_callback=logger, - boot_mode=args.bootMode + boot_mode=args.bootMode, + tpm_support=args.tpm ) if args.snapOnly: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/lib/ec2imgutils/VERSION new/ec2imgutils-10.0.1/lib/ec2imgutils/VERSION --- old/ec2imgutils-9.0.4/lib/ec2imgutils/VERSION 2021-11-03 14:51:59.424617738 +0100 +++ new/ec2imgutils-10.0.1/lib/ec2imgutils/VERSION 2022-05-24 22:27:25.522310684 +0200 @@ -1 +1 @@ -9.0.4 +10.0.1 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/lib/ec2imgutils/ec2deprecateimg.py new/ec2imgutils-10.0.1/lib/ec2imgutils/ec2deprecateimg.py --- old/ec2imgutils-9.0.4/lib/ec2imgutils/ec2deprecateimg.py 2021-11-03 14:51:59.424617738 +0100 +++ new/ec2imgutils-10.0.1/lib/ec2imgutils/ec2deprecateimg.py 2022-05-24 22:27:25.522310684 +0200 @@ -31,6 +31,7 @@ def __init__( self, access_key=None, + deprecation_date='', deprecation_period=6, deprecation_image_id=None, deprecation_image_name=None, @@ -67,10 +68,11 @@ self.replacement_image_name_fragment = replacement_image_name_fragment self.replacement_image_name_match = replacement_image_name_match self.secret_key = secret_key - - self._set_deprecation_date() - self._set_deletion_date() - + try: + self._set_deprecation_date(deprecation_date) + self._set_deletion_date() + except Exception: + raise self.replacement_image_tag = None # --------------------------------------------------------------------- @@ -173,17 +175,30 @@ # --------------------------------------------------------------------- def _set_deletion_date(self): - """Set the date when the deprecation perios expires""" - now = datetime.datetime.now() - expire = now + dateutil.relativedelta.relativedelta( + """Set the date when the deprecation period expires""" + dep_date = datetime.datetime.strptime(self.deprecation_date, '%Y%m%d') + expire = dep_date + dateutil.relativedelta.relativedelta( months=+self.deprecation_period) self.deletion_date = self._format_date(expire) # --------------------------------------------------------------------- - def _set_deprecation_date(self): - """Set the deprecation day in the YYYYMMDD format""" - now = datetime.datetime.now() - self.deprecation_date = self._format_date(now) + def _set_deprecation_date(self, deprecation_date=''): + """Set the deprecation date provided in the YYYYMMDD format""" + dep_date = None + if deprecation_date: + try: + dep_date = datetime.datetime.strptime( + deprecation_date, + '%Y%m%d' + ) + self.deprecation_date = deprecation_date + except Exception as e: + msg = 'The deprecation date provided, "%s", is not valid.' \ + % deprecation_date + raise EC2DeprecateImgException(msg) from e + else: + dep_date = datetime.datetime.now() + self.deprecation_date = self._format_date(dep_date) # --------------------------------------------------------------------- def _set_replacement_image_info(self): @@ -203,9 +218,9 @@ condition = self.replacement_image_name_match images = self._find_images_by_name_regex_match(condition) else: - msg = 'No replacement image condition set. Should not reach ' - msg += 'this point.' - raise EC2DeprecateImgException(msg) + # Set image tag to empty string if no replacement image provided + self.replacement_image_tag = '' + return if not images: msg = 'Replacement image not found, "%s" ' % condition @@ -235,10 +250,13 @@ self.log.debug('Deprecating images in region: {}'.format(self.region)) self.log.debug('\tDeprecated on {}'.format(self.deprecation_date)) - self.log.debug('Removal date {}'.format(self.deletion_date)) - self.log.debug( - 'Replacement image {}'.format(self.replacement_image_tag) - ) + self.log.debug('\tRemoval date {}'.format(self.deletion_date)) + if self.replacement_image_tag: + self.log.debug( + '\tReplacement image {}'.format(self.replacement_image_tag) + ) + else: + self.log.debug("\tNo replacement image provided") ec2 = self._connect() for image in images: @@ -260,15 +278,18 @@ 'Key': 'Removal date', 'Value': self.deletion_date } - replacement_image_data = { - 'Key': 'Replacement image', - 'Value': self.replacement_image_tag - } tags = [ deprecated_on_data, removal_date_data, - replacement_image_data ] + + if self.replacement_image_tag: + replacement_image_data = { + 'Key': 'Replacement image', + 'Value': self.replacement_image_tag + } + tags.append(replacement_image_data) + ec2.create_tags( Resources=[image['ImageId']], Tags=tags ) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/lib/ec2imgutils/ec2uploadimg.py new/ec2imgutils-10.0.1/lib/ec2imgutils/ec2uploadimg.py --- old/ec2imgutils-9.0.4/lib/ec2imgutils/ec2uploadimg.py 2021-11-03 14:51:59.424617738 +0100 +++ new/ec2imgutils-10.0.1/lib/ec2imgutils/ec2uploadimg.py 2022-05-24 22:27:25.522310684 +0200 @@ -61,7 +61,8 @@ wait_count=1, log_level=logging.INFO, log_callback=None, - boot_mode=None + boot_mode=None, + tpm_support=None ): EC2ImgUtils.__init__( self, @@ -92,6 +93,7 @@ self.ssh_key_pair_name = ssh_key_pair_name self.ssh_key_private_key_file = ssh_key_private_key_file self.ssh_timeout = ssh_timeout + self.tpm = tpm_support self.use_grub2 = use_grub2 self.use_private_ip = use_private_ip self.vpc_subnet_id = vpc_subnet_id @@ -110,6 +112,16 @@ self.storage_volume_size = 2 * self.root_volume_size self.aborted = False + if sriov_type and sriov_type != 'simple': + raise EC2UploadImgException( + 'sriov_type can only be None or simple' + ) + tpm_versions = ['2.0', 'v2.0'] + if tpm_support and tpm_support not in tpm_versions: + raise EC2UploadImgException( + 'tpm_support must be one of %s' % str(tpm_versions) + ) + def abort(self): """ Set the abort flag to take appropriate action and stop image creation. @@ -873,6 +885,11 @@ register_args['KernelId'] = self.bootkernel if self.sriov_type: register_args['SriovNetSupport'] = self.sriov_type + if self.tpm: + tpm_version = self.tpm + if not tpm_version.startswith('v'): + tpm_version = 'v%s' % tpm_version + register_args['TpmSupport'] = tpm_version ami = self._connect().register_image(**register_args) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/man/man1/ec2deprecateimg.1 new/ec2imgutils-10.0.1/man/man1/ec2deprecateimg.1 --- old/ec2imgutils-9.0.4/man/man1/ec2deprecateimg.1 2021-11-03 14:51:59.432617680 +0100 +++ new/ec2imgutils-10.0.1/man/man1/ec2deprecateimg.1 2022-05-24 22:27:25.522310684 +0200 @@ -14,9 +14,10 @@ sticky, i.e. not visible to others if the image is shared. Images are tagged with: -- Deprecated on -> today's date in YYYYMMDD format -- Removal date -> today's date plus the deprecation period specified -- Replacement image -> The AMI ID and name of the replacement image +- Deprecated on -> provided deprecation date (or today's date if no value +provided) in YYYYMMDD format +- Removal date -> deprecation date plus the deprecation period specified +- Replacement image -> The AMI ID and name of the replacement image(optional) In EC2 a deprecated image is set into a state that makes it invisible to new users. This can be considered equivalent to a deletion. As such the tool @@ -55,11 +56,14 @@ with the .I access_key_id in the configuration file. +.IP "--deprecation-date YYYYMMDD" +Specifies the date when the image is considered deprecated. This parameter is +optional and if it's not provided it will default to the date on which the +program is executed. .IP "-d --deprecation-period NUMBER_OF_MONTHS" Specifies the number of months this image will be considered deprecated. After the deprecation period expires the image may be removed. The deprecation time -is added to the date on which the program is executed and forms the value for -the +is added to the deprecation date and forms the value for the .I Removal date tag in the format .I YYYYMMDD. @@ -135,7 +139,7 @@ .IR --replacement-name-frag , or .IR --replacement-name-match , -must be specified. +can be specified(optional). .IP "--replacement-name IMAGE_NAME" Specify the name of the image considered to be the replacement for the image(s) that are being deprecated. The option is mutually exclusive @@ -152,7 +156,7 @@ .IR --replacement-name-frag , or .IR --replacement-name-match , -must be specified. +can be specified(optional). .IP "--replacement-name-frag IMAGE_NAME_FRAGMENT" Specify a section of an image name to be considered for the replacement image. This option is mutually exclusive with @@ -171,7 +175,7 @@ .IR --replacement-name-frag , or .IR --replacement-name-match , -must be specified. +can be specified(optional). .IP "--replacement-name-match REGEX" Specify a regular expression to match an image name to be considered for the replacement image. This option is mutually exclusive with @@ -190,7 +194,7 @@ .IR --replacement-name-frag , or .IR --replacement-name-match , -must be specified. +can be specified(optional). .IP "-r --regions EC2_REGIONS" A comma separated list of Amazon EC2 regions, or a single region. If no region argument is specified all EC2 connected regions will be processed. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-9.0.4/man/man1/ec2uploadimg.1 new/ec2imgutils-10.0.1/man/man1/ec2uploadimg.1 --- old/ec2imgutils-9.0.4/man/man1/ec2uploadimg.1 2021-11-03 14:51:59.432617680 +0100 +++ new/ec2imgutils-10.0.1/man/man1/ec2uploadimg.1 2022-05-24 22:27:25.522310684 +0200 @@ -169,6 +169,16 @@ .IP "--ssh-timeout SSH_TIME_OUT" Specifies the amount of time to wait in seconds to establish an SSH connection with the helper instance. +.IP "--tpm-support" +Optionally specify the version of the TPM implementation the OS in the image +supports. This option can only be used if +.I boot-mode +is set to a value other than +.I bios. +Accepted values are +.I 2.0 +alternatively prefixed with a +.I "v". .IP "-t --type AWS_UPLOAD_INST_TYPE" Specifies the instance type to launch for the instance being used to upload the image. This value overrides the value given with the