Raise InvalidContainerStateError when await_state fails

This commit is contained in:
Disassembler 2020-03-20 15:20:11 +01:00
parent 44c1a8638d
commit d4bbce2dcf
No known key found for this signature in database
GPG Key ID: 524BD33A0EE29499

View File

@ -73,7 +73,10 @@ class Container:
def await_state(self, awaited_state):
# Block execution until the container reaches the desired state or until timeout
subprocess.run(['lxc-wait', '-P', CONTAINERS_DIR, '-s', awaited_state.value, '-t', '30', self.name], check=True)
try:
subprocess.run(['lxc-wait', '-P', CONTAINERS_DIR, '-s', awaited_state.value, '-t', '30', self.name], check=True)
except subprocess.CalledProcessError:
raise InvalidContainerStateError(self.name, self.get_state())
def mount_rootfs(self):
# Prepares container rootfs