本文整理汇总了Python中spacewalk.common.rhnException.rhnFault函数的典型用法代码示例。如果您正苦于以下问题:Python rhnFault函数的具体用法?Python rhnFault怎么用?Python rhnFault使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rhnFault函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: auth_client
def auth_client(self, token):
""" Authenticate a system based on the same authentication tokens
the client is sending for GET requests
"""
log_debug(3)
# Build a UserDictCase out of the token
dict = UserDictCase(token)
# Set rhnFlags so that we can piggyback on apacheAuth's auth_client
rhnFlags.set('AUTH_SESSION_TOKEN', dict)
# XXX To clean up apacheAuth.auth_client's logging, this is not about
# GET requests
result = apacheAuth.auth_client()
if not result:
raise rhnFault(33, _("Invalid session key"))
log_debug(4, "Client auth OK")
# We checked it already, so we're sure it's there
client_id = dict['X-RHN-Server-Id']
server = rhnServer.search(client_id)
if not server:
raise rhnFault(8, _("This server ID no longer exists"))
# XXX: should we check if the username still has access to it?
# probably not, because there is no known good way we can
# update the server system_id on the client side when
# permissions change... Damn it. --gafton
self.server = server
self.server_id = client_id
self.user = dict['X-RHN-Auth-User-Id']
return server
开发者ID:cliffy94,项目名称:spacewalk,代码行数:32,代码来源:proxy.py
示例2: new_user
def new_user(self, username, password, email = None,
org_id = None, org_password = None):
"""
Finish off creating the user.
The user has to exist (must be already reserved), the password must
match and we set the e-mail address if one is given
Return true if success
"""
log_debug(1, username, email)
# email has to be a string or nothing
if not checkValue(email, None, "", type("")):
raise rhnFault(30, _faultValueString(email, "email"))
# be somewhat drastic about the org values
if org_id and org_password:
org_password = str(org_password)
try:
org_id = int(str(org_id))
except ValueError:
raise rhnFault(30, _faultValueString(org_id, "org_id")), None, sys.exc_info()[2]
else:
org_id = org_password = None
username, password = rhnUser.check_user_password(username, password)
email = rhnUser.check_email(email)
# now create this user
ret = rhnUser.new_user(username, password, email, org_id, org_password)
# rhnUser.new_user will raise it's own faults.
return ret
开发者ID:glubbered,项目名称:spacewalk,代码行数:30,代码来源:registration.py
示例3: valid
def valid(self):
log_debug(4)
# check for anonymous
if self.attrs.get('machine_id'):
entitlements = check_entitlement_by_machine_id(self.attrs.get('machine_id'))
log_debug(4, "found entitlements for machine_id", self.attrs.get('machine_id'), entitlements)
if 'salt_entitled' in entitlements:
raise rhnFault(48, """
This system is already registered as a Salt Minion. If you want to register it as a traditional client
please delete it first via the web UI or API and then register it using the traditional tools.
""")
if 'type' in self.attrs and self.attrs['type'] \
and string.upper(self.attrs['type']) == "ANONYMOUS":
raise rhnFault(28, """
You need to re-register your system with SUSE Manager.
Previously you have chosen to skip the creation of a system profile
with SUSE Manager and this trial feature is no longer available now.
""") # we don't support anonymous anymore
# now we have a real server. Get its secret
sid = self.attrs["system_id"]
secret = getServerSecret(sid)
if secret is None:
# no secret, can't validate
log_debug(1, "Server id %s not found in database" % sid)
return 0
return self.__validate_checksum(secret)
开发者ID:m47ik,项目名称:uyuni,代码行数:28,代码来源:server_certificate.py
示例4: _get_file_revision
def _get_file_revision(self, config_channel, revision, path):
if revision and not revision.isdigit():
raise rhnFault(4016, "Invalid revision number '%s' specified for path %s "
"in channel %s" % (revision, path, config_channel),
explain=0)
f = self._get_file(config_channel, path, revision=revision)
if not f:
raise rhnFault(4011, "File %s (revision %s) does not exist "
"in channel %s" % (path, revision, config_channel),
explain=0)
if f['label'] == 'file' and f['is_binary'] == 'Y':
raise rhnFault(4004, "File %s (revision %s) seems to contain "
"binary data" % (path, revision),
explain=0)
# We have to read the contents of the first file here, because the LOB
# object is tied to a cursor; if we re-execute the cursor, the LOB
# seems to be invalid (bug 151220)
# Empty files or directories may have NULL instead of lobs
fc_lob = f.get('file_contents')
if fc_lob:
f['file_content'] = rhnSQL.read_lob(fc_lob).splitlines()
else:
f['file_content'] = ''
return f
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:27,代码来源:rhn_config_management.py
示例5: entitle
def entitle(self, server_id, history, virt_type=None):
"""
Entitle a server according to the entitlements we have configured.
"""
log_debug(3, self.entitlements)
entitle_server = rhnSQL.Procedure("rhn_entitlements.entitle_server")
# TODO: entitle_server calls can_entitle_server, so we're doing this
# twice for each successful call. Is it necessary for external error
# handling or can we ditch it?
can_entitle_server = rhnSQL.Function(
"rhn_entitlements.can_entitle_server", rhnSQL.types.NUMBER())
can_ent = None
history["entitlement"] = ""
# Do a quick check to see if both virt entitlements are present. (i.e.
# activation keys stacked together) If so, give preference to the more
# powerful virtualization platform and remove the regular virt
# entitlement from the list.
found_virt = False
found_virt_platform = False
for entitlement in self.entitlements:
if entitlement[0] == VIRT_ENT_LABEL:
found_virt = True
elif entitlement[0] == VIRT_PLATFORM_ENT_LABEL:
found_virt_platform = True
for entitlement in self.entitlements:
if virt_type is not None and entitlement[0] in \
(VIRT_ENT_LABEL, VIRT_PLATFORM_ENT_LABEL):
continue
# If both virt entitlements are present, skip the least powerful:
if found_virt and found_virt_platform and entitlement[0] == VIRT_ENT_LABEL:
log_debug(1, "Virtualization and Virtualization Platform " +
"entitlements both present.")
log_debug(1, "Skipping Virtualization.")
continue
try:
can_ent = can_entitle_server(server_id, entitlement[0])
except rhnSQL.SQLSchemaError, e:
can_ent = 0
try:
# bugzilla #160077, skip attempting to entitle if we cant
if can_ent:
entitle_server(server_id, entitlement[0])
except rhnSQL.SQLSchemaError, e:
log_error("Token failed to entitle server", server_id,
self.get_names(), entitlement[0], e.errmsg)
if e.errno == 20220:
# ORA-20220: (servergroup_max_members) - Server group membership
# cannot exceed maximum membership
raise rhnFault(91,
_("Registration failed: RHN Software service entitlements exhausted: %s") % entitlement[0]), None, sys.exc_info()[2]
# No idea what error may be here...
raise rhnFault(90, e.errmsg), None, sys.exc_info()[2]
开发者ID:flavio,项目名称:spacewalk,代码行数:60,代码来源:server_token.py
示例6: __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
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:33,代码来源:packageUpload.py
示例7: _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
开发者ID:TJM,项目名称:spacewalk,代码行数:30,代码来源:rhnRepository.py
示例8: update_crash_count
def update_crash_count(self, system_id, crash, crash_count):
self.auth_system(system_id)
log_debug(1, self.server_id, "Updating crash count for %s to %s" % (crash, crash_count))
server_org_id = self.server.server['org_id']
server_crash_dir = get_crash_path(str(server_org_id), str(self.server_id), crash)
if not server_crash_dir:
log_debug(1, self.server_id, "Error composing crash directory path")
raise rhnFault(5002)
h = rhnSQL.prepare(_query_update_crash_count)
r = h.execute(
crash_count=crash_count,
server_id=self.server_id,
crash=crash)
rhnSQL.commit()
if r == 0:
log_debug(1, self.server_id, "No record for crash: %s" % crash)
raise rhnFault(5005, "Invalid crash name: %s" % crash)
absolute_dir = os.path.join(CFG.MOUNT_POINT, server_crash_dir)
absolute_file = os.path.join(absolute_dir, 'count')
log_debug(1, self.server_id, "Updating crash count file: %s" % absolute_file)
f = open(absolute_file, 'w+')
f.write(crash_count)
f.close()
return 1
开发者ID:dewayneHat,项目名称:spacewalk,代码行数:31,代码来源:abrt.py
示例9: _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,
}
开发者ID:TJM,项目名称:spacewalk,代码行数:32,代码来源:scap.py
示例10: 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])
开发者ID:TJM,项目名称:spacewalk,代码行数:35,代码来源:rhnUser.py
示例11: authzOrg
def authzOrg(self, info):
# This function is a lot more complicated than it should be; the
# corner case is pushes without a channel; we have to deny regular
# users the ability to push to their org.
# If the org id is not specified, default to the user's org id
if not info.has_key("orgId"):
info["orgId"] = self.org_id
log_debug(4, "info[orgId]", info["orgId"], "org id", self.org_id)
org_id = info["orgId"]
if org_id == "":
# Satellites are not allowwd to push in the null org
raise rhnFault(4, _("You are not authorized to manage packages in the null org"))
if org_id and self.org_id != org_id:
# Not so fast...
raise rhnFault(32, _("You are not allowed to manage packages in the %s org") % org_id)
# Org admins and channel admins have full privileges; we could use
# user_manages_channes, except for the case where there are no chanels
if self.isOrgAdmin() or self.isChannelAdmin():
log_debug(4, "Org authorized (org_admin or channel_admin)")
return
# regular user at this point... check if the user manages any channels
if user_manages_channels(self.user_id):
log_debug(4, "Org authorized (user manages a channel)")
return
# ok, you're a regular user who doesn't manage any channels.
# take a hike.
raise rhnFault(32, _("You are not allowed to perform administrative tasks"))
开发者ID:kidaa30,项目名称:spacewalk,代码行数:35,代码来源:userAuth.py
示例12: 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
开发者ID:m47ik,项目名称:uyuni,代码行数:35,代码来源:packages.py
示例13: __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
开发者ID:TJM,项目名称:spacewalk,代码行数:33,代码来源:server_hardware.py
示例14: management_diff
def management_diff(self, dict):
log_debug(1)
self._get_and_validate_session(dict)
param_names = ['config_channel_src', 'revision_src', 'path', ]
for p in param_names:
val = dict.get(p)
if val is None:
raise rhnFault(4007, "No content sent for `%s'" % p)
log_debug(4, "Params sent", dict)
path = dict['path']
config_channel_src = dict['config_channel_src']
revision_src = dict.get('revision_src')
fsrc = self._get_file_revision(config_channel_src, revision_src, path)
config_channel_dst = dict.get('config_channel_dst')
if config_channel_dst is None:
config_channel_dst = config_channel_src
revision_dst = dict.get('revision_dst')
fdst = self._get_file_revision(config_channel_dst, revision_dst, path)
if fsrc['label'] != fdst['label']:
raise rhnFault(4017,
"Path %s is a %s in channel %s while it is a %s in channel %s"
% (path, fsrc['label'],
config_channel_src, fdst['label'], config_channel_dst),
explain=0)
if fsrc['label'] == 'symlink':
if (fsrc["symlink"] != fdst['symlink']) or self.__attributes_differ(fsrc, fdst):
(first_row, second_row) = self.__header(path, fsrc, config_channel_src, fdst, config_channel_dst)
first_row += ' target: %s' % fsrc["symlink"]
second_row += ' target: %s' % fdst["symlink"]
return first_row + "\n" + second_row + "\n"
return ""
diff = difflib.unified_diff(
fsrc['file_content'], fdst['file_content'], path, path, fsrc['modified'], fdst['modified'], lineterm='')
try:
first_row = next(diff)
except StopIteration:
return ""
if not first_row.startswith('---'):
# Hmm, weird
return first_row + '\n'.join(list(diff))
try:
second_row = next(diff)
except StopIteration:
second_row = ''
if not second_row.startswith('+++'):
# Hmm, weird
return second_row + '\n'.join(list(diff))
(first_row, second_row) = self.__header(path, fsrc, config_channel_src, fdst, config_channel_dst)
return first_row + "\n" + second_row + '\n' + '\n'.join(list(diff))
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:60,代码来源:rhn_config_management.py
示例15: check_user_password
def check_user_password(username, password):
""" Do some minimal checks on the data thrown our way. """
# username is required
if not username:
raise rhnFault(11)
# password is required
if not password:
raise rhnFault(12)
if len(username) < CFG.MIN_USER_LEN:
raise rhnFault(13, _("username should be at least %d characters")
% CFG.MIN_USER_LEN)
if len(username) > CFG.MAX_USER_LEN:
raise rhnFault(700, _("username should be less than %d characters")
% CFG.MAX_USER_LEN)
username = username[:CFG.MAX_USER_LEN]
# Invalid characters
# ***NOTE*** Must coordinate with web and installer folks about any
# changes to this set of characters!!!!
invalid_re = re.compile(".*[\s&+%'`\"=#]", re.I)
tmp = invalid_re.match(username)
if tmp is not None:
pos = tmp.regs[0]
raise rhnFault(15, _("username = `%s', invalid character `%s'") % (
username, username[pos[1] - 1]))
# use new password validation method
validate_new_password(password)
return username, password
开发者ID:TJM,项目名称:spacewalk,代码行数:30,代码来源:rhnUser.py
示例16: management_remove_channel
def management_remove_channel(self, dict):
log_debug(1)
self._get_and_validate_session(dict)
config_channel = dict.get('config_channel')
# XXX Validate the namespace
row = rhnSQL.fetchone_dict(self._query_config_channel_by_label,
org_id=self.org_id, label=config_channel)
if not row:
raise rhnFault(4009, "Channel not found")
delete_call = rhnSQL.Procedure('rhn_config.delete_channel')
try:
delete_call(row['id'])
except rhnSQL.SQLError:
e = sys.exc_info()[1]
errno = e.args[0]
if errno == 2292:
raise_with_tb(rhnFault(4005, "Cannot remove non-empty channel %s" %
config_channel, explain=0), sys.exc_info()[2])
raise
log_debug(5, "Removed:", config_channel)
rhnSQL.commit()
return ""
开发者ID:BlackSmith,项目名称:spacewalk,代码行数:28,代码来源:rhn_config_management.py
示例17: _verifyProxyAuthToken
def _verifyProxyAuthToken(auth_token):
""" verifies the validity of a proxy auth token
NOTE: X-RHN-Proxy-Auth described in proxy/broker/rhnProxyAuth.py
"""
log_debug(4, auth_token)
token, hostname = splitProxyAuthToken(auth_token)
hostname = hostname.strip()
ipv4_regex = '^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$'
# This ipv6 regex was develeoped by Stephen Ryan at Dataware.
# (http://forums.intermapper.com/viewtopic.php?t=452) It is licenced
# under a Creative Commons Attribution-ShareAlike 3.0 Unported
# License, so we are free to use it as long as we attribute it to him.
ipv6_regex = '^((([0-9A-Fa-f]{1,4}:){7}([0-9A-Fa-f]{1,4}|:))|(([0-9A-Fa-f]{1,4}:){6}(:[0-9A-Fa-f]{1,4}|((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){5}(((:[0-9A-Fa-f]{1,4}){1,2})|:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3})|:))|(([0-9A-Fa-f]{1,4}:){4}(((:[0-9A-Fa-f]{1,4}){1,3})|((:[0-9A-Fa-f]{1,4})?:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){3}(((:[0-9A-Fa-f]{1,4}){1,4})|((:[0-9A-Fa-f]{1,4}){0,2}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){2}(((:[0-9A-Fa-f]{1,4}){1,5})|((:[0-9A-Fa-f]{1,4}){0,3}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(([0-9A-Fa-f]{1,4}:){1}(((:[0-9A-Fa-f]{1,4}){1,6})|((:[0-9A-Fa-f]{1,4}){0,4}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:))|(:(((:[0-9A-Fa-f]{1,4}){1,7})|((:[0-9A-Fa-f]{1,4}){0,5}:((25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)(\.(25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)){3}))|:)))(%.+)?$'
hostname_is_ip_address = re.match(ipv4_regex, hostname) or re.match(ipv6_regex, hostname)
headers = rhnFlags.get('outputTransportOptions')
if len(token) < 5:
# Bad auth information; decline any action
log_debug(4, "incomplete proxy authentication token: %s"
% auth_token)
headers['X-RHN-Proxy-Auth-Error'] = '%s:%s' % (
1003, _("incomplete proxy authentication token: %s") % auth_token)
if not hostname_is_ip_address:
headers['X-RHN-Proxy-Auth-Origin'] = hostname
raise rhnFault(1003) # Invalid session key
log_debug(5, "proxy auth token: %s, hostname: %s"
% (repr(token), hostname or 'n/a'))
proxyId, proxyUser, rhnServerTime, expireOffset, signature = token[:5]
computed = computeSignature(CFG.SECRET_KEY, proxyId, proxyUser,
rhnServerTime, expireOffset)
if computed != signature:
log_error("Proxy signature failed: proxy id='%s', proxy user='%s'" %
(proxyId, proxyUser))
log_debug(4, "Sent proxy signature %s does not match ours %s." % (
signature, computed))
headers['X-RHN-Proxy-Auth-Error'] = '%s:%s' % (
1003, _("Sent proxy signature %s does not match ours %s.") % (
signature, computed))
if not hostname_is_ip_address:
headers['X-RHN-Proxy-Auth-Origin'] = hostname
raise rhnFault(1003) # Invalid session key
# Convert the expiration/time to floats:
rhnServerTime = float(rhnServerTime)
expireOffset = float(expireOffset)
if rhnServerTime + expireOffset < time.time():
log_debug(4, "Expired proxy authentication token")
headers['X-RHN-Proxy-Auth-Error'] = '%s:%s' % (1004, "Expired")
if not hostname_is_ip_address:
headers['X-RHN-Proxy-Auth-Origin'] = hostname
raise rhnFault(1004) # Expired client authentication token
log_debug(4, "Proxy auth OK: sigs match; not an expired token")
return 1
开发者ID:TJM,项目名称:spacewalk,代码行数:60,代码来源:apacheAuth.py
示例18: __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 mapping in info:
k = mapping
else:
k = key
if k not in info:
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
开发者ID:shastah,项目名称:spacewalk,代码行数:32,代码来源:server_hardware.py
示例19: 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]
开发者ID:crashdummymch,项目名称:puppet-crashdummyMCH-spacewalk,代码行数:25,代码来源:rhnRepository.py
示例20: get_package_path
def get_package_path(server_id, pkg_spec, channel):
log_debug(3, server_id, pkg_spec, channel)
if isinstance(pkg_spec, ListType):
pkg = pkg_spec[:4]
#Insert EPOCH
pkg.insert(1, None)
else:
pkg = parseRPMFilename(pkg_spec)
if pkg is None:
log_debug(4, "Error", "Requested weird package", pkg_spec)
raise rhnFault(17, _("Invalid RPM package %s requested") % pkg_spec)
statement = """
select p.id, p.path path, pe.epoch epoch
from
rhnPackageArch pa,
rhnChannelPackage cp,
rhnPackage p,
rhnPackageEVR pe,
rhnServerChannel sc,
rhnPackageName pn,
rhnChannel c
where 1=1
and c.label = :channel
and pn.name = :name
and sc.server_id = :server_id
and pe.version = :ver
and pe.release = :rel
and c.id = sc.channel_id
and c.id = cp.channel_id
and pa.label = :arch
and pn.id = p.name_id
and p.id = cp.package_id
and p.evr_id = pe.id
and sc.channel_id = cp.channel_id
and p.package_arch_id = pa.id
"""
h = rhnSQL.prepare(statement)
pkg = map(str, pkg)
h.execute(name = pkg[0], ver = pkg[2], rel = pkg[3], arch = pkg[4],
channel = channel, server_id = server_id)
rs = h.fetchall_dict()
if not rs:
log_debug(4, "Error", "Non-existant package requested", server_id,
pkg_spec, channel)
raise rhnFault(17, _("Invalid RPM package %s requested") % pkg_spec)
# It is unlikely for this query to return more than one row,
# but it is possible
# (having two packages with the same n, v, r, a and different epoch in
# the same channel is prohibited by the RPM naming scheme; but extra
# care won't hurt)
max_row = rs[0]
for each in rs[1:]:
# Compare the epoch as string
if _none2emptyString(each['epoch']) > _none2emptyString(max_row['epoch']):
max_row = each
# Set the flag for the proxy download accelerator
rhnFlags.set("Download-Accelerator-Path", max_row['path'])
return check_package_file(max_row['path'], max_row['id'], pkg_spec), max_row['id']
开发者ID:adelton,项目名称:spacewalk,代码行数:60,代码来源:rhnPackage.py
注:本文中的spacewalk.common.rhnException.rhnFault函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论