zabgrab.services.servers¶
Choosing which Zabbix server(s) to use.
- zabgrab.services.servers.SaveServer¶
Saves a new server (name, URL) to the user’s config.
- Type:
- zabgrab.services.servers.ADD_SERVER_SNIPPET¶
Config showing how to add a server, for hints.
- Type:
Functions
|
Parse a server URL typed by the user, adding |
|
Resolve a server name or URL. |
|
Resolve the one server to fetch from. |
|
Resolve the servers to search ( |
|
Suggest a name for a server from its URL's hostname. |
- zabgrab.services.servers.select_server(configured, config, ui, *, save=None)[source]¶
Resolve the one server to fetch from.
- Parameters:
configured (str or Choice of str or None) – A server name or URL, a choice to ask about, or
Noneto ask which of the configured servers to use.config (Config) – The configuration.
ui (UI) – For questions and warnings.
save (SaveServer, optional) – If given, offered for custom URLs entered at a prompt.
- Returns:
Server – The server.
- Raises:
ZabgrabError – If a server name is unknown and the user can’t be asked.
InputRequired – If a question is needed but the session isn’t interactive.
- Return type:
- zabgrab.services.servers.select_servers(cli, configured, config, ui, *, save=None)[source]¶
Resolve the servers to search (
hosts,items).- Parameters:
cli (sequence of str) – The
--servernames or URLs given; each is used if there are any.configured (str or Choice of str or None) – Otherwise, the one server to use (see
select_server()).config (Config) – The configuration.
ui (UI) – For questions and warnings.
save (SaveServer, optional) – If given, offered for custom URLs entered at a prompt.
- Returns:
list of Server – The servers.
- Return type:
- zabgrab.services.servers.resolve_server(ref, config, ui, *, save=None)[source]¶
Resolve a server name or URL.
Unknown names get a “did you mean” suggestion: a question if the session is interactive (falling back to asking which server to use), else a hint.
- Parameters:
ref (str) – A configured server’s name, or a URL.
config (Config) – The configuration.
ui (UI) – For questions and warnings.
save (SaveServer, optional) – If given, offered for custom URLs entered at a prompt.
- Returns:
Server – The server.
- Raises:
ZabgrabError – If the name is unknown and the session isn’t interactive.
- Return type:
- zabgrab.services.servers.parse_url(text)[source]¶
Parse a server URL typed by the user, adding
https://if needed.- Parameters:
text (str) – What the user typed.
- Returns:
str – The URL.
- Raises:
ValueError – If it isn’t a URL.
- Return type:
- zabgrab.services.servers.suggest_name(url, existing)[source]¶
Suggest a name for a server from its URL’s hostname.
The first hostname label that isn’t
zabbixorwwwis used, made into a valid name and numbered if needed to avoid clashes.- Parameters:
- Returns:
str – The name.
- Return type:
Examples
>>> suggest_name("https://zabbix.demo.example.org", ["demo"]) 'demo-2'