def create(self, name, environment, checksumtype='sha256'): repo_id = "{0}-{1}".format(name, environment) relative_url = "/{0}/{1}/".format(environment, name) checksumtype = checksumtype pulp = RepositoryAPI(self.connection) response = pulp.create_and_configure( id=repo_id, display_name=name, description=repo_id, notes={'_repo-type': 'rpm-repo'}, importer_type_id='yum_importer', importer_config={}, distributors=[{'distributor_id': 'yum_distributor', 'distributor_type_id': 'yum_distributor', 'distributor_config': { 'relative_url': relative_url, 'http': True, 'https': True, 'checksum_type': checksumtype }, 'auto_publish': True, 'relative_path': relative_url }] ) if response.response_code == Constants.PULP_POST_CREATED: Log.log_info("%s created in %s", name, environment) else: Log.log_info("failed to create %s in %s", name, environment) Log.log_debug(response)
def run(self): from pulp.bindings.repository import RepositoryAPI for environment in self.args.environment: repo_id = "{0}-{1}".format(self.args.repo, environment) pulp = RepositoryAPI(self.connections[environment]) response = pulp.delete(repo_id) if response.response_code == Constants.PULP_DELETE_ACCEPTED: Log.log_info("%s deleted in %s", self.args.repo, environment) else: Log.log_info("failed to delete %s in %s", self.args.repo, environment) Log.log_debug(response)
def run(self): from pulp.bindings.repository import RepositoryAPI from pulp.bindings.repository import RepositoryActionsAPI for environment in self.args.environment: repo_id = "{0}-{1}".format(self.args.repo, environment) display_name = self.args.repo relative_url = "/{0}/{1}/".format(environment, self.args.repo) checksum_type = self.args.checksum_type pulp = RepositoryAPI(self.connections[environment]) response = pulp.create_and_configure( id=repo_id, display_name=display_name, description=repo_id, notes={'_repo-type': 'rpm-repo'}, importer_type_id='yum_importer', importer_config={}, distributors=[{ 'distributor_id': 'yum_distributor', 'distributor_type_id': 'yum_distributor', 'distributor_config': { 'relative_url': relative_url, 'http': True, 'https': True, 'checksum_type': checksum_type }, 'auto_publish': True, 'relative_path': relative_url }]) if response.response_code == Constants.PULP_POST_CREATED: Log.log_info("%s created in %s", display_name, environment) else: Log.log_info("failed to create %s in %s", display_name, environment) Log.log_debug(response) pulp = RepositoryActionsAPI(self.connections[environment]) response = pulp.publish(repo_id, 'yum_distributor', {}) if response.response_code == Constants.PULP_POST_ACCEPTED: Log.log_info("%s published in %s", display_name, environment) else: Log.log_info("failed to publish %s in %s", display_name, environment) Log.log_debug(response)
def run(self): from pulp.bindings.repository import RepositoryAPI from pulp.bindings.repository import RepositoryActionsAPI for environment in self.args.environment: repo_id = "{0}-{1}".format(self.args.repo, environment) display_name = self.args.repo relative_url = "/{0}/{1}/".format(environment, self.args.repo) checksum_type = self.args.checksum_type pulp = RepositoryAPI(self.connections[environment]) response = pulp.create_and_configure( id=repo_id, display_name=display_name, description=repo_id, notes={'_repo-type': 'rpm-repo'}, importer_type_id='yum_importer', importer_config={}, distributors=[{'distributor_id': 'yum_distributor', 'distributor_type_id': 'yum_distributor', 'distributor_config': { 'relative_url': relative_url, 'http': True, 'https': True, 'checksum_type': checksum_type }, 'auto_publish': True, 'relative_path': relative_url }] ) if response.response_code == Constants.PULP_POST_CREATED: Log.log_info("%s created in %s", display_name, environment) else: Log.log_info("failed to create %s in %s", display_name, environment) Log.log_debug(response) pulp = RepositoryActionsAPI(self.connections[environment]) response = pulp.publish(repo_id, 'yum_distributor', {}) if response.response_code == Constants.PULP_POST_ACCEPTED: Log.log_info("%s published in %s", display_name, environment) else: Log.log_info("failed to publish %s in %s", display_name, environment) Log.log_debug(response)
class TestRepositoryUpdateAPI(unittest.TestCase): def setUp(self): self.api = RepositoryAPI(mock.MagicMock(spec=PulpConnection)) self.expected_path = self.api.base_path + "foo/" self.repo_id = 'foo' def test_repo_only(self): self.api.update(self.repo_id, {'baz': 'qux'}) expected_body = {'delta': {'baz': 'qux'}} self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body) def test_distributors(self): self.api.update(self.repo_id, {}, distributor_configs={'foo': { 'bar': 'baz' }}) expected_body = { 'delta': {}, 'distributor_configs': { 'foo': { 'bar': 'baz' } } } self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body) def test_importer(self): self.api.update(self.repo_id, {}, importer_config={'foo': 'bar'}) expected_body = {'delta': {}, 'importer_config': {'foo': 'bar'}} self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body)
def create(self, name, environment, checksumtype='sha256'): repo_id = "{0}-{1}".format(name, environment) relative_url = "/{0}/{1}/".format(environment, name) checksumtype = checksumtype pulp = RepositoryAPI(self.connection) response = pulp.create_and_configure(id=repo_id, display_name=name, description=repo_id, notes={'_repo-type': 'rpm-repo'}, importer_type_id='yum_importer', importer_config={}, distributors=[{ 'distributor_id': 'yum_distributor', 'distributor_type_id': 'yum_distributor', 'distributor_config': { 'relative_url': relative_url, 'http': True, 'https': True, 'checksum_type': checksumtype }, 'auto_publish': True, 'relative_path': relative_url }]) if response.response_code == Constants.PULP_POST_CREATED: Log.log_info("%s created in %s", name, environment) else: Log.log_info("failed to create %s in %s", name, environment) Log.log_debug(response)
class TestRepositoryUpdateAPI(unittest.TestCase): def setUp(self): self.api = RepositoryAPI(mock.MagicMock(spec=PulpConnection)) self.expected_path = self.api.base_path + "foo/" self.repo_id = 'foo' def test_repo_only(self): self.api.update(self.repo_id, {'baz': 'qux'}) expected_body = {'delta': {'baz': 'qux'}} self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body) def test_distributors(self): self.api.update(self.repo_id, {}, distributor_configs={'foo': {'bar': 'baz'}}) expected_body = {'delta': {}, 'distributor_configs': {'foo': {'bar': 'baz'}}} self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body) def test_importer(self): self.api.update(self.repo_id, {}, importer_config={'foo': 'bar'}) expected_body = {'delta': {}, 'importer_config': {'foo': 'bar'}} self.api.server.PUT.assert_called_once_with(self.expected_path, expected_body)
def setUp(self): self.api = RepositoryAPI(mock.MagicMock(spec=PulpConnection)) self.expected_path = self.api.base_path + "foo/" self.repo_id = 'foo'