示例#1
0
    def test_unbind_repo_exists(self):
        """
        Tests the normal case of unbinding a repo that exists in the repo file.
        """

        # Setup
        repoid = 'test-unbind-repo'
        repo_file = RepoFile(self.TEST_REPO_FILENAME)
        repo_file.add_repo(Repo(repoid))
        repo_file.save()

        # Test
        repolib.unbind(self.TEST_REPO_FILENAME, self.TEST_MIRROR_LIST_FILENAME, self.TEST_KEYS_DIR,
                       self.TEST_CERT_DIR,
                       'test-unbind-repo', self.LOCK)

        # verify
        repo_file = RepoFile(self.TEST_REPO_FILENAME)
        repo_file.load(
            allow_missing=False)  # the file should still be there, so error if it doesn't

        self.assertEqual(0, len(repo_file.all_repos()))

        certdir = os.path.join(self.TEST_CERT_DIR, repoid)
        self.assertFalse(os.path.exists(certdir))
示例#2
0
    def test_unbind_repo_exists(self):
        """
        Tests the normal case of unbinding a repo that exists in the repo file.
        """

        # Setup
        repoid = 'test-unbind-repo'
        repo_file = RepoFile(self.TEST_REPO_FILENAME)
        repo_file.add_repo(Repo(repoid))
        repo_file.save()

        # Test
        repolib.unbind(self.TEST_REPO_FILENAME, self.TEST_MIRROR_LIST_FILENAME, self.TEST_KEYS_DIR,
                       self.TEST_CERT_DIR,
                       'test-unbind-repo', self.LOCK)

        # verify
        repo_file = RepoFile(self.TEST_REPO_FILENAME)
        repo_file.load(
            allow_missing=False)  # the file should still be there, so error if it doesn't

        self.assertEqual(0, len(repo_file.all_repos()))

        certdir = os.path.join(self.TEST_CERT_DIR, repoid)
        self.assertFalse(os.path.exists(certdir))
示例#3
0
    def test_unbind_missing_file(self):
        """
        Tests that calling unbind in the case where the underlying .repo file has been
        deleted does not result in an error.
        """

        # Setup
        self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)
示例#4
0
    def test_unbind_missing_repo(self):
        """
        Tests that calling unbind on a repo that isn't bound does not result in
        an error.
        """

        # Setup
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME, ['http://pulp'], {}, None, None, ENABLED, LOCK)

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR, 'fake-repo', LOCK)
示例#5
0
    def test_unbind_missing_repo(self):
        """
        Tests that calling unbind on a repo that isn't bound does not result in
        an error.
        """
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR,
                     REPO_ID, REPO_NAME, ['http://pulp'], {}, None, ENABLED, LOCK)

        # This shouldn't throw an error; the net effect is still that the repo is unbound. This test
        # just makes sure this runs without error, which is why there are no assertions.
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR,
                       'fake-repo', LOCK)
示例#6
0
    def test_unbind_missing_file(self):
        """
        Tests that calling unbind in the case where the underlying .repo file has been
        deleted does not result in an error.
        """

        # Setup
        self.assertTrue(not os.path.exists(TEST_REPO_FILENAME))

        # Test
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME,
                       TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)
示例#7
0
    def test_unbind_missing_repo(self):
        """
        Tests that calling unbind on a repo that isn't bound does not result in
        an error.
        """
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME,
                     TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME,
                     ['http://pulp'], {}, None, ENABLED, LOCK)

        # This shouldn't throw an error; the net effect is still that the repo is unbound. This test
        # just makes sure this runs without error, which is why there are no assertions.
        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME,
                       TEST_KEYS_DIR, TEST_CERT_DIR, 'fake-repo', LOCK)
示例#8
0
    def test_unbind_repo_with_keys(self):
        """
        Tests that unbinding a repo that had GPG keys deletes the key files.
        """
        url_list = ['http://pulp1']
        keys = {'key1' : 'KEY1', 'key2' : 'KEY2'}
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR,
                     REPO_ID, REPO_NAME, url_list, keys, None, ENABLED, LOCK)
        self.assertTrue(os.path.exists(os.path.join(TEST_KEYS_DIR, REPO_ID)))

        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR,
                       REPO_ID, LOCK)

        self.assertTrue(not os.path.exists(os.path.join(TEST_KEYS_DIR, REPO_ID)))
