Package ganeti :: Module jstore
[hide private]
[frames] | no frames]

Module jstore

source code

Module implementing the job queue handling.

Functions [hide private]
None or int
_ReadNumericFile(file_name)
Reads a file containing a number.
source code
 
ReadSerial()
Read the serial file.
source code
 
ReadVersion()
Read the queue version.
source code
utils.FileLock
InitAndVerifyQueue(must_lock)
Open and lock job queue.
source code
boolean
CheckDrainFlag()
Check if the queue is marked to be drained.
source code
 
SetDrainFlag(drain_flag)
Sets the drain flag for the queue.
source code
int
FormatJobID(job_id)
Convert a job ID to int format.
source code
str
GetArchiveDirectory(job_id)
Returns the archive directory for a job.
source code
 
ParseJobId(job_id)
Parses a job ID and converts it to integer.
source code
Variables [hide private]
  JOBS_PER_ARCHIVE_DIRECTORY = 10000

Imports: errno, os, constants, errors, runtime, utils, pathutils


Function Details [hide private]

_ReadNumericFile(file_name)

source code 

Reads a file containing a number.

Returns: None or int
None if file is not found, otherwise number

ReadSerial()

source code 

Read the serial file.

The queue should be locked while this function is called.

ReadVersion()

source code 

Read the queue version.

The queue should be locked while this function is called.

InitAndVerifyQueue(must_lock)

source code 

Open and lock job queue.

If necessary, the queue is automatically initialized.

Parameters:
  • must_lock (bool) - Whether an exclusive lock must be held.
Returns: utils.FileLock
Lock object for the queue. This can be used to change the locking mode.

CheckDrainFlag()

source code 

Check if the queue is marked to be drained.

This currently uses the queue drain file, which makes it a per-node flag. In the future this can be moved to the config file.

Returns: boolean
True if the job queue is marked drained

SetDrainFlag(drain_flag)

source code 

Sets the drain flag for the queue.

Parameters:
  • drain_flag (boolean) - Whether to set or unset the drain flag

Attention: This function should only called the current holder of the queue lock

FormatJobID(job_id)

source code 

Convert a job ID to int format.

Currently this just is a no-op that performs some checks, but if we want to change the job id format this will abstract this change.

Parameters:
  • job_id (int or long) - the numeric job id
Returns: int
the formatted job id

GetArchiveDirectory(job_id)

source code 

Returns the archive directory for a job.

Parameters:
  • job_id (str) - Job identifier
Returns: str
Directory name