예제 #1
0
def main():
    parser = argparse.ArgumentParser("aptly-publisher")

    group_common = parser.add_argument_group("Common")
    parser.add_argument('action', help="Action to perform (publish, promote, cleanup)")
    group_common.add_argument('-v', '--verbose', action="store_true")
    group_common.add_argument('-d', '--debug', action="store_true")
    group_common.add_argument('--dry', '--dry-run', action="store_true")
    group_common.add_argument('--timeout', type=int, default=300, help="Aptly client timeout. Raise for larger publishes and slow server.")
    group_common.add_argument('--url', required=True, help="URL to Aptly API, eg. http://localhost:8080")
    group_common.add_argument('--recreate', action="store_true", help="Drop publish and create it again, only way to add new components")
    group_common.add_argument('--force-overwrite', action="store_true", help="Overwrite files in pool/ directory without notice")
    group_common.add_argument('--publish-contents', action="store_true", default=False, help="Publish contents. It's slow so disabled by default to support large repositories.")

    group_publish = parser.add_argument_group("Action 'publish'")
    group_publish.add_argument('-c', '--config', default="/etc/aptly/publisher.yaml", help="Configuration YAML file")
    group_publish.add_argument('--dists', nargs='+', help="Space-separated list of distribution to work with (including prefix), default all.")

    group_promote = parser.add_argument_group("Action 'promote'")
    group_promote.add_argument('--source', help="Source publish to take snapshots from")
    group_promote.add_argument('--target', help="Target publish to update")
    group_promote.add_argument('--components', nargs='+', help="Space-separated list of components to promote")
    group_promote.add_argument('--packages', nargs='+', help="Space-separated list of packages to promote")
    group_promote.add_argument('--diff', action="store_true", help="Show differences between publishes (snapshots to be updated)")

    args = parser.parse_args()

    if args.verbose:
        lg_root.setLevel(logging.INFO)

    if args.debug:
        lg_root.setLevel(logging.DEBUG)

    client = Aptly(args.url, dry=args.dry, timeout=args.timeout)
    publishmgr = PublishManager(client)

    if args.action == 'publish':
        action_publish(client, publishmgr, config_file=args.config,
                       recreate=args.recreate,
                       force_overwrite=args.force_overwrite,
                       publish_contents=args.publish_contents,
                       publish_names=args.dists)
    elif args.action == 'promote':
        if not args.source or not args.target:
            parser.error("Action 'promote' requires both --source and --target arguments")
        action_promote(client, source=args.source, target=args.target,
                       components=args.components, recreate=args.recreate,
                       packages=args.packages, diff=args.diff,
                       force_overwrite=args.force_overwrite,
                       publish_contents=args.publish_contents)
    elif args.action == 'cleanup':
        publishmgr.cleanup_snapshots()
        sys.exit(0)
예제 #2
0
def main():
    parser = argparse.ArgumentParser("Aptly publisher")

    group_common = parser.add_argument_group("Common")
    parser.add_argument('action', help="Action to perform (publish, promote, cleanup)")
    group_common.add_argument('-v', '--verbose', action="store_true")
    group_common.add_argument('-d', '--debug', action="store_true")
    group_common.add_argument('--dry', '--dry-run', action="store_true")
    group_common.add_argument('--url', required=True, help="URL to Aptly API, eg. http://localhost:8080")
    group_common.add_argument('--recreate', action="store_true", help="Drop publish and create it again, only way to add new components")

    group_publish = parser.add_argument_group("Action 'publish'")
    group_publish.add_argument('-c', '--config', default="/etc/aptly/publisher.yaml", help="Configuration YAML file")

    group_promote = parser.add_argument_group("Action 'promote'")
    group_promote.add_argument('--source', help="Source publish to take snapshots from")
    group_promote.add_argument('--target', help="Target publish to update")
    group_promote.add_argument('--components', nargs='+', help="Space-separated list of components to promote")
    group_promote.add_argument('--packages', nargs='+', help="Space-separated list of packages to promote")
    group_promote.add_argument('--diff', action="store_true", help="Show differences between publishes (snapshots to be updated)")

    args = parser.parse_args()

    if args.verbose:
        lg_root.setLevel(logging.INFO)

    if args.debug:
        lg_root.setLevel(logging.DEBUG)

    client = Aptly(args.url, dry=args.dry)
    publishmgr = PublishManager(client)

    if args.action == 'publish':
        action_publish(client, publishmgr, config_file=args.config, recreate=args.recreate)
    elif args.action == 'promote':
        if not args.source or not args.target:
            parser.error("Action 'promote' requires both --source and --target arguments")
        action_promote(client, source=args.source, target=args.target,
                       components=args.components, recreate=args.recreate,
                       packages=args.packages, diff=args.diff)
    elif args.action == 'cleanup':
        publishmgr.cleanup_snapshots()
        sys.exit(0)
