com.redhat.rhn.manager.action
Class ActionManager

java.lang.Object
  extended by com.redhat.rhn.manager.BaseManager
      extended by com.redhat.rhn.manager.action.ActionManager

public class ActionManager
extends BaseManager

ActionManager - the singleton class used to provide Business Operations on Actions where those operations interact with other top tier Business Objects. Operations that require the Action make changes to


Field Summary
static java.lang.String[] PACKAGES_NOT_REMOVABLE
           
 
Method Summary
static void addServerToAction(java.lang.Long sid, Action action)
          Adds a server to an action
static void archiveActions(User user, java.lang.String label)
          Archives the action set with the given label.
static DataResult archivedActions(User user, PageControl pc)
          Retrieve the list of completed actions for a particular user
static void cancelAction(User user, Action action)
          Cancels the server actions associated with a given action, and if required deals with assicuated pending kickstart actions.
static void cancelActions(User user, java.util.List actionsToCancel)
          Cancels all actions in given list.
static DataResult completedActions(User user, PageControl pc)
          Retrieve the list of completed actions for a particular user
static DataResult completedSystems(User user, Action action, PageControl pc)
          Retrieves the systems that have completed a given action
static Action createBaseAction(User user, Server server, ActionType type)
           
static Action createConfigAction(User user, java.util.Collection<java.lang.Long> revisions, java.util.Collection<java.lang.Long> serverIds, ActionType type, java.util.Date earliest)
          Create a Config Action.
static Action createConfigActionForServers(User user, java.util.Collection<java.lang.Long> revisions, java.util.Collection<Server> servers, ActionType type, java.util.Date earliest)
          Create a Config Action.
static Action createConfigDiffAction(User user, java.util.Set<java.lang.Long> revisions, java.util.Set servers)
          Create a Config File Diff action.
static Action createConfigUploadAction(User user, java.util.Set filenames, Server server, ConfigChannel channel, java.util.Date earliest)
          Create a Config Upload action.
static ErrataAction createErrataAction(Org org, Errata errata)
          Creates an errata action with the specified Org
static Action createErrataAction(User user, Errata errata)
          Creates an errata action
static Action createPatchInstallAction(User user, Server server, RhnSet set)
           
static Action createPatchRemoveAction(User user, Server server, RhnSet set)
           
static Action createPatchSetInstallAction(User user, Server server, PatchSet patchSet)
           
static ScriptActionDetails createScript(java.lang.String username, java.lang.String groupname, java.lang.Long timeout, java.lang.String script)
          Creates a ScriptActionDetails which contains an arbitrary script to be run by a ScriptRunAction.
static DataResult failedActions(User user, PageControl pc)
          Retrieve the list of failed actions for a particular user
static DataResult failedSystems(User user, Action action, PageControl pc)
          Retrieves the systems that failed completing a given action
static DataResult getPackageList(java.lang.Long aid, PageControl pc)
          Returns the list of packages associated with a specific action.
static DataResult inProgressSystems(User user, Action action, PageControl pc)
          Retrieves the systems that are in the process of completing a given action
static Action lookupAction(User user, java.lang.Long aid)
          Retreive the specified Action, assuming that the User making the request has the required permissions.
static Action lookupLastCompletedAction(User user, ActionType type, Server server)
          Lookup the last completed Action on a Server given the user, action type and server.
static DataResult pendingActions(User user, PageControl pc)
          Retrieve the list of pending actions for a particular user
static DataResult pendingActionsInSet(User user, PageControl pc, java.lang.String setLabel)
          Retrieve the list of pending actions for a particular user within the given set.
static DataResult recentlyScheduledActions(User user, PageControl pc, long age)
          Retrieve the list of unarchived scheduled actions for the current user
static int removeActions(java.util.List actionIds)
          Removes a list of actions.
static void removeSystemFromAction(Server serverIn, Action actionIn)
          Remove the system from the passed in Action.
static void rescheduleAction(Action action)
          Reschedule the action so it can be attempted again.
static void rescheduleAction(Action action, boolean onlyFailed)
          Reschedule the action so it can be attempted again.
static java.util.List scheduleAllErrataUpdate(User scheduler, Server srvr, java.util.Date earliest)
          Schedules all Errata for the given system.
static Action scheduleHardwareRefreshAction(User scheduler, Server srvr, java.util.Date earliestAction)
          Schedule a KickstartAction against a system
