本文整理汇总了Python中rhsm.config.initConfig函数的典型用法代码示例。如果您正苦于以下问题:Python initConfig函数的具体用法?Python initConfig怎么用?Python initConfig使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了initConfig函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, logger, options):
self.logger = logger
self.options = options
self.cert_uuid = None
self.rhsm_config = rhsm_config.initConfig(rhsm_config.DEFAULT_CONFIG_PATH)
self.readConfig()
开发者ID:mtulio,项目名称:virt-who,代码行数:7,代码来源:subscriptionmanager.py
示例2: __init__
def __init__(self, options):
self.rhncfg = initUp2dateConfig()
self.rhsmcfg = config.Config(initConfig())
# Sometimes we need to send up the entire contents of the system id file
# which is referred to in Satellite 5 nomenclature as a "certificate"
# although it is not an X509 certificate.
try:
self.system_id_contents = open(self.rhncfg["systemIdPath"], 'r').read()
except IOError:
system_exit(os.EX_IOERR, _("Could not read legacy system id at %s") % self.rhncfg["systemIdPath"])
self.system_id = self.get_system_id(self.system_id_contents)
self.proxy_host = None
self.proxy_port = None
self.proxy_user = None
self.proxy_pass = None
self.cp = None
self.db = ProductDatabase()
self.consumer_id = None
self.options = options
self.is_hosted = is_hosted()
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:26,代码来源:migrate.py
示例3: postconfig_hook
def postconfig_hook(conduit):
""" update """
# register rpm name for yum history recording"
# yum on 5.7 doesn't have this method, so check for it
from subscription_manager import logutil
logutil.init_logger_for_yum()
from subscription_manager.injectioninit import init_dep_injection
init_dep_injection()
# If a tool (it's, e.g., Mock) manages a chroot via 'yum --installroot',
# we must update entitlements in that directory.
chroot(conduit.getConf().installroot)
cfg = config.initConfig()
cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))
if hasattr(conduit, 'registerPackageName'):
conduit.registerPackageName("subscription-manager")
try:
update(conduit, cache_only)
warnOrGiveUsageMessage(conduit)
warnExpired(conduit)
except Exception, e:
conduit.error(2, str(e))
开发者ID:NehaRawat,项目名称:subscription-manager,代码行数:26,代码来源:subscription-manager.py
示例4: _try_satellite6_configuration
def _try_satellite6_configuration(config):
"""
Try to autoconfigure for Satellite 6
"""
try:
from rhsm.config import initConfig
rhsm_config = initConfig()
logger.debug('Trying to autoconf Satellite 6')
cert = file(rhsmCertificate.certpath(), 'r').read()
key = file(rhsmCertificate.keypath(), 'r').read()
rhsm = rhsmCertificate(key, cert)
# This will throw an exception if we are not registered
logger.debug('Checking if system is subscription-manager registered')
rhsm.getConsumerId()
logger.debug('System is subscription-manager registered')
rhsm_hostname = rhsm_config.get('server', 'hostname')
rhsm_hostport = rhsm_config.get('server', 'port')
rhsm_proxy_hostname = rhsm_config.get('server', 'proxy_hostname').strip()
rhsm_proxy_port = rhsm_config.get('server', 'proxy_port').strip()
rhsm_proxy_user = rhsm_config.get('server', 'proxy_user').strip()
rhsm_proxy_pass = rhsm_config.get('server', 'proxy_password').strip()
proxy = None
if rhsm_proxy_hostname != "":
logger.debug("Found rhsm_proxy_hostname %s", rhsm_proxy_hostname)
proxy = "http://"
if rhsm_proxy_user != "" and rhsm_proxy_pass != "":
logger.debug("Found user and password for rhsm_proxy")
proxy = proxy + rhsm_proxy_user + ":" + rhsm_proxy_pass + "@"
proxy = proxy + rhsm_proxy_hostname + rhsm_proxy_port
else:
proxy = proxy + rhsm_proxy_hostname + ':' + rhsm_proxy_port
logger.debug("RHSM Proxy: %s", proxy)
logger.debug("Found Satellite Server Host: %s, Port: %s",
rhsm_hostname, rhsm_hostport)
rhsm_ca = rhsm_config.get('rhsm', 'repo_ca_cert')
logger.debug("Found CA: %s", rhsm_ca)
logger.debug("Setting authmethod to CERT")
config.set(APP_NAME, 'authmethod', 'CERT')
# Directly connected to Red Hat, use cert auth directly with the api
if rhsm_hostname == 'subscription.rhn.redhat.com':
logger.debug("Connected to Red Hat Directly, using cert-api")
rhsm_hostname = 'cert-api.access.redhat.com'
rhsm_ca = None
else:
# Set the host path
# 'rhsm_hostname' should really be named ~ 'rhsm_host_base_url'
rhsm_hostname = rhsm_hostname + ':' + rhsm_hostport + '/redhat_access'
logger.debug("Trying to set auto_configuration")
set_auto_configuration(config, rhsm_hostname, rhsm_ca, proxy)
return True
except Exception as e:
logger.debug(e)
logger.debug('System is NOT subscription-manager registered')
return False
开发者ID:iphands,项目名称:insights-client,代码行数:59,代码来源:auto_config.py
示例5: __init__
def __init__(self, logger):
self.logger = logger
self.cert_uuid = None
self.config = rhsm_config.initConfig(rhsm_config.DEFAULT_CONFIG_PATH)
self.readConfig()
# Consumer ID obtained from consumer certificate
self.cert_uuid = self.uuid()
开发者ID:thomasmckay,项目名称:virt-who,代码行数:9,代码来源:subscriptionmanager.py
示例6: readConfig
def readConfig(self):
""" Parse rhsm.conf in order to obtain consumer
certificate and key paths. """
self.rhsm_config = rhsm_config.initConfig(
rhsm_config.DEFAULT_CONFIG_PATH)
consumer_cert_dir = self.rhsm_config.get("rhsm", "consumerCertDir")
cert = 'cert.pem'
key = 'key.pem'
self.cert_file = os.path.join(consumer_cert_dir, cert)
self.key_file = os.path.join(consumer_cert_dir, key)
开发者ID:candlepin,项目名称:virt-who,代码行数:10,代码来源:subscriptionmanager.py
示例7: __init__
def __init__(self, logger, username=None, password=None):
self.logger = logger
self.cert_uuid = None
self.username = username
self.password = password
self.config = rhsm_config.initConfig(rhsm_config.DEFAULT_CONFIG_PATH)
self.readConfig()
# Consumer ID obtained from consumer certificate
self.cert_uuid = self.uuid()
开发者ID:candlepin,项目名称:virt-whom,代码行数:11,代码来源:subscriptionmanager.py
示例8: transaction
def transaction(self):
"""
Call Package Profile
"""
cfg = config.initConfig()
if '1' == cfg.get('rhsm', 'package_profile_on_trans'):
package_profile_client = ProfileActionClient()
package_profile_client.update()
else:
# do nothing
return
开发者ID:Januson,项目名称:subscription-manager,代码行数:11,代码来源:subscription-manager.py
示例9: config
def config(self):
""" update """
logutil.init_logger_for_yum()
init_dep_injection()
chroot(self.base.conf.installroot)
cfg = config.initConfig()
cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))
try:
if os.getuid() == 0:
self._update(cache_only)
self._warnOrGiveUsageMessage()
else:
logger.info(_('Not root, Subscription Management repositories not updated'))
self._warnExpired()
except Exception as e:
logger.error(str(e))
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:20,代码来源:subscription-manager.py
示例10: _try_satellite6_configuration
def _try_satellite6_configuration(config):
"""
Try to autoconfigure for Satellite 6
"""
try:
from rhsm.config import initConfig
RHSM_CONFIG = initConfig()
logger.debug('Trying to autoconf Satellite 6')
cert = file(rhsmCertificate.certpath(), 'r').read()
key = file(rhsmCertificate.keypath(), 'r').read()
rhsm = rhsmCertificate(key, cert)
# This will throw an exception if we are not registered
logger.debug('Checking if system is subscription-manager registered')
rhsm.getConsumerId()
logger.debug('System is subscription-manager registered')
rhsm_hostname = RHSM_CONFIG.get('server', 'hostname')
logger.debug("Found Satellite Server: %s", rhsm_hostname)
rhsm_ca = RHSM_CONFIG.get('rhsm', 'repo_ca_cert')
logger.debug("Found CA: %s", rhsm_ca)
logger.debug("Setting authmethod to CERT")
config.set(APP_NAME, 'authmethod', 'CERT')
# Directly connected to Red Hat, use cert auth directly with the api
if rhsm_hostname == 'subscription.rhn.redhat.com':
logger.debug("Connected to RH Directly, using cert-api")
rhsm_hostname = 'cert-api.access.redhat.com'
rhsm_ca = None
else:
# Set the cert verify CA, and path
rhsm_hostname = rhsm_hostname + '/redhat_access'
logger.debug("Trying to set auto_configuration")
set_auto_configuration(config, rhsm_hostname, rhsm_ca)
return True
except:
logger.debug('System is NOT subscription-manager registered')
return False
开发者ID:miclark,项目名称:redhat-access-insights,代码行数:40,代码来源:__init__.py
示例11: config_hook
def config_hook(conduit):
""" update """
# register rpm name for yum history recording"
# yum on 5.7 doesn't have this method, so check for it
from subscription_manager import logutil
logutil.init_logger_for_yum()
from subscription_manager.injectioninit import init_dep_injection
init_dep_injection()
cfg = config.initConfig()
cache_only = not bool(cfg.get_int('rhsm', 'full_refresh_on_yum'))
if hasattr(conduit, 'registerPackageName'):
conduit.registerPackageName("subscription-manager")
try:
update(conduit, cache_only)
warnOrGiveUsageMessage(conduit)
warnExpired(conduit)
except Exception, e:
conduit.error(2, str(e))
开发者ID:jaredjennings,项目名称:subscription-manager,代码行数:22,代码来源:subscription-manager.py
示例12: get_state
ServiceLevelNotSupportedException, AllProductsCoveredException, \
NoProductsException
from subscription_manager.gui.messageWindow import InfoDialog, OkDialog
from subscription_manager.jsonwrapper import PoolWrapper
_ = lambda x: gettext.ldgettext("rhsm", x)
gettext.textdomain("rhsm")
gtk.glade.bindtextdomain("rhsm")
gtk.glade.textdomain("rhsm")
log = logging.getLogger('rhsm-app.' + __name__)
CFG = config.initConfig()
REGISTERING = 0
SUBSCRIBING = 1
state = REGISTERING
def get_state():
global state
return state
def set_state(new_state):
global state
state = new_state
开发者ID:NehaRawat,项目名称:subscription-manager,代码行数:30,代码来源:registergui.py
示例13: Repo
except ImportError as e:
HAS_DEB822 = False
from subscription_manager import utils
from subscription_manager.certdirectory import Path
from six.moves import configparser
from six.moves.urllib.parse import parse_qs, urlparse, urlunparse, urlencode
from rhsm.config import initConfig
from rhsmlib.services import config
log = logging.getLogger(__name__)
conf = config.Config(initConfig())
repo_files = []
class Repo(dict):
# (name, mutable, default) - The mutability information is only used in disconnected cases
PROPERTIES = {
'name': (0, None),
'baseurl': (0, None),
'enabled': (1, '1'),
'gpgcheck': (1, '1'),
'gpgkey': (0, None),
'sslverify': (1, '1'),
'sslcacert': (0, None),
'sslclientkey': (0, None),
开发者ID:Januson,项目名称:subscription-manager,代码行数:31,代码来源:repofile.py
示例14: list
return list(items_from_store.items())
return config.RhsmConfigParser.items(self, section)
def save(self, config_file=None):
if self.raise_io:
raise IOError
return None
def stubInitConfig():
return StubConfig()
# create a global CFG object,then replace it with our own that candlepin
# read from a stringio
config.initConfig(config_file="test/rhsm.conf")
config.CFG = StubConfig()
# we are not actually reading test/rhsm.conf, it's just a placeholder
config.CFG.read("test/rhsm.conf")
class MockActionLock(ActionLock):
PATH = tempfile.mkstemp()[1]
class StubProduct(Product):
def __init__(self, product_id, name=None, version=None,
architectures=None, provided_tags=None,
os=None, brand_name=None):
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:31,代码来源:stubs.py
示例15: initConfig
import os
import string
import logging
from urllib import basejoin
from iniparse import ConfigParser
from rhsm.config import initConfig
from rhsm.connection import RemoteServerException, RestlibException
from certlib import ActionLock, DataLib, ConsumerIdentity
from certdirectory import Path, EntitlementDirectory, ProductDirectory
log = logging.getLogger('rhsm-app.' + __name__)
CFG = initConfig()
class RepoLib(DataLib):
def __init__(self, lock=ActionLock(), uep=None):
DataLib.__init__(self, lock, uep)
def _do_update(self):
action = UpdateAction(uep=self.uep)
return action.perform()
def get_repos(self):
print "get_repos"
current = set()
action = UpdateAction(uep=self.uep)
开发者ID:splice,项目名称:subscription-manager,代码行数:30,代码来源:repolib.py
示例16: initConfig
"""
Module to interact with Satellite Based Certificates
"""
import os
import logging
from constants import InsightsConstants as constants
logger = logging.getLogger(constants.app_name)
# RHSM and Subscription Manager
RHSM_CONFIG = None
try:
from rhsm.config import initConfig
from rhsm.certificate import create_from_pem
RHSM_CONFIG = initConfig()
except ImportError:
logger.debug("Could not load RHSM modules")
# Class for dealing with rhsmCertificates
class rhsmCertificate:
try:
PATH = RHSM_CONFIG.get('rhsm', 'consumerCertDir')
except:
pass
KEY = 'key.pem'
CERT = 'cert.pem'
@classmethod
开发者ID:Prosper95,项目名称:insights-client,代码行数:31,代码来源:cert_auth.py
示例17: initConfig
PROD_STATUS_CACHE, ENT_DIR, PROD_DIR, CP_PROVIDER, OVERRIDE_STATUS_CACHE, \
POOLTYPE_CACHE
from subscription_manager import isodate
from subscription_manager.jsonwrapper import PoolWrapper
from subscription_manager.repolib import RepoActionInvoker
from subscription_manager import utils
# FIXME FIXME
from subscription_manager.identity import ConsumerIdentity
from dateutil.tz import tzlocal
log = logging.getLogger('rhsm-app.' + __name__)
_ = gettext.gettext
cfg = initConfig()
ENT_CONFIG_DIR = cfg.get('rhsm', 'entitlementCertDir')
# Expected permissions for identity certificates:
ID_CERT_PERMS = stat.S_IRUSR | stat.S_IWUSR | stat.S_IRGRP
def system_log(message, priority=syslog.LOG_NOTICE):
utils.system_log(message, priority)
# FIXME: move me to identity.py
def persist_consumer_cert(consumerinfo):
"""
Calls the consumerIdentity, persists and gets consumer info
"""
开发者ID:aweiteka,项目名称:subscription-manager,代码行数:31,代码来源:managerlib.py
示例18: is_hosted
def is_hosted():
rhsmcfg = config.Config(initConfig())
hostname = rhsmcfg['server']['hostname']
return bool(re.search('subscription\.rhn\.(.*\.)*redhat\.com', hostname) or
re.search('subscription\.rhsm\.(.*\.)*redhat\.com', hostname))
开发者ID:Lorquas,项目名称:subscription-manager,代码行数:5,代码来源:migrate.py
示例19:
from subscription_manager.gui.allsubs import AllSubscriptionsTab
from subscription_manager.gui.importsub import ImportSubDialog
from subscription_manager.gui.installedtab import InstalledProductsTab
from subscription_manager.gui.mysubstab import MySubscriptionsTab
from subscription_manager.gui.preferences import PreferencesDialog
from subscription_manager.gui.utils import handle_gui_exception, linkify
from subscription_manager.gui.reposgui import RepositoriesDialog
from subscription_manager.gui.networkConfig import reset_resolver
from subscription_manager.overrides import Overrides
from subscription_manager.cli import system_exit
from subscription_manager.i18n import ugettext as _
log = logging.getLogger(__name__)
cfg = config.initConfig()
ONLINE_DOC_URL_TEMPLATE = "https://access.redhat.com/documentation/%s/red_hat_subscription_management/"
ONLINE_DOC_FALLBACK_URL = "https://access.redhat.com/documentation/en-us/red_hat_subscription_management/"
# every GUI browser from https://docs.python.org/2/library/webbrowser.html with updates within last 2 years of writing
PREFERRED_BROWSERS = [
"mozilla",
"firefox",
"epiphany",
"konqueror",
"opera",
"google-chrome",
"chrome",
"chromium",
"chromium-browser",
开发者ID:Januson,项目名称:subscription-manager,代码行数:31,代码来源:managergui.py
示例20: subman_profile_enabled
def subman_profile_enabled():
cfg = rhsmConfig.initConfig()
try:
return cfg.get('rhsm', 'package_profile_on_trans') == '1'
except NoOptionError:
return False
开发者ID:Katello,项目名称:katello-agent,代码行数:6,代码来源:utils.py
注:本文中的rhsm.config.initConfig函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论