Skip to content

Commit

Permalink
Merge pull request #967 from BenoitPoulet/master
Browse files Browse the repository at this point in the history
Fixes for Nag. 3.13 and Centreon 22.10, 23.04+
  • Loading branch information
HenriWahl authored Sep 27, 2023
2 parents 93371ae + 7b2467b commit 1ebf9b5
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions Nagstamon/Servers/Centreon/CentreonAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def init_config(self):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

self.centreon_version_major = int(data["web"]["major"])
Expand All @@ -95,8 +95,10 @@ def init_config(self):
# RestAPI version
if self.centreon_version_major == 21:
self.restapi_version = "latest"
else:
elif self.centreon_version_major == 22:
self.restapi_version = "v22.04"
else:
self.restapi_version = "v23.04"
if conf.debug_mode is True:
self.Debug(server='[' + self.get_name() + ']', debug='Centreon API version used : ' + self.restapi_version)

Expand Down Expand Up @@ -160,7 +162,7 @@ def get_token(self):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

token = data["security"]["token"]
Expand Down Expand Up @@ -195,7 +197,7 @@ def GetHost(self, host):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

fqdn = str(data["result"][0]["fqdn"])
Expand Down Expand Up @@ -230,7 +232,7 @@ def get_host_and_service_id(self, host, service=''):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

host_id = data["result"][0]["id"]
Expand Down Expand Up @@ -264,7 +266,7 @@ def get_host_and_service_id(self, host, service=''):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

if host == "Meta_Services":
Expand Down Expand Up @@ -334,7 +336,7 @@ def _get_status(self):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

if data["meta"]["total"] == 0:
Expand Down Expand Up @@ -391,7 +393,7 @@ def _get_status(self):

# check if any error occured
errors_occured = self.check_for_error(data, error, status_code)
if errors_occured is not False:
if errors_occured is not None:
return (errors_occured)

if data["meta"]["total"] == 0:
Expand Down Expand Up @@ -549,6 +551,15 @@ def _set_recheck(self, host, service):
]
}

# This new parameter was added in 23.04
if self.restapi_version == "v23.04":
property_to_add = {
"check": {
"is_forced": True
}
}
rechecks.update(property_to_add)

try:
# Host
if service == '':
Expand Down

0 comments on commit 1ebf9b5

Please sign in to comment.