예제 #3
0
def main():
    parser = argparse.ArgumentParser("aptly-publisher")

    group_common = parser.add_argument_group("Common")
    parser.add_argument(
        'action',
        help=
        "Action to perform (publish, promote, cleanup, restore, dump, purge)")
    group_common.add_argument('-v', '--verbose', action="store_true")
    group_common.add_argument('-d', '--debug', action="store_true")
    group_common.add_argument('--dry', '--dry-run', action="store_true")
    group_common.add_argument(
        '--timeout',
        type=int,
        default=300,
        help="Aptly client timeout. Raise for larger publishes and slow server."
    )
    group_common.add_argument(
        '--url',
        required=True,
        help="URL to Aptly API, eg. http://localhost:8080")
    group_common.add_argument(
        '--recreate',
        action="store_true",
        help="Drop publish and create it again, only way to add new components"
    )
    group_common.add_argument(
        '--no-recreate',
        action="store_true",
        help=
        "Never recreate publish (even when we are adding new components where it's the only option)"
    )
    group_common.add_argument(
        '--force-overwrite',
        action="store_true",
        help="Overwrite files in pool/ directory without notice")
    group_common.add_argument(
        '--publish-contents',
        action="store_true",
        default=False,
        help=
        "Publish contents. It's slow so disabled by default to support large repositories."
    )
    group_common.add_argument(
        '--acquire-by-hash',
        action="store_true",
        default=False,
        help=
        "Use Acquire-by-hash option. This may help with repository consistency."
    )
    group_common.add_argument(
        '--components',
        nargs='+',
        help=
        "Space-separated list of components to promote or restore or to purge (in case of purge)"
    )
    group_common.add_argument(
        '--storage',
        default="",
        help=
        "Storage backend to use for all publishes, can be empty (filesystem, default), swift:[name] or s3:[name]"
    )
    group_common.add_argument('-p',
                              '--publish',
                              nargs='+',
                              help="Space-separated list of publish")

    group_publish = parser.add_argument_group("Action 'publish'")
    group_publish.add_argument('-c',
                               '--config',
                               default="/etc/aptly/publisher.yaml",
                               help="Configuration YAML file")
    group_publish.add_argument(
        '--dists',
        nargs='+',
        help=
        "Space-separated list of distribution to work with (including prefix), default all."
    )
    group_publish.add_argument(
        '--architectures',
        nargs='+',
        help=
        "List of architectures to publish (also determined by config, defaults to amd64, i386)"
    )
    group_publish.add_argument(
        '--only-latest',
        action="store_true",
        default=False,
        help="Publish only latest packages of every publishes")

    group_promote = parser.add_argument_group("Action 'promote'")
    group_promote.add_argument(
        '--source',
        help=
        "Source publish to take snapshots from. Can be regular expression, eg. jessie(/?.*)/nightly"
    )
    group_promote.add_argument(
        '--target',
        help=
        "Target publish to update. Must be format if source is regex, eg. jessie{0}/testing"
    )
    group_promote.add_argument(
        '--packages',
        nargs='+',
        help="Space-separated list of packages to promote")
    group_promote.add_argument(
        '--diff',
        action="store_true",
        help="Show differences between publishes (snapshots to be updated)")

    group_purge = parser.add_argument_group("Purge")
    group_purge.add_argument('--hard',
                             action="store_true",
                             default=False,
                             help="Remove all unused packages and snapshots")

    group_restore = parser.add_argument_group("Action 'restore'")
    group_restore.add_argument('-r',
                               '--restore-file',
                               help="File used to restore publish")

    group_save = parser.add_argument_group("Action 'dump'")
    group_save.add_argument('-s',
                            '--save-dir',
                            default='.',
                            help="Path of where dump of publish will be done")
    group_save.add_argument('-x',
                            '--prefix',
                            default="saved-",
                            help="Prefix for dump files' names")

    args = parser.parse_args()

    if args.verbose:
        lg_aptly.setLevel(logging.INFO)
        lg.setLevel(logging.INFO)

    if args.debug:
        lg_aptly.setLevel(logging.DEBUG)
        lg.setLevel(logging.DEBUG)

    client = Aptly(args.url, dry=args.dry, timeout=args.timeout)
    publishmgr = PublishManager(client, storage=args.storage)

    if args.action == 'publish':
        action_publish(client,
                       publishmgr,
                       config_file=args.config,
                       recreate=args.recreate,
                       no_recreate=args.no_recreate,
                       force_overwrite=args.force_overwrite,
                       publish_contents=args.publish_contents,
                       acquire_by_hash=args.acquire_by_hash,
                       publish_names=args.publish,
                       publish_dist=args.dists,
                       architectures=args.architectures,
                       only_latest=args.only_latest,
                       components=args.components)
    elif args.action == 'promote':
        if not args.source or not args.target:
            parser.error(
                "Action 'promote' requires both --source and --target arguments"
            )
        action_promote(client,
                       source=args.source,
                       target=args.target,
                       components=args.components,
                       recreate=args.recreate,
                       no_recreate=args.no_recreate,
                       packages=args.packages,
                       diff=args.diff,
                       force_overwrite=args.force_overwrite,
                       publish_contents=args.publish_contents,
                       acquire_by_hash=args.acquire_by_hash,
                       storage=args.storage)
    elif args.action == 'cleanup':
        publishmgr.cleanup_snapshots()
        sys.exit(0)
    elif args.action == 'dump':
        action_dump(publishmgr, args.save_dir, args.publish, args.prefix)
    elif args.action == 'purge':
        config = load_config(args.config)
        publishmgr.do_purge(config,
                            components=args.components,
                            hard_purge=args.hard)
    elif args.action == "restore":
        action_restore(publishmgr,
                       components=args.components,
                       recreate=args.recreate,
                       restore_file=args.restore_file)
