本文整理汇总了Python中spacewalk.common.rhnLog.log_debug函数的典型用法代码示例。如果您正苦于以下问题:Python log_debug函数的具体用法?Python log_debug怎么用?Python log_debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了log_debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: schedule_virt_guest_pkg_install
def schedule_virt_guest_pkg_install(server_id, action_id, dry_run=0):
"""
ShadowAction that schedules a package installation action for the
rhn-virtualization-guest package.
"""
log_debug(3)
virt_host_package_name = "rhn-virtualization-guest"
tools_channel = SubscribedChannel(server_id, "rhn-tools")
found_tools_channel = tools_channel.is_subscribed_to_channel()
if not found_tools_channel:
raise InvalidAction("System not subscribed to the RHN Tools channel.")
rhn_v12n_package = ChannelPackage(server_id, virt_host_package_name)
if not rhn_v12n_package.exists():
raise InvalidAction("Could not find the rhn-virtualization-guest package.")
try:
install_scheduler = PackageInstallScheduler(server_id, action_id, rhn_v12n_package)
if (not dry_run):
install_scheduler.schedule_package_install()
else:
log_debug(4, "dry run requested")
except NoActionInfo, nai:
raise InvalidAction(str(nai)), None, sys.exc_info()[2]
示例2: _getSourcePackageChecksum
def _getSourcePackageChecksum(self, org_id, pkg_infos):
""" Gives checksum info of available source packages.
Also does an existance check on the filesystem.
"""
log_debug(3)
statement = """
select
ps.path path,
c.checksum,
c.checksum_type
from
rhnSourceRpm sr,
rhnPackageSource ps,
rhnChecksumView c
where
sr.name = :name
and ps.source_rpm_id = sr.id
and ( ps.org_id = :orgid or
( ps.org_id is null and :orgid is null )
)
and ps.checksum_id = c.id
"""
h = rhnSQL.prepare(statement)
row_list = {}
for pkg in pkg_infos.keys():
row_list[pkg] = self._get_package_checksum(h,
{'name': pkg, 'orgid': org_id})
return row_list
示例3: __init__
def __init__(self, dict=None):
log_debug(4, dict)
self.ifaces = {}
self.db_ifaces = []
# parameters which are not allowed to be empty and set to NULL
self._autonull = ('hw_addr', 'module')
if not dict:
return
for name, info in dict.items():
if name == 'class':
# Ignore it
continue
if not isinstance(info, type({})):
raise rhnFault(53, "Unexpected format for interface %s" %
name)
vdict = {}
for key, mapping in self.key_mapping.items():
# Look at the mapping first; if not found, look for the key
if info.has_key(mapping):
k = mapping
else:
k = key
if not info.has_key(k):
raise rhnFault(53, "Unable to find required field %s"
% key)
val = info[k]
vdict[mapping] = val
if 'ipaddr' in info and info['ipaddr']:
vdict['ipv4'] = NetIfaceAddress4(
[{'ipaddr': info['ipaddr'], 'broadcast': info['broadcast'], 'netmask': info['netmask']}])
if 'ipv6' in info and info['ipv6']:
vdict['ipv6'] = NetIfaceAddress6(info["ipv6"])
self.ifaces[name] = vdict
示例4: validate_new_password
def validate_new_password(password):
""" Perform all the checks required for new passwords """
log_debug(3, "Entered validate_new_password")
#
# We're copying the code because we don't want to
# invalidate any of the existing passwords.
#
# Validate password based on configurable length
# regular expression
if not password:
raise rhnFault(12)
if len(password) < CFG.MIN_PASSWD_LEN:
raise rhnFault(14, _("password must be at least %d characters")
% CFG.MIN_PASSWD_LEN)
if len(password) > CFG.MAX_PASSWD_LEN:
raise rhnFault(701, _("Password must be shorter than %d characters")
% CFG.MAX_PASSWD_LEN)
password = password[:CFG.MAX_PASSWD_LEN]
invalid_re = re.compile(
r"[^ A-Za-z0-9`[email protected]#$%^&*()-_=+[{\]}\\|;:'\",<.>/?~]")
asterisks_re = re.compile(r"^\**$")
# make sure the password isn't all *'s
tmp = asterisks_re.match(password)
if tmp is not None:
raise rhnFault(15, "password cannot be all asterisks '*'")
# make sure we have only printable characters
tmp = invalid_re.search(password)
if tmp is not None:
pos = tmp.regs[0]
raise rhnFault(15,
_("password contains character `%s'") % password[pos[1] - 1])
示例5: getAnyChecksum
def getAnyChecksum(self, info, username=None, password=None, session=None, is_source=0):
""" returns checksum info of available packages
also does an existance check on the filesystem.
"""
log_debug(3)
pkg_infos = info.get('packages')
channels = info.get('channels', [])
force = info.get('force', 0)
orgid = info.get('org_id')
if orgid == 'null':
null_org = 1
else:
null_org = None
if not session:
org_id, force = rhnPackageUpload.authenticate(username, password,
channels=channels,
null_org=null_org,
force=force)
else:
try:
org_id, force = rhnPackageUpload.authenticate_session(
session, channels=channels, null_org=null_org, force=force)
except rhnSession.InvalidSessionError:
raise_with_tb(rhnFault(33), sys.exc_info()[2])
except rhnSession.ExpiredSessionError:
raise_with_tb(rhnFault(34), sys.exc_info()[2])
if is_source:
ret = self._getSourcePackageChecksum(org_id, pkg_infos)
else:
ret = self._getPackageChecksum(org_id, pkg_infos)
return ret
示例6: getSourcePackagePath
def getSourcePackagePath(self, pkgFilename):
""" OVERLOADS getSourcePackagePath in common/rhnRepository.
snag src.rpm and nosrc.rpm from local repo, after ensuring
we are authorized to fetch it.
"""
log_debug(3, pkgFilename)
if pkgFilename[-8:] != '.src.rpm' and pkgFilename[-10:] != '.nosrc.rpm':
raise rhnFault(17, _("Invalid SRPM package requested: %s")
% pkgFilename)
# Connect to the server to get an authorization for downloading this
# package
server = rpclib.Server(self.rhnParentXMLRPC, proxy=self.httpProxy,
username=self.httpProxyUsername,
password=self.httpProxyPassword)
if self.caChain:
server.add_trusted_cert(self.caChain)
try:
retval = server.proxy.package_source_in_channel(
pkgFilename, self.channelName, self.clientInfo)
except xmlrpclib.Fault, e:
raise rhnFault(1000,
_("Error retrieving source package: %s") % str(e)), None, sys.exc_info()[2]
示例7: update
def update(server_id, action_id, data={}):
log_debug(3, server_id, action_id)
action_status = rhnFlags.get('action_status')
if action_status == 3:
# Action failed
kickstart_state = 'failed'
next_action_type = None
else:
kickstart_state = 'deployed'
#This is horrendous, but in order to fix it I would have to change almost all of the
#actions code, which we don't have time to do for the 500 beta. --wregglej
try:
ks_session_type = server_kickstart.get_kickstart_session_type(server_id, action_id)
except rhnException, re:
ks_session_type = None
if ks_session_type is None:
next_action_type = "None"
elif ks_session_type == 'para_guest':
next_action_type = 'kickstart_guest.initiate'
else:
next_action_type = 'kickstart.initiate'
示例8: _execute_wrapper
def _execute_wrapper(self, function, *p, **kw):
params = ','.join(["%s: %s" % (key, value) for key, value
in list(kw.items())])
log_debug(5, "Executing SQL: \"%s\" with bind params: {%s}"
% (self.sql, params))
if self.sql is None:
raise rhnException("Cannot execute empty cursor")
if self.blob_map:
for blob_var in list(self.blob_map.keys()):
kw[blob_var] = BufferType(kw[blob_var])
try:
retval = function(*p, **kw)
except psycopg2.InternalError:
e = sys.exc_info()[1]
error_code = 99999
m = re.match('ERROR: +-([0-9]+)', e.pgerror)
if m:
error_code = int(m.group(1))
raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
except psycopg2.ProgrammingError:
e = sys.exc_info()[1]
raise sql_base.SQLStatementPrepareError(self.dbh, e.pgerror, self.sql)
except KeyError:
e = sys.exc_info()[1]
raise sql_base.SQLError("Unable to bound the following variable(s): %s"
% (string.join(e.args, " ")))
return retval
示例9: __call__
def __call__(self, *args):
log_debug(2, self.name, args)
# Buildup a string for the positional arguments to the procedure:
positional_args = ""
i = 1
for arg in args:
if len(positional_args) == 0:
positional_args = "%s"
else:
positional_args = positional_args + ", %s"
i += 1
query = "SELECT %s(%s)" % (self.name, positional_args)
log_debug(2, query, args)
try:
ret = self.cursor.execute(query, args)
except psycopg2.Error:
e = sys.exc_info()[1]
error_code = 99999
m = re.match('ERROR: +-([0-9]+)', e.pgerror)
if m:
error_code = int(m.group(1))
raise sql_base.SQLSchemaError(error_code, e.pgerror, e)
if self.ret_type is None:
return ret
else:
return self.cursor.fetchone()[0]
示例10: __processPackage
def __processPackage(package, org_id, channels, source):
log_debug(4, org_id, channels, source)
if 'md5sum' in package: # for old rhnpush compatibility
package['checksum_type'] = 'md5'
package['checksum'] = package['md5sum']
del(package['md5sum'])
if 'checksum' not in package:
raise rhnFault(50, "The package's checksum digest has not been specified")
if 'packageSize' not in package:
raise rhnFault(50, "The package size has not been specified")
header = rhn_rpm.headerLoad(package['header'].data)
if not header:
raise rhnFault(50)
packageSize = package['packageSize']
relpath = package.get('relativePath')
if 'header_start' in package:
header_start = package['header_start']
else:
header_start = 0
if 'header_end' in package:
header_end = package['header_end']
else:
# Just say the whole package
header_end = packageSize
checksum_type = package['checksum_type']
checksum = package['checksum']
p = createPackage(header, packageSize, checksum_type, checksum, relpath, org_id,
header_start, header_end, channels)
return p
示例11: process
def process(self):
log_debug(3)
# nice thing that req has a read() method, so it makes it look just
# like an fd
try:
fd = self.input.decode(self.req)
except IOError: # client timed out
return apache.HTTP_BAD_REQUEST
# Read the data from the request
_body = fd.read()
fd.close()
# In this case, we talk to a client (maybe through a proxy)
# make sure we have something to decode
if _body is None or len(_body) == 0:
return apache.HTTP_BAD_REQUEST
# Decode the request; avoid logging crappy responses
try:
params, method = self.decode(_body)
except xmlrpclib.ResponseError:
log_error("Got bad XML-RPC blob of len = %d" % len(_body))
return apache.HTTP_BAD_REQUEST
else:
if params is None:
params = ()
# make the actual function call and return the result
return self.call_function(method, params)
示例12: schedulePoller
def schedulePoller(server_id, action_id, dry_run=0):
log_debug(3, dry_run)
prepared_query = rhnSQL.prepare(_query_schedulePoller)
prepared_query.execute(action_id=action_id)
row = prepared_query.fetchone_dict()
if not row:
raise InvalidAction("No schedulePoller actions found.")
if not row.has_key('minute'):
raise InvalidAction("schedulePoller action %s has no minute associated with it." % str(action_id))
if not row.has_key('hour'):
raise InvalidAction("schedulePoller action %s has no hour associated with it." % str(action_id))
if not row.has_key('dom'):
raise InvalidAction("schedulePoller action %s has no day of the month associated with it." % str(action_id))
if not row.has_key('month'):
raise InvalidAction("schedulePoller action %s has no month associated with it." % str(action_id))
if not row.has_key('dow'):
raise InvalidAction("schedulePoller action %s has no day of the week associated with it." % str(action_id))
return (row['minute'], row['hour'], row['dom'], row['month'], row['dow'])
示例13: _store_file
def _store_file(self, action_id, scap_file):
r_dir = get_action_path(self.server.server['org_id'], self.server_id, action_id)
if not r_dir:
log_debug(1, self.server_id, "Error composing SCAP action directory path")
raise rhnFault(5102)
r_file = get_actionfile_path(self.server.server['org_id'], self.server_id, action_id, scap_file['filename'])
if not r_file:
log_debug(1, self.server_id, "Error composing SCAP action file path")
raise rhnFault(5103)
if not scap_file['content-encoding'] == 'base64':
log_debug(1, self.server_id, "Invalid content encoding: %s" % scap_file['content-encoding'])
raise rhnFault(5104)
# Create the file on filer
filecontent = decodestring(scap_file['filecontent'])
# TODO assert for the size of the file
absolute_dir = os.path.join(CFG.MOUNT_POINT, r_dir)
absolute_file = os.path.join(absolute_dir, scap_file['filename'])
if not os.path.exists(absolute_dir):
log_debug(1, self.server_id, "Creating action directory: %s" % absolute_dir)
os.makedirs(absolute_dir)
mode = stat.S_IRWXU | stat.S_IRWXG | stat.S_IROTH | stat.S_IXOTH
os.chmod(absolute_dir, mode)
os.chmod(os.path.dirname(os.path.normpath(absolute_dir)), mode)
log_debug(1, self.server_id, "Creating file: %s" % absolute_file)
f = open(absolute_file, 'w+')
f.write(filecontent)
return {'result': True,
}
示例14: initiate
def initiate(server_id, action_id, dry_run=0):
log_debug(3)
h = rhnSQL.prepare(_query_initiate_guest)
h.execute(action_id=action_id)
row = h.fetchone_dict()
if not row:
raise InvalidAction("Kickstart action without an associated kickstart")
kickstart_host = row['kickstart_host']
virt_type = row['virt_type']
name = row['guest_name']
boot_image = "spacewalk-koan"
append_string = row['append_string']
vcpus = row['vcpus']
disk_gb = row['disk_gb']
mem_kb = row['mem_kb']
ks_session_id = row['ks_session_id']
virt_bridge = row['virt_bridge']
disk_path = row['disk_path']
cobbler_system_name = row['cobbler_system_name']
if not boot_image:
raise InvalidAction("Boot image missing")
return (kickstart_host, cobbler_system_name, virt_type, ks_session_id, name,
mem_kb, vcpus, disk_gb, virt_bridge, disk_path, append_string)
示例15: _repodata_taskomatic
def _repodata_taskomatic(self, file_name):
log_debug(3, 'repodata', file_name)
content_type = "application/x-gzip"
if file_name in ["repomd.xml", "comps.xml"]:
content_type = "text/xml"
elif file_name not in ["primary.xml.gz", "other.xml.gz",
"filelists.xml.gz", "updateinfo.xml.gz", "Packages.gz"]:
log_debug(2, "Unknown repomd file requested: %s" % file_name)
raise rhnFault(6)
# XXX this won't be repconned or CDNd
if file_name == "comps.xml":
return self._repodata_python(file_name)
file_path = "%s/%s/%s" % (CFG.REPOMD_PATH_PREFIX, self.channelName, file_name)
rhnFlags.set('Content-Type', content_type)
try:
rhnFlags.set('Download-Accelerator-Path', file_path)
return self._getFile(CFG.REPOMD_CACHE_MOUNT_POINT + "/" + file_path)
except IOError, e:
# For file not found, queue up a regen, and return 404
if e.errno == 2 and file_name != "comps.xml":
taskomatic.add_to_repodata_queue(self.channelName,
"repodata request", file_name, bypass_filters=True)
rhnSQL.commit()
# This returns 404 to the client
raise rhnFault(6), None, sys.exc_info()[2]
raise