Revision fb8dcb62
b/lib/cmdlib.py | ||
---|---|---|
150 | 150 |
else: |
151 | 151 |
raise NotImplementedError |
152 | 152 |
|
153 |
def DeclareLocks(self, level): |
|
154 |
"""Declare LU locking needs for a level |
|
155 |
|
|
156 |
While most LUs can just declare their locking needs at ExpandNames time, |
|
157 |
sometimes there's the need to calculate some locks after having acquired |
|
158 |
the ones before. This function is called just before acquiring locks at a |
|
159 |
particular level, but after acquiring the ones at lower levels, and permits |
|
160 |
such calculations. It can be used to modify self.needed_locks, and by |
|
161 |
default it does nothing. |
|
162 |
|
|
163 |
This function is only called if you have something already set in |
|
164 |
self.needed_locks for the level. |
|
165 |
|
|
166 |
@param level: Locking level which is going to be locked |
|
167 |
@type level: member of ganeti.locking.LEVELS |
|
168 |
|
|
169 |
""" |
|
170 |
|
|
153 | 171 |
def CheckPrereq(self): |
154 | 172 |
"""Check prerequisites for this LU. |
155 | 173 |
|
b/lib/mcpu.py | ||
---|---|---|
131 | 131 |
|
132 | 132 |
""" |
133 | 133 |
if level in lu.needed_locks: |
134 |
# This gives a chance to LUs to make last-minute changes after acquiring |
|
135 |
# locks at any preceding level. |
|
136 |
lu.DeclareLocks(level) |
|
134 | 137 |
# This is always safe to do, as we can't acquire more/less locks than |
135 | 138 |
# what was requested. |
136 | 139 |
lu.needed_locks[level] = self.context.glm.acquire(level, |
Also available in: Unified diff