[Spacewalk-list] API error with scheduleApplyErrata

Radovan Drazny rdrazny at redhat.com
Fri May 12 16:34:57 UTC 2017


On Friday, May 12, 2017 12:21:40 PM CEST Olivier FONT wrote:
> Hi folks,
> 
> I am facing an issue with my spacewalk release 2.6's API.
> I try to schedule an Errata with the method "scheduleApplyErrata".
> 
> According with this method, I schedule the installation using an iso8601
> format:
> Method: scheduleApplyErrata
> <https://10.31.252.200/rhn/apidoc/handlers/SystemHandler.jsp#top>
> Description:
> Schedules an action to apply errata updates to multiple systems at a given
> date/time.
> 
> Parameters:
> 
>    - string sessionKey
>    - array:
>       - int - serverId
>    - array:
>       - int - errataId
>    - dateTime.iso8601 earliestOccurrence
> 
> Returns:
> 
>    - array:
>       - int - actionId
> 
> Available since: 13.0
> I tried this :
> Client.system.scheduleApplyErrata(Key,host.get('id'),errata.get('id'),str(20
> 170512T13:20:24))
> 
> But Python returns this error message:
> 
> Client.system.scheduleApplyErrata(Key,host.get('id'),errata.get('id'),str(20
> 170512T13:20:24)) SyntaxError: invalid
> syntax
> ^
> 
> I tried different date format(2017-05-12T132024 2017-05-12T13:20:24, ...)
> same result.
> 
> Is there a specific format for the earliestOccurence option?
> 
> Thanks for your help.
> Olivier FONT

The syntax error is caused by...well, syntax error :-) You need to quote the 
20170512T13:20:24, so it should be str("20170512T13:20:24"). That's the syntax 
error Python is complainig about.

But even if you quote the string, you are going to hit a problem with the API 
itself. First of all - you need to provide a list of errata, even if there is 
only one. As for the time format - use xmlrpclib.TImeDate object and Python 
standard datetime module. So final command could look for example like this:

Client.system.scheduleApplyErrata(Key,\
host.get('id'),\
[errata.get('id')],\
xmlrpclib.DateTime(datetime.datetime.now()))

-- 
Radovan Dražný





More information about the Spacewalk-list mailing list