def setUpClass(cls): """Create class-wide variables.""" cls.cfg = config.get_config() cls.file_repositories_api = RepositoriesFileApi( FileApiClient(cls.cfg.get_bindings_config())) cls.repo = cls.file_repositories_api.create(gen_repo()) cls.file_content_api = ContentFilesApi( FileApiClient(cls.cfg.get_bindings_config())) with tempfile.NamedTemporaryFile() as tmp_file: tmp_file.write(b"not empty") tmp_file.flush() monitor_task( cls.file_content_api.create(relative_path=utils.uuid4(), file=tmp_file.name).task) cls.cert_guards_api = ContentGuardsX509Api( CertGuardApiClient(cls.cfg.get_bindings_config())) with open(X509_CA_CERT_FILE_PATH, "r") as x509_ca_cert_data_file: x509_ca_cert_data = x509_ca_cert_data_file.read() cls.content_guard = cls.cert_guards_api.create({ "name": utils.uuid4(), "ca_certificate": x509_ca_cert_data })
def gen_user(cfg=config.get_config(), model_permissions=None, object_permissions=None): """Create a user with a set of permissions in the pulp database.""" cli_client = cli.Client(cfg) if model_permissions is None: model_permissions = [] if object_permissions is None: object_permissions = [] user = { "username": utils.uuid4(), "password": utils.uuid4(), "model_permissions": model_permissions, "object_permissions": object_permissions, } utils.execute_pulpcore_python( cli_client, "\n".join(CREATE_USER_CMD).format(**user), ) api_config = cfg.get_bindings_config() api_config.username = user["username"] api_config.password = user["password"] user["core_api_client"] = CoreApiClient(api_config) user["api_client"] = FileApiClient(api_config) user["distribution_api"] = DistributionsFileApi(user["api_client"]) return user
def setUpClass(cls): """Initialize class-wide variables""" cls.cfg = config.get_config() cls.api_client = api.Client(cls.cfg, api.json_handler) cls.file_client = FileApiClient(cls.cfg.get_bindings_config()) cls.remotes_api = RemotesFileApi(cls.file_client)
def setUpClass(cls): """ Create all the client instances needed to communicate with Pulp. """ configuration = Configuration(**BINDINGS_CONFIGURATION) file_client = FileApiClient(configuration) migration_client = MigrationApiClient(configuration) # Create api clients for all resource types cls.file_repo_api = RepositoriesFileApi(file_client) cls.file_content_api = ContentFilesApi(file_client) cls.migration_plans_api = MigrationPlansApi(migration_client) cls.pulp2content_api = Pulp2ContentApi(migration_client) cls.pulp2repositories_api = Pulp2RepositoriesApi(migration_client) set_pulp2_snapshot(name='file_base_4repos')
def setUpClass(cls): """ Create all the client instances needed to communicate with Pulp. """ configuration = Configuration(**BINDINGS_CONFIGURATION) file_client = FileApiClient(configuration) migration_client = MigrationApiClient(configuration) # Create api clients for all resource types cls.file_repo_api = RepositoriesFileApi(file_client) cls.file_repo_versions_api = RepositoriesFileVersionsApi(file_client) cls.file_remote_api = RemotesFileApi(file_client) cls.file_distribution_api = DistributionsFileApi(file_client) cls.file_publication_api = PublicationsFileApi(file_client) cls.file_content_api = ContentFilesApi(file_client) cls.migration_plans_api = MigrationPlansApi(migration_client) cls.pulp2content_api = Pulp2ContentApi(migration_client) cls.pulp2repositories_api = Pulp2RepositoriesApi(migration_client)
def setUpClass(cls): """ Create all the client instances needed to communicate with Pulp. """ configuration = Configuration() configuration.username = '******' configuration.password = '******' configuration.host = 'http://pulp' configuration.safe_chars_for_path_param = '/' core_client = CoreApiClient(configuration) file_client = FileApiClient(configuration) migration_client = MigrationApiClient(configuration) # Create api clients for all resource types cls.file_repo_api = RepositoriesFileApi(file_client) cls.file_repo_versions_api = RepositoriesFileVersionsApi(file_client) cls.file_content_api = ContentFilesApi(file_client) cls.tasks_api = TasksApi(core_client) cls.migration_plans_api = MigrationPlansApi(migration_client)
def setUp(self): self.client = FileApiClient(self.cfg.get_bindings_config()) self.remotes_api = RemotesFileApi(self.client) self.remote_attrs = { "name": utils.uuid4(), "url": FILE_FIXTURE_MANIFEST_URL, "ca_cert": None, "client_cert": None, "client_key": None, "tls_validation": False, "proxy_url": None, "username": "******", "password": "******", "download_concurrency": 10, "policy": "on_demand", "total_timeout": None, "connect_timeout": None, "sock_connect_timeout": None, "sock_read_timeout": None, } self.remote = self.remotes_api.create(self.remote_attrs)
def setUpClass(cls): """ Create all the client instances needed to communicate with Pulp. """ configuration = Configuration(**BINDINGS_CONFIGURATION) file_client = FileApiClient(configuration) rpm_client = RpmApiClient(configuration) migration_client = MigrationApiClient(configuration) # Create api clients for File cls.file_repo_api = RepositoriesFileApi(file_client) cls.file_repo_versions_api = RepositoriesFileVersionsApi(file_client) cls.file_remote_api = RemotesFileApi(file_client) cls.file_distribution_api = DistributionsFileApi(file_client) cls.file_publication_api = PublicationsFileApi(file_client) cls.file_content_api = ContentFilesApi(file_client) # Create api clients for RPM cls.rpm_repo_api = RepositoriesRpmApi(rpm_client) cls.rpm_repo_versions_api = RepositoriesRpmVersionsApi(rpm_client) cls.rpm_remote_api = RemotesRpmApi(rpm_client) cls.rpm_distribution_api = DistributionsRpmApi(rpm_client) cls.rpm_publication_api = PublicationsRpmApi(rpm_client) cls.rpm_content_apis = { 'advisory': ContentAdvisoriesApi(rpm_client), 'disttree': ContentDistributionTreesApi(rpm_client), 'modulemd': ContentModulemdsApi(rpm_client), 'modulemd-defaults': ContentModulemdDefaultsApi(rpm_client), 'category': ContentPackagecategoriesApi(rpm_client), 'environment': ContentPackageenvironmentsApi(rpm_client), 'group': ContentPackagegroupsApi(rpm_client), 'langpack': ContentPackagelangpacksApi(rpm_client), 'package': ContentPackagesApi(rpm_client), } # Create api clients for Migration cls.migration_plans_api = MigrationPlansApi(migration_client) cls.pulp2content_api = Pulp2ContentApi(migration_client) cls.pulp2repositories_api = Pulp2RepositoriesApi(migration_client)
def gen_file_client(): """Return an OBJECT for file client.""" configuration = config.get_config().get_bindings_config() return FileApiClient(configuration)
upload.pulp_href, UploadCommit(sha256=sha256hasher.hexdigest()) ) created_resources = monitor_task(commit_response.task) artifact = artifacts.read(created_resources[0]) return artifact # Configure HTTP basic authorization: basic configuration = Configuration() configuration.username = '******' configuration.password = '******' configuration.safe_chars_for_path_param = '/' core_client = CoreApiClient(configuration) file_client = FileApiClient(configuration) # Create api clients for all resource types artifacts = ArtifactsApi(core_client) repositories = RepositoriesApi(core_client) repoversions = RepositoriesVersionsApi(core_client) filecontent = ContentFilesApi(file_client) filedistributions = DistributionsFileApi(core_client) filepublications = PublicationsFileApi(file_client) fileremotes = RemotesFileApi(file_client) tasks = TasksApi(core_client) uploads = UploadsApi(core_client) # Test creating an Artifact from a 1mb file uploaded in 200kb chunks with NamedTemporaryFile() as downloaded_file:
def gen_file_client(): """Return an OBJECT for file client.""" return FileApiClient(configuration)
def setUp(self): """Create an API client.""" self.client = FileApiClient(self.cfg.get_bindings_config()) self.repo_api = RepositoriesFileApi(self.client)