labpack/platforms/aws/ec2.py
def delete_image(self, image_id):

        '''
            method for removing an image from AWS EC2

        :param image_id: string with AWS id of instance
        :return: string with AWS response from snapshot delete
        '''

        title = '%s.delete_image' % self.__class__.__name__

    # validate inputs
        input_fields = {
            'image_id': image_id
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)

    # report query
        self.iam.printer('Removing image %s from AWS region %s.' % (image_id, self.iam.region_name))

    # retrieve state
        old_state = self.check_image_state(image_id)

    # discover snapshot id and tags associated with instance id
        image_details = self.read_image(image_id)
        tag_list = image_details['tags']
        snapshot_id = image_details['snapshot_id']

    # remove tags from instance
        try:
            delete_kwargs = {
                'Resources': [ image_id ],
                'Tags': self.iam.prepare(tag_list)
            }
            self.connection.delete_tags(**delete_kwargs)
            self.iam.printer('Tags have been deleted from %s.' % image_id)
        except:
            raise AWSConnectionError(title)

    # deregister image
        try:
            self.connection.deregister_image(
                ImageId=image_id
            )
        except:
            raise AWSConnectionError(title)
        self.iam.printer('Image %s has been deregistered.' % image_id)

    # delete snapshot
        try:
            response = self.connection.delete_snapshot(
                SnapshotId=snapshot_id
            )
        except:
            raise AWSConnectionError(title)
        self.iam.printer('Snapshot %s associated with image %s has been deleted.' % (snapshot_id, image_id))

        return response

            method for removing an image from AWS EC2

        :param image_id: string with AWS id of instance
        :return: string with AWS response from snapshot delete
        
method for removing an image from AWS EC2
method for removing an image from AWS EC2
def delete_image(self, image_id):
        title = '%s.delete_image' % self.__class__.__name__
        input_fields = {
            'image_id': image_id
        }
        for key, value in input_fields.items():
            object_title = '%s(%s=%s)' % (title, key, str(value))
            self.fields.validate(value, '.%s' % key, object_title)
        self.iam.printer('Removing image %s from AWS region %s.' % (image_id, self.iam.region_name))
        old_state = self.check_image_state(image_id)
        image_details = self.read_image(image_id)
        tag_list = image_details['tags']
        snapshot_id = image_details['snapshot_id']
        try:
            delete_kwargs = {
                'Resources': [ image_id ],
                'Tags': self.iam.prepare(tag_list)
            }
            self.connection.delete_tags(**delete_kwargs)
            self.iam.printer('Tags have been deleted from %s.' % image_id)
        except:
            raise AWSConnectionError(title)
        try:
            self.connection.deregister_image(
                ImageId=image_id
            )
        except:
            raise AWSConnectionError(title)
        self.iam.printer('Image %s has been deregistered.' % image_id)
        try:
            response = self.connection.delete_snapshot(
                SnapshotId=snapshot_id
            )
        except:
            raise AWSConnectionError(title)
        self.iam.printer('Snapshot %s associated with image %s has been deleted.' % (snapshot_id, image_id))
        return response
def delete_image ( self , image_id ) : title = '%s.delete_image' % self . __class__ . __name__ input_fields = { 'image_id' : image_id } for key , value in input_fields . items ( ) : object_title = '%s(%s=%s)' % ( title , key , str ( value ) ) self . fields . validate ( value , '.%s' % key , object_title ) self . iam . printer ( 'Removing image %s from AWS region %s.' % ( image_id , self . iam . region_name ) ) old_state = self . check_image_state ( image_id ) image_details = self . read_image ( image_id ) tag_list = image_details [ 'tags' ] snapshot_id = image_details [ 'snapshot_id' ] try : delete_kwargs = { 'Resources' : [ image_id ] , 'Tags' : self . iam . prepare ( tag_list ) } self . connection . delete_tags ( ** delete_kwargs ) self . iam . printer ( 'Tags have been deleted from %s.' % image_id ) except : raise AWSConnectionError ( title ) try : self . connection . deregister_image ( ImageId = image_id ) except : raise AWSConnectionError ( title ) self . iam . printer ( 'Image %s has been deregistered.' % image_id ) try : response = self . connection . delete_snapshot ( SnapshotId = snapshot_id ) except : raise AWSConnectionError ( title ) self . iam . printer ( 'Snapshot %s associated with image %s has been deleted.' % ( snapshot_id , image_id ) ) return response
method for removing an image from AWS EC2
method for removing an image from AWS EC2
'''
            method for removing an image from AWS EC2

        :param image_id: string with AWS id of instance
        :return: string with AWS response from snapshot delete
        ''' # validate inputs # report query # retrieve state # discover snapshot id and tags associated with instance id # remove tags from instance # deregister image # delete snapshot
string with AWS response from snapshot delete
string with AWS response from snapshot delete
self
image_id
string with AWS id of instance
string with AWS id of instance