Hello community,

here is the log from the commit of package python3-ec2imgutils for 
openSUSE:Factory checked in at 2020-09-01 20:09:09
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python3-ec2imgutils (Old)
 and      /work/SRC/openSUSE:Factory/.python3-ec2imgutils.new.3399 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "python3-ec2imgutils"

Tue Sep  1 20:09:09 2020 rev:12 rq:830919 version:9.0.0

Changes:
--------
--- /work/SRC/openSUSE:Factory/python3-ec2imgutils/python3-ec2imgutils.changes  
2020-06-19 17:24:36.488106218 +0200
+++ 
/work/SRC/openSUSE:Factory/.python3-ec2imgutils.new.3399/python3-ec2imgutils.changes
        2020-09-01 20:09:51.792662423 +0200
@@ -1,0 +2,8 @@
+Mon Aug 24 17:57:41 UTC 2020 - Robert Schweikert <[email protected]>
+
+- Update to version 9.0.0
+  + Handle traceback generated by ec2uploadimg
+  + Fix ec2removeimg implementation w.r.t. missing implementation of
+    delete confirmation when multiple images are to be deleted
+
+-------------------------------------------------------------------

Old:
----
  ec2imgutils-8.1.2.tar.bz2

New:
----
  ec2imgutils-9.0.0.tar.bz2

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ python3-ec2imgutils.spec ++++++
--- /var/tmp/diff_new_pack.1aony6/_old  2020-09-01 20:09:52.300662660 +0200
+++ /var/tmp/diff_new_pack.1aony6/_new  2020-09-01 20:09:52.300662660 +0200
@@ -19,7 +19,7 @@
 %define upstream_name ec2imgutils
 
 Name:           python3-ec2imgutils
-Version:        8.1.2
+Version:        9.0.0
 Release:        0
 Summary:        Image management utilities for AWS EC2
 License:        GPL-3.0-or-later

++++++ ec2imgutils-8.1.2.tar.bz2 -> ec2imgutils-9.0.0.tar.bz2 ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/ec2deprecateimg 
new/ec2imgutils-9.0.0/ec2deprecateimg
--- old/ec2imgutils-8.1.2/ec2deprecateimg       2020-06-15 18:21:48.173480336 
+0200
+++ new/ec2imgutils-9.0.0/ec2deprecateimg       2020-08-24 19:56:36.351121300 
+0200
@@ -1,6 +1,6 @@
 #!/usr/bin/python3
 
-# Copyright 2018 SUSE LLC
+# Copyright 2020 SUSE LLC
 #
 # This file is part of ec2imgutils
 #
@@ -188,9 +188,8 @@
 )
 argparse.add_argument(
     '--version',
-    action='store_true',
-    default=False,
-    dest='version',
+    action='version',
+    version=utils.get_version(),
     help='Program version'
 )
 
@@ -198,13 +197,6 @@
 
 logger = utils.get_logger(args.verbose)
 
-if args.version:
-    version_file_name = 'VERSION'
-    base_path = os.path.dirname(utils.__file__)
-    version = open(base_path + os.sep + version_file_name, 'r').read().strip()
-    logger.info(version)
-    sys.exit(0)
-
 # Explicit check required to to the group issue, see comment above
 if (
         not args.depImgID and not
@@ -250,7 +242,7 @@
                                            'access_key_id',
                                            '--access-id')
     except EC2AccountException as e:
-        logger.exception(e)
+        logger.error(e)
         sys.exit(1)
 
 if not access_key:
@@ -266,7 +258,7 @@
                                            'secret_access_key',
                                            '--secret-key')
     except EC2AccountException as e:
-        logger.exception(e)
+        logger.error(e)
         sys.exit(1)
 
 if not secret_key:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/ec2listimg 
new/ec2imgutils-9.0.0/ec2listimg
--- old/ec2imgutils-8.1.2/ec2listimg    2020-06-15 18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/ec2listimg    2020-08-24 19:56:36.351121300 +0200
@@ -103,9 +103,8 @@
 )
 argparse.add_argument(
     '--version',
-    action='store_true',
-    default=False,
-    dest='version',
+    action='version',
+    version=utils.get_version(),
     help='Program version'
 )
 
@@ -113,13 +112,6 @@
 
 logger = utils.get_logger(args.verbose)
 
