浏览代码

Use normalized way to get config for custom module

Change-Id: I8fe09f450695eaad1546262cef8df5bc4bb02308
pull/56/head
Adam Tengler 7 年前
父节点
当前提交
8455c25933
共有 1 个文件被更改,包括 12 次插入12 次删除
  1. +12
    -12
      _modules/saltresource.py

+ 12
- 12
_modules/saltresource.py 查看文件

@@ -16,30 +16,30 @@ try:
except ImportError:
HAS_POSTGRES = False

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


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


def _get_options(ret=None):
'''
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



正在加载...
取消
保存