From a7562af8a9649232e98791b96c59fcb8b7b32b75 Mon Sep 17 00:00:00 2001
From: Antoine Catton <acatton@tiolive.com>
Date: Mon, 24 Oct 2011 10:04:59 +0200
Subject: [PATCH] Add promises on davstorage recipe

---
 slapos/recipe/davstorage/__init__.py | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/slapos/recipe/davstorage/__init__.py b/slapos/recipe/davstorage/__init__.py
index 625e11b3..fd150f08 100644
--- a/slapos/recipe/davstorage/__init__.py
+++ b/slapos/recipe/davstorage/__init__.py
@@ -25,6 +25,8 @@
 #
 ##############################################################################
 import subprocess
+import httplib
+import base64
 
 from slapos.recipe.librecipe import GenericBaseRecipe
 
@@ -82,4 +84,28 @@ class Recipe(GenericBaseRecipe):
       [self.options['apache-binary'], '-f', config_file, '-DFOREGROUND'])
     path_list.append(wrapper)
 
+    promise = self.createPythonScript(self.options['promise'],
+      __name__ + '.promise',
+      dict(host=self.options['ip'], port=int(self.options['port']),
+           user=self.options['user'], password=self.options['password'])
+                                     )
+    path_list.append(promise)
+
     return path_list
+
+def promise(args):
+  host = args['host']
+  port = args['port']
+  user = args['user']
+  password = args['password']
+
+  connection = httplib.HTTPSConnection(host, port)
+  auth = base64.b64encode('%s:%s' % (user, password))
+  connection.request('OPTIONS', '/',
+                     headers=dict(
+                       Authorization='Basic %s' % auth,
+                     )
+                    )
+  connection.getresponse()
+
+  return 0
-- 
2.30.9