channel.software.clone help

Latest response

I am trying to write a python script and I can't seem to get the clone method to work correctly. I am certain this is something I am doing wrong, because I am just learning python. Could someone please help me understand why I am getting this error? I am attaching the script as well for your review.

Here is the error:
Traceback (most recent call last):
File "./create_patching_channels.py", line 34, in module
client.channel.software.clone(key, channel_label, parent_channel_name, parent_channel_label, parent_channel_label)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1199, in call
return self.__send(self.__name, args)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1489, in __request
verbose=self.__verbose
File "/usr/lib64/python2.6/xmlrpclib.py", line 1253, in request
return self._parse_response(h.getfile(), sock)
File "/usr/lib64/python2.6/xmlrpclib.py", line 1392, in _parse_response
return u.close()
File "/usr/lib64/python2.6/xmlrpclib.py", line 838, in close
raise Fault(**self._stack[0])
xmlrpclib.Fault: Fault -1: 'redstone.xmlrpc.XmlRpcFault: Could not find method: clone in class: com.redhat.rhn.frontend.xmlrpc.channel.software.ChannelSoftwareHandler with params: [java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String]'

Attachments

Responses

Hi Joseph,

There was mistake in passing parameters to channel.software.clone API. We need to pass 3rd parameter as "Struct". Here is list of parameters needed to clone API.

Parameters:

string sessionKey
string original_label
struct - channel details
    string "name"
    string "label"
    string "summary"
    string "parent_label" - (optional)
    string "arch_label" - (optional)
    string "gpg_url" - (optional)
    string "gpg_id" - (optional)
    string "gpg_fingerprint" - (optional)
    string "description" - (optional)
boolean original_state

I have made some changes in your script for you, now it should work and solve your purpose

#!/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://someserver/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
    parent_channel_summary = leading_channel_tag + "Clone Channel"   # Set channel Summary as per your requirement. 
    clone_channel_details = { 'label'         : parent_channel_label,
                      'name'          : parent_channel_name,
                      'summary'       : parent_channel_summary
                      }

    print "\nName: " + parent_channel_name
    print "Label: " + parent_channel_label
    print "Summary : " + parent_channel_summary

    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, clone_channel_details, False)
    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

Regards,
Ashish

Thank you so much. That completely solved my problem.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.