Skip to content

Commit

Permalink
Use a python file for default configuration | refs #29229
Browse files Browse the repository at this point in the history
  • Loading branch information
sdiemer committed Jun 20, 2019
1 parent 7b0ddb4 commit d1ceedc
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 67 deletions.
57 changes: 0 additions & 57 deletions mm_client/conf.json

This file was deleted.

57 changes: 57 additions & 0 deletions mm_client/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Miris Manager client base configuration
# This file should not be modified directly, put your modification in another json file and give the path to the client.

BASE_CONF = {
# Logging level
'LOG_LEVEL': 'INFO',

# Server URL of Miris Manager
'SERVER_URL': 'https://mirismanager',

# API key of this system in Miris Manager
# The API key is automatically set when empty and when Capus Manager discovery mode is enabled.
'API_KEY': '',

# Secret key of this system in Miris Manager, used to sign messages
'SECRET_KEY': '',

# Try to register this system if no API_KEY is defined
'AUTO_REGISTRATION': True,

# Notify systemd watchdog after each long polling call
'WATCHDOG': False,

# Verify server SSL certificate
'VERIFY_SSL': False,

# API requests max duration in seconds
'TIMEOUT': 10,

# Proxies for API requests
# Example: {'http': 'http://10.10.1.10:3128', 'https': 'http://10.10.1.10:1080'}
'PROXIES': None,

# This list makes available or not actions buttons in Miris Manager
'CAPABILITIES': {},

# List of Miris Manager urls (do not overwritte this)
'API_CALLS': {
'PING': {'method': 'get', 'url': '/api/', 'anonymous': True},
'TIME': {'method': 'get', 'url': '/api/time/', 'anonymous': True},
'INFO': {'method': 'get', 'url': '/api/info/', 'anonymous': True},
'LONG_POLLING': {'method': 'get', 'url': '/remote-event/v3'},
'SET_COMMAND_STATUS': {'method': 'post', 'url': '/api/v3/fleet/control/set-command-status/'},
'GET_INFO': {'method': 'get', 'url': '/api/v3/fleet/systems/get-info/'},
'SET_INFO': {'method': 'post', 'url': '/api/v3/fleet/systems/set-info/'},
'SET_STATUS': {'method': 'post', 'url': '/api/v3/fleet/systems/set-status/'},
'SET_SCREENSHOT': {'method': 'post', 'url': '/api/v3/fleet/systems/set-screenshot/'},
'REGISTER_SYSTEM': {'method': 'post', 'url': '/api/v3/fleet/systems/register/'},
'GET_MESSAGE': {'method': 'get', 'url': '/api/v3/fleet/messages/get/'},
'ADD_MESSAGE': {'method': 'post', 'url': '/api/v3/fleet/messages/add/'},
'ARCHIVE_MESSAGE': {'method': 'post', 'url': '/api/v3/fleet/messages/archive/'},
'DELETE_MESSAGE': {'method': 'post', 'url': '/api/v3/fleet/messages/delete/'},
'PREPARE_TUNNEL': {'method': 'post', 'url': '/api/v3/fleet/proxy/prepare-tunnel/'},
'SET_PROFILES': {'method': 'post', 'url': '/api/v3/fleet/profiles/set/'},
'CHECK_TOKEN': {'method': 'post', 'url': '/api/v3/users/check-token/'}
}
}
8 changes: 2 additions & 6 deletions mm_client/lib/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@
import logging
import os
import re
from ..conf import BASE_CONF

logger = logging.getLogger('mm_client.lib.configuration')

BASE_CONF_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), 'conf.json')


def load_conf(default_conf=None, local_conf=None):
# copy default configuration
with open(BASE_CONF_PATH, 'r') as fo:
content = fo.read()
content = re.sub(r'\n\s*//.*', '\n', content) # remove comments
conf = json.loads(content)
conf = BASE_CONF.copy()
# update with default and local configuration
for index, conf_override in enumerate((default_conf, local_conf)):
if not conf_override:
Expand Down
4 changes: 0 additions & 4 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ setup_requires=
setuptools
wheel

[options.package_data]
mm_client =
conf.json

[options.extras_require]
dev =
black
Expand Down

0 comments on commit d1ceedc

Please sign in to comment.