From 924f5362551760cc249e2946c0ae30a3dfc76459 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C5=81ukasz=20Nowak?= <luke@nexedi.com>
Date: Mon, 2 May 2011 15:19:10 +0000
Subject: [PATCH] Implement request simulator for Zeo.

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@45774 20353a03-c40f-0410-a6d1-a30d3c3de9de
---
 .../erp5/src/slapos/recipe/erp5/__init__.py   | 33 +++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py b/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py
index 61a5987d16..be6cf40a4a 100644
--- a/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py
+++ b/slapos/recipe/erp5/src/slapos/recipe/erp5/__init__.py
@@ -93,6 +93,39 @@ class Recipe(BaseSlapRecipe):
     ))
     return self.path_list
 
+  def _requestZeoFileStorage(self, server_name, storage_name):
+    """Local, slap.request compatible, call to ask for filestorage on Zeo
+
+    filter_kw can be used to select specific Zeo server
+
+    Someday in future it will be possible to invoke:
+
+    self.request(
+      software_release=self.computer_partition.getSoftwareRelease().getURI(),
+      software_type='Zeo Server',
+      partition_reference=storage_name,
+      filter_kw={'server_name': server_name},
+      shared=True
+    )
+
+    Thanks to this it will be possible to select precisely on which server
+    which storage will be placed.
+    """
+    base_port = 35001
+    if getattr(self, '_zeo_storage_dict', None) is None:
+      self._zeo_storage_dict = {}
+    if getattr(self, '_zeo_storage_port_dict', None) is None:
+      self._zeo_storage_port_dict = {}
+    self._zeo_storage_port_dict.setdefault(server_name,
+        base_port+len(self._zeo_storage_port_dict))
+    self._zeo_storage_dict[server_name] = self._zeo_storage_dict.get(
+        server_name, []) + [storage_name]
+    return dict(
+      ip=self.getLocalIPv4Address(),
+      port=self._zeo_storage_port_dict[server_name],
+      storage_name=storage_name
+    )
+
   def installLogrotate(self):
     """Installs logortate main configuration file and registers its to cron"""
     logrotate_d = os.path.abspath(os.path.join(self.etc_directory,
-- 
2.30.9