Avoid extending a class if it does not exists (#19059)
This commit is contained in:
parent
6b1586748f
commit
3b509b1095
3 changed files with 28 additions and 32 deletions
|
@ -168,23 +168,21 @@ import copy
|
|||
try:
|
||||
from zabbix_api import ZabbixAPI, ZabbixAPISubClass
|
||||
|
||||
# Extend the ZabbixAPI
|
||||
# Since the zabbix-api python module too old (version 1.0, no higher version so far),
|
||||
# it does not support the 'hostinterface' api calls,
|
||||
# so we have to inherit the ZabbixAPI class to add 'hostinterface' support.
|
||||
class ZabbixAPIExtends(ZabbixAPI):
|
||||
hostinterface = None
|
||||
|
||||
def __init__(self, server, timeout, user, passwd, **kwargs):
|
||||
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
|
||||
self.hostinterface = ZabbixAPISubClass(self, dict({"prefix": "hostinterface"}, **kwargs))
|
||||
|
||||
HAS_ZABBIX_API = True
|
||||
except ImportError:
|
||||
HAS_ZABBIX_API = False
|
||||
|
||||
|
||||
# Extend the ZabbixAPI
|
||||
# Since the zabbix-api python module too old (version 1.0, no higher version so far),
|
||||
# it does not support the 'hostinterface' api calls,
|
||||
# so we have to inherit the ZabbixAPI class to add 'hostinterface' support.
|
||||
class ZabbixAPIExtends(ZabbixAPI):
|
||||
hostinterface = None
|
||||
|
||||
def __init__(self, server, timeout, user, passwd, **kwargs):
|
||||
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
|
||||
self.hostinterface = ZabbixAPISubClass(self, dict({"prefix": "hostinterface"}, **kwargs))
|
||||
|
||||
|
||||
class Host(object):
|
||||
def __init__(self, module, zbx):
|
||||
self._module = module
|
||||
|
|
|
@ -107,18 +107,17 @@ import copy
|
|||
try:
|
||||
from zabbix_api import ZabbixAPI, ZabbixAPISubClass
|
||||
|
||||
# Extend the ZabbixAPI
|
||||
# Since the zabbix-api python module too old (version 1.0, no higher version so far).
|
||||
class ZabbixAPIExtends(ZabbixAPI):
|
||||
def __init__(self, server, timeout, user, passwd, **kwargs):
|
||||
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
|
||||
|
||||
HAS_ZABBIX_API = True
|
||||
except ImportError:
|
||||
HAS_ZABBIX_API = False
|
||||
|
||||
|
||||
# Extend the ZabbixAPI
|
||||
# Since the zabbix-api python module too old (version 1.0, no higher version so far).
|
||||
class ZabbixAPIExtends(ZabbixAPI):
|
||||
def __init__(self, server, timeout, user, passwd, **kwargs):
|
||||
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
|
||||
|
||||
|
||||
class HostMacro(object):
|
||||
def __init__(self, module, zbx):
|
||||
self._module = module
|
||||
|
|
|
@ -147,22 +147,21 @@ try:
|
|||
from zabbix_api import ZabbixAPI, ZabbixAPISubClass
|
||||
from zabbix_api import ZabbixAPIException
|
||||
from zabbix_api import Already_Exists
|
||||
|
||||
# Extend the ZabbixAPI
|
||||
# Since the zabbix-api python module too old (version 1.0, and there's no higher version so far), it doesn't support the 'screenitem' api call,
|
||||
# we have to inherit the ZabbixAPI class to add 'screenitem' support.
|
||||
class ZabbixAPIExtends(ZabbixAPI):
|
||||
screenitem = None
|
||||
|
||||
def __init__(self, server, timeout, user, passwd, **kwargs):
|
||||
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
|
||||
self.screenitem = ZabbixAPISubClass(self, dict({"prefix": "screenitem"}, **kwargs))
|
||||
|
||||
HAS_ZABBIX_API = True
|
||||
except ImportError:
|
||||
HAS_ZABBIX_API = False
|
||||
|
||||
|
||||
# Extend the ZabbixAPI
|
||||
# Since the zabbix-api python module too old (version 1.0, and there's no higher version so far), it doesn't support the 'screenitem' api call,
|
||||
# we have to inherit the ZabbixAPI class to add 'screenitem' support.
|
||||
class ZabbixAPIExtends(ZabbixAPI):
|
||||
screenitem = None
|
||||
|
||||
def __init__(self, server, timeout, user, passwd, **kwargs):
|
||||
ZabbixAPI.__init__(self, server, timeout=timeout, user=user, passwd=passwd)
|
||||
self.screenitem = ZabbixAPISubClass(self, dict({"prefix": "screenitem"}, **kwargs))
|
||||
|
||||
|
||||
class Screen(object):
|
||||
def __init__(self, module, zbx):
|
||||
self._module = module
|
||||
|
|
Loading…
Reference in a new issue