[Erp5-report] r33933 rafael - in /erp5/trunk/utils/erp5.recipe.mysqlserver: ./ src/ src/erp...

nobody at svn.erp5.org nobody at svn.erp5.org
Fri Mar 19 20:41:27 CET 2010


Author: rafael
Date: Fri Mar 19 20:41:27 2010
New Revision: 33933

URL: http://svn.erp5.org?rev=33933&view=rev
Log:

Initial Import 

This recipe generates a new server setup for MySQL, and allow to have multiple
MySQL servers running in the same machine. This does not compile new MySQL Software 
only reuse some existing one.



Added:
    erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt   (with props)
    erp5/trunk/utils/erp5.recipe.mysqlserver/README.txt   (with props)
    erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/__init__.py
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/__init__.py
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/
    erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt?rev=33933&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt [utf8] Fri Mar 19 20:41:27 2010
@@ -1,0 +1,9 @@
+Changelog
+=========
+
+1.0 (2010-03-19)
+----------------
+
+- Initial version 
+  [Rafael Monnerat]
+

Propchange: erp5/trunk/utils/erp5.recipe.mysqlserver/CHANGES.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/README.txt
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/README.txt?rev=33933&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/README.txt (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/README.txt [utf8] Fri Mar 19 20:41:27 2010
@@ -1,0 +1,45 @@
+Introduction
+============
+
+This recipe generates a new server setup for MySQL, and allow to have multiple
+MySQL servers running in the same machine. This does not compile new MySQL Software 
+only reuse some existing one.
+
+Example
+=======
+
+You can use it with a part like this::
+
+  [default-database]
+  recipe = erp5.recipe.mysqlserver
+  mysql_software_bin = /usr/bin
+  mysql_bin_folder = ${buildout:bin-directory}
+  mysql_datadir = ${buildout:directory}/var/mysql
+  mysql_cnf_file = ${buildout:etc-directory}/my.cnf
+ 
+
+Options
+=======
+
+mysql_software_bin
+
+   Where the Orginal Software Binaries are installed, like /usr/bin when 
+   are provided by Linux Packages.
+
+mysql_bin_folder
+
+   Where the Executable Wrapper scripts like mysql, mysqladmin, mysqldump, 
+   mysqld_safe will be created. 
+
+mysql_datadir
+  
+   Where the MYSQL data will be kept.
+
+mysql_cnf_file
+
+   Define the configuration file path used by The Mysql Server.
+
+mysql_auto_start
+
+   if true this start the MySQL server when run this recipe.
+

Propchange: erp5/trunk/utils/erp5.recipe.mysqlserver/README.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py?rev=33933&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/setup.py [utf8] Fri Mar 19 20:41:27 2010
@@ -1,0 +1,33 @@
+from setuptools import setup, find_packages
+
+name = "erp5.recipe.mysqlserver"
+version = '1.0'
+
+def read(name):
+    return open(name).read()
+
+long_description=( read('README.txt')
+                   + '\n' +
+                   read('CHANGES.txt')
+                 )
+
+setup(
+    name = name,
+    version = version,
+    author = "Rafael Monnerat",
+    author_email = "rafael at nexedi.com",
+    description = "ZC Buildout recipe for create a mysql database",
+    long_description=long_description,
+    license = "ZPL 2.1",
+    keywords = "mysql buildout",
+    url='http://www.erp5.org/HowToUseBuildout',
+    classifiers=[
+        "License :: OSI Approved :: Zope Public License",
+        "Framework :: Buildout",
+        ],
+    packages = find_packages('src'),
+    package_dir = {'': 'src'},
+    install_requires = ['zc.recipe.egg'],
+    namespace_packages = ['erp5', 'erp5.recipe'],
+    entry_points = {'zc.buildout': ['default = %s:Recipe' % name]},
+    )

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/__init__.py?rev=33933&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/__init__.py [utf8] Fri Mar 19 20:41:27 2010
@@ -1,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__) 

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/__init__.py?rev=33933&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/__init__.py [utf8] Fri Mar 19 20:41:27 2010
@@ -1,0 +1,6 @@
+# See http://peak.telecommunity.com/DevCenter/setuptools#namespace-packages
+try:
+    __import__('pkg_resources').declare_namespace(__name__)
+except ImportError:
+    from pkgutil import extend_path
+    __path__ = extend_path(__path__, __name__) 