示例#9
0
    def test_unbind_repo_with_keys(self):
        """
        Tests that unbinding a repo that had GPG keys deletes the key files.
        """
        url_list = ['http://pulp1']
        keys = {'key1': 'KEY1', 'key2': 'KEY2'}
        repolib.bind(self.TEST_REPO_FILENAME, self.TEST_MIRROR_LIST_FILENAME, self.TEST_KEYS_DIR,
                     self.TEST_CERT_DIR,
                     REPO_ID, REPO_NAME, url_list, keys, None, ENABLED, self.LOCK)
        self.assertTrue(os.path.exists(os.path.join(self.TEST_KEYS_DIR, REPO_ID)))

        repolib.unbind(self.TEST_REPO_FILENAME, self.TEST_MIRROR_LIST_FILENAME, self.TEST_KEYS_DIR,
                       self.TEST_CERT_DIR,
                       REPO_ID, self.LOCK)

        self.assertTrue(not os.path.exists(os.path.join(self.TEST_KEYS_DIR, REPO_ID)))
示例#10
0
    def test_unbind_repo_with_mirrorlist(self):
        """
        Tests that unbinding a repo that had a mirror list deletes the mirror list
        file.
        """
        url_list = ['http://pulp1', 'http://pulp2', 'http://pulp3']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR,
                     REPO_ID, REPO_NAME, url_list, {}, None, ENABLED, LOCK)
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME, TEST_KEYS_DIR, TEST_CERT_DIR,
                       REPO_ID, LOCK)

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()
        self.assertEqual(0, len(repo_file.all_repos()))
        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
示例#11
0
    def test_unbind_repo_with_mirrorlist(self):
        """
        Tests that unbinding a repo that had a mirror list deletes the mirror list
        file.
        """
        url_list = ['http://pulp1', 'http://pulp2', 'http://pulp3']
        repolib.bind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME,
                     TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, REPO_NAME,
                     url_list, {}, None, ENABLED, LOCK)
        self.assertTrue(os.path.exists(TEST_MIRROR_LIST_FILENAME))

        repolib.unbind(TEST_REPO_FILENAME, TEST_MIRROR_LIST_FILENAME,
                       TEST_KEYS_DIR, TEST_CERT_DIR, REPO_ID, LOCK)

        repo_file = RepoFile(TEST_REPO_FILENAME)
        repo_file.load()
        self.assertEqual(0, len(repo_file.all_repos()))
        self.assertTrue(not os.path.exists(TEST_MIRROR_LIST_FILENAME))
示例#12
0
 def unbind(self, conduit, repo_id, options):
     """
     Bind a repository.
         @param conduit: A handler conduit.
     @type conduit: L{pulp.agent.lib.conduit.Conduit}
     @param repo_id: A repository ID.
     @type repo_id: str
     @param options: Unbind options.
     @type options: dict
     @return: An unbind report.
     @rtype: L{BindReport}
     """
     log.info('unbind: %s, options:%s', repo_id, options)
     cfg = conduit.get_consumer_config().graph()
     report = BindReport(repo_id)
     repolib.unbind(cfg.filesystem.repo_file,
                    os.path.join(cfg.filesystem.mirror_list_dir,
                                 repo_id), cfg.filesystem.gpg_keys_dir,
                    cfg.filesystem.cert_dir, repo_id)
     report.set_succeeded()
     return report
示例#13
0
文件: bind.py 项目: asmacdo/pulp_rpm
 def unbind(self, conduit, repo_id, options):
     """
     Bind a repository.
         @param conduit: A handler conduit.
     @type conduit: L{pulp.agent.lib.conduit.Conduit}
     @param repo_id: A repository ID.
     @type repo_id: str
     @param options: Unbind options.
     @type options: dict
     @return: An unbind report.
     @rtype: L{BindReport}
     """
     log.info('unbind: %s, options:%s', repo_id, options)
     cfg = conduit.get_consumer_config().graph()
     report = BindReport(repo_id)
     repolib.unbind(
         cfg.filesystem.repo_file,
         os.path.join(cfg.filesystem.mirror_list_dir, repo_id),
         cfg.filesystem.gpg_keys_dir,
         cfg.filesystem.cert_dir,
         repo_id)
     report.set_succeeded()
     return report