Skip to content

Commit

Permalink
Better handling of disabled or unset collector in rest calls and safe…
Browse files Browse the repository at this point in the history
… references
  • Loading branch information
cvaroqui committed Mar 30, 2018
1 parent 6dbf4e8 commit 8a866f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lib/extconfig.py
Expand Up @@ -457,18 +457,24 @@ def handle_reference(self, ref, scope=False, impersonate=None, config=None):
elif _ref == "var":
val = rcEnv.paths.pathvar
elif _ref == "collector_api":
val = rcEnv.dbopensvc.replace("/feed/default/call/xmlrpc", "/init/rest/api") if rcEnv.dbopensvc else ""
if rcEnv.dbopensvc:
val = rcEnv.dbopensvc.replace("/feed/default/call/xmlrpc", "/init/rest/api") if rcEnv.dbopensvc else ""
else:
val = ""
elif _ref == "dnsuxsockd":
val = rcEnv.paths.dnsuxsockd
elif _ref == "dnsuxsock":
val = rcEnv.paths.dnsuxsock
elif _ref.startswith("safe://"):
if hasattr(self, "node"):
val = self.node.download_from_safe(_ref, svcname=self.svcname)
else:
val = self.download_from_safe(_ref)
val = val.decode()
SECRETS.append(val)
try:
if hasattr(self, "node"):
val = self.node.download_from_safe(_ref, svcname=self.svcname)
else:
val = self.download_from_safe(_ref)
val = val.decode()
SECRETS.append(val)
except ex.excError as exc:
val = ""
else:
val = None

Expand Down
2 changes: 2 additions & 0 deletions lib/node.py
Expand Up @@ -2586,6 +2586,8 @@ def collector_api(self, svcname=None):
"""
if rcEnv.dbopensvc is None:
raise ex.excError("node.dbopensvc is not set in node.conf")
elif rcEnv.dbopensvc_host == "none":
raise ex.excError("node.dbopensvc is set to 'none' in node.conf")
data = {}
if self.options.user is None:
username, password = self.collector_auth_node()
Expand Down

0 comments on commit 8a866f4

Please sign in to comment.