static KickstartAction scheduleKickstartAction(KickstartData ksdata, User scheduler, Server srvr, java.util.Date earliestAction, java.lang.String appendString)
          Schedule a KickstartAction against a system
static KickstartGuestAction scheduleKickstartGuestAction(ProvisionVirtualInstanceCommand pcmd, java.lang.Long ksSessionId)
          Schedule a KickstartGuestAction against a system
static Action schedulePackageAction(User scheduler, Server srvr, java.util.List pkgs, ActionType type, java.util.Date earliestAction)
          Schedules a package action of the given type for the given server with the packages given as a list.
static PackageAction schedulePackageInstall(User scheduler, Server srvr, java.util.List pkgs, java.util.Date earliestAction)
          Schedules one or more package installation actions for the given server.
static Action schedulePackageInstall(User scheduler, Server srvr, java.lang.Long nameId, java.lang.Long evrId)
          Schedules a package action of the given type for the given server with the packages given as a list.
static PackageAction schedulePackageInstall(User scheduler, Server srvr, RhnSet pkgs)
          Schedules one or more package installation actions for the given server.
static PackageAction schedulePackageRefresh(User scheduler, Server server)
          Schedules a package list refresh action for the given server.
static PackageAction schedulePackageRemoval(User scheduler, Server srvr, RhnSet pkgs)
          Schedules one or more package removal actions for the given server.
static PackageAction schedulePackageRunTransaction(User scheduler, Server server, java.util.List pkgs, java.util.Date earliest)
          Schedules a package runtransaction action.
static PackageAction schedulePackageUpgrade(User scheduler, Server srvr, RhnSet pkgs)
          Schedules one or more package upgrade actions for the given server.
static PackageAction schedulePackageVerify(User scheduler, Server srvr, RhnSet pkgs)
          Schedules one or more package verification actions for the given server.
static Action scheduleRebootAction(User scheduler, Server srvr, java.util.Date earliestAction)
          Schedule a KickstartAction against a system
static ScriptRunAction scheduleScriptRun(User scheduler, Server srvr, java.lang.String name, ScriptActionDetails script)
          Schedules one or more package installation actions for the given server.
static ScriptRunAction scheduleScriptRun(User scheduler, Server srvr, java.lang.String name, ScriptActionDetails script, java.util.Date earliest)
          Schedules one or more package installation actions for the given server.
static void storeAction(Action actionIn)
          Stores the action in the database through hibernate
 
Methods inherited from class com.redhat.rhn.manager.BaseManager
makeDataResult, makeDataResult, makeDataResultNoPagination, processListControl, processPageControl
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PACKAGES_NOT_REMOVABLE

public static final java.lang.String[] PACKAGES_NOT_REMOVABLE
Method Detail

removeActions

public static int removeActions(java.util.List actionIds)
Removes a list of actions.

Parameters:
actionIds - actions to remove
Returns:
int the number of failed action removals

lookupAction

public static Action lookupAction(User user,
                                  java.lang.Long aid)
Retreive the specified Action, assuming that the User making the request has the required permissions.

Parameters:
user - The user making the lookup request.
aid - The id of the Action to lookup.
Returns:
the specified Action.
Throws:
LookupException - if the Action can't be looked up.

lookupLastCompletedAction

public static Action lookupLastCompletedAction(User user,
                                               ActionType type,
                                               Server server)
Lookup the last completed Action on a Server given the user, action type and server. This is useful especially in cases where we want to find the last deployed config action ...

Parameters:
user - the user doing the search (needed for permssion checking)
type - the action type of the action to be queried.
server - the server who's latest completed action is desired.
Returns:
the Action found or null if none exists

archiveActions

public static void archiveActions(User user,
                                  java.lang.String label)
Archives the action set with the given label.

Parameters:
user - User associated with the set of actions.
label - Action label to be updated.

cancelActions

public static void cancelActions(User user,
                                 java.util.List actionsToCancel)
Cancels all actions in given list.

Parameters:
user - User associated with the set of actions.
actionsToCancel - List of actions to be cancelled.

cancelAction

public static void cancelAction(User user,
                                Action action)
Cancels the server actions associated with a given action, and if required deals with assicuated pending kickstart actions. Actions themselves are not deleted, only the ServerActions associated with them.

Parameters:
user - User requesting the action be cancelled.
action - Action to be cancelled.

addServerToAction

public static void addServerToAction(java.lang.Long sid,
                                     Action action)
Adds a server to an action

Parameters:
sid - The server id
action - The parent action

createErrataAction

