client/rhel/rhn-client-tools/man/en/spacewalk-channel.8 | 3 ++
client/rhel/rhn-client-tools/src/bin/spacewalk-channel.py | 17 ++++++++++++--
2 files changed, 18 insertions(+), 2 deletions(-)
New commits:
commit 81df0f7ac4c1ac35f2311e897f75dbc6aa065acc
Author: Milan Zazrivec <mzazrivec(a)redhat.com>
Date: Fri Sep 21 13:49:24 2012 +0200
859281 - rhn-channel: new option to list base channel of a system
diff --git a/client/rhel/rhn-client-tools/man/en/spacewalk-channel.8 b/client/rhel/rhn-client-tools/man/en/spacewalk-channel.8
index 8bb986d..3814c9e 100644
--- a/client/rhel/rhn-client-tools/man/en/spacewalk-channel.8
+++ b/client/rhel/rhn-client-tools/man/en/spacewalk-channel.8
@@ -33,6 +33,9 @@ specified channels via the command line. A visit to the Red Hat Network
.IP "\fB-l, --list\fP"
Print a list of channel(s) that you are currently subscribed to.
.br
+.IP "\fB-b, --base\fP"
+Print a base channel that you are currently subscribed to.
+.br
.IP "\fB-L, --available-channels\fP"
Print a list of all available child channels.
.br
diff --git a/client/rhel/rhn-client-tools/src/bin/spacewalk-channel.py b/client/rhel/rhn-client-tools/src/bin/spacewalk-channel.py
index 0164e8b..8146214 100644
--- a/client/rhel/rhn-client-tools/src/bin/spacewalk-channel.py
+++ b/client/rhel/rhn-client-tools/src/bin/spacewalk-channel.py
@@ -63,6 +63,8 @@ def processCommandline():
help=_('unsubscribe from channel')),
Option('-l', '--list', action='store_true',
help=_('list channels')),
+ Option('-b', '--base', action='store_true',
+ help='show base channel of a system'),
Option('-L', '--available-channels', action='store_true',
help=_('list all available child channels')),
Option('-v', '--verbose', action='store_true',
@@ -79,10 +81,10 @@ def processCommandline():
# 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 not OPTIONS.user and not OPTIONS.list:
+ if not OPTIONS.user and not OPTIONS.list and not OPTIONS.base:
print _("Username: "),
OPTIONS.user = sys.stdin.readline().rstrip('\n')
- if not OPTIONS.password and not OPTIONS.list:
+ if not OPTIONS.password and not OPTIONS.list and not OPTIONS.base:
OPTIONS.password = getpass.getpass()
def get_available_channels(user, password):
@@ -148,6 +150,17 @@ def main():
systemExit(1, _('Unable to locate SystemId file. Is this system registered?'))
channels.sort()
print '\n'.join(channels)
+ elif OPTIONS.base:
+ try:
+ for channel in getChannels().channels():
+ # Base channel has no parent
+ if not channel['parent_channel']:
+ print channel['label']
+ 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?')
+
elif OPTIONS.available_channels:
channels = get_available_channels(OPTIONS.user, OPTIONS.password)
channels.sort()