예제 #4
0
def main():
    parser = argparse.ArgumentParser("Aptly publisher")

    group_common = parser.add_argument_group("Common")
    parser.add_argument('action',
                        help="Action to perform (publish, promote, cleanup)")
    group_common.add_argument('-v', '--verbose', action="store_true")
    group_common.add_argument('-d', '--debug', action="store_true")
    group_common.add_argument('--dry', '--dry-run', action="store_true")
    group_common.add_argument(
        '--url',
        required=True,
        help="URL to Aptly API, eg. http://localhost:8080")
    group_common.add_argument(
        '--recreate',
        action="store_true",
        help="Drop publish and create it again, only way to add new components"
    )

    group_publish = parser.add_argument_group("Action 'publish'")
    group_publish.add_argument('-c',
                               '--config',
                               default="/etc/aptly/publisher.yaml",
                               help="Configuration YAML file")

    group_promote = parser.add_argument_group("Action 'promote'")
    group_promote.add_argument('--source',
                               help="Source publish to take snapshots from")
    group_promote.add_argument('--target', help="Target publish to update")
    group_promote.add_argument(
        '--components',
        nargs='+',
        help="Space-separated list of components to promote")
    group_promote.add_argument(
        '--diff',
        action="store_true",
        help="Show differences between publishes (snapshots to be updated)")

    args = parser.parse_args()

    if args.verbose:
        lg_root.setLevel(logging.INFO)

    if args.debug:
        lg_root.setLevel(logging.DEBUG)

    client = Aptly(args.url, dry=args.dry)
    publishmgr = PublishManager(client)

    if args.action == 'publish':
        action_publish(client,
                       publishmgr,
                       config_file=args.config,
                       recreate=args.recreate)
    elif args.action == 'promote':
        if not args.source or not args.target:
            parser.error(
                "Action 'promote' requires both --source and --target arguments"
            )
        action_promote(client,
                       source=args.source,
                       target=args.target,
                       components=args.components,
                       recreate=args.recreate,
                       diff=args.diff)
    elif args.action == 'cleanup':
        publishmgr.cleanup_snapshots()
        sys.exit(0)