-if args.version:
-    version_file_name = 'VERSION'
-    base_path = os.path.dirname(utils.__file__)
-    version = open(base_path + os.sep + version_file_name, 'r').read().strip()
-    logger.info(version)
-    sys.exit(0)
-
 config_file = os.path.expanduser(args.config_file_path)
 config = None
 if not os.path.isfile(config_file):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/ec2publishimg 
new/ec2imgutils-9.0.0/ec2publishimg
--- old/ec2imgutils-8.1.2/ec2publishimg 2020-06-15 18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/ec2publishimg 2020-08-24 19:56:36.351121300 +0200
@@ -130,11 +130,11 @@
     dest='verbose',
     help='Enable verbose output, default "False"'
 )
+
 argparse.add_argument(
     '--version',
-    action='store_true',
-    default=False,
-    dest='version',
+    action='version',
+    version=utils.get_version(),
     help='Program version'
 )
 
@@ -142,13 +142,6 @@
 
 logger = utils.get_logger(args.verbose)
 
-if args.version:
-    version_file_name = 'VERSION'
-    base_path = os.path.dirname(utils.__file__)
-    version = open(base_path + os.sep + version_file_name, 'r').read()
-    logger.info(version)
-    sys.exit(0)
-
 # Explicit check required to to the group issue, see comment above
 if (
         not args.pubImgID and not
@@ -170,7 +163,7 @@
 try:
     config = utils.get_config(config_file)
 except Exception as e:
-    logger.exception(e)
+    logger.error(e)
     sys.exit(1)
 
 access_key = args.accessKey
@@ -182,7 +175,7 @@
                                            'access_key_id',
                                            '--access-id')
     except EC2AccountException as e:
-        logger.exception(e)
+        logger.error(e)
         sys.exit(1)
 
 if not access_key:
@@ -198,7 +191,7 @@
                                            'secret_access_key',
                                            '--secret-key')
     except EC2AccountException as e:
-        logger.exception(e)
+        logger.error(e)
         sys.exit(1)
 
 if not secret_key:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/ec2removeimg 
new/ec2imgutils-9.0.0/ec2removeimg
--- old/ec2imgutils-8.1.2/ec2removeimg  2020-06-15 18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/ec2removeimg  2020-08-24 19:56:36.351121300 +0200
@@ -15,7 +15,7 @@
 # GNU General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with ec2publishimg. If not, see <http://www.gnu.org/licenses/>.
+# along with ec2removeimg. If not, see <http://www.gnu.org/licenses/>.
 
 import argparse
 import os
@@ -47,7 +47,7 @@
     action='store_true',
     default=False,
     dest='all',
-    help='Delete all image that match the search criteria'
+    help='Delete all images that match the search criteria'
 )
 help_msg = 'Do not perform any action, print information about actions that '
 help_msg += 'would be performed instead (Optional)'
@@ -70,40 +70,40 @@
 # also requires one argument to be specified even if --version is specified
 # This parser behavior is true even if --version and the group are part of the
 # same subgroup
