#!/usr/bin/python import xmlrpclib import datetime now = datetime.datetime.now() current_date = now.strftime("%m%d%Y") leading_channel_tag = "test-" SATELLITE_URL = "http://somehost/rpc/api" SATELLITE_LOGIN = "foo" SATELLITE_PASSWORD ="bar" client = xmlrpclib.Server(SATELLITE_URL, verbose=0) key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD) redhat_channels = client.channel.listRedHatChannels(key) type(client) for redhat_channel in redhat_channels: channel_label = str(redhat_channel["label"]) child_channels = client.channel.software.listChildren(key, channel_label) if child_channels: parent_channel_name = leading_channel_tag + str(redhat_channel["name"]) + "-" + current_date parent_channel_label = leading_channel_tag + channel_label + "-" + current_date print "\nName: " + parent_channel_name print "Label: " + parent_channel_label if client.configchannel.channelExists(key, parent_channel_label): print parent_channel_label + "Exists" else: # label is being used for both label information and summary information client.channel.software.clone(key, channel_label, parent_channel_name, parent_channel_label, parent_channel_label) for child_channel in child_channels: child_channel_name = leading_channel_tag + str(child_channel["name"]) + "-" + current_date child_channel_label = leading_channel_tag + str(child_channel["label"]) + "-" + current_date print "\tName: " + child_channel_name print "\tLabel: " + child_channel_label client.auth.logout(key)