utils/spacewalk-common-channels | 85 ++++++++++++++++++++----------------
utils/spacewalk-common-channels.ini | 47 +++++++++++++------
2 files changed, 81 insertions(+), 51 deletions(-)
New commits:
commit c4cab6d5da4bbc77a68da2401de88424a422b60b
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Wed Feb 17 00:14:38 2010 +0100
fixed activationkey option behavior when creating child channels only
diff --git a/utils/spacewalk-common-channels b/utils/spacewalk-common-channels
index 4a30020..8b55880 100755
--- a/utils/spacewalk-common-channels
+++ b/utils/spacewalk-common-channels
@@ -67,7 +67,7 @@ def connect(user, password, server):
def add_channels(channels, section, arch):
base_channels = ['']
- optional = ['activationkey']
+ optional = ['activationkey', 'base_channel_activationkey']
mandatory = ['label', 'name', 'summary', 'checksum',
'arch']
if config.has_option(section, 'base_channels'):
@@ -80,6 +80,9 @@ def add_channels(channels, section, arch):
channel = { 'base_channel': config.get(section, 'base_channel')}
if base_channel:
+ if channel['base_channel'] not in channels:
+ # there isn't such base channel so skip also child
+ continue
# set base channel values so they can be used as macros
for (k,v) in channels[channel['base_channel']].items():
config.set(section, 'base_channel_' + k, v)
@@ -203,7 +206,6 @@ Create everything as well as unlimited activation key for every
channel:
else:
raise e
- activationkey = None
if create_channel:
base_info = channels[base_channel_label]
if options.verbose:
@@ -240,13 +242,9 @@ Create everything as well as unlimited activation key for every
channel:
[], False)
try:
client.activationkey.create(*ak_args)
- activationkey = "%s-%s" % (org_id,
base_info['activationkey'])
except xmlrpclib.Fault, e:
sys.stderr.write("ERROR: %s: %s\n" % (
base_info['label'], e.faultString))
- else:
- # set this in dry run
- activationkey = base_info['activationkey']
else:
# check whether channel exists
try:
@@ -282,7 +280,10 @@ Create everything as well as unlimited activation key for every
channel:
child_info['label'], e.faultString))
if options.key_limit is not None:
- if activationkey:
+ if ('base_channel_activationkey' in child_info
+ and child_info['base_channel_activationkey']):
+ activationkey = "%s-%s" % (
+ org_id,
child_info['base_channel_activationkey'])
if options.verbose:
sys.stdout.write("** Activation key '%s' - adding
child channel...\n" % (
activationkey))
commit 3a157e2c7d5ae8be5cb0461eaa14807e1a490fbe
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Feb 16 23:44:39 2010 +0100
added base_channel_* macros expansion
to be able distinguish e.g. spacewalk for different base channels
diff --git a/utils/spacewalk-common-channels b/utils/spacewalk-common-channels
index ed54441..4a30020 100755
--- a/utils/spacewalk-common-channels
+++ b/utils/spacewalk-common-channels
@@ -68,7 +68,7 @@ def connect(user, password, server):
def add_channels(channels, section, arch):
base_channels = ['']
optional = ['activationkey']
- mandatory = ['label', 'name', 'summary', 'checksum',
'arch', 'base_channel']
+ mandatory = ['label', 'name', 'summary', 'checksum',
'arch']
if config.has_option(section, 'base_channels'):
base_channels = re.split(SPLIT_PATTERN, config.get(section,
'base_channels', 1))
@@ -76,8 +76,13 @@ def add_channels(channels, section, arch):
config.set(section, 'arch', arch)
config.set(section, 'section', section)
for base_channel in base_channels:
- channel = {}
config.set(section, 'base_channel', base_channel)
+ channel = { 'base_channel': config.get(section, 'base_channel')}
+
+ if base_channel:
+ # set base channel values so they can be used as macros
+ for (k,v) in channels[channel['base_channel']].items():
+ config.set(section, 'base_channel_' + k, v)
for k in optional:
if config.has_option(section,k):
@@ -147,33 +152,41 @@ Create everything as well as unlimited activation key for every
channel:
client = None
channels = {}
- # read matching channels from config and sort them, base channels first
- for pattern in args:
- for section in fnmatch.filter(config.sections(), pattern):
- archs = re.split(SPLIT_PATTERN, config.get(section, 'archs'))
- if options.archs:
- # filter out archs not set on commandline
- archs = filter(lambda a: a in options.archs, archs)
- for arch in archs:
- add_channels(channels, section, arch)
-
- # list of base_channels to create
+ sections = []
+ # sort base channels first and child last
+ for section in config.sections():
+ if config.has_option(section, 'base_channels'): # child
+ sections.append(section)
+ else: # base
+ sections.insert(0,section)
+ for section in sections:
+ archs = re.split(SPLIT_PATTERN, config.get(section, 'archs'))
+ if options.archs:
+ # filter out archs not set on commandline
+ archs = filter(lambda a: a in options.archs, archs)
+ for arch in archs:
+ add_channels(channels, section, arch)
+
+ # list of base_channels to deal with
base_channels = {}
# list of child_channels for given base_channel
child_channels = {}
- for (name, attr) in channels.items():
- if attr['base_channel']:
- if attr['base_channel'] not in base_channels:
- base_channels[attr['base_channel']] = False
- if attr['base_channel'] in child_channels:
- child_channels[attr['base_channel']].append(name)
+ # filter out non-matching channels
+ for pattern in args:
+ for name in fnmatch.filter(channels.keys(), pattern):
+ attr = channels[name]
+ if attr['base_channel']:
+ if attr['base_channel'] not in base_channels:
+ base_channels[attr['base_channel']] = False
+ if attr['base_channel'] in child_channels:
+ child_channels[attr['base_channel']].append(name)
+ else:
+ child_channels[attr['base_channel']] = [name]
else:
- child_channels[attr['base_channel']] = [name]
- else:
- # this channel is base channel
- base_channels[name] = True
- if name not in child_channels:
- child_channels[name] = []
+ # this channel is base channel
+ base_channels[name] = True
+ if name not in child_channels:
+ child_channels[name] = []
for (base_channel_label, create_channel) in sorted(base_channels.items()):
@@ -276,7 +289,7 @@ Create everything as well as unlimited activation key for every
channel:
if not options.dry_run:
try:
client.activationkey.addChildChannels(key, activationkey,
-
child_info['label'])
+
[child_info['label']])
except xmlrpclib.Fault, e:
sys.stderr.write("ERROR: %s: %s\n" % (
child_info['label'], e.faultString))
diff --git a/utils/spacewalk-common-channels.ini b/utils/spacewalk-common-channels.ini
index 4a65f2f..f0b674e 100644
--- a/utils/spacewalk-common-channels.ini
+++ b/utils/spacewalk-common-channels.ini
@@ -114,7 +114,7 @@ base_channels = centos5-%(arch)s
[epel5]
label = epel5-%(base_channel)s
-name = EPEL 5 (%(arch)s)
+name = EPEL 5 for %(base_channel_name)s
archs = i386, x86_64, ppc
base_channels = centos5-%(arch)s
@@ -166,19 +166,19 @@ base_channels = centos4-%(arch)s
[epel4]
label = epel4-%(base_channel)s
-name = EPEL 4 (%(arch)s)
+name = EPEL 4 for %(base_channel_name)s
archs = i386, x86_64, ppc
base_channels = centos4-%(arch)s
[spacewalk08-server]
label = spacewalk08-server-%(base_channel)s
-name = Spacewalk Server 0.8 (%(arch)s)
+name = Spacewalk Server 0.8 for %(base_channel_name)s
archs = i386, x86_64
base_channels = fedora12-%(arch)s fedora11-%(arch)s centos5-%(arch)s
[spacewalk08-client]
label = spacewalk08-client-%(base_channel)s
-name = Spacewalk Client 0.8 (%(arch)s)
+name = Spacewalk Client 0.8 for %(base_channel_name)s
archs = i386, x86_64
base_channels = fedora12-%(arch)s fedora11-%(arch)s centos5-%(arch)s
commit 6504c2cddcf778e1ad489027d7a02ce074914f62
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Feb 16 15:06:29 2010 +0100
simplify code
diff --git a/utils/spacewalk-common-channels b/utils/spacewalk-common-channels
index e6cd8ca..ed54441 100755
--- a/utils/spacewalk-common-channels
+++ b/utils/spacewalk-common-channels
@@ -65,8 +65,7 @@ def connect(user, password, server):
key = client.auth.login(user, password)
return client, key
-def setup_channel(section, arch):
- channels = {}
+def add_channels(channels, section, arch):
base_channels = ['']
optional = ['activationkey']
mandatory = ['label', 'name', 'summary', 'checksum',
'arch', 'base_channel']
@@ -86,7 +85,6 @@ def setup_channel(section, arch):
for k in mandatory:
channel[k] = config.get(section, k)
channels[channel['label']] = channel
- return channels
if __name__ == "__main__":
# options parsing
@@ -157,8 +155,7 @@ Create everything as well as unlimited activation key for every
channel:
# filter out archs not set on commandline
archs = filter(lambda a: a in options.archs, archs)
for arch in archs:
- channel = setup_channel(section, arch)
- channels.update(channel)
+ add_channels(channels, section, arch)
# list of base_channels to create
base_channels = {}
commit e0b77566e2678f27fca6eca9e52534ab12386247
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Feb 16 11:50:08 2010 +0100
spacewalk is child of centos5 - moved on back
diff --git a/utils/spacewalk-common-channels.ini b/utils/spacewalk-common-channels.ini
index 76a9066..4a65f2f 100644
--- a/utils/spacewalk-common-channels.ini
+++ b/utils/spacewalk-common-channels.ini
@@ -70,18 +70,6 @@ archs = %(_f12_archs)s
checksum = sha256
base_channels = fedora12-%(arch)s
-[spacewalk08-server]
-label = spacewalk08-server-%(base_channel)s
-name = Spacewalk Server 0.8 (%(arch)s)
-archs = i386, x86_64
-base_channels = fedora12-%(arch)s fedora11-%(arch)s centos5-%(arch)s
-
-[spacewalk08-client]
-label = spacewalk08-client-%(base_channel)s
-name = Spacewalk Client 0.8 (%(arch)s)
-archs = i386, x86_64
-base_channels = fedora12-%(arch)s fedora11-%(arch)s centos5-%(arch)s
-
[centos5]
archs = %(_x86_archs)s
name = CentOS 5 (%(arch)s)
@@ -182,3 +170,15 @@ name = EPEL 4 (%(arch)s)
archs = i386, x86_64, ppc
base_channels = centos4-%(arch)s
+[spacewalk08-server]
+label = spacewalk08-server-%(base_channel)s
+name = Spacewalk Server 0.8 (%(arch)s)
+archs = i386, x86_64
+base_channels = fedora12-%(arch)s fedora11-%(arch)s centos5-%(arch)s
+
+[spacewalk08-client]
+label = spacewalk08-client-%(base_channel)s
+name = Spacewalk Client 0.8 (%(arch)s)
+archs = i386, x86_64
+base_channels = fedora12-%(arch)s fedora11-%(arch)s centos5-%(arch)s
+
commit 51f07d9b63dcb49ba3356c448cfa1ae882ac01d5
Author: Michael Mraka <michael.mraka(a)redhat.com>
Date: Tue Feb 16 11:49:27 2010 +0100
added an explanation of ini format
diff --git a/utils/spacewalk-common-channels.ini b/utils/spacewalk-common-channels.ini
index ebbc2af..76a9066 100644
--- a/utils/spacewalk-common-channels.ini
+++ b/utils/spacewalk-common-channels.ini
@@ -1,3 +1,22 @@
+#
+# These are definitions of common channels and their names in Spacewalk.
+#
+# Every section defines a set channels (base or child) for a given list
+# of architectures.
+#
+# Mandatory options for a section (have to be defined or inherited from [DEFAULT]):
+# label
+# name
+# summary
+# archs
+# checksum
+# Optional options for a section:
+# activationkey
+# base_channels (child channel has to have it)
+#
+# Base channels have to be defined before child channels.
+#
+
[DEFAULT]
label = %(section)s-%(arch)s
checksum = sha1