[_states/cubicweb] implement "cubicweb.running" by starting the service
authorArthur Lutz <arthur.lutz@logilab.fr>
Thu, 09 Apr 2015 10:58:36 +0200
changeset 32 6b02c03c9e29
parent 31 f870744fcff8
child 33 a1670eb524e6
[_states/cubicweb] implement "cubicweb.running" by starting the service
_states/cubicweb_instance.py
--- a/_states/cubicweb_instance.py	Thu Apr 09 10:57:28 2015 +0200
+++ b/_states/cubicweb_instance.py	Thu Apr 09 10:58:36 2015 +0200
@@ -33,8 +33,15 @@
         ret['result'] = None
         ret['comment'] = 'Instance {0} is set to be started'.format(name)
         return ret
-    ret['comment'] = "Dunno what to do"
-    ret['result'] = False
+    else:
+        start_cmd = __salt__['cubicweb.start'](name)
+        if __salt__['cubicweb.status'](name):
+            ret['comment'] = "Instance {0} started".format(name)
+            ret['changes'][name] = True
+            return ret
+        else:
+            ret['comment'] = "Failed to start {0}. Error {1}".format(name, start_cmd)
+            ret['result'] = False
     return ret
 
 def present(name,