-publish_image_condition_group = argparse.add_mutually_exclusive_group()
-publish_image_condition_group.add_argument(
+remove_image_condition_group = argparse.add_mutually_exclusive_group()
+remove_image_condition_group.add_argument(
     '--image-id',
     dest='image_id',
-    help='The AMI ID of the image to be published (Optional)',
+    help='The AMI ID of the image to be removed (Optional)',
     metavar='AMI_ID'
 )
-publish_image_condition_group.add_argument(
+remove_image_condition_group.add_argument(
     '--image-name',
     dest='image_name',
-    help='The image name of the image to be published (Optional)',
+    help='The image name of the image to be removed (Optional)',
     metavar='IMAGE_NAME'
 )
 help_msg = 'An image name fragment to match the image name of the image to be '
-help_msg += 'published (Optional)'
-publish_image_condition_group.add_argument(
+help_msg += 'removed (Optional)'
+remove_image_condition_group.add_argument(
     '--image-name-frag',
     dest='image_name_frag',
     help=help_msg,
     metavar='IMAGE_NAME_FRAGMENT'
 )
 help_msg = 'A regular expression to match the image name of the image to be '
-help_msg += 'published (Optional)'
-publish_image_condition_group.add_argument(
+help_msg += 'removed (Optional)'
+remove_image_condition_group.add_argument(
     '--image-name-match',
     dest='image_name_match',
     help=help_msg,
     metavar='REGEX'
 )
 argparse.add_argument(
-    '--no-confirm',
+    '--confirm',
     action='store_true',
     default=False,
-    dest='no_confirm',
+    dest='confirm',
     help='Remove matched images with confirmation of action'
 )
 argparse.add_argument(
@@ -113,7 +113,7 @@
     dest='preserve_snap',
     help='Do not remove the snapshot associated with the image'
 )
-help_msg = 'Comma separated list of regions for publishing, all integrated '
+help_msg = 'Comma separated list of regions for removing, all integrated '
 help_msg += 'regions if not given (Optional)'
 argparse.add_argument(
     '-r', '--regions',
@@ -136,9 +136,8 @@
 )
 argparse.add_argument(
     '--version',
-    action='store_true',
-    default=False,
-    dest='version',
+    action='version',
+    version=utils.get_version(),
     help='Program version'
 )
 
@@ -146,13 +145,6 @@
 
 logger = utils.get_logger(args.verbose)
 
-if args.version:
-    version_file_name = 'VERSION'
-    base_path = os.path.dirname(utils.__file__)
-    version = open(base_path + os.sep + version_file_name, 'r').read().strip()
-    logger.info(version)
-    sys.exit(0)
-
 # Explicit check required to to the group issue, see comment above
 if (
         not args.image_id and not
@@ -174,7 +166,7 @@
 try:
     config = utils.get_config(config_file)
 except Exception as e:
-    logger.exception(e)
+    logger.error(e)
     sys.exit(1)
 
 access_key = args.access_key
@@ -186,7 +178,7 @@
                                            'access_key_id',
                                            '--access-id')
     except EC2AccountException as e:
-        logger.exception(e)
+        logger.error(e)
         sys.exit(1)
 
 if not access_key:
@@ -202,7 +194,7 @@
                                            'secret_access_key',
                                            '--secret-key')
     except EC2AccountException as e:
-        logger.exception(e)
+        logger.error(e)
         sys.exit(1)
 
 if not secret_key:
@@ -221,7 +213,7 @@
     image_name_fragment=args.image_name_frag,
     image_name_match=args.image_name_match,
     keep_snap=args.preserve_snap,
-    no_confirm=args.no_confirm,
+    confirm=args.confirm,
     remove_all=args.all,
     secret_key=secret_key,
     log_callback=logger
@@ -237,7 +229,7 @@
         else:
             remover.remove_images()
 except EC2RemoveImgException as e:
-    logger.exception(e)
+    logger.error(e)
     sys.exit(1)
 except Exception as e:
     logger.exception(e)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/ec2uploadimg 
new/ec2imgutils-9.0.0/ec2uploadimg
--- old/ec2imgutils-8.1.2/ec2uploadimg  2020-06-15 18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/ec2uploadimg  2020-08-24 19:56:36.351121300 +0200
@@ -1,5 +1,6 @@
 #!/usr/bin/python3
 
+
 # Copyright 2020 SUSE LLC
 #
 # This file is part of ec2imgutils
@@ -266,9 +267,8 @@
     help=help_msg)
 argparse.add_argument(
     '--version',
-    action='store_true',
-    default=False,
-    dest='version',
+    action='version',
+    version=utils.get_version(),
     help='Program version'
 )
 help_msg = 'The ID, starts with "subnet-" of the VPC subnet in which the '
@@ -290,6 +290,14 @@
     metavar='AWS_WAIT_COUNT',
     type=int
 )
+argparse.add_argument(
+    '--use-snapshot',
+    action='store_true',
+    default=False,
+    dest='useSnap',
+    help='Create the image using an existing snapshot that is specified \
+          as the source variable (Optional)'
+)
 
 args = argparse.parse_args()
 logger = utils.get_logger(args.verbose)
@@ -301,6 +309,11 @@
     logger.info(version)
     sys.exit(0)
 
+if args.useSnap and (args.snapOnly or args.rootSwapMethod):
+    logger.error('The options --use-snapshot cannot be specified \
+                 with --snaponly or --use-root-swap')
+    sys.exit(1)
+
 config_file = os.path.expanduser(args.configFilePath)
 config = None
 if not os.path.isfile(config_file):
@@ -313,15 +326,10 @@
     print_ex()
     sys.exit(1)
 
-if not os.path.isfile(args.source):
-    logger.error('Could not find specified image file: %s' % args.source)
-    sys.exit(1)
-
-try:
-    utils.check_account_keys(config, args)
-except Exception:
-    print_ex()
-    sys.exit(1)
+if not args.useSnap:
+    if not os.path.isfile(args.source):
+        logger.error('Could not find specified image file: %s' % args.source)
+        sys.exit(1)
 
 access_key = args.accessKey
 if not access_key:
@@ -331,8 +339,8 @@
                                            None,
                                            'access_key_id',
                                            '--access-id')
