当前位置: 首页>>代码示例>>Python>>正文


Python Manifest.check_signature方法代码示例

本文整理汇总了Python中manifest.Manifest.check_signature方法的典型用法代码示例。如果您正苦于以下问题:Python Manifest.check_signature方法的具体用法?Python Manifest.check_signature怎么用?Python Manifest.check_signature使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在manifest.Manifest的用法示例。


在下文中一共展示了Manifest.check_signature方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Activation

# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import check_signature [as 别名]

#.........这里部分代码省略.........
            satCerts.store_rhnCryptoKey(
                constants.CLIENT_KEY_PREFIX + creds.get_id(), creds.get_key(), None)

    def import_channel_families(self):
        """Insert channel family data into DB."""

        # Debug
        print("Channel families in cert: %d" % len(self.sat5_cert.channel_families)) # pylint: disable=E1101

        batch = []
        for cf in self.sat5_cert.channel_families: # pylint: disable=E1101
            label = cf.name
            try:
                family = self.families[label]
                family_object = ChannelFamily()
                for k in family.keys():
                    family_object[k] = family[k]
                family_object['label'] = label
                batch.append(family_object)
                self.families_to_import.append(label)
            except KeyError:
                print("ERROR: Channel family '%s' was not found in mapping" % label)

        # Perform import
        backend = SQLBackend()
        importer = ChannelFamilyImport(batch, backend)
        importer.run()

    @staticmethod
    def _remove_repositories():
        """This method removes repositories obtained from manifest"""
        hdel_repos = rhnSQL.prepare("""
            delete from rhnContentSource where
            label like :prefix || '%%'
            and org_id is null
        """)
        hdel_repos.execute(prefix=constants.MANIFEST_REPOSITORY_DB_PREFIX)
        rhnSQL.commit()

    def _update_repositories(self):
        """Setup SSL credential to access repositories
           We do this in 2 steps:
           1. Fetching provided repositories from manifest - URL contains variables to substitute
           2. Assigning one certificate/key set to each repository"""

        # First delete all repositories from previously used manifests
        self._remove_repositories()

        backend = SQLBackend()
        type_id = backend.lookupContentSourceType('yum')

        # Lookup CA cert
        ca_cert = satCerts.lookup_cert(constants.CA_CERT_NAME, None)
        ca_cert_id = int(ca_cert['id'])

        content_sources_batch = {}
        for entitlement in self.manifest.get_all_entitlements():
            creds = entitlement.get_credentials()
            client_cert = satCerts.lookup_cert(constants.CLIENT_CERT_PREFIX +
                                               creds.get_id(), None)
            client_key = satCerts.lookup_cert(constants.CLIENT_KEY_PREFIX +
                                              creds.get_id(), None)
            client_cert_id = int(client_cert['id'])
            client_key_id = int(client_key['id'])
            for product in entitlement.get_products():
                repositories = product.get_repositories()
                for repository in repositories:
                    if repository not in content_sources_batch:
                        content_source = ContentSource()
                        content_source['label'] = constants.MANIFEST_REPOSITORY_DB_PREFIX + repository
                        content_source['source_url'] = repositories[repository]
                        content_source['org_id'] = None
                        content_source['type_id'] = type_id
                        content_source['ssl_ca_cert_id'] = ca_cert_id
                        content_source['ssl_client_cert_id'] = client_cert_id
                        content_source['ssl_client_key_id'] = client_key_id
                        content_sources_batch[repository] = content_source

        importer = ContentSourcesImport(content_sources_batch.values(), backend)
        importer.run()

    def activate(self):
        if self.manifest.check_signature():
            print("Populating channel families...")
            self.import_channel_families()
            print("Updating certificates...")
            self._update_certificates()
            print("Updating manifest repositories...")
            self._update_repositories()
        else:
            raise ManifestValidationError("Manifest validation failed! Make sure the specified manifest is correct.")

    @staticmethod
    def deactivate():
        """Function to remove certificates and manifest repositories from DB"""
        rhnSQL.initDB()
        print("Removing certificates...")
        Activation._remove_certificates()
        print("Removing manifest repositories...")
        Activation._remove_repositories()
开发者ID:phurrelmann,项目名称:spacewalk,代码行数:104,代码来源:activation.py


注:本文中的manifest.Manifest.check_signature方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。