Temporary compatibility layer for numhosts property support.

Temporary fix: AttributeError: 'IPNetwork' object has no attribute 'numhosts'

Change-Id: Ic3b18de3fc3b3e37cd6250a8e26ff010a3a6d80c
(cherry picked from commit ce22b15)
This commit is contained in:
Alexey Stepanov 2016-07-08 10:42:13 +03:00
parent 7ed6cbdc05
commit 0099af9c7d
1 changed files with 15 additions and 0 deletions

View File

@ -36,6 +36,21 @@ from devops.models.volume import DiskDevice
from devops.models.volume import Volume
def _numhosts(self):
msg = (
'numhosts property is temporary compatibility spike '
'and will be dropped soon! '
'Replace by len(IPNetwork()) if required.'
)
logger.warning(msg)
warn(msg, DeprecationWarning)
return len(self)
IPNetwork.numhosts = property(
fget=_numhosts,
doc="""Temporary compatibility layer for numhosts property support.""")
class Environment(DriverModel):
class Meta(object):
db_table = 'devops_environment'