-    except EC2AccountException:
-        print_ex()
+    except EC2AccountException as e:
+        logger.error(e)
         sys.exit(1)
 
 if not access_key:
@@ -347,8 +355,8 @@
                                            None,
                                            'secret_access_key',
                                            '--secret-key')
-    except EC2AccountException:
-        print_ex()
+    except EC2AccountException as e:
+        logger.error(e)
         sys.exit(1)
 
 if not secret_key:
@@ -430,8 +438,9 @@
                                                    region,
                                                    'ami',
                                                    '--ec2-ami')
-                except Exception:
-                    print_ex('Could not determine helper AMI-ID')
+                except Exception as e:
+                    logger.error('Could not determine helper AMI-ID')
+                    logger.error(e)
                     sys.exit(1)
             bootkernel = args.akiID
             if args.virtType == 'hvm':
@@ -498,23 +507,31 @@
                 key_pair_name, ssh_private_key_file = \
                     setup.create_upload_key_pair()
             if not key_pair_name:
-                key_pair_name = utils.get_from_config(args.accountName,
-                                                      config,
-                                                      region,
-                                                      'ssh_key_name',
-                                                      '--ssh-key-pair')
+                try:
+                    key_pair_name = utils.get_from_config(args.accountName,
+                                                          config,
+                                                          region,
+                                                          'ssh_key_name',
+                                                          '--ssh-key-pair')
+                except Exception as e:
+                    logger.error(e)
+                    sys.exit(1)
             if not key_pair_name:
                 logger.error('Could not determine key pair name')
                 sys.exit(1)
 
             if not ssh_private_key_file:
-                ssh_private_key_file = utils.get_from_config(
-                    args.accountName,
-                    config,
-                    region,
-                    'ssh_private_key',
-                    '--private-key-file'
-                )
+                try:
+                    ssh_private_key_file = utils.get_from_config(
+                        args.accountName,
+                        config,
+                        region,
+                        'ssh_private_key',
+                        '--private-key-file'
+                    )
+                except Exception as e:
+                    logger.error(e)
+                    sys.exit(1)
 
             if not ssh_private_key_file:
                 logger.error(
@@ -532,11 +549,16 @@
 
             ssh_user = args.sshUser
             if not ssh_user:
-                ssh_user = utils.get_from_config(args.accountName,
-                                                 config,
-                                                 region,
-                                                 'user',
-                                                 '--user')
+                try:
+                    ssh_user = utils.get_from_config(args.accountName,
+                                                     config,
+                                                     region,
+                                                     'user',
+                                                     '--user')
+                except Exception as e:
+                    logger.error(e)
+                    sys.exit(1)
+
             if not ssh_user:
                 logger.error('Could not determine ssh user to use')
                 sys.exit(1)
@@ -557,13 +579,15 @@
                         'subnet_id_%s' % region,
                         '--vpc-subnet-id'
                     )
-                    if vpc_subnet_id:
-                        logger.debug('Using VPC subnet: %s' % vpc_subnet_id)
                 except Exception:
                     msg = 'Not using a subnet-id, none given on the '
                     msg += 'command line and none found in config for '
                     msg += '"subnet_id_%s" value' % region
-                    print_ex(msg)
+                    logger.error(msg)
+                    sys.exit(1)
+
+                if vpc_subnet_id:
+                    logger.debug('Using VPC subnet: %s' % vpc_subnet_id)
 
             security_group_ids = args.securityGroupIds
             if not security_group_ids and not args.runningID:
@@ -585,7 +609,7 @@
                         msg = 'No security group specified in the '
                         msg += 'configuration, "security_group_ids_%s" or '
                         msg += 'given on the command line.'
