本文整理汇总了Python中manifest.Manifest.get_satellite_certificate方法的典型用法代码示例。如果您正苦于以下问题:Python Manifest.get_satellite_certificate方法的具体用法?Python Manifest.get_satellite_certificate怎么用?Python Manifest.get_satellite_certificate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类manifest.Manifest
的用法示例。
在下文中一共展示了Manifest.get_satellite_certificate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Activation
# 需要导入模块: from manifest import Manifest [as 别名]
# 或者: from manifest.Manifest import get_satellite_certificate [as 别名]
class Activation(object):
"""Class inserting channel families and SSL metadata into DB."""
def __init__(self, manifest_path):
rhnSQL.initDB()
self.manifest = Manifest(manifest_path)
self.sat5_cert = SatelliteCert()
self.sat5_cert.load(self.manifest.get_satellite_certificate())
verify_mappings()
# Channel families metadata
f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r')
try:
self.families = json.load(f)
finally:
if f is not None:
f.close()
self.families_to_import = []
@staticmethod
def _remove_certificates():
for description_prefix in (constants.CA_CERT_NAME,
constants.CLIENT_CERT_PREFIX,
constants.CLIENT_KEY_PREFIX):
satCerts.delete_rhnCryptoKey_null_org(description_prefix)
def _update_certificates(self):
"""Delete and insert certificates needed for syncing from CDN repositories."""
# Remove all previously used certs/keys
self._remove_certificates()
# Read RHSM cert
f = open(constants.CA_CERT_PATH, 'r')
try:
ca_cert = f.read()
finally:
if f is not None:
f.close()
# Insert RHSM cert and certs from manifest into DB
satCerts.store_rhnCryptoKey(
constants.CA_CERT_NAME, ca_cert, None)
for entitlement in self.manifest.get_all_entitlements():
creds = entitlement.get_credentials()
satCerts.store_rhnCryptoKey(
constants.CLIENT_CERT_PREFIX + creds.get_id(), creds.get_cert(), None)
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()
#.........这里部分代码省略.........