class JobQueue(object):
Queue used to manage the jobs.
Class Method |
|
Create and store multiple jobs. |
Method | __init__ |
Constructor for JobQueue. |
Method |
|
Cancels a job. |
Method |
|
Changes a job's priority. |
Method |
|
Checks if a job has been finalized. |
Method |
|
Load the given job file from disk. |
Method |
|
Update a job's on disk storage. |
Instance Variable | context |
Undocumented |
Instance Variable | depmgr |
Undocumented |
Class Method | _ |
Return all known job IDs. |
Static Method | _ |
Verifies the status of an RPC call. |
Static Method | _ |
Build list of directories containing job files. |
Static Method | _ |
Returns the archived job file for a give job id. |
Static Method | _ |
Returns the job file for a given job id. |
Static Method | _ |
Resolves relative job IDs in dependencies. |
Method | _ |
Gets the status of a job for dependencies. |
Method | _ |
Helper for returning the node name/ip list. |
Method | _ |
Gets RPC runner with context. |
Method | _ |
Load the given job file from disk. |
Method | _ |
Loads a job from the disk or memory. |
Method | _ |
Modifies a job. |
Method | _ |
Renames a file locally and then replicate the change. |
Method | _ |
Writes a file locally and then replicates it to all nodes. |
Instance Variable | _memcache |
Undocumented |
Instance Variable | _my |
Undocumented |
Instance Variable | _nodes |
Undocumented |
Constructor for JobQueue.
The constructor will initialize the job queue object and then start loading the current jobs from disk, either for starting them (if they were queue) or for aborting them (if they were already running).
Parameters | |
context:GanetiContext | the context object for access to the configuration data and other ganeti objects |
cfg | Undocumented |
Cancels a job.
This will only succeed if the job has not started yet.
Parameters | |
job | job ID of job to be cancelled. |
Changes a job's priority.
Parameters | |
job | ID of the job whose priority should be changed |
priority:int | New priority |
Checks if a job has been finalized.
Parameters | |
job | Job identifier |
Returns | |
boolean | True if the job has been finalized, False if the timeout has been reached, None if the job doesn't exist |
Load the given job file from disk.
Given a job file, read, load and restore it in a _QueuedJob format. In case of error reading the job, it gets returned as None, and the exception is logged.
Parameters | |
job | job identifier |
try | Whether to try loading an archived job |
writable | Undocumented |
Returns | |
_QueuedJob or None | either None or the job object |
Update a job's on disk storage.
After a job has been modified, this function needs to be called in order to write the changes to disk and replicate them to the other nodes.
Parameters | |
job:_QueuedJob | the changed job |
replicate:boolean | whether to replicate the change to remote nodes |
Return all known job IDs.
The method only looks at disk because it's a requirement that all jobs are present on disk (so in the _memcache we don't have any extra IDs).
Parameters | |
sort:boolean | perform sorting on the returned job ids |
archived | Undocumented |
Returns | |
list | the list of job IDs |
Verifies the status of an RPC call.
Since we aim to keep consistency should this node (the current master) fail, we will log errors if our rpc fail, and especially log the case when more than half of the nodes fails.
Parameters | |
result | the data as returned from the rpc call |
nodes:list | the list of nodes we made the call to |
failmsg:str | the identifier to be used for logging |
Build list of directories containing job files.
Parameters | |
archived:bool | Whether to include directories for archived jobs |
Returns | |
list | Undocumented |
Returns the archived job file for a give job id.
Parameters | |
job | the job identifier |
Returns | |
str | the path to the archived job file |
Returns the job file for a given job id.
Parameters | |
job | the job identifier |
Returns | |
str | the path to the job file |
Resolves relative job IDs in dependencies.
Parameters | |
resolve | Function to resolve a relative job ID |
deps:list | Dependencies |
Returns | |
tuple; (boolean, string or list) | If successful (first tuple item), the returned list contains resolved job IDs along with the requested status; if not successful, the second element is an error message |
Gets the status of a job for dependencies.
Parameters | |
job | Job ID |
Raises | |
errors.JobLost | If job can't be found |
Helper for returning the node name/ip list.
Returns | |
(list, list) | a tuple of two lists, the first one with the node names and the second one with the node addresses |
Load the given job file from disk.
Given a job file, read, load and restore it in a _QueuedJob format.
Parameters | |
job | job identifier |
try | Whether to try loading an archived job |
writable | Undocumented |
Returns | |
_QueuedJob or None | either None or the job object |
Loads a job from the disk or memory.
Given a job id, this will return the cached job object if existing, or try to load the job from the disk. If loading from disk, it will also add the job to the cache.
Parameters | |
job | the job id |
Returns | |
_QueuedJob or None | either None or the job object |
Modifies a job.
Parameters | |
job | Job ID |
mod | Modifying function, receiving job object as parameter, returning tuple of (status boolean, message string) |
Renames a file locally and then replicate the change.
This function will rename a file in the local queue directory and then replicate this rename to all the other nodes we have.
Parameters | |
rename:list of (old, new) | List containing tuples mapping old to new names |
Writes a file locally and then replicates it to all nodes.
This function will replace the contents of a file on the local node and then replicate it to all the other nodes we have.
Parameters | |
file | the path of the file to be replicated |
data:str | the new contents of the file |
replicate:boolean | whether to spread the changes to the remote nodes |