-                        print_ex(msg % region)
+                        logger.error(msg)
                     if not security_group_ids and vpc_subnet_id:
                         ec2 = boto3.client(
                             aws_access_key_id=access_key,
@@ -645,6 +669,9 @@
                 elif args.rootSwapMethod:
                     ami = uploader.create_image_use_root_swap(args.source)
                     print('Created image: ', ami)
+                elif args.useSnap:
+                    ami = uploader.create_image_from_snapshot(args.source)
+                    print('Created image: ', ami)
                 else:
                     ami = uploader.create_image(args.source)
                     print('Created image: ', ami)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/lib/ec2imgutils/VERSION 
new/ec2imgutils-9.0.0/lib/ec2imgutils/VERSION
--- old/ec2imgutils-8.1.2/lib/ec2imgutils/VERSION       2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/lib/ec2imgutils/VERSION       2020-08-24 
19:56:36.347121332 +0200
@@ -1 +1 @@
-8.1.2
+9.0.0
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2publishimg.py 
new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2publishimg.py
--- old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2publishimg.py      2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2publishimg.py      2020-08-24 
19:56:36.347121332 +0200
@@ -156,6 +156,44 @@
         images = self._get_images()
 
         for image in images:
+            skip_state = ['invalid', 'deregistered', 'transient', 'fail']
+            if image['State'] == 'pending':
+                waiter = self._connect().get_waiter('image_available')
+                self.log.info("Current state of image %s is %s. Waiting up "
+                              "to 10 minutes for it to become 'available'.",
+                              image['ImageId'], image['State'])
+                wait_status = 1
+                try:
+                    wait_status = waiter.wait(
+                        ImageIds=[image['ImageId']],
+                        Filters=[
+                            {
+                                'Name': 'state',
+                                'Values': ['available']
+                            }
+                        ],
+                        WaiterConfig={
+                            'Delay': 15,
+                            'MaxAttempts': 40
+                        }
+                    )
+                except Exception:
+                    wait_status = 1
+
+                if wait_status:
+                    self.log.info("Skipping image %s as it failed to become"
+                                  "'available'", image['ImageId'])
+                    continue
+                else:
+                    self.log.info("Image %s is now 'available'.",
+                                  image['ImageId'])
+
+            elif image['State'] in skip_state:
+                self.log.info("Skipping image %s as the state is %s"
+                              " and is not able to be published.",
+                              image['ImageId'], image['State'])
+                continue
+
             if self.visibility == 'all':
                 self._connect().modify_image_attribute(
                     ImageId=image['ImageId'],
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2removeimg.py 
new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2removeimg.py
--- old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2removeimg.py       2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2removeimg.py       2020-08-24 
19:56:36.347121332 +0200
@@ -16,6 +16,7 @@
 # along with ec2publishimg. If not, see <http://www.gnu.org/licenses/>.
 
 import logging
+import sys
 import time
 
 import ec2imgutils.ec2utils as utils
@@ -35,7 +36,7 @@
             image_name_fragment=None,
             image_name_match=None,
             keep_snap=False,
-            no_confirm=None,
+            confirm=None,
             remove_all=False,
             secret_key=None,
             log_level=logging.INFO,
@@ -53,7 +54,7 @@
         self.image_name_fragment = image_name_fragment
         self.image_name_match = image_name_match
         self.keep_snap = keep_snap
-        self.no_confirm = no_confirm
+        self.confirm = confirm
         self.remove_all = remove_all
         self.secret_key = secret_key
 
@@ -64,7 +65,9 @@
            found only one image"""
 
         if not images:
-            self.log.info('No images to remove found in region', self.region)
+            self.log.info(
+                'No images to remove found in region: {}'.format(self.region)
+            )
 
         if len(images) > 1 and not self.remove_all:
             msg = 'Found multiple images to remove, but "all" is '
@@ -104,7 +107,7 @@
                 msg = msg % self.image_name_match
                 raise EC2RemoveImgException(msg)
         else:
-            msg = 'No deprecation image condition set. Should not reach '
+            msg = 'No remove image condition set. Should not reach '
             msg += 'this point.'
             raise EC2RemoveImgException(msg)
 
@@ -140,8 +143,8 @@
         header_msg = 'Would remove image '
         if not self.keep_snap:
             header_msg += 'and snapshot '
-        header_msg += 'in region: '
-        self.log.info(header_msg, self.region)
+        header_msg += 'in region: {}'
+        self.log.info(header_msg.format(self.region))
         for image in images:
             if not self.keep_snap:
                 snapshot = self._get_snapshot_id(image)
@@ -166,16 +169,45 @@
             raise EC2RemoveImgException('Image ambiguity')
 
         for image in images:
-            ec2.deregister_image(ImageId=image['ImageId'])
-            if not self.keep_snap:
-                snapshot = self._get_snapshot_id(image)
-                # Give the EC2 backend a little bit of time to catch up
-                time.sleep(1)
-                ec2.delete_snapshot(SnapshotId=snapshot)
-
-            self.log.debug('Removing in region: {}'.format(self.region))
-            self.log.debug(
-                '\tImage: %s\t%s' % (image['ImageId'], image['Name'])
-            )
-            if not self.keep_snap:
-                self.log.debug('\tSnapshot: {}'.format(snapshot))
+            delete = 'True'
+            if self.confirm:
+                delete = self._query_yes_no(image)
+
+            if delete:
+                ec2.deregister_image(ImageId=image['ImageId'])
+                if not self.keep_snap:
+                    snapshot = self._get_snapshot_id(image)
+                    # Give the EC2 backend a little bit of time to catch up
+                    time.sleep(1)
+                    ec2.delete_snapshot(SnapshotId=snapshot)
+
+                    self.log.debug(
+                        'Removing in region: {}'.format(self.region))
+                    self.log.debug(
+                        '\tImage: %s\t%s' % (image['ImageId'], image['Name'])
+                    )
+                if not self.keep_snap:
+                    self.log.debug('\tSnapshot: {}'.format(snapshot))
+            else:
+                continue
+    # ---------------------------------------------------------------------
+
+    def _query_yes_no(self, image):
+        yes = {'yes', 'y', 'ye', ''}
+        no = {'no', 'n'}
+
+        while True:
+            try:
+                choice = input(
+                            '\tConfirm Delete Image: %s\t%s (Y/n)'
+                            % (image['ImageId'], image['Name'])
+                        ).lower()
+                if choice in yes:
+                    return True
+                elif choice in no:
+                    return False
+                else:
+                    sys.stdout.write("Please respond with 'yes' or 'no'\n")
+            except KeyboardInterrupt:
+                raise EC2RemoveImgException(
+                        'Keyboard Interrupt received, exiting')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2uploadimg.py 
new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2uploadimg.py
--- old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2uploadimg.py       2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2uploadimg.py       2020-08-24 
19:56:36.347121332 +0200
@@ -647,7 +647,12 @@
                 continue
             this_device_size = device['size']
             unit = this_device_size[-1]
-            size = int(this_device_size[:-1])
+            try:
+                size = int(this_device_size[:-1])
+            except ValueError:
+                self.log.info('Skipping non integer sized disk')
+                continue
+
             size_multiplier = 1
             if unit == 'T':
                 size_multiplier = 1024
@@ -952,6 +957,8 @@
         """Unpack the uploaded image file"""
         if self.aborted:
             return
+        raw_image_file = None
+        files = ''
         if (
                 image_filename.find('.tar') != -1 or
                 image_filename.find('.tbz') != -1 or
@@ -962,8 +969,9 @@
             files = self._execute_ssh_command(command).split('\r\n')
         elif image_filename[-2:] == 'xz':
             files = [image_filename]
+        elif image_filename[-3:] == 'raw':
+            raw_image_file = image_filename
 
-        raw_image_file = None
         if files:
             # Find the disk image
             for fl in files:
@@ -993,6 +1001,24 @@
         return ami
 
     # ---------------------------------------------------------------------
+    def create_image_from_snapshot(self, source):
+        """Create an AMI (Amazon Machine Image) from the given snapshot"""
+
+        try:
+            response = self._connect().describe_snapshots(SnapshotIds=[source])
+
+        except Exception:
+            self.log.error('Unable to retrieve details for snapshot %s',
+                           source)
+            sys.exit(1)
+
+        snapshot = response['Snapshots'][0]
+        ami = self._register_image(snapshot)
+
+        return ami
+
+    # ---------------------------------------------------------------------
+
     def create_image_use_root_swap(self, source):
         """Creae an AMI (Amazon Machine Image) from the given source using
            the root swap method"""
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2utils.py 
new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2utils.py
--- old/ec2imgutils-8.1.2/lib/ec2imgutils/ec2utils.py   2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/lib/ec2imgutils/ec2utils.py   2020-08-24 
19:56:36.347121332 +0200
@@ -18,6 +18,7 @@
 import boto3
 import configparser
 import logging
+import os
 import re
 import sys
 
@@ -29,35 +30,6 @@
 )
 
 
-# -----------------------------------------------------------------------------
-def check_account_keys(config, command_args):
-    """Verify that API access keys are available"""
-    if (command_args.accessKey and command_args.secretKey):
-        # All data specified on the command line nothing to do
-        return 1
-    _basic_account_check(config, command_args)
-    account = command_args.accountName
-    account_name = generate_config_account_name(account)
-    access_key = None
-    if config.has_option(account_name, 'access_key_id'):
-        access_key = config.get(account_name, 'access_key_id')
-    secret_key = None
-    if config.has_option(account_name, 'secret_access_key'):
-        secret_key = config.get(account_name, 'secret_access_key')
-    if access_key and secret_key:
-        # All data specified on the command line nothing to do
-        return 1
-    if command_args.accessKey and secret_key:
-        # Combination of config and command line
-        return 1
-    if access_key and command_args.secretKey:
-        # Combination of config and command line
-        return 1
-    msg = 'Could not determine the access keys from data on command line '
-    msg += 'and configuration file.'
-    raise EC2AccountException(msg)
-
-
 # ----------------------------------------------------------------------------
 def find_images_by_id(images, image_id):
     """Return a list of images that match the given ID. By definition this
@@ -151,6 +123,45 @@
 
 
 # -----------------------------------------------------------------------------
+def get_account_info_from_aws(account, entry):
+    """Return a access value from the aws credentials file."""
+
+    config = configparser.RawConfigParser()
+    parsed = None
+    value = None
+    configFilePath = ['~/.aws/credentials', '~/.aws/config']
+
+    for config_file in configFilePath:
+        aws_file = os.path.expanduser(config_file)
+
+        try:
+            parsed = config.read(aws_file)
+        except Exception:
+            continue
+
+        if not parsed:
+            msg = 'Error parsing config file: %s' % aws_file
+            raise EC2ConfigFileParseException(msg)
+
+        try:
+            item = 'aws_' + entry
+            if config_file == '~/.aws/config':
+                section = 'profile ' + account
+            else:
+                section = account
+
+            if config.has_option(section, item):
+                value = config.get(section, item)
+
+        except Exception:
+            continue
+    if not value:
+        raise EC2AccountException
+
+    return value
+
+
+# -----------------------------------------------------------------------------
 def get_from_config(account, config, region, entry, cmd_line_arg):
     """Retrieve an entry from the configuration"""
     value = None
@@ -166,11 +177,22 @@
             raise EC2AccountException(msg % cmd_line_arg)
 
         account_name = generate_config_account_name(account)
-        try:
+
+        if config.has_option(account_name, entry):
             value = config.get(account_name, entry)
-        except Exception:
-            msg = 'Unable to get %s value from account section %s'
-            raise EC2AccountException(msg % (entry, account))
+
+        if not value:
+            if entry in ['secret_access_key', 'access_key_id']:
+                try:
+                    value = get_account_info_from_aws(account, entry)
+                except EC2AccountException:
+                    msg = 'Unable to determine the %s value from '
+                    msg += '~/.ec2utils.conf, ~/.aws/config, or '
+                    msg += '~/.aws/credentials for account/profile %s.'
+                    raise EC2AccountException(msg % (entry, account))
+            else:
+                msg = 'Unable to get %s value from account/region section %s'
+                raise EC2AccountException(msg % (entry, account))
 
     return value
 
@@ -241,3 +263,11 @@
 
     logger.addHandler(console_handler)
     return logger
+
+
+# ----------------------------------------------------------------------------
+def get_version():
+    version_file_name = 'VERSION'
+    base_path = os.path.dirname(__file__)
+    version = open(base_path + os.sep + version_file_name, 'r').read()
+    return version.rstrip('\n')
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/man/man1/ec2deprecateimg.1 
new/ec2imgutils-9.0.0/man/man1/ec2deprecateimg.1
--- old/ec2imgutils-8.1.2/man/man1/ec2deprecateimg.1    2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/man/man1/ec2deprecateimg.1    2020-08-24 
19:56:36.347121332 +0200
@@ -37,7 +37,14 @@
 .I ssh_key_name
 and
 .IR ssh_private_key .
-this allows the program to connect to EC2.
+This allows the program to connect to EC2.
+If the access_key_id and/or secret_access_key are not found in
+.IR ~/.ec2utils.conf,
+the search will use the ACCOUNT_NAME to look for a matching section
+[profile ACCOUNT_NAME] in
+.IR ~/.aws/config
+or [ACCOUNT_NAME] in
+.IR ~/.aws/credentials.
 .IP "--access-id AWS_ACCESS_KEY"
 Specifies the AWS access key and overrides the value given for the
 .I account
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/man/man1/ec2listimg.1 
new/ec2imgutils-9.0.0/man/man1/ec2listimg.1
--- old/ec2imgutils-8.1.2/man/man1/ec2listimg.1 2020-06-15 18:21:48.173480336 
+0200
+++ new/ec2imgutils-9.0.0/man/man1/ec2listimg.1 2020-08-24 19:56:36.347121332 
+0200
@@ -23,7 +23,15 @@
 .I ssh_key_name
 and
 .IR ssh_private_key .
-this allows the program to connect to EC2. Only the
+This allows the program to connect to EC2.
+If the access_key_id and/or secret_access_key are not found in
+.IR ~/.ec2utils.conf,
+the search will use the ACCOUNT_NAME to look for a matching section
+[profile ACCOUNT_NAME] in
+.IR ~/.aws/config
+or [ACCOUNT_NAME] in
+.IR ~/.aws/credentials.
+Only the
 .IR access_key_id
 and
 .IR secret_access_key
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/man/man1/ec2publishimg.1 
new/ec2imgutils-9.0.0/man/man1/ec2publishimg.1
--- old/ec2imgutils-8.1.2/man/man1/ec2publishimg.1      2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/man/man1/ec2publishimg.1      2020-08-24 
19:56:36.347121332 +0200
@@ -23,6 +23,13 @@
 and
 .IR ssh_private_key .
 These allow the program to connect to EC2.
+If the access_key_id and/or secret_access_key are not found in
+.IR ~/.ec2utils.conf,
+the search will use the ACCOUNT_NAME to look for a matching section
+[profile ACCOUNT_NAME] in
+.IR ~/.aws/config
+or [ACCOUNT_NAME] in
+.IR ~/.aws/credentials.
 .IP "--access-id AWS_ACCESS_KEY"
 Specifies the AWS access key and overrides the value given for the
 .I account
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/man/man1/ec2removeimg.1 
new/ec2imgutils-9.0.0/man/man1/ec2removeimg.1
--- old/ec2imgutils-8.1.2/man/man1/ec2removeimg.1       2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/man/man1/ec2removeimg.1       2020-08-24 
19:56:36.347121332 +0200
@@ -22,7 +22,15 @@
 .I ssh_key_name
 and
 .IR ssh_private_key .
-this allows the program to connect to EC2. Only the
+This allows the program to connect to EC2.
+If the access_key_id and/or secret_access_key are not found in
+.IR ~/.ec2utils.conf,
+the search will use the ACCOUNT_NAME to look for a matching section
+[profile ACCOUNT_NAME] in
+.IR ~/.aws/config
+or [ACCOUNT_NAME] in
+.IR ~/.aws/credentials.
+Only the 
 .IR access_key_id
 and
 .IR secret_access_key
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ec2imgutils-8.1.2/man/man1/ec2uploadimg.1 
new/ec2imgutils-9.0.0/man/man1/ec2uploadimg.1
--- old/ec2imgutils-8.1.2/man/man1/ec2uploadimg.1       2020-06-15 
18:21:48.173480336 +0200
+++ new/ec2imgutils-9.0.0/man/man1/ec2uploadimg.1       2020-08-24 
19:56:36.347121332 +0200
@@ -34,7 +34,14 @@
 .I secret_access_key
 .I ssh_key_name
 .I ssh_private_key
-this allows the program to connect to EC2.
+This allows the program to connect to EC2.
+If the access_key_id and/or secret_access_key are not found in
+.IR ~/.ec2utils.conf,
+the search will use the ACCOUNT_NAME to look for a matching section
+[profile ACCOUNT_NAME] in
+.IR ~/.aws/config
+or [ACCOUNT_NAME] in
+.IR ~/.aws/credentials.
 .IP "--access-id AWS_ACCESS_KEY"
 Specifies the AWS access key and overrides the value given for the
 .I account
@@ -136,6 +143,9 @@
 When this argument is set only a snapshot of the uploaded image will be
 created. The snapshot may then be used in a separate operation to register
 an AMI.
+.IP "--use-snapshot"
+When this argument is set the image will be created from an existing snapshot.
+The snapshotID is specified as the source variable.
 .IP "--sriov-support"
 Enable SRIOV support for HVM images. This implies that the appropriate
 driver has to be included in the image.


Reply via email to