From 5503b6f20ed6bfb28c5d3285b36c7ec809ced55d Mon Sep 17 00:00:00 2001 From: Bo Maryniuk Date: Mon, 12 Oct 2015 23:43:57 +0200 Subject: [PATCH] Implement Philips HUE wrapper caller for Minion Proxy --- salt/modules/philips_hue.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 salt/modules/philips_hue.py diff --git a/salt/modules/philips_hue.py b/salt/modules/philips_hue.py new file mode 100644 index 0000000000..b80e5a5389 --- /dev/null +++ b/salt/modules/philips_hue.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +''' +Philips HUE lamps module for proxy. +''' + +from __future__ import absolute_import +import sys + +__virtualname__ = 'hue' +__proxyenabled__ = ['philips_hue'] + + +def _proxy(): + ''' + Get proxy. + ''' + return __opts__['proxymodule'] + + +def __virtual__(): + ''' + Start the Philips HUE only for proxies. + ''' + + def _mkf(cmd_name, doc): + def _cmd(*args, **kw): + return _proxy()[_proxy().loaded_base_name + "." + cmd_name](*args, **kw) + return _cmd + + import salt.proxy.philips_hue as hue + for method in dir(hue): + if method.startswith('call_'): + setattr(sys.modules[__name__], method[5:], _mkf(method, getattr(hue, method).__doc__)) + del hue + + return _proxy() and __virtualname__ or False