Revision 874f6148 lib/hypervisor/hv_chroot.py
b/lib/hypervisor/hv_chroot.py | ||
---|---|---|
167 | 167 |
raise HypervisorError("Can't run the chroot start script: %s" % |
168 | 168 |
result.output) |
169 | 169 |
|
170 |
def StopInstance(self, instance, force=False, retry=False, name=None): |
|
170 |
def StopInstance(self, instance, force=False, retry=False, name=None, |
|
171 |
timeout=None): |
|
171 | 172 |
"""Stop an instance. |
172 | 173 |
|
173 | 174 |
This method has complicated cleanup tests, as we must: |
... | ... | |
176 | 177 |
- finally unmount the instance dir |
177 | 178 |
|
178 | 179 |
""" |
180 |
assert(timeout is None or force is not None) |
|
181 |
|
|
179 | 182 |
if name is None: |
180 | 183 |
name = instance.name |
181 | 184 |
|
... | ... | |
183 | 186 |
if not os.path.exists(root_dir) or not self._IsDirLive(root_dir): |
184 | 187 |
return |
185 | 188 |
|
189 |
timeout_cmd = [] |
|
190 |
if timeout is not None: |
|
191 |
timeout_cmd.extend(["timeout", str(timeout)]) |
|
192 |
|
|
186 | 193 |
# Run the chroot stop script only once |
187 | 194 |
if not retry and not force: |
188 |
result = utils.RunCmd(["chroot", root_dir, "/ganeti-chroot", "stop"]) |
|
195 |
result = utils.RunCmd(timeout_cmd.extend(["chroot", root_dir, |
|
196 |
"/ganeti-chroot", "stop"])) |
|
189 | 197 |
if result.failed: |
190 | 198 |
raise HypervisorError("Can't run the chroot stop script: %s" % |
191 | 199 |
result.output) |
Also available in: Unified diff