diff --git a/roles/fedimg/files/partial_upload.py b/roles/fedimg/files/partial_upload.py new file mode 100644 index 0000000000..7705067ae3 --- /dev/null +++ b/roles/fedimg/files/partial_upload.py @@ -0,0 +1,62 @@ +#!/bin/env python +# -*- coding: utf8 -*- +""" Triggers a partial upload process with the specified raw.xz URL. """ + +import argparse +import logging +import logging.config + +import fedmsg.config + +from fedimg.config import AWS_ACCESS_ID +from fedimg.config import AWS_SECRET_KEY +from fedimg.services.ec2.ec2initiate import main as ec2main + +logging.config.dictConfig(fedmsg.config.load_config()['logging']) +log = logging.getLogger('fedmsg') + + +def get_args(): + parser = argparse.ArgumentParser( + description="Trigger a partial upload based on the arguments") + parser.add_argument( + "-u", "--url", type=str, help=".raw.xz URL", required=True) + parser.add_argument( + "-c", "--compose-id", type=str, help="compose id of the .raw.xz file", + required=True) + parser.add_argument( + "-p", "--push-notifications", + help="Bool to check if we need to push fedmsg notifications", + action="store_true", required=False) + parser.add_argument( + "-v", "--volume", help="volume type for the image", required=False) + + args = parser.parse_args() + + return ( + args.url, + args.compose_id, + args.push_notifications, + args.volume + ) + + +def main(): + url, compose_id, push_notifications, volume = get_args() + + if volume is not None: + volume = [volume] + + ec2main( + image_urls=url, + access_id=AWS_ACCESS_ID, + secret_key=AWS_SECRET_KEY, + regions=None, + volume_types=volume, + push_notifications=push_notifications, + compose_id=compose_id + ) + + +if __name__ == '__main__': + main() diff --git a/roles/fedimg/tasks/main.yml b/roles/fedimg/tasks/main.yml index b1538c43a3..a3bfb3fc1f 100644 --- a/roles/fedimg/tasks/main.yml +++ b/roles/fedimg/tasks/main.yml @@ -28,6 +28,14 @@ tags: - fedimg +- name: copy manual partial trigger script + copy: > + src=partial_upload.py + dest=/usr/local/bin/partial_upload.py + mode=0755 + tags: + - fedimg + - name: copy base configuration template: > src=fedimg-conf.toml dest=/etc/fedimg/fedimg-conf.toml