Commit eb4ac92d authored by Rafael Monnerat's avatar Rafael Monnerat

Improve ERP5 Site creation:

* Configure memcached 
* Configure Conversion server
* Configure Repository List
* Accept initial bt5 setup.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@44303 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 069e9c6d
......@@ -33,6 +33,8 @@ import sys
import zc.buildout
import zc.recipe.egg
CREATE_ERP5_SITE = 0
# Taken from Zope2 egg
def write_inituser(fn, user, password):
fp = open(fn, "w")
......@@ -70,11 +72,9 @@ class Recipe(BaseSlapRecipe):
apache_login=self.installLoginApache(ip=self.getGlobalIPv6Address(),
port=13000, backend=zope_access, key=ca_conf['login_key'],
certificate=ca_conf['login_certificate']))
if self.options.get('erp5_site_id') not in [None, ""]:
if CREATE_ERP5_SITE:
self.installERP5Site(user, password, zope_access,
mysql_conf['mysql_database'], mysql_conf['ip'],
mysql_conf['tcp_port'], mysql_conf['mysql_user'],
mysql_conf['mysql_password'], self.options.get('erp5_site_id'))
mysql_conf, conversion_server_conf, memcached_conf, self.site_id)
self.installTestRunner(ca_conf, mysql_conf, conversion_server_conf)
self.linkBinary()
self.setConnectionDict(dict(
......@@ -336,24 +336,29 @@ class Recipe(BaseSlapRecipe):
self._createDirectory(os.path.join(self.erp5_directory, directory))
return user, password
def installERP5Site(self, user, password, zope_access, database_name,
database_ip, database_port, database_user, database_password,
erp5_site_id='erp5'):
def installERP5Site(self, user, password, zope_access, mysql_conf,
conversion_server_conf, memcached_conf, erp5_site_id):
""" Create a script controlled by supervisor, which creates a erp5
site on current available zope and mysql environment"""
# XXX Conversion server and memcache server coordinates are not relevant
# for pure site creation.
https_connection_url = "http://%s:%s@%s/" % (user, password, zope_access)
mysql_connection_string = "%s@%s:%s %s %s" % (database_name,
database_ip, database_port, database_user, database_password)
mysql_connection_string = "%(mysql_database)s@%(ip)s:%(tcp_port)s %(mysql_user)s %(mysql_password)s" % mysql_conf
# XXX URL list vs. repository + list of bt5 names?
bt5_url_list = self.options.get("bt5_url_list", '')
bt5_repository_list = self.options.get("bt5_repository_list", '')
self.path_list.extend(zc.buildout.easy_install.scripts([('erp5_update',
__name__ + '.erp5', 'updateERP5')], self.ws,
sys.executable, self.wrapper_directory,
arguments=[erp5_site_id, mysql_connection_string,
https_connection_url, bt5_url_list]))
arguments=[erp5_site_id,
mysql_connection_string,
https_connection_url,
memcached_conf['memcached_url'],
conversion_server_conf['conversion_server_ip'],
conversion_server_conf['conversion_server_port'],
bt5_url_list,
bt5_repository_list]))
return []
def installZeo(self, ip, port, name, path):
......
......@@ -26,38 +26,80 @@
##############################################################################
import time
import urllib
import xmlrpclib
import socket
def updateERP5(args):
base_url = args[2]
mysql_string = args[1]
site_id = args[0]
sleep = 30
mysql_string = args[1]
base_url = args[2]
memcached_provider = args[3]
conversion_server_address = args[4]
conversion_server_port = args[5]
bt5_list = args[6]
bt5_repository_list = []
if len(args) > 7:
bt5_repository_list = args[7]
erp5_catalog_storage = "erp5_mysql_innodb_catalog"
sleep = 60
while True:
try:
test_url = '%s/%s/getId' % (base_url, site_id)
result = urllib.urlopen(test_url).read()
# XXX This result should be more assertive
if result != site_id:
proxy = xmlrpclib.ServerProxy(base_url)
if proxy.isERP5SitePresent() == False:
url = '%s/manage_addProduct/ERP5/manage_addERP5Site' % base_url
result = urllib.urlopen(url, urllib.urlencode({
"id": site_id,
# This parameter should be an argument in future.
"erp5_catalog_storage": "erp5_mysql_innodb_catalog",
"erp5_catalog_storage": erp5_catalog_storage,
"erp5_sql_connection_string": mysql_string,
"cmf_activity_sql_connection_string": mysql_string, }))
print result.read()
result = urllib.urlopen(test_url).read()
print "ERP5 Site creation output: %s" % result.read()
if proxy.isERP5SitePresent() == True:
print "Site was created successfuly!"
# Update URL to ERP5 Site
erp5 = xmlrpclib.ServerProxy("%s/%s" % (base_url, site_id),
allow_none=1)
# Update Cache Coordinates
erp5.portal_memcached.default_memcached_plugin.\
setUrlString(memcached_provider)
# Update and enable System preferrence with ERP5 Site Coordinates.
# XXX NO SYSTEM PREFERENCE AS DEFAULT so it is used Default
# Preference instead as object creation is not possible by
# xmlrpc or post.
preference = erp5.portal_preferences.default_site_preference
preference.setPreferredOoodocServerAddress(conversion_server_address)
preference.setPreferredOoodocServerPortNumber(conversion_server_port)
preference.enable()
if len(bt5_repository_list) > 0:
erp5.portal_templates.\
updateRepositoryBusinessTemplateList(bt5_repository_list, None)
if len(bt5_list) > 0:
# XXX If no repository is provided, use just trunk.
if len(erp5.portal_templates.getRepositoryList()) == 0:
bt5_repository_list = ["http://www.erp5.org/dists/snapshot/bt5"]
erp5.portal_templates.\
updateRepositoryBusinessTemplateList(bt5_repository_list, None)
if result == site_id:
print "Ready for install one business."
# XXX Suggestion for future
# POST '%s/erp5/portal_templates/updateRepositoryBusinessTemplateList <
# repository_list
erp5.portal_templates.\
installBusinessTemplatesFromRepositories(bt5_list)
# POST '%s/erp5/portal_templates/installBusinessTemplatesFromRepositories <
# template_list
# The persistent cache is only configurable after install \
# erp5_dms.
#erp5.portal_memcached.persistent_memcached_plugin.\
# setUrlString(kumo_address)
else:
print "ERP5 site is already present, ignore."
except IOError:
print "Unable to connect!"
print "Unable to create the ERP5 Site!"
except socket.error, e:
print "Unable to connect to ZOPE!"
time.sleep(sleep)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment