From 31cb5abfe207d5adfcc3bba9eb7464810f5675cf Mon Sep 17 00:00:00 2001 From: Dudás Ádám <dudas.adam@cloud.bme.hu> Date: Sun, 9 Mar 2014 18:24:49 +0100 Subject: [PATCH] storage: make is_in_use into property --- circle/storage/models.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/circle/storage/models.py b/circle/storage/models.py index a9298b9..995e7b8 100644 --- a/circle/storage/models.py +++ b/circle/storage/models.py @@ -175,13 +175,14 @@ class Disk(AclBase, TimeStampedModel): return any((not i.is_deletable() for i in self.derivatives.all())) + @property def is_in_use(self): - """Returns if disk is attached to an active VM. + """True if disk is attached to an active VM. 'In use' means the disk is attached to a VM which is not STOPPED, as any other VMs leave the disk in an inconsistent state. """ - return any([i.state != 'STOPPED' for i in self.instance_set.all()]) + return any(i.state != 'STOPPED' for i in self.instance_set.all()) def get_exclusive(self): """Get an instance of the disk for exclusive usage. @@ -432,7 +433,7 @@ class Disk(AclBase, TimeStampedModel): if self.type not in mapping.keys(): raise self.WrongDiskTypeError(self.type) - if self.is_in_use(): + if self.is_in_use: raise self.DiskInUseError(self) # from this point on, the caller has to guarantee that the disk is not -- libgit2 0.26.0