Bug 1008677 - RFE: API to schedule package install action for multiple systems
RFE: API to schedule package install action for multiple systems
Status: CLOSED CURRENTRELEASE
Product: Red Hat Satellite 5
Classification: Red Hat
Component: API (Show other bugs)
560
Unspecified Unspecified
medium Severity medium
: ---
: ---
Assigned To: Tomas Lestach
Martin Korbel
:
: 1000033 (view as bug list)
Depends On:
Blocks: 1113221
  Show dependency treegraph
 
Reported: 2013-09-16 16:06 EDT by Dimitar Yordanov
Modified: 2015-01-16 04:13 EST (History)
4 users (show)

See Also:
Fixed In Version: spacewalk-java-2.3.8-41
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2015-01-16 04:13:56 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Dimitar Yordanov 2013-09-16 16:06:15 EDT
Description of problem:

As we prefer one issue per Bz, I am moving the customer request from 
Bug 910739 # Comment 3 here. 

Customer with case #00902410 is requesting to add following,

<from API>
Method: scheduleApplyErrata
 Description:
 Schedules an action to apply errata updates to multiple systems. 
Parameters:
 
• string sessionKey 
• array: ◦int - serverId
 
• array: ◦int - errataId

Returns: 
• int - 1 on success, exception thrown otherwise. 
</from API>

so the above allows for ***multiple*** serverId's in a single API call. It does return a 1 and we'd like an action id so we can get a status on which machines have been remediated. 

The below call is the current 

<from API>


--------------------------------------------------------------------------------

Method: schedulePackageInstall
 Description:
 Schedule package installation for a system. 
Parameters:
 
• string sessionKey 
• int serverId 
• array: ◦int - packageId
 
• dateTime.iso8601 earliestOccurrence 

Returns: 
• int - 1 on success, exception thrown otherwise. 

</from API>

so what we would ideally like is within a ***single*** call specify multiple system id's ***and*** get an actionID returned so we can use it to check status on ***all** systems.

As you can see from the above we'd ideally like the following:

from UBS>
Method: schedulePackageInstall
 Description:
Schedule package installation for multiple systems. 
Parameters:
 
• string sessionKey 
• array: ◦int - serverId
 
• array: ◦int - packageId

Returns: 
• int - ID of the action scheduled, otherwise exception thrown on error 
</from UBS>

...and then the obvious API call that we can send the actionID (perhaps a liskPackageActions)and get a status on all systems associated with that actionID.

Impact:

We currently use customized tools to schedule package installs which based on the above isn't ideal as its an individual api call for each server, imaging a package install schedules for 5000+ systems. We then have another call which uses the time stamp of the scheduled job to find the systems and get the job status from them, this again is one per system.

Justification:

We use the "schedulePackageInstall" often on a daily basis, and is our most frequently internally used function and most important. Having the  functionality outlined above would not only be beneficialy for BUS but certainly for most other customers that make use of the API.
Comment 1 Tomas Lestach 2013-09-17 06:13:12 EDT
system.scheduleApplyErrata with the option to specify list of servers and list of errata is available since Jul 2010.
It was added via spacewalk commit: 1811f27e1ee15b2d099809c7d67b0f9e6e2f3f2b
Comment 2 Tomas Lestach 2013-09-17 06:19:25 EDT
system.schedulePackageInstall is to be implemented

Please, include the namespace, when writing about the API calls.
Comment 3 Martin Korbel 2014-10-15 02:25:15 EDT
TESTED on Satellite-5.7.0-RHEL6-re20141001.0 (spacewalk-java-2.3.8-28.el6sat)

The method works fine good, but in documentation, there is mistake (/rhn/apidoc/handlers/SystemHandler.jsp#schedulePackageInstall). This method does not return integer, but array of integers.

<API DOC>

 Method: schedulePackageInstall
Description:
Schedule package installation for a system.

Parameters:

    string sessionKey
    array:
        int - serverId
    array:
        int - packageId
    dateTime.iso8601 earliestOccurrence

Returns:

    int actionId - The action id of the scheduled action 


</API DOC>




Reproducer:
#!/usr/bin/python
import xmlrpclib
import datetime


SATELLITE_URL = "http://localhost/rpc/api"
SATELLITE_LOGIN = "admin"
SATELLITE_PASSWORD = "xxx"

client = xmlrpclib.Server(SATELLITE_URL, verbose=0)
key = client.auth.login(SATELLITE_LOGIN, SATELLITE_PASSWORD)
print "-------  One system -------------"
print client.system.schedulePackageInstall(key, 1000010016, [81, 3899], datetime.datetime.now())
print "-------  Multi systems -------------"
print client.system.schedulePackageInstall(key, [1000010016, 1000010018], [2940, 39], datetime.datetime.now())
client.auth.logout(key)



Output:
-------  One system -------------
86
-------  Multi systems -------------
[87, 88]
Comment 4 Tomas Lestach 2014-10-15 07:19:16 EDT
For the record system.schedulePackageInstall was implemented in Jun 2014 ...

spacewalk.git: 6b84302fec6ff558e31807e09259e02f51607c82

Fix of the issue described in Comment#3 ...

spacewalk.gitL
Comment 7 Martin Korbel 2014-10-23 08:07:23 EDT
VERIFIED on Satellite-5.7.0-RHEL6-re20141017.0 (spacewalk-java-2.3.8-44.el6sat)

<API DOC>
Method: schedulePackageInstall
Description:
Schedule package installation for a system.

Parameters:

    string sessionKey
    array:
        int - serverId
    array:
        int - packageId
    dateTime.iso8601 earliestOccurrence

Returns:

    array:
        int - actionId
</API DOC>
Comment 8 Tomas Lestach 2014-10-23 08:40:01 EDT
*** Bug 1000033 has been marked as a duplicate of this bug. ***
Comment 10 Pavel Studeník 2015-01-14 10:56:54 EST
Reverified with spacewalk-java-2.3.8-96.el6sat.noarch

>>> systems = [1000010080, 1000010083]
>>> packages = [33218, 33135]

>>> print client.system.schedulePackageInstall(key, systems, packages, datetime.now() )
[1229, 1230]

Note You need to log in before you can comment on or make changes to this bug.