public static ErrataAction createErrataAction(Org org,
                                              Errata errata)
Creates an errata action with the specified Org

Parameters:
org - The org that needs the errata.
errata - The errata pertaining to this action
Returns:
The created action

createErrataAction

public static Action createErrataAction(User user,
                                        Errata errata)
Creates an errata action

Parameters:
user - The user scheduling errata
errata - The errata pertaining to this action
Returns:
The created action

createConfigUploadAction

public static Action createConfigUploadAction(User user,
                                              java.util.Set filenames,
                                              Server server,
                                              ConfigChannel channel,
                                              java.util.Date earliest)
Create a Config Upload action. This is a much different action from the other config actions (doesn't involve revisions).

Parameters:
user - The scheduler for this config action.
filenames - A set of config file name ids as Longs
server - The server for which to schedule this action.
channel - The config channel to which files will be uploaded.
earliest - The soonest time that this action could be executed.
Returns:
The created upload action

createConfigDiffAction

public static Action createConfigDiffAction(User user,
                                            java.util.Set<java.lang.Long> revisions,
                                            java.util.Set servers)
Create a Config File Diff action.

Parameters:
user - The user scheduling a diff action.
revisions - A set of revision ids as Longs
servers - A set of server ids as Longs
Returns:
The created diff action

createConfigActionForServers

public static Action createConfigActionForServers(User user,
                                                  java.util.Collection<java.lang.Long> revisions,
                                                  java.util.Collection<Server> servers,
                                                  ActionType type,
                                                  java.util.Date earliest)
Create a Config Action.

Parameters:
user - The user scheduling the action.
revisions - A set of revision ids as Longs
servers - A set of server objects
type - The type of config action
earliest - The earliest time this action could execute.
Returns:
The created config action

createConfigAction

public static Action createConfigAction(User user,
                                        java.util.Collection<java.lang.Long> revisions,
                                        java.util.Collection<java.lang.Long> serverIds,
                                        ActionType type,
                                        java.util.Date earliest)
Create a Config Action.

Parameters:
user - The user scheduling the action.
revisions - A set of revision ids as Longs
serverIds - A set of server ids as Longs
type - The type of config action
earliest - The earliest time this action could execute.
Returns:
The created config action

createPatchRemoveAction

public static Action createPatchRemoveAction(User user,
                                             Server server,
                                             RhnSet set)
Parameters:
user - The user scheduling the patch removal
server - The server patch removal applies to
set - The set of patches to remove
Returns:
Patch removal Action to perform

createPatchInstallAction

public static Action createPatchInstallAction(User user,
                                              Server server,
                                              RhnSet set)
Parameters:
user - The user scheduling the patch removal
server - The server patch removal applies to
set - The set of patches to remove
Returns:
Patch intsall Action to perform TODO factor patch actions into one method

createPatchSetInstallAction

public static Action createPatchSetInstallAction(User user,
                                                 Server server,
                                                 PatchSet patchSet)
Parameters:
user - The user scheduling the patch cluster install
server - The server patch cluster install applies to
patchSet - The patch cluster to install
Returns:
Patch Cluster install Action to perform

createBaseAction

public static Action createBaseAction(User user,
                                      Server server,
                                      ActionType type)
Parameters:
user - The user scheduling the action
server - The server the action is being scheduled for
type - The type of the action
Returns:
The Action we have created

storeAction

public static void storeAction(Action actionIn)
Stores the action in the database through hibernate

Parameters:
actionIn - The action to be stored

rescheduleAction

public static void rescheduleAction(Action action)
Reschedule the action so it can be attempted again.

Parameters:
action - Action to reschedule

rescheduleAction

public static void rescheduleAction(Action action,
                                    boolean onlyFailed)
Reschedule the action so it can be attempted again.

Parameters:
action - Action to reschedule
onlyFailed - reschedule only the ServerActions w/failed status

recentlyScheduledActions

public static DataResult recentlyScheduledActions(User user,
                                                  PageControl pc,
                                                  long age)
Retrieve the list of unarchived scheduled actions for the current user

Parameters:
user - The user in question
pc - The details of which results to return
age - how many days old a system can be in order to count as a "recently" scheduled action
Returns:
A list containing the pending actions for the user

pendingActions

public static DataResult pendingActions(User user,
                                        PageControl pc)
Retrieve the list of pending actions for a particular user

Parameters:
user - The user in question
pc - The details of which results to return
Returns:
A list containing the pending actions for the user

pendingActionsInSet

public static DataResult pendingActionsInSet(User user,
                                             PageControl pc,
                                             java.lang.String setLabel)
Retrieve the list of pending actions for a particular user within the given set.

Parameters:
user - The user in question
pc - The details of which results to return
setLabel - Label of an RhnSet of actions IDs to limit the results to.
Returns:
A list containing the pending actions for the user.

failedActions

public static DataResult failedActions(User user,
                                       PageControl pc)
Retrieve the list of failed actions for a particular user

Parameters:
user - The user in question
pc - The details of which results to return
Returns:
A list containing the pending actions for the user

completedActions

public static DataResult completedActions(User user,
                                          PageControl pc)
Retrieve the list of completed actions for a particular user

Parameters:
user - The user in question
pc - The details of which results to return
Returns:
A list containing the pending actions for the user

archivedActions

public static DataResult archivedActions(User user,
                                         PageControl pc)
Retrieve the list of completed actions for a particular user

Parameters:
user - The user in question
pc - The details of which results to return
Returns:
A list containing the pending actions for the user

getPackageList

public static DataResult getPackageList(java.lang.Long aid,
                                        PageControl pc)
Returns the list of packages associated with a specific action.

Parameters:
aid - The action id for the action in question
pc - The details of which results to return
Returns:
Return a list containing the packages for the action.

completedSystems

public static DataResult completedSystems(User user,
                                          Action action,
                                          PageControl pc)
Retrieves the systems that have completed a given action

Parameters:
user - The user in question.
action - The Action.
pc - The PageControl.
Returns:
Returns list containing the completed systems.

inProgressSystems

public static DataResult inProgressSystems(User user,
                                           Action action,
                                           PageControl pc)
Retrieves the systems that are in the process of completing a given action

Parameters:
user - The user in question.
action - The Action.
pc - The PageControl.
Returns:
Returns list containing the completed systems.

failedSystems

public static DataResult failedSystems(User user,
                                       Action action,
                                       PageControl pc)
Retrieves the systems that failed completing a given action

Parameters:
user - The user in question.
action - The Action.
pc - The PageControl.
Returns:
Returns list containing the completed systems.

schedulePackageRefresh

public static PackageAction schedulePackageRefresh(User scheduler,
                                                   Server server)
Schedules a package list refresh action for the given server.

Parameters:
scheduler - User scheduling the action.
server - Server for which the action affects.
Returns:
The scheduled PackageAction

schedulePackageRunTransaction

public static PackageAction schedulePackageRunTransaction(User scheduler,
                                                          Server server,
                                                          java.util.List pkgs,
                                                          java.util.Date earliest)
Schedules a package runtransaction action.

Parameters:
scheduler - User scheduling the action.
server - Server for which the action affects.
pkgs - List of PackageMetadata's to be run.
earliest - The earliest time this action should be run.
Returns:
The scheduled PackageAction

schedulePackageRemoval

public static PackageAction schedulePackageRemoval(User scheduler,
                                                   Server srvr,
                                                   RhnSet pkgs)
Schedules one or more package removal actions for the given server.

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
pkgs - The set of packages to be removed.
Returns:
Currently scheduled PackageAction

schedulePackageUpgrade

public static PackageAction schedulePackageUpgrade(User scheduler,
                                                   Server srvr,
                                                   RhnSet pkgs)
Schedules one or more package upgrade actions for the given server. Note: package upgrade = package install

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
pkgs - The set of packages to be removed.
Returns:
Currently scheduled PackageAction

schedulePackageInstall

public static PackageAction schedulePackageInstall(User scheduler,
                                                   Server srvr,
                                                   java.util.List pkgs,
                                                   java.util.Date earliestAction)
Schedules one or more package installation actions for the given server.

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
pkgs - The set of packages to be removed.
earliestAction - Date of earliest action to be executed
Returns:
Currently scheduled PackageAction

schedulePackageInstall

public static PackageAction schedulePackageInstall(User scheduler,
                                                   Server srvr,
                                                   RhnSet pkgs)
Schedules one or more package installation actions for the given server.

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
pkgs - The set of packages to be removed.
Returns:
Currently scheduled PackageAction

schedulePackageVerify

public static PackageAction schedulePackageVerify(User scheduler,
                                                  Server srvr,
                                                  RhnSet pkgs)
Schedules one or more package verification actions for the given server.

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
pkgs - The set of packages to be removed.
Returns:
Currently scheduled PackageAction

scheduleScriptRun

public static ScriptRunAction scheduleScriptRun(User scheduler,
                                                Server srvr,
                                                java.lang.String name,
                                                ScriptActionDetails script)
Schedules one or more package installation actions for the given server. Note: package upgrade = package install

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
script - The set of packages to be removed.
name - Name of Script action.
Returns:
Currently scheduled ScriptRunAction

scheduleScriptRun

public static ScriptRunAction scheduleScriptRun(User scheduler,
                                                Server srvr,
                                                java.lang.String name,
                                                ScriptActionDetails script,
                                                java.util.Date earliest)
Schedules one or more package installation actions for the given server. Note: package upgrade = package install

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
script - The set of packages to be removed.
name - Name of Script action.
earliest - Earliest occurrence of the script.
Returns:
Currently scheduled ScriptRunAction

createScript

public static ScriptActionDetails createScript(java.lang.String username,
                                               java.lang.String groupname,
                                               java.lang.Long timeout,
                                               java.lang.String script)
Creates a ScriptActionDetails which contains an arbitrary script to be run by a ScriptRunAction.

Parameters:
username - Username of script
groupname - Group script runs as
script - Script contents
timeout - script timeout
Returns:
ScriptActionDetails containing script to be run by ScriptRunAction

scheduleKickstartAction

public static KickstartAction scheduleKickstartAction(KickstartData ksdata,
                                                      User scheduler,
                                                      Server srvr,
                                                      java.util.Date earliestAction,
                                                      java.lang.String appendString)
Schedule a KickstartAction against a system

Parameters:
ksdata - KickstartData to associate with this Action
scheduler - User scheduling the action.
srvr - Server for which the action affects.
earliestAction - Date run the Action
appendString - extra options to add to the action.
Returns:
Currently scheduled KickstartAction

scheduleKickstartGuestAction

public static KickstartGuestAction scheduleKickstartGuestAction(ProvisionVirtualInstanceCommand pcmd,
                                                                java.lang.Long ksSessionId)
Schedule a KickstartGuestAction against a system

Parameters:
pcmd - most information needed to create this action
ksSessionId - Kickstart Session ID to associate with this action
Returns:
Currently scheduled KickstartAction

scheduleRebootAction

public static Action scheduleRebootAction(User scheduler,
                                          Server srvr,
                                          java.util.Date earliestAction)
Schedule a KickstartAction against a system

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
earliestAction - Date run the Action
Returns:
Currently scheduled KickstartAction

scheduleHardwareRefreshAction

public static Action scheduleHardwareRefreshAction(User scheduler,
                                                   Server srvr,
                                                   java.util.Date earliestAction)
Schedule a KickstartAction against a system

Parameters:
scheduler - User scheduling the action.
srvr - Server for which the action affects.
earliestAction - Date run the Action
Returns:
Currently scheduled KickstartAction

scheduleAllErrataUpdate

public static java.util.List scheduleAllErrataUpdate(User scheduler,
                                                     Server srvr,
                                                     java.util.Date earliest)
Schedules all Errata for the given system.

Parameters:
scheduler - Person scheduling the action.
srvr - Server whose errata is going to be scheduled.
earliest - Earliest possible time action will occur.
Returns:
Currently scheduled Errata Actions

removeSystemFromAction

public static void removeSystemFromAction(Server serverIn,
                                          Action actionIn)
Remove the system from the passed in Action.

Parameters:
serverIn - to remove from Action
actionIn - to process

schedulePackageInstall

public static Action schedulePackageInstall(User scheduler,
                                            Server srvr,
                                            java.lang.Long nameId,
                                            java.lang.Long evrId)
Schedules a package action of the given type for the given server with the packages given as a list.

Parameters:
scheduler - The user scheduling the action.
srvr - The server that this action is for.
nameId - nameId rhnPackage.name_id
evrId - evrId of action
Returns:
The action that has been scheduled.

schedulePackageAction

public static Action schedulePackageAction(User scheduler,
                                           Server srvr,
                                           java.util.List pkgs,
                                           ActionType type,
                                           java.util.Date earliestAction)
Schedules a package action of the given type for the given server with the packages given as a list.

Parameters:
scheduler - The user scheduling the action.
srvr - The server that this action is for.
pkgs - A list of maps containing keys 'name_id' and 'evr_id' with Long values.
type - The type of the package action. One of the static types found in ActionFactory
earliestAction - The earliest time that this action could happen.
Returns:
The action that has been scheduled.