本文整理汇总了Python中spacewalk.common.rhnConfig.CFG.set方法的典型用法代码示例。如果您正苦于以下问题:Python CFG.set方法的具体用法?Python CFG.set怎么用?Python CFG.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类spacewalk.common.rhnConfig.CFG
的用法示例。
在下文中一共展示了CFG.set方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def __init__(self, req):
""" init with http request object """
# FIXME: should rename some things:
# self.bodyFd --> self.body or self.data or ?
# self.caChain --> self.caCert
self.req = req
# turn wsgi.input object into a SmartIO instance so it can be read
# more than once
if 'wsgi.input' in self.req.headers_in:
smartFd = SmartIO(max_mem_size=CFG.MAX_MEM_FILE_SIZE)
smartFd.write(self.req.headers_in['wsgi.input'].read())
self.req.headers_in['wsgi.input'] = smartFd
self.responseContext = ResponseContext()
self.uri = None # ''
# Common settings for both the proxy and the redirect
# broker and redirect immediately alter these for their own purposes
self.caChain = CFG.CA_CHAIN
self.httpProxy = CFG.HTTP_PROXY
self.httpProxyUsername = CFG.HTTP_PROXY_USERNAME
self.httpProxyPassword = CFG.HTTP_PROXY_PASSWORD
if not self.httpProxyUsername:
self.httpProxyPassword = ''
self.rhnParent = CFG.RHN_PARENT or ''
self.rhnParent = rhnLib.parseUrl(self.rhnParent)[1].split(':')[0]
CFG.set('RHN_PARENT', self.rhnParent)
示例2: __init__
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def __init__(self, req):
""" init with http request object """
# FIXME: should rename some things:
# self.bodyFd --> self.body or self.data or ?
# self.caChain --> self.caCert
self.req = req
self.responseContext = ResponseContext()
self.uri = None # ''
# Common settings for both the proxy and the redirect
# broker and redirect immediately alter these for their own purposes
self.caChain = CFG.CA_CHAIN
self.httpProxy = CFG.HTTP_PROXY
self.httpProxyUsername = CFG.HTTP_PROXY_USERNAME
self.httpProxyPassword = CFG.HTTP_PROXY_PASSWORD
if not self.httpProxyUsername:
self.httpProxyPassword = ""
self.rhnParent = CFG.RHN_PARENT or ""
self.rhnParent = rhnLib.parseUrl(self.rhnParent)[1].split(":")[0]
CFG.set("RHN_PARENT", self.rhnParent)
示例3: __init__
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def __init__(self, channel_label, repo_type, url=None, fail=False,
filters=None, no_errata=False, sync_kickstart=False, latest=False,
metadata_only=False, strict=0, excluded_urls=None, no_packages=False,
log_dir="reposync", log_level=None):
self.regen = False
self.fail = fail
self.filters = filters or []
self.no_packages = no_packages
self.no_errata = no_errata
self.sync_kickstart = sync_kickstart
self.latest = latest
self.metadata_only = metadata_only
self.ks_tree_type = 'externally-managed'
self.ks_install_type = 'generic_rpm'
initCFG('server.satellite')
rhnSQL.initDB()
# setup logging
log_filename = channel_label + '.log'
log_path = default_log_location + log_dir + '/' + log_filename
if log_level is None:
log_level = 0
CFG.set('DEBUG', log_level)
rhnLog.initLOG(log_path, log_level)
# os.fchown isn't in 2.4 :/
if isSUSE():
os.system("chgrp www " + log_path)
else:
os.system("chgrp apache " + log_path)
log2disk(0, "Command: %s" % str(sys.argv))
log2disk(0, "Sync of channel started.")
self.channel_label = channel_label
self.channel = self.load_channel()
if not self.channel:
log(0, "Channel %s does not exist." % channel_label)
if not url:
# TODO:need to look at user security across orgs
h = rhnSQL.prepare("""select s.id, s.source_url, s.label, fm.channel_family_id
from rhnContentSource s,
rhnChannelContentSource cs,
rhnChannelFamilyMembers fm
where s.id = cs.source_id
and cs.channel_id = fm.channel_id
and cs.channel_id = :channel_id""")
h.execute(channel_id=int(self.channel['id']))
source_data = h.fetchall_dict()
self.urls = []
if excluded_urls is None:
excluded_urls = []
if source_data:
for row in source_data:
if row['source_url'] not in excluded_urls:
self.urls.append((row['id'], row['source_url'], row['label'], row['channel_family_id']))
else:
self.urls = [(None, u, None, None) for u in url]
if not self.urls:
log2stderr(0, "Channel %s has no URL associated" % channel_label)
self.repo_plugin = self.load_plugin(repo_type)
self.strict = strict
self.all_packages = []
示例4: __init__
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False,
log_level=None, mount_point=None, consider_full=False):
self.cdn_repository_manager = CdnRepositoryManager(mount_point)
self.no_packages = no_packages
self.no_errata = no_errata
self.no_rpms = no_rpms
self.no_kickstarts = no_kickstarts
if log_level is None:
log_level = 0
self.log_level = log_level
if mount_point:
self.mount_point = "file://" + mount_point
self.consider_full = consider_full
else:
self.mount_point = CFG.CDN_ROOT
self.consider_full = True
CFG.set('DEBUG', log_level)
rhnLog.initLOG(self.log_path, self.log_level)
log2disk(0, "Command: %s" % str(sys.argv))
rhnSQL.initDB()
initCFG('server.satellite')
verify_mappings()
f = None
# try block in try block - this is hack for python 2.4 compatibility
# to support finally
try:
try:
# Channel families mapping to channels
f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r')
self.families = json.load(f)
f.close()
# Channel metadata
f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r')
self.channel_metadata = json.load(f)
f.close()
# Dist/Release channel mapping
f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r')
self.channel_dist_mapping = json.load(f)
f.close()
# Kickstart metadata
f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r')
self.kickstart_metadata = json.load(f)
f.close()
except IOError:
e = sys.exc_info()[1]
raise CdnMappingsLoadError("Problem with loading file: %s" % e)
finally:
if f is not None:
f.close()
# Map channels to their channel family
self.channel_to_family = {}
for family in self.families:
for channel in self.families[family]['channels']:
self.channel_to_family[channel] = family
# Set already synced channels
h = rhnSQL.prepare("""
select label from rhnChannel where org_id is null
""")
h.execute()
channels = h.fetchall_dict() or []
self.synced_channels = [ch['label'] for ch in channels]
示例5: __init__
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False,
log_level=None, mount_point=None, consider_full=False, force_kickstarts=False,
force_all_errata=False, email=False, import_batch_size=None):
if log_level is None:
log_level = 0
self.log_level = log_level
CFG.set('DEBUG', log_level)
self.email = email
if self.email:
initEMAIL_LOG()
rhnLog.initLOG(self.log_path, self.log_level)
log2disk(0, "Command: %s" % str(sys.argv))
rhnSQL.initDB()
initCFG('server.satellite')
self.cdn_repository_manager = CdnRepositoryManager(mount_point)
self.no_packages = no_packages
self.no_errata = no_errata
self.no_rpms = no_rpms
if self.no_packages and self.no_rpms:
log(0, "Parameter --no-rpms has no effect.")
self.no_kickstarts = no_kickstarts
self.force_all_errata = force_all_errata
self.force_kickstarts = force_kickstarts
if self.no_kickstarts and self.force_kickstarts:
log(0, "Parameter --force-kickstarts has no effect.")
if mount_point:
self.mount_point = "file://" + mount_point
self.consider_full = consider_full
else:
self.mount_point = CFG.CDN_ROOT
self.consider_full = True
verify_mappings()
f = None
# try block in try block - this is hack for python 2.4 compatibility
# to support finally
try:
try:
# Channel families mapping to channels
f = open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r')
self.families = json.load(f)
f.close()
# Channel metadata
f = open(constants.CHANNEL_DEFINITIONS_PATH, 'r')
self.channel_metadata = json.load(f)
f.close()
# Dist/Release channel mapping
f = open(constants.CHANNEL_DIST_MAPPING_PATH, 'r')
self.channel_dist_mapping = json.load(f)
f.close()
# Kickstart metadata
f = open(constants.KICKSTART_DEFINITIONS_PATH, 'r')
self.kickstart_metadata = json.load(f)
f.close()
except IOError:
e = sys.exc_info()[1]
log(1, "Ignoring channel mappings: %s" % e)
self.families = {}
self.channel_metadata = {}
self.channel_dist_mapping = {}
self.kickstart_metadata = {}
finally:
if f is not None:
f.close()
# Map channels to their channel family
self.channel_to_family = {}
for family in self.families:
for channel in self.families[family]['channels']:
self.channel_to_family[channel] = family
# Set already synced channels, entitled null-org channels and custom channels with associated
# CDN repositories
h = rhnSQL.prepare("""
select distinct c.label, c.org_id
from rhnChannelFamilyPermissions cfp inner join
rhnChannelFamily cf on cfp.channel_family_id = cf.id inner join
rhnChannelFamilyMembers cfm on cf.id = cfm.channel_family_id inner join
rhnChannel c on cfm.channel_id = c.id
where c.org_id is null
or (c.org_id is not null and
exists (
select cs.id
from rhnContentSource cs inner join
rhnChannelContentSource ccs on ccs.source_id = cs.id
where ccs.channel_id = c.id
and cs.org_id is null
)
)
order by c.org_id nulls first, label
""")
h.execute()
#.........这里部分代码省略.........
示例6: processCommandline
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def processCommandline():
options = [
Option('--sanity-only', action='store_true', help="confirm certificate sanity. Does not activate "
+ "the Red Hat Satellite locally or remotely."),
Option('--ignore-expiration', action='store_true', help='execute regardless of the expiration '
+ 'of the RHN Certificate (not recommended).'),
Option('--ignore-version-mismatch', action='store_true', help='execute regardless of version '
+ 'mismatch of existing and new certificate.'),
Option('-v', '--verbose', action='count', help='be verbose '
+ '(accumulable: -vvv means "be *really* verbose").'),
Option('--dump-version', action='store', help="requested version of XML dump"),
Option('--manifest', action='store', help='the RHSM manifest path/filename to activate for CDN'),
Option('--rhn-cert', action='store', help='this option is deprecated, use --manifest instead'),
Option('--deactivate', action='store_true', help='deactivate CDN-activated Satellite'),
Option('--disconnected', action='store_true', help="activate locally, not subscribe to remote repository"),
Option('--manifest-info', action='store_true', help="show information about currently activated manifest"),
Option('--manifest-download', action='store_true',
help="download new manifest from RHSM to temporary location"),
Option('--manifest-refresh', action='store_true', help="download new manifest from RHSM and activate it"),
Option('--manifest-reconcile-request', action='store_true',
help="request regeneration of entitlement certificates")
]
parser = OptionParser(option_list=options)
options, args = parser.parse_args()
initCFG('server.satellite')
if options.verbose is None:
options.verbose = 0
CFG.set('DEBUG', options.verbose)
rhnLog.initLOG(LOG_PATH, options.verbose)
log2disk(0, "Command: %s" % str(sys.argv))
# we take no extra commandline arguments that are not linked to an option
if args:
writeError("These arguments make no sense in this context (try --help): %s" % repr(args))
sys.exit(1)
# No need to check further if deactivating
if options.deactivate:
return options
if options.sanity_only:
options.disconnected = 1
if options.manifest_refresh:
options.manifest_download = 1
if CFG.DISCONNECTED and not options.disconnected:
msg = """Satellite server has been setup to run in disconnected mode.
Either correct server configuration in /etc/rhn/rhn.conf
or use --disconnected to activate it locally."""
writeError(msg)
sys.exit(1)
options.http_proxy = idn_ascii_to_puny(CFG.HTTP_PROXY)
options.http_proxy_username = CFG.HTTP_PROXY_USERNAME
options.http_proxy_password = CFG.HTTP_PROXY_PASSWORD
log(1, 'HTTP_PROXY: %s' % options.http_proxy)
log(1, 'HTTP_PROXY_USERNAME: %s' % options.http_proxy_username)
log(1, 'HTTP_PROXY_PASSWORD: <password>')
return options
示例7: __init__
# 需要导入模块: from spacewalk.common.rhnConfig import CFG [as 别名]
# 或者: from spacewalk.common.rhnConfig.CFG import set [as 别名]
def __init__(self, no_packages=False, no_errata=False, no_rpms=False, no_kickstarts=False,
log_level=None):
self.no_packages = no_packages
self.no_errata = no_errata
self.no_rpms = no_rpms
self.no_kickstarts = no_kickstarts
if log_level is None:
log_level = 0
self.log_level = log_level
CFG.set('DEBUG', log_level)
rhnLog.initLOG(self.log_path, self.log_level)
log2disk(0, "Command: %s" % str(sys.argv))
rhnSQL.initDB()
initCFG('server.satellite')
try:
# Channel families mapping to channels
with open(constants.CHANNEL_FAMILY_MAPPING_PATH, 'r') as f:
self.families = json.load(f)
# Channel metadata
with open(constants.CHANNEL_DEFINITIONS_PATH, 'r') as f:
self.channel_metadata = json.load(f)
# Dist/Release channel mapping
with open(constants.CHANNEL_DIST_MAPPING_PATH, 'r') as f:
self.channel_dist_mapping = json.load(f)
# Channel to repositories mapping
with open(constants.CONTENT_SOURCE_MAPPING_PATH, 'r') as f:
self.content_source_mapping = json.load(f)
# Kickstart metadata
with open(constants.KICKSTART_DEFINITIONS_PATH, 'r') as f:
self.kickstart_metadata = json.load(f)
# Channel to kickstart repositories mapping
with open(constants.KICKSTART_SOURCE_MAPPING_PATH, 'r') as f:
self.kickstart_source_mapping = json.load(f)
except IOError:
e = sys.exc_info()[1]
log2stderr(0, "ERROR: Problem with loading file: %s" % e)
raise CdnMappingsLoadError()
# Map channels to their channel family
self.channel_to_family = {}
for family in self.families:
for channel in self.families[family]['channels']:
self.channel_to_family[channel] = family
# Set already synced channels
h = rhnSQL.prepare("""
select label from rhnChannel where org_id is null
""")
h.execute()
channels = h.fetchall_dict() or []
self.synced_channels = [ch['label'] for ch in channels]
# Set SSL-keys for channel family
self.family_keys = {}