예제 #5
0
def main():
    parser = argparse.ArgumentParser("aptly-publisher")

    group_common = parser.add_argument_group("Common")
    parser.add_argument(
        'action',
        help="Action to perform (publish, promote, cleanup, restore, dump)")
    group_common.add_argument('-v', '--verbose', action="store_true")
    group_common.add_argument('-d', '--debug', action="store_true")
    group_common.add_argument('--dry', '--dry-run', action="store_true")
    group_common.add_argument(
        '--timeout',
        type=int,
        default=300,
        help="Aptly client timeout. Raise for larger publishes and slow server."
    )
    group_common.add_argument(
        '--url',
        required=True,
        help="URL to Aptly API, eg. http://localhost:8080")
    group_common.add_argument(
        '--recreate',
        action="store_true",
        help="Drop publish and create it again, only way to add new components"
    )
    group_common.add_argument(
        '--no-recreate',
        action="store_true",
        help=
        "Never recreate publish (even when we are adding new components where it's the only option)"
    )
    group_common.add_argument(
        '--force-overwrite',
        action="store_true",
        help="Overwrite files in pool/ directory without notice")
    group_common.add_argument(
        '--publish-contents',
        action="store_true",
        default=False,
        help=
        "Publish contents. It's slow so disabled by default to support large repositories."
    )
    group_common.add_argument(
        '--components',
        nargs='+',
        help="Space-separated list of components to promote or restore")
    group_common.add_argument('-p',
                              '--publish',
                              nargs='+',
                              help="Space-separated list of publish")

    group_publish = parser.add_argument_group("Action 'publish'")
    group_publish.add_argument('-c',
                               '--config',
                               default="/etc/aptly/publisher.yaml",
                               help="Configuration YAML file")
    group_publish.add_argument(
        '--dists',
        nargs='+',
        help=
        "Space-separated list of distribution to work with (including prefix), default all."
    )
    group_publish.add_argument(
        '--architectures',
        nargs='+',
        help=
        "List of architectures to publish (also determined by config, defaults to amd64, i386)"
    )

    group_promote = parser.add_argument_group("Action 'promote'")
    group_promote.add_argument('--source',
                               help="Source publish to take snapshots from")
    group_promote.add_argument('--target', help="Target publish to update")
    group_promote.add_argument(
        '--packages',
        nargs='+',
        help="Space-separated list of packages to promote")
    group_promote.add_argument(
        '--diff',
        action="store_true",
        help="Show differences between publishes (snapshots to be updated)")

    group_restore = parser.add_argument_group("Action 'restore'")
    group_restore.add_argument('-r',
                               '--restore-file',
                               help="File used to restore publish")

    group_save = parser.add_argument_group("Action 'dump'")
    group_save.add_argument('-s',
                            '--save-dir',
                            help="Path of where dump of publish will be done")
    group_save.add_argument('-x',
                            '--prefix',
                            default="saved-",
                            help="Prefix for dump files' names")

    args = parser.parse_args()

    if args.verbose:
        lg_root.setLevel(logging.INFO)

    if args.debug:
        lg_root.setLevel(logging.DEBUG)

    client = Aptly(args.url, dry=args.dry, timeout=args.timeout)
    publishmgr = PublishManager(client)

    if args.action == 'publish':
        action_publish(client,
                       publishmgr,
                       config_file=args.config,
                       recreate=args.recreate,
                       no_recreate=args.no_recreate,
                       force_overwrite=args.force_overwrite,
                       publish_contents=args.publish_contents,
                       publish_names=args.publish,
                       publish_dist=args.dists,
                       architectures=args.architectures)
    elif args.action == 'promote':
        if not args.source or not args.target:
            parser.error(
                "Action 'promote' requires both --source and --target arguments"
            )
        action_promote(client,
                       source=args.source,
                       target=args.target,
                       components=args.components,
                       recreate=args.recreate,
                       no_recreate=args.no_recreate,
                       packages=args.packages,
                       diff=args.diff,
                       force_overwrite=args.force_overwrite,
                       publish_contents=args.publish_contents)
    elif args.action == 'cleanup':
        publishmgr.cleanup_snapshots()
        sys.exit(0)
    elif args.action == 'dump':
        action_dump(publishmgr, args.save_dir, args.publish, args.prefix)
    elif args.action == "restore":
        action_restore(publishmgr,
                       components=args.components,
                       recreate=args.recreate,
                       restore_file=args.restore_file)