Revision e2b4a7ba
b/lib/jqueue.py | ||
---|---|---|
59 | 59 |
from ganeti import ht |
60 | 60 |
from ganeti import query |
61 | 61 |
from ganeti import qlang |
62 |
from ganeti import pathutils |
|
62 | 63 |
|
63 | 64 |
|
64 | 65 |
JOBQUEUE_THREADS = 25 |
... | ... | |
1680 | 1681 |
files = [self._GetJobPath(job_id) for job_id in self._GetJobIDsUnlocked()] |
1681 | 1682 |
|
1682 | 1683 |
# Upload current serial file |
1683 |
files.append(constants.JOB_QUEUE_SERIAL_FILE)
|
|
1684 |
files.append(pathutils.JOB_QUEUE_SERIAL_FILE)
|
|
1684 | 1685 |
|
1685 | 1686 |
# Static address list |
1686 | 1687 |
addrs = [node.primary_ip] |
... | ... | |
1813 | 1814 |
serial = self._last_serial + count |
1814 | 1815 |
|
1815 | 1816 |
# Write to file |
1816 |
self._UpdateJobQueueFile(constants.JOB_QUEUE_SERIAL_FILE,
|
|
1817 |
self._UpdateJobQueueFile(pathutils.JOB_QUEUE_SERIAL_FILE,
|
|
1817 | 1818 |
"%s\n" % serial, True) |
1818 | 1819 |
|
1819 | 1820 |
result = [jstore.FormatJobID(v) |
... | ... | |
1836 | 1837 |
@return: the path to the job file |
1837 | 1838 |
|
1838 | 1839 |
""" |
1839 |
return utils.PathJoin(constants.QUEUE_DIR, "job-%s" % job_id)
|
|
1840 |
return utils.PathJoin(pathutils.QUEUE_DIR, "job-%s" % job_id)
|
|
1840 | 1841 |
|
1841 | 1842 |
@staticmethod |
1842 | 1843 |
def _GetArchivedJobPath(job_id): |
... | ... | |
1848 | 1849 |
@return: the path to the archived job file |
1849 | 1850 |
|
1850 | 1851 |
""" |
1851 |
return utils.PathJoin(constants.JOB_QUEUE_ARCHIVE_DIR,
|
|
1852 |
return utils.PathJoin(pathutils.JOB_QUEUE_ARCHIVE_DIR,
|
|
1852 | 1853 |
jstore.GetArchiveDirectory(job_id), |
1853 | 1854 |
"job-%s" % job_id) |
1854 | 1855 |
|
... | ... | |
1867 | 1868 |
|
1868 | 1869 |
""" |
1869 | 1870 |
jlist = [] |
1870 |
for filename in utils.ListVisibleFiles(constants.QUEUE_DIR):
|
|
1871 |
for filename in utils.ListVisibleFiles(pathutils.QUEUE_DIR):
|
|
1871 | 1872 |
m = constants.JOB_FILE_RE.match(filename) |
1872 | 1873 |
if m: |
1873 | 1874 |
jlist.append(int(m.group(1))) |
b/lib/jstore.py | ||
---|---|---|
28 | 28 |
from ganeti import errors |
29 | 29 |
from ganeti import runtime |
30 | 30 |
from ganeti import utils |
31 |
from ganeti import pathutils |
|
31 | 32 |
|
32 | 33 |
|
33 | 34 |
JOBS_PER_ARCHIVE_DIRECTORY = 10000 |
... | ... | |
54 | 55 |
The queue should be locked while this function is called. |
55 | 56 |
|
56 | 57 |
""" |
57 |
return _ReadNumericFile(constants.JOB_QUEUE_SERIAL_FILE)
|
|
58 |
return _ReadNumericFile(pathutils.JOB_QUEUE_SERIAL_FILE)
|
|
58 | 59 |
|
59 | 60 |
|
60 | 61 |
def ReadVersion(): |
... | ... | |
63 | 64 |
The queue should be locked while this function is called. |
64 | 65 |
|
65 | 66 |
""" |
66 |
return _ReadNumericFile(constants.JOB_QUEUE_VERSION_FILE)
|
|
67 |
return _ReadNumericFile(pathutils.JOB_QUEUE_VERSION_FILE)
|
|
67 | 68 |
|
68 | 69 |
|
69 | 70 |
def InitAndVerifyQueue(must_lock): |
... | ... | |
81 | 82 |
getents = runtime.GetEnts() |
82 | 83 |
|
83 | 84 |
# Lock queue |
84 |
queue_lock = utils.FileLock.Open(constants.JOB_QUEUE_LOCK_FILE)
|
|
85 |
queue_lock = utils.FileLock.Open(pathutils.JOB_QUEUE_LOCK_FILE)
|
|
85 | 86 |
try: |
86 | 87 |
# The queue needs to be locked in exclusive mode to write to the serial and |
87 | 88 |
# version files. |
... | ... | |
102 | 103 |
version = ReadVersion() |
103 | 104 |
if version is None: |
104 | 105 |
# Write new version file |
105 |
utils.WriteFile(constants.JOB_QUEUE_VERSION_FILE,
|
|
106 |
utils.WriteFile(pathutils.JOB_QUEUE_VERSION_FILE,
|
|
106 | 107 |
uid=getents.masterd_uid, gid=getents.masterd_gid, |
107 | 108 |
data="%s\n" % constants.JOB_QUEUE_VERSION) |
108 | 109 |
|
... | ... | |
116 | 117 |
serial = ReadSerial() |
117 | 118 |
if serial is None: |
118 | 119 |
# Write new serial file |
119 |
utils.WriteFile(constants.JOB_QUEUE_SERIAL_FILE,
|
|
120 |
utils.WriteFile(pathutils.JOB_QUEUE_SERIAL_FILE,
|
|
120 | 121 |
uid=getents.masterd_uid, gid=getents.masterd_gid, |
121 | 122 |
data="%s\n" % 0) |
122 | 123 |
|
... | ... | |
150 | 151 |
@return: True if the job queue is marked drained |
151 | 152 |
|
152 | 153 |
""" |
153 |
return os.path.exists(constants.JOB_QUEUE_DRAIN_FILE)
|
|
154 |
return os.path.exists(pathutils.JOB_QUEUE_DRAIN_FILE)
|
|
154 | 155 |
|
155 | 156 |
|
156 | 157 |
def SetDrainFlag(drain_flag): |
... | ... | |
165 | 166 |
getents = runtime.GetEnts() |
166 | 167 |
|
167 | 168 |
if drain_flag: |
168 |
utils.WriteFile(constants.JOB_QUEUE_DRAIN_FILE, data="",
|
|
169 |
utils.WriteFile(pathutils.JOB_QUEUE_DRAIN_FILE, data="",
|
|
169 | 170 |
uid=getents.masterd_uid, gid=getents.masterd_gid) |
170 | 171 |
else: |
171 |
utils.RemoveFile(constants.JOB_QUEUE_DRAIN_FILE)
|
|
172 |
utils.RemoveFile(pathutils.JOB_QUEUE_DRAIN_FILE)
|
|
172 | 173 |
|
173 | 174 |
assert (not drain_flag) ^ CheckDrainFlag() |
174 | 175 |
|
Also available in: Unified diff