Exemplo n.º 1
0
def upgrade(v1_database, v2_database):
    report = UpgradeStepReport()

    # Applies to both yum and iso importers
    repo_importers = v2_database.repo_importers.find()
    for repo_importer in repo_importers:
        repo_working_dir = repos.importer_working_dir(
            repo_importer['importer_type_id'], repo_importer['repo_id'])

        # CA certificate
        if repo_importer['config'].get('ssl_ca_cert', None):
            filename = os.path.join(repo_working_dir, 'ssl_ca_cert')
            f = open(filename, 'w')
            f.write(repo_importer['config']['ssl_ca_cert'])
            f.close()

        # Client Certificate
        if repo_importer['config'].get('ssl_client_cert', None):
            filename = os.path.join(repo_working_dir, 'ssl_client_cert')
            f = open(filename, 'w')
            f.write(repo_importer['config']['ssl_client_cert'])
            f.close()

    report.succeeded()
    return report
Exemplo n.º 2
0
    def test_upgrade(self):
        # Test
        report = repos.upgrade(self.v1_test_db.database,
                               self.tmp_test_db.database)

        # Verify
        self.assertTrue(report.success)

        all_repos = self.tmp_test_db.database.repos.find({})
        self.assertTrue(all_repos.count() > 0)
        for r in all_repos:
            working_dir = repos.repository_working_dir(r['id'], mkdir=False)
            self.assertTrue(os.path.exists(working_dir),
                            msg='Missing: %s' % working_dir)

        repo_importers = self.tmp_test_db.database.repo_importers.find({})
        self.assertTrue(repo_importers.count() > 0)
        for i in repo_importers:
            working_dir = repos.importer_working_dir(i['importer_type_id'],
                                                     i['repo_id'],
                                                     mkdir=False)
            self.assertTrue(os.path.exists(working_dir),
                            msg='Missing: %s' % working_dir)

        repo_distributors = self.tmp_test_db.database.repo_distributors.find(
            {})
        self.assertTrue(repo_distributors.count() > 0)
        for d in repo_distributors:
            working_dir = repos.distributor_working_dir(
                d['distributor_type_id'], d['repo_id'], mkdir=False)
            self.assertTrue(os.path.exists(working_dir),
                            msg='Missing: %s' % working_dir)
Exemplo n.º 3
0
    def test_upgrade(self):
        # Test
        report = feed_certs.upgrade(self.v1_test_db.database, self.tmp_test_db.database)

        # Verify
        self.assertTrue(report is not None)
        self.assertTrue(report.success)

        all_repo_importers = self.tmp_test_db.database.repo_importers.find({})
        self.assertTrue(all_repo_importers.count() > 0)
        for repo_importer in all_repo_importers:
            importer_working_dir = repos.importer_working_dir(repo_importer['importer_type_id'],
                                                              repo_importer['repo_id'],
                                                              mkdir=False)

            expected_cert_path = os.path.join(importer_working_dir, 'ssl_ca_cert')
            self.assertTrue(os.path.exists(expected_cert_path))
            self._assert_contents(expected_cert_path, repo_importer['config']['ssl_ca_cert'])

            expected_cert_path = os.path.join(importer_working_dir, 'ssl_client_cert')
            self.assertTrue(os.path.exists(expected_cert_path))
            self._assert_contents(expected_cert_path, repo_importer['config']['ssl_client_cert'])
Exemplo n.º 4
0
    def test_upgrade(self):
        # Test
        report = feed_certs.upgrade(self.v1_test_db.database, self.tmp_test_db.database)

        # Verify
        self.assertTrue(report is not None)
        self.assertTrue(report.success)

        # Primarily, the upgrade shouldn't error if the repo doesn't contain certs. Also
        # check to make sure it's not writing cert files anyway.

        all_repo_importers = self.tmp_test_db.database.repo_importers.find({})
        self.assertTrue(all_repo_importers.count() > 0)
        for repo_importer in all_repo_importers:
            importer_working_dir = repos.importer_working_dir(repo_importer['importer_type_id'],
                                                              repo_importer['repo_id'],
                                                              mkdir=False)

            expected_cert_path = os.path.join(importer_working_dir, 'ssl_ca_cert')
            self.assertTrue(not os.path.exists(expected_cert_path))

            expected_cert_path = os.path.join(importer_working_dir, 'ssl_client_cert')
            self.assertTrue(not os.path.exists(expected_cert_path))
Exemplo n.º 5
0
    def test_upgrade(self):
        # Test
        report = repos.upgrade(self.v1_test_db.database, self.tmp_test_db.database)

        # Verify
        self.assertTrue(report.success)

        all_repos = self.tmp_test_db.database.repos.find({})
        self.assertTrue(all_repos.count() > 0)
        for r in all_repos:
            working_dir = repos.repository_working_dir(r['id'], mkdir=False)
            self.assertTrue(os.path.exists(working_dir), msg='Missing: %s' % working_dir)

        repo_importers = self.tmp_test_db.database.repo_importers.find({})
        self.assertTrue(repo_importers.count() > 0)
        for i in repo_importers:
            working_dir = repos.importer_working_dir(i['importer_type_id'], i['repo_id'], mkdir=False)
            self.assertTrue(os.path.exists(working_dir), msg='Missing: %s' % working_dir)

        repo_distributors = self.tmp_test_db.database.repo_distributors.find({})
        self.assertTrue(repo_distributors.count() > 0)
        for d in repo_distributors:
            working_dir = repos.distributor_working_dir(d['distributor_type_id'], d['repo_id'], mkdir=False)
            self.assertTrue(os.path.exists(working_dir), msg='Missing: %s' % working_dir)
Exemplo n.º 6
0
def upgrade(v1_database, v2_database):
    report = UpgradeStepReport()

    # Applies to both yum and iso importers
    repo_importers = v2_database.repo_importers.find()
    for repo_importer in repo_importers:
        repo_working_dir = repos.importer_working_dir(repo_importer['importer_type_id'], repo_importer['repo_id'])

        # CA certificate
        if repo_importer['config'].get('ssl_ca_cert', None):
            filename = os.path.join(repo_working_dir, 'ssl_ca_cert')
            f = open(filename, 'w')
            f.write(repo_importer['config']['ssl_ca_cert'])
            f.close()

        # Client Certificate
        if repo_importer['config'].get('ssl_client_cert', None):
            filename = os.path.join(repo_working_dir, 'ssl_client_cert')
            f = open(filename, 'w')
            f.write(repo_importer['config']['ssl_client_cert'])
            f.close()

    report.succeeded()
    return report