Skip to content

Commit 7bd58a6

Browse files
committed
Merge pull request #7 from Mattikin/master
Fixed TypeError
2 parents 6769e2e + 645febb commit 7bd58a6

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

ZenPacks/community/VMwareESXiMonitor/ESXiDatastore.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,22 @@ def device(self):
3939
def usedSpace(self):
4040
capacity = self.capacity
4141
free = self.freeSpace()
42-
if capacity is None or free is None:
43-
return None
44-
return capacity - free
42+
if capacity is not None and free is not None:
43+
return capacity - free
44+
return None
4545

46-
def freeSpace(self):
47-
free = self.cacheRRDValue('diskFreeSpace')
48-
if free is None or isnan(free):
49-
return None
50-
return long(free)
46+
def freeSpace(self, default = None):
47+
free = self.cacheRRDValue('diskFreeSpace', default)
48+
if free is not None and free != 'Unknown' and not isnan(free):
49+
return long(free)
50+
return None
5151

5252
def usedPercent(self):
5353
capacity = self.capacity
5454
used = self.usedSpace()
55-
if capacity is None or used is None:
56-
return 'Unknown'
57-
return round(100.0 * used / capacity)
55+
if capacity is not None and used is not None:
56+
return round(100.0 * used / capacity)
57+
return 'Unknown'
5858

5959
InitializeClass(ESXiDatastore)
6060

ZenPacks/community/VMwareESXiMonitor/ESXiVM.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,17 @@ class ESXiVM(DeviceComponent, ManagedEntity):
3838
def device(self):
3939
return self.esxiHost()
4040

41-
def adminStatus(self):
42-
status = self.cacheRRDValue('adminStatus')
43-
if status is None or isnan(status):
44-
return None
45-
return int(status)
46-
47-
def operStatus(self):
48-
status = self.cacheRRDValue('operStatus')
49-
if status is None or isnan(status):
50-
return None
51-
return int(status)
41+
def adminStatus(self, default = None):
42+
status = self.cacheRRDValue('adminStatus', default)
43+
if status is not None and status != 'Unknown' and not isnan(status):
44+
return int(status)
45+
return None
46+
47+
def operStatus(self, default = None):
48+
status = self.cacheRRDValue('operStatus', default)
49+
if status is not None and status != 'Unknown' and not isnan(status):
50+
return int(status)
51+
return None
5252

5353
InitializeClass(ESXiVM)
5454

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# or saved. Do not modify them directly here.
44
# NB: PACKAGES is deprecated
55
NAME = "ZenPacks.community.VMwareESXiMonitor"
6-
VERSION = "2.0.4"
6+
VERSION = "2.0.5"
77
AUTHOR = "Eric Enns, Matthias Kittl"
88
LICENSE = ""
99
NAMESPACE_PACKAGES = ['ZenPacks', 'ZenPacks.community']

0 commit comments

Comments
 (0)