diff options
author | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-08-02 17:06:13 +0200 |
---|---|---|
committer | Javier Sánchez Parra <jsanchez@soleta.eu> | 2022-09-27 09:48:35 +0200 |
commit | 2cbe6b774c8ffb10129f994d51f4237586331b7e (patch) | |
tree | 071773769ba1b518436e41ccdb7e1eb96bbe0657 /ogcp/og_server.py | |
parent | c4aa1f2f54d312581a70ad97e09198154f3840b3 (diff) |
Retreive scopes from several ogServers
Update the configuration file format to support several ogServers and
retrieve scopes from those ogServers.
The old config file format is still supported.
Diffstat (limited to 'ogcp/og_server.py')
-rw-r--r-- | ogcp/og_server.py | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/ogcp/og_server.py b/ogcp/og_server.py index 0d7fdf8..07dcb2b 100644 --- a/ogcp/og_server.py +++ b/ogcp/og_server.py @@ -11,9 +11,8 @@ import requests import json class OGServer: - def __init__(self, ip=app.config['IP'], - port=app.config['PORT'], - api_token=app.config['API_TOKEN']): + def __init__(self, name, ip, port, api_token): + self.name = name self.ip = ip self.port = port self.api_token = api_token @@ -34,3 +33,19 @@ class OGServer: headers=self.HEADERS, json=payload) return r + + +servers = [] +if {'IP', 'PORT', 'API_TOKEN'} <= app.config.keys(): + # Config file backward compatibility + servers.append(OGServer(app.config['IP'], + app.config['IP'], + app.config['PORT'], + app.config['API_TOKEN'])) +else: + for server in app.config['SERVERS']: + ogserver = OGServer(server['NAME'], + server['IP'], + server['PORT'], + server['API_TOKEN']) + servers.append(ogserver) |