Exemple #1
0
    def publish(self, name, environment):
        repo_id = "{0}-{1}".format(name, environment)
        pulp = RepositoryActionsAPI(self.connection)
        response = pulp.publish(repo_id, 'yum_distributor', {})

        if response.response_code == Constants.PULP_POST_ACCEPTED:
            Log.log_debug("%s published in %s", name, environment)
        else:
            Log.log_debug("failed to publish %s in %s", name, environment)
            Log.log_debug(response)
Exemple #2
0
    def publish(self, name, environment):
        repo_id = "{0}-{1}".format(name, environment)
        pulp = RepositoryActionsAPI(self.connection)
        response = pulp.publish(repo_id, 'yum_distributor', {})

        if response.response_code == Constants.PULP_POST_ACCEPTED:
            Log.log_debug("%s published in %s", name, environment)
        else:
            Log.log_debug("failed to publish %s in %s", name, environment)
            Log.log_debug(response)
Exemple #3
0
class TestRepositoryActionsAPI(unittest.TestCase):
    """Tests for the binding to the 'v2/repositories/<repo-id>/actions/sync/' API."""

    def setUp(self):
        self.pulp_connection = mock.MagicMock(spec=PulpConnection)
        self.actions_api = RepositoryActionsAPI(self.pulp_connection)
        self.repo_id = 'mock_repo'
        self.override_config = {'key': 'value'}

    def test_sync(self):
        """Assert the sync API path is called."""
        self.response = self.actions_api.sync(self.repo_id, self.override_config)
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/sync/',
            {'override_config': self.override_config}
        )

    def test_publish(self):
        """Assert the publish API path is called."""
        self.response = self.actions_api.publish(
            self.repo_id,
            'mock_distributor',
            self.override_config
        )
        self.override_config['id'] = 'mock_distributor'
        body = {'id': 'mock_distributor', 'override_config': self.override_config}
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/publish/',
            body
        )

    def test_associate(self):
        """Assert the associate API path is called."""
        self.response = self.actions_api.associate(self.repo_id, 'other_repo')
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/associate/',
            {'source_repo_id': 'other_repo'}
        )

    def test_download(self):
        """Assert the download API path is called and the default parameters are correct."""
        self.response = self.actions_api.download(self.repo_id)
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/download/',
            {'verify_all_units': False}
        )

    def test_download_verify(self):
        """Assert the download API path is called and the default parameters are correct."""
        self.response = self.actions_api.download(self.repo_id, verify_all_units=True)
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/download/',
            {'verify_all_units': True}
        )
Exemple #4
0
class TestRepositoryActionsAPI(unittest.TestCase):
    """Tests for the binding to the 'v2/repositories/<repo-id>/actions/sync/' API."""
    def setUp(self):
        self.pulp_connection = mock.MagicMock(spec=PulpConnection)
        self.actions_api = RepositoryActionsAPI(self.pulp_connection)
        self.repo_id = 'mock_repo'
        self.override_config = {'key': 'value'}

    def test_sync(self):
        """Assert the sync API path is called."""
        self.response = self.actions_api.sync(self.repo_id,
                                              self.override_config)
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/sync/',
            {'override_config': self.override_config})

    def test_publish(self):
        """Assert the publish API path is called."""
        self.response = self.actions_api.publish(self.repo_id,
                                                 'mock_distributor',
                                                 self.override_config)
        self.override_config['id'] = 'mock_distributor'
        body = {
            'id': 'mock_distributor',
            'override_config': self.override_config
        }
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/publish/', body)

    def test_associate(self):
        """Assert the associate API path is called."""
        self.response = self.actions_api.associate(self.repo_id, 'other_repo')
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/associate/',
            {'source_repo_id': 'other_repo'})

    def test_download(self):
        """Assert the download API path is called and the default parameters are correct."""
        self.response = self.actions_api.download(self.repo_id)
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/download/',
            {'verify_all_units': False})

    def test_download_verify(self):
        """Assert the download API path is called and the default parameters are correct."""
        self.response = self.actions_api.download(self.repo_id,
                                                  verify_all_units=True)
        self.pulp_connection.POST.assert_called_once_with(
            '/v2/repositories/mock_repo/actions/download/',
            {'verify_all_units': True})
Exemple #5
0
    def run(self):
        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

            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)
Exemple #6
0
    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)
Exemple #7
0
 def setUp(self):
     self.pulp_connection = mock.MagicMock(spec=PulpConnection)
     self.actions_api = RepositoryActionsAPI(self.pulp_connection)
     self.repo_id = 'mock_repo'
     self.override_config = {'key': 'value'}
Exemple #8
0
 def setUp(self):
     self.pulp_connection = mock.MagicMock(spec=PulpConnection)
     self.actions_api = RepositoryActionsAPI(self.pulp_connection)
     self.repo_id = 'mock_repo'
     self.override_config = {'key': 'value'}