Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 597031 Details for
Bug 838502
With "spacewalk-channel" "redhat-rhn-proxy*" channels can be manipulated.
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
"spacewalk-channel" should not manipulate rhn-proxy channels.
spacewalk-channel (text/plain), 6.30 KB, created by
Dimitar Yordanov
on 2012-07-09 09:34:51 UTC
(
hide
)
Description:
"spacewalk-channel" should not manipulate rhn-proxy channels.
Filename:
MIME Type:
Creator:
Dimitar Yordanov
Created:
2012-07-09 09:34:51 UTC
Size:
6.30 KB
patch
obsolete
>#!/usr/bin/python ># ># Copyright (c) 2009 Red Hat, Inc. ># ># This software is licensed to you under the GNU General Public License, ># version 2 (GPLv2). There is NO WARRANTY for this software, express or ># implied, including the implied warranties of MERCHANTABILITY or FITNESS ># FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 ># along with this software; if not, see ># http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. ># ># Red Hat trademarks are not licensed under GPLv2. No permission is ># granted to use or replicate Red Hat trademarks that are incorporated ># in this software or its documentation. ># >import getpass >import os >import re >import socket >import sys >import urlparse >import xmlrpclib >from rhn import rpclib > >from optparse import Option, OptionParser > >import gettext >t = gettext.translation('rhn-client-tools', fallback=True) >_ = t.ugettext > >def systemExit(code, msgs=None): > "Exit with a code and optional message(s). Saved a few lines of code." > if msgs: > if type(msgs) not in [type([]), type(())]: > msgs = (msgs, ) > for msg in msgs: > sys.stderr.write(str(msg)+'\n') > sys.exit(code) > ># quick check to see if you are a super-user. >if os.getuid() != 0: > systemExit(8, 'ERROR: must be root to execute\n') > >_LIBPATH = "/usr/share/rhn" ># add to the path if need be >if _LIBPATH not in sys.path: > sys.path.append(_LIBPATH) > >from up2date_client.rhnChannel import subscribeChannels, unsubscribeChannels, getChannels >from up2date_client import up2dateAuth, config, up2dateErrors > >def processCommandline(): > "process the commandline, setting the OPTIONS object" > optionsTable = [ > Option('-c', '--channel', action='append', > help='name of channel you want to (un)subscribe'), > Option('-a', '--add', action='store_true', > help='subscribe to channel'), > Option('-r', '--remove', action='store_true', > help='unsubscribe from channel'), > Option('-l', '--list', action='store_true', > help='list channels'), > Option('-L', '--available-channels', action='store_true', > help='list all available child channels'), > Option('-v', '--verbose', action='store_true', > help='verbose output'), > Option('-u', '--user', action='store', > help='your user name'), > Option('-p', '--password', action='store', > help='your password'), > ] > optionParser = OptionParser(option_list=optionsTable) > global OPTIONS > OPTIONS, args = optionParser.parse_args() > > # we take no extra commandline arguments that are not linked to an option > if args: > systemExit(1, "ERROR: these arguments make no sense in this context (try --help)") > if OPTIONS.channel: > for chann in OPTIONS.channel: > if re.match("^redhat-rhn-proxy.*$",chann): > systemExit(1, "ERROR: RHN-Proxy channels can not be manipulated via spacewalk-channel tool!") > if not OPTIONS.user and not OPTIONS.list: > print "Username: ", > OPTIONS.user = sys.stdin.readline().rstrip('\n') > if not OPTIONS.password and not OPTIONS.list: > OPTIONS.password = getpass.getpass() > > >def get_available_channels(user, password): > """ return list of available child channels """ > cfg = config.initUp2dateConfig() > satellite_url = config.getServerlURL()[0] > parts = urlparse.urlsplit(satellite_url) > satellite_url = urlparse.SplitResult(parts.scheme, parts.netloc, '/rpc/api', > parts.query, parts.fragment).geturl() > > client = xmlrpclib.Server(satellite_url, verbose=0) > try: > key = client.auth.login(user, password) > except xmlrpclib.Fault, exc: > systemExit(1, "Error during client authentication: %s" % exc.faultString) > > system_id = re.sub('^ID-', '', rpclib.xmlrpclib.loads(up2dateAuth.getSystemId())[0][0]['system_id']) > result = [] > try: > channels = client.system.listChildChannels(key, int(system_id)) > except xmlrpclib.Fault, exc: > systemExit(1, "Error when listing child channels: %s" % exc.faultString) > > for channel in channels: > if 'LABEL' in channel: > result.extend([channel['LABEL']]) > else: > result.extend([channel['label']]) > return result > >def need_channel(channel): > """ die gracefuly if channel is empty """ > if not channel: > systemExit(4, "ERROR: you have to specify at least one channel") > >def main(): > if OPTIONS.add: > need_channel(OPTIONS.channel) > result = subscribeChannels(OPTIONS.channel, OPTIONS.user, OPTIONS.password) > if OPTIONS.verbose: > if result == 0: > print "Channel(s): %s successfully added" % ', '.join(OPTIONS.channel) > else: > sys.stderr.write("Error during adding channel(s) %s" % ', '.join(OPTIONS.channel)) > if result != 0: > sys.exit(result) > elif OPTIONS.remove: > need_channel(OPTIONS.channel) > result = unsubscribeChannels(OPTIONS.channel, OPTIONS.user, OPTIONS.password) > if OPTIONS.verbose: > if result == 0: > print "Channel(s): %s successfully removed" % ', '.join(OPTIONS.channel) > else: > sys.stderr.write("Error during removal of channel(s) %s" % ', '.join(OPTIONS.channel)) > if result != 0: > sys.exit(result) > elif OPTIONS.list: > try: > channels = map(lambda x: x['label'], getChannels().channels()) > except up2dateErrors.NoChannelsError: > systemExit(1, 'This system is not associated with any channel.') > except up2dateErrors.NoSystemIdError: > systemExit(1, 'Unable to locate SystemId file. Is this system registered?') > channels.sort() > print '\n'.join(channels) > elif OPTIONS.available_channels: > channels = get_available_channels(OPTIONS.user, OPTIONS.password) > channels.sort() > for chann in channels: > if not re.match("^redhat-rhn-proxy.*$",chann): > print chann > else: > systemExit(3, "ERROR: you may want to specify --add, --remove or --list") > >try: > processCommandline() > main() >except KeyboardInterrupt: > systemExit(0, "\nUser interrupted process.") >except up2dateErrors.RhnServerException, e: > # do not print traceback, it will scare people > systemExit(1, e)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 838502
: 597031