Browse Source

Use normalized way to get config for custom module

Change-Id: I8fe09f450695eaad1546262cef8df5bc4bb02308
pull/56/head
Adam Tengler 7 years ago
parent
commit
8455c25933
1 changed files with 12 additions and 12 deletions
  1. +12
    -12
      _modules/saltresource.py

+ 12
- 12
_modules/saltresource.py View File

except ImportError: except ImportError:
HAS_POSTGRES = False HAS_POSTGRES = False


__virtualname__ = 'saltresource'
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)




def __virtual__(): def __virtual__():
if not HAS_POSTGRES: if not HAS_POSTGRES:
return False, 'Could not import saltresource module; psycopg2 is not installed.' return False, 'Could not import saltresource module; psycopg2 is not installed.'
return 'saltresource'
return __virtualname__




def _get_options(ret=None): def _get_options(ret=None):
''' '''
Get the postgres options from salt. Get the postgres options from salt.
''' '''
attrs = {'host': 'host',
'user': 'user',
'passwd': 'passwd',
'db': 'db',
'port': 'port'}

_options = salt.returners.get_returner_options('returner.postgres_graph_db',
ret,
attrs,
__salt__=__salt__,
__opts__=__opts__)
defaults = {'host': '127.0.0.1',
'user': 'salt',
'passwd': 'salt',
'db': 'salt',
'port': '5432'}

_options = {}
for key, default in defaults.items():
_options[key] = __salt__['config.get']('%s.%s' % (__virtualname__, key), default)

return _options return _options





Loading…
Cancel
Save