Script 'mail_helper' called by obssrc Hello community, here is the log from the commit of package python-ec2imgutils for openSUSE:Factory checked in at 2026-04-08 17:15:28 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-ec2imgutils (Old) and /work/SRC/openSUSE:Factory/.python-ec2imgutils.new.21863 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-ec2imgutils" Wed Apr 8 17:15:28 2026 rev:4 rq:1345040 version:10.0.5 Changes: -------- --- /work/SRC/openSUSE:Factory/python-ec2imgutils/python-ec2imgutils.changes 2025-05-31 19:17:51.541218328 +0200 +++ /work/SRC/openSUSE:Factory/.python-ec2imgutils.new.21863/python-ec2imgutils.changes 2026-04-08 17:15:46.144016252 +0200 @@ -1,0 +2,7 @@ +Tue Mar 31 20:12:18 UTC 2026 - Robert Schweikert <[email protected]> + +- Update to version 10.0.5 (jsc#PCT-1097) + + add new option to apply tags when image gets uploaded + + add new option to set the channel timeout during upload + +------------------------------------------------------------------- Old: ---- ec2imgutils-10.0.4.tar.bz2 New: ---- ec2imgutils-10.0.5.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-ec2imgutils.spec ++++++ --- /var/tmp/diff_new_pack.mMXVz7/_old 2026-04-08 17:15:46.964049967 +0200 +++ /var/tmp/diff_new_pack.mMXVz7/_new 2026-04-08 17:15:46.964049967 +0200 @@ -1,7 +1,7 @@ # # spec file for package python-ec2imgutils # -# Copyright (c) 2025 SUSE LLC +# Copyright (c) 2026 SUSE LLC # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -25,7 +25,7 @@ %define upstream_name ec2imgutils Name: python-ec2imgutils -Version: 10.0.4 +Version: 10.0.5 Release: 0 Summary: Image management utilities for AWS EC2 License: GPL-3.0-or-later ++++++ ec2imgutils-10.0.4.tar.bz2 -> ec2imgutils-10.0.5.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-10.0.4/ec2uploadimg new/ec2imgutils-10.0.5/ec2uploadimg --- old/ec2imgutils-10.0.4/ec2uploadimg 2025-05-29 17:48:55.888418765 +0200 +++ new/ec2imgutils-10.0.5/ec2uploadimg 2026-03-31 22:09:58.114080552 +0200 @@ -20,6 +20,7 @@ import argparse import boto3 +import json import os import sys import signal @@ -150,6 +151,16 @@ dest='grub2', help='The image uses the GRUB2 bootloader (Optional)' ) + help_msg = 'Provide valid json or a file name of a list of dicts ' + help_msg += 'each dict having a "Key" and "Value" assignment ' + help_msg += 'representing the key and value of a tag to be applied to ' + help_msg += 'the image. (Optional)' + parser.add_argument( + '--image-tags', + dest='imageTags', + help=help_msg, + metavar='IMAGE_TAGS' + ) help_msg = 'Set the protocol version to be used when instances are ' help_msg += 'launched from the image, supported values 2.0/v2.0. ' help_msg += '(Optional)' @@ -254,6 +265,16 @@ metavar='SSH_TIME_OUT', type=int ) + help_msg = 'Timeout value for inactivity in the channel used for the ' + help_msg += 'image upload, default 900s (Optional)' + parser.add_argument( + '--channel-timeout', + default=900, + dest='channelTimeout', + help=help_msg, + metavar='CHANNEL_TIME_OUT', + type=int + ) help_msg = 'The image supports NitroTPM, supported values 2.0/v2.0' help_msg += ' (Optional)' parser.add_argument( @@ -369,6 +390,53 @@ check_amiID_or_runningID_provided(args, logger) check_regions_parameter(args, logger) check_tpm_support_has_allowed_boot_options(args, logger) + check_image_tags(args, logger) + + +# ---------------------------------------------------------------------------- +def check_image_tags(args, logger): + """This function determines if a file path is provided and if this + is the case loads the json from the file. Set the argument to the + resulting json object. If the json is provided as a string create the + json object""" + imgTags = None + error = '' + usr_img_tags = args.imageTags + if usr_img_tags: + if 'Key' in usr_img_tags and 'Value' in usr_img_tags: + try: + imgTags = json.loads(usr_img_tags) + except json.decoder.JSONDecodeError: + error = 'Decode' + # The given argument is not valid json it could be a file path with + # Key abd Value as part of the file name + if not imgTags: + if os.path.isfile(os.path.expanduser(usr_img_tags)): + try: + imgTags = json.loads(open(usr_img_tags, 'r').read()) + except PermissionError: + error = 'File' + except json.decoder.JSONDecodeError: + error = 'Decode' + except Exception: + error = 'Unknown' + else: + error = 'File' + + if not imgTags: + if error == 'File': + err_msg = 'Attempted to load file %s but the file could ' + err_msg += 'not be found or read' + logger.error(err_msg % usr_img_tags) + sys.exit(1) + elif error == 'Decode': + logger.error('Provided json for tags is invalid') + sys.exit(1) + else: + logger.error('Unknown error processing image-tags argument') + sys.exit(1) + + args.imageTags = imgTags # ---------------------------------------------------------------------------- @@ -920,6 +988,7 @@ ssh_key_pair_name=key_pair_name, ssh_key_private_key_file=ssh_private_key_file, ssh_timeout=args.sshTimeout, + channel_timeout=args.channelTimeout, use_grub2=args.grub2, use_private_ip=args.usePrivateIP, vpc_subnet_id=vpc_subnet_id, @@ -928,7 +997,8 @@ log_callback=logger, boot_mode=args.bootMode, tpm_support=args.tpm, - imds_support=args.imdsVersion + imds_support=args.imdsVersion, + image_tags=args.imageTags ) return uploader except EC2UploadImgException as e: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-10.0.4/lib/ec2imgutils/VERSION new/ec2imgutils-10.0.5/lib/ec2imgutils/VERSION --- old/ec2imgutils-10.0.4/lib/ec2imgutils/VERSION 2025-05-29 17:48:55.888418765 +0200 +++ new/ec2imgutils-10.0.5/lib/ec2imgutils/VERSION 2026-03-31 22:09:58.114080552 +0200 @@ -1 +1 @@ -10.0.4 +10.0.5 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-10.0.4/lib/ec2imgutils/ec2uploadimg.py new/ec2imgutils-10.0.5/lib/ec2imgutils/ec2uploadimg.py --- old/ec2imgutils-10.0.4/lib/ec2imgutils/ec2uploadimg.py 2025-05-29 17:48:55.888418765 +0200 +++ new/ec2imgutils-10.0.5/lib/ec2imgutils/ec2uploadimg.py 2026-03-31 22:09:58.114080552 +0200 @@ -15,10 +15,12 @@ # You should have received a copy of the GNU General Public License # along with ec2uploadimg. If not, see <http://www.gnu.org/licenses/>. +import botocore import json import logging import os import paramiko +import socket import sys import threading import time @@ -55,6 +57,7 @@ ssh_key_pair_name=None, ssh_key_private_key_file=None, ssh_timeout=300, + channel_timeout=900, use_grub2=False, use_private_ip=False, vpc_subnet_id='', @@ -64,7 +67,8 @@ log_callback=None, boot_mode=None, tpm_support=None, - imds_support=None + imds_support=None, + image_tags=None ): EC2ImgUtils.__init__( self, @@ -96,6 +100,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.channel_timeout = channel_timeout self.tpm = tpm_support self.use_grub2 = use_grub2 self.use_private_ip = use_private_ip @@ -115,6 +120,7 @@ self.ssh_client = None self.storage_volume_size = 2 * self.root_volume_size self.aborted = False + self.image_tags = image_tags if sriov_type and sriov_type != 'simple': raise EC2UploadImgException( @@ -964,22 +970,46 @@ self.progress_timer.start() # --------------------------------------------------------------------- + def _tag_image(self, ami_id): + """Tag the image""" + + if self.image_tags: + self.log.debug('Applying tags') + try: + self._connect().create_tags( + Resources=[ami_id], Tags=self.image_tags + ) + except botocore.exceptions.ParamValidationError: + msg = 'Tag appllication failed, please apply tags ' + msg += 'manually via the aws tool or the web console. ' + msg += 'Tag value validation failed.' + self.log.debug(msg) + + # --------------------------------------------------------------------- def _upload_image(self, target_dir, source): """Upload the source file to the instance""" + if self.aborted: return filename = source.split(os.sep)[-1] sftp = self.ssh_client.open_sftp() try: + sftp.get_channel().settimeout(self.channel_timeout) self.log.debug('Uploading image file: {}'.format(source)) sftp.put(source, '%s/%s' % (target_dir, filename), self._upload_progress) if self.log_level == logging.DEBUG: print() + except socket.timeout: + self._clean_up() + error_msg = 'Channel timeout reached during upload process.' + raise EC2UploadImgException(error_msg) except Exception as e: self._clean_up() raise e + finally: + sftp.close() return filename @@ -1040,6 +1070,7 @@ snapshot = self.create_snapshot(source) ami = self._register_image(snapshot) + self._tag_image(ami) return ami @@ -1057,6 +1088,7 @@ snapshot = response['Snapshots'][0] ami = self._register_image(snapshot) + self._tag_image(ami) return ami @@ -1169,6 +1201,8 @@ ) self._clean_up() + + self._tag_image(ami['ImageId']) return ami['ImageId'] # --------------------------------------------------------------------- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/ec2imgutils-10.0.4/man/man1/ec2uploadimg.1 new/ec2imgutils-10.0.5/man/man1/ec2uploadimg.1 --- old/ec2imgutils-10.0.4/man/man1/ec2uploadimg.1 2025-05-29 17:48:55.888418765 +0200 +++ new/ec2imgutils-10.0.5/man/man1/ec2uploadimg.1 2026-03-31 22:09:58.114080552 +0200 @@ -119,6 +119,16 @@ value from the configuration file or will use the value given with .I --boot-kernel as the aki ID when a para virtual image is being registered. +.IP "--image-tags" +Optionally specify tags that should be applied to the image once it has been +uploaded. The value for the argument is a valid json string representing +a list of dictionaries where each dictionary specifies the key for the tag +using the keyword "Key" and the value for this key with the keyword "Value". +Alternatively the value of the argument may point to a file that specifies +the same json construct. Example: +.I '[{"Key":"1234", "Value":"5678"},{"Key":"Hello", "Value":"Goodbye"}]' +Would lead to the uploaded image having 2 tags, one with the key "1234" +and the other with the key "Hello". Each key would have the assigned values. .IP "--imds-support" Optionally specify the version for accessing the Instance MetaData Service (IMDS). The default is to access the IMDS using the version 1.0 implementation. @@ -180,6 +190,9 @@ .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 "--channel-timeout CHANNEL_TIME_OUT" +Specifies the amount of time to wait in seconds to consider an upload +unsuccessful per inactivity in the channel used. .IP "--tpm-support" Optionally specify the version of the TPM implementation the OS in the image supports. This option can only be used if