Added: erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py?rev=33933&view=auto
==============================================================================
--- erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py (added)
+++ erp5/trunk/utils/erp5.recipe.mysqlserver/src/erp5/recipe/mysqlserver/__init__.py [utf8] Fri Mar 19 20:41:27 2010
@@ -1,0 +1,112 @@
+# -*- coding: utf-8 -*-
+##############################################################################
+#
+# Copyright (c) 2010 Nexedi SA and Contributors. All Rights Reserved.
+# Copyright (c) 2006-2008 Zope Corporation and Contributors.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+##############################################################################
+
+import os
+import logging
+from time import sleep
+import subprocess
+
+class Recipe(object):
+    
+  def __init__(self, buildout, name, options):
+    self.buildout, self.options, self.name = buildout, options, name
+    self.logger=logging.getLogger(self.name)
+
+    options['location'] = os.path.join(
+        buildout['buildout']['parts-directory'],
+        self.name)
+
+    options.setdefault('mysql_bin_folder', 
+                       buildout['buildout']['bin-directory'])
+
+    options.setdefault("mysql_auto_start", "false")
+
+
+  def _popen(self, command):
+    process = subprocess.Popen(command, 
+                               stdout=subprocess.PIPE, 
+                               stderr=subprocess.PIPE,
+                               shell=True, close_fds=True)
+    stdout, stderr = process.communicate()
+    return stdout, stderr
+
+  def _writeFile(self, path, content, force=1):
+    """ Create one file with a certain content
+    """
+    if not os.path.exists(path) or force:
+      f = open(path, 'w')
+      f.write('%s' % content)
+      f.close()
+    else:
+      # XXX raise "What?"
+      print "*"*99
+      pass
+      
+  def _createExecutable(self, command):
+    """
+      Create commands to manage mysql like:
+        mysql , mysqldump
+    """
+    options = self.options
+    mysql_software_bin = options.get("mysql_software_bin")
+    mysql_cnf_file = options.get("mysql_cnf_file")
+    mysql_bin_folder = options.get("mysql_bin_folder")
+
+    # Write mysql command
+    mysql_content = MYSQL_COMMAND_TEMPLATE % \
+                            (dict(mysql_software_bin=mysql_software_bin,
+                                  command=command,
+                                  mysql_cnf_file=mysql_cnf_file))
+
+    command_path = "%s/%s" % (mysql_bin_folder, command)
+    self._writeFile(command_path, mysql_content)
+    os.chmod(command_path, 0755)
+
+  def install(self):
+    options = self.options
+    location = options['location']
+
+    datadir = options.get('mysql_datadir')
+    if not os.path.exists(datadir):
+      os.mkdir(datadir)
+
+    ibdata1 = os.path.join(datadir, 'ibdata1')
+    mysql_software_bin = options.get("mysql_software_bin")
+    if not os.path.exists(ibdata1):
+      command = [ '%s/mysql_install_db' % (mysql_software_bin) , 
+                  '--datadir=%s' % (datadir)]
+
+      self._popen(command)
+
+    self._createExecutable("mysql")
+    self._createExecutable("mysqld_safe")
+    self._createExecutable("mysqladmin")
+    self._createExecutable("mysqldump")
+
+    if options.get("mysql_auto_start").lower() == "true":
+      mysql_bin_folder = options.get("mysql_bin_folder")
+      command = '%s/mysqld_safe &' % (mysql_bin_folder)
+      subprocess.call(command, shell=True)
+      sleep(20)
+
+
+    return location
+
+  update = install
+
+
+MYSQL_COMMAND_TEMPLATE = """#!/bin/sh
+%(mysql_software_bin)s/%(command)s --defaults-file=%(mysql_cnf_file)s $@
+"""




More information about the Erp5-report mailing list