Пример #1
0
def migrate(ctx, database, force, yes, dockerd_socket):
    """ Migrate packages from the given database file. """

    manager: PackageManager = ctx.obj

    if not yes and not force:
        click.confirm('Continue with package migration?', abort=True, show_default=True)

    try:
        manager.migrate_packages(PackageDatabase.from_file(database), dockerd_socket)
    except Exception as err:
        exit_cli(f'Failed to migrate packages {err}', fg='red')
    except KeyboardInterrupt:
        exit_cli('Operation canceled by user', fg='red')
Пример #2
0
    def get_manager() -> 'PackageManager':
        """ Creates and returns PackageManager instance.

        Returns:
            PackageManager
        """

        docker_api = DockerApi(docker.from_env())
        registry_resolver = RegistryResolver()
        return PackageManager(
            DockerApi(docker.from_env(), ProgressManager()), registry_resolver,
            PackageDatabase.from_file(),
            MetadataResolver(docker_api, registry_resolver),
            ServiceCreator(FeatureRegistry(SonicDB), SonicDB), device_info,
            filelock.FileLock(PACKAGE_MANAGER_LOCK_FILE, timeout=0))
Пример #3
0
    def get_manager() -> 'PackageManager':
        """ Creates and returns PackageManager instance.

        Returns:
            PackageManager
        """

        docker_api = DockerApi(docker.from_env(), ProgressManager())
        registry_resolver = RegistryResolver()
        metadata_resolver = MetadataResolver(docker_api, registry_resolver)
        cfg_mgmt = config_mgmt.ConfigMgmt(source=INIT_CFG_JSON)
        cli_generator = CliGenerator(log)
        feature_registry = FeatureRegistry(SonicDB)
        service_creator = ServiceCreator(feature_registry, SonicDB,
                                         cli_generator, cfg_mgmt)

        return PackageManager(
            docker_api, registry_resolver, PackageDatabase.from_file(),
            metadata_resolver, service_creator, device_info,
            filelock.FileLock(PACKAGE_MANAGER_LOCK_FILE, timeout=0))
Пример #4
0
def fake_db_for_migration(fake_metadata_resolver):
    content = {}
    add_package(content,
                fake_metadata_resolver,
                'docker-database',
                'latest',
                description='SONiC database service',
                default_reference='1.0.0',
                installed=True,
                built_in=True)
    add_package(content,
                fake_metadata_resolver,
                'docker-orchagent',
                'latest',
                description='SONiC switch state service',
                default_reference='1.0.0',
                installed=True,
                built_in=True)
    add_package(content,
                fake_metadata_resolver,
                'Azure/docker-test',
                '1.6.0',
                description='SONiC Package Manager Test Package',
                default_reference='1.6.0',
                installed=False,
                built_in=False)
    add_package(content,
                fake_metadata_resolver,
                'Azure/docker-test-2',
                '2.0.0',
                description='SONiC Package Manager Test Package #2',
                default_reference='2.0.0',
                installed=False,
                built_in=False)
    add_package(content,
                fake_metadata_resolver,
                'Azure/docker-test-3',
                '1.6.0',
                description='SONiC Package Manager Test Package #3',
                default_reference='1.6.0',
                installed=True,
                built_in=False)
    add_package(content,
                fake_metadata_resolver,
                'Azure/docker-test-4',
                '1.5.0',
                description='SONiC Package Manager Test Package #4',
                default_reference='1.5.0',
                installed=True,
                built_in=False)
    add_package(content,
                fake_metadata_resolver,
                'Azure/docker-test-5',
                '1.5.0',
                description='SONiC Package Manager Test Package #5',
                default_reference='1.5.0',
                installed=True,
                built_in=False)
    add_package(content,
                fake_metadata_resolver,
                'Azure/docker-test-6',
                '2.0.0',
                description='SONiC Package Manager Test Package #6',
                default_reference='2.0.0',
                installed=True,
                built_in=False)

    yield PackageDatabase(content)