Ejemplo n.º 1
0
def quay_migration(args, work_dir):
    # Set up and verify the connection to Artifactory
    art_access = setup_art_access(args.artifactory, args.username, args.password, args.repo, args.ignore_cert)

    q = Queue.Queue()

    # If the user provides a set of images, don't query the upstream
    if 'image_file' in args and args.image_file:
        image_names, images = parse_image_file(args.image_file)
        for image_name, tag in images:
            q.put_nowait((image_name, tag))
    else:
        quay = QuayAccess(args.namespace, args.token)
        image_names = quay.get_catalog()
        if not image_names:
            logging.error("Failed to retrieve catalog.")
    # Set up the token based connection to Quay
    source = DockerRegistryAccess(url="https://quay.io", username="******", password=args.token,
                                  ignore_cert=args.ignore_cert)
    if image_names:
        print "Found %d repositories." % len(image_names)
        populate_tags(image_names, source, q)
    if not q.empty():
        # Perform the migration
        perform_migration(source, art_access, q, work_dir, "quay")
    else:
        print "Nothing to migrate."
Ejemplo n.º 2
0
def ecr_migration(args, work_dir):
    if args.workers < MIN_NUM_OF_WORKERS or args.workers > MAX_NUM_OF_WORKERS:
        parser.error("--num-of-workers must be between %d and %d." % (MIN_NUM_OF_WORKERS, MAX_NUM_OF_WORKERS))

    # Set up and verify the connection to the source registry
    source = DockerRegistryAccess(url=args.source, username='******', password=args.token, method='basic',
                                  ignore_cert=args.ignore_cert)
    common_migration(args, work_dir, source, "ecr")
Ejemplo n.º 3
0
def gcr_migration(args, work_dir):
    if args.workers < MIN_NUM_OF_WORKERS or args.workers > MAX_NUM_OF_WORKERS:
        parser.error("--num-of-workers must be between %d and %d." % (MIN_NUM_OF_WORKERS, MAX_NUM_OF_WORKERS))
    password = parse_key_file(args.keyfile)
    if not password:
        sys.exit("Unable to read key file or key is empty.")
    # Set up and verify the connection to the source registry
    source = DockerRegistryAccess(url=args.source, username='******', password=password, method='basic',
                                  ignore_cert=args.ignore_cert)
    common_migration(args, work_dir, source, "gcr")
Ejemplo n.º 4
0
def generic_migration(args, work_dir, registry="generic"):
    # Verify the more intricate argument requirements
    if bool(args.source_username) != bool(args.source_password):
        parser.error("--source-username and --source-password must both be provided or neither.")
    if args.workers < MIN_NUM_OF_WORKERS or args.workers > MAX_NUM_OF_WORKERS:
        parser.error("--num-of-workers must be between %d and %d." % (MIN_NUM_OF_WORKERS, MAX_NUM_OF_WORKERS))

    # Set up and verify the connection to the source registry
    source = DockerRegistryAccess(url=args.source, username=args.source_username, password=args.source_password,
                                  ignore_cert=args.ignore_cert)
    common_migration(args, work_dir, source, registry)
Ejemplo n.º 5
0
def generic_migration(args, work_dir):
    # Verify the more intricate argument requirements
    if bool(args.source_username) != bool(args.source_password):
        parser.error("--source-username and --source-password must both be provided or neither.")
    if args.workers < MIN_NUM_OF_WORKERS or args.workers > MAX_NUM_OF_WORKERS:
        parser.error("--num-of-workers must be between %d and %d." % (MIN_NUM_OF_WORKERS, MAX_NUM_OF_WORKERS))

    # Set up and verify the connection to the source registry
    source = DockerRegistryAccess(args.source, args.source_username, args.source_password, args.ignore_cert)
    if not source.verify_is_v2():
        sys.exit("The provided URL does not appear to be a valid V2 repository.")

    # Set up and verify the connection to Artifactory
    art_access = setup_art_access(args.artifactory, args.username, args.password, args.repo, args.ignore_cert)

    image_names = []
    q = Queue.Queue()
    # Build the list of image/tags
    # If the user provides a set of images, don't query the upstream
    if 'image_file' in args and args.image_file:
        image_names, images = parse_image_file(args.image_file)
        for image_name, tag in images:
            q.put_nowait((image_name, tag))
    else:
        logging.info("Requesting catalog from source registry.")
        image_names = source.get_catalog()
        if not image_names:
            print "Found no repositories."

    if image_names:
        print "Found %d repositories." % len(image_names)
        populate_tags(image_names, source, q)
    if not q.empty():
        # Perform the migration
        perform_migration(source, art_access, q, work_dir)
    else:
        print "Nothing to migrate."