Commit 7d1e2d89 authored by Benjamin Blanc's avatar Benjamin Blanc

erp5_bootstrap: change way to bootstrap scalability business configuration

parent b70fdde8
......@@ -6,14 +6,7 @@ import base64
import time
MAX_INSTALLATION_TIME = 60*30
def getConnection(protocol, host):
if protocol == 'https':
return httplib.HTTPSConnection(host)
elif protocol == 'http':
return httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
MAX_TESTING_TIME = 60
user = "%(user)s"
password = "%(password)s"
......@@ -22,24 +15,50 @@ site_id = "%(site_id)s"
mysql_url = "%(sql_connection_string)s"
protocol = "%(protocol)s"
scalability = "%(scalability)s" == "True"
erp5_catalog_storage = 'erp5_mysql_innodb_catalog'
header_dict = {'Authorization': 'Basic %%s' %% \
base64.encodestring('%%s:%%s' %% (user, password)).strip()}
zope_connection = getConnection(protocol,host)
def getConnection():
if protocol == 'https':
return httplib.HTTPSConnection(host)
elif protocol == 'http':
return httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
def waitFor0PendingActivities():
# TODO: tolerate 1 pending activities ? (mail server...)
start_time = time.time()
while MAX_INSTALLATION_TIME > time.time()-start_time:
zope_connection = getConnection()
zope_connection.request(
'GET', '/%%s/portal_activities/getMessageList' %%(site_id),
headers=header_dict
)
message_list_text = result.read()
message_list = [s.strip() for s in message_list_text[1:-1].split(',')]
if len(message_list)==0:
print "There is no pending activities."
break
print "There is %d pending activities" %len(message_list)
def testIfExist(page, unexcepted_word_content="Site Error"):
zope_connection = getConnection()
zope_connection.request('GET', '/%%s/%%s', site_id, pages)
result = zope_connection.getresponse()
return not unexcepted_content in result.read()
# Check if an ERP5 site is already created, as ERP5 does support having
# 2 instances in the same zope, and this script should not destroy user data
zope_connection = getConnection()
zope_connection.request('GET', '/isERP5SitePresent', headers=header_dict)
result = zope_connection.getresponse()
if result.status == 204: # and (result.read() == "False"):
# Use a new connection
zope_connection = getConnection(protocol,host)
zope_connection = getConnection()
# Create the expected ERP5 instance
zope_connection.request(
'POST', '/manage_addProduct/ERP5/manage_addERP5Site',
......@@ -60,64 +79,33 @@ if result.status == 204: # and (result.read() == "False"):
print "ERP5 site created."
#dirty way to wait erp5 site creation
time.sleep(30)
# Scalability: Install and configure small buisiness
# Scalability case
if scalability:
print "Scalability case"
# Here check if configurator is available
configurator_available = False
if not configurator_available:
# Fix site consistency
zope_connection = getConnection(protocol,host)
# Fix site consistency
if not testIfExist("/%%s/portal_configurator/" %site_id):
zope_connection = getConnection()
zope_connection.request(
'GET', '/%%s/ERP5Site_launchFixConfigurationConsistency' %%(site_id),
headers=header_dict
)
print "Check consistency sent"
print "Check consistency..."
result = zope_connection.getresponse()
print result.read()
print "Response read"
# Dirty way to wait configurator availability
time.sleep(30)
# Here check if configurator is available
# Send a request ? How to know if it is ready/available ?
configurator_available = False
# Here check if S&MB not already installed
configurator_already_applied = False
business_object_name = "1"
if configurator_available and not configurator_already_applied:
# Install testing scalability business configuration
zope_connection = getConnection(protocol,host)
# Wait activities
waitFor0PendingActivities()
print "Site consistency checking: done."
# Install testing scalability business configuration if not exists
if testIfExist("/%%s/portal_configurator/" %site_id) \
and not testIfExist("/%%s/sale_order_module/" %site_id):
zope_connection = getConnection()
zope_connection.request(
'GET', '/%%s/business_configuration_module/%%s/build' %%(business_object_name, site_id),
'GET', '/%%s/business_configuration_module/1/build' %%(business_object_name, site_id),
headers=header_dict
)
print "Business building sent"
print "Build scalability business configuration..."
print result.read()
print "Response read"
# Wait for 0-pending activities
start_time = time.time()
while MAX_INSTALLATION_TIME > time.time()-start_time:
zope_connection = getConnection(protocol,host)
zope_connection.request(
'GET', '/%%s/portal_activities/getMessageList' %%(site_id),
headers=header_dict
)
message_list_text = result.read()
message_list = [s.strip() for s in message_list_text[1:-1].split(',')]
if len(message_list)==0:
print "There is no pending activities."
print "Testing scalability business configuration is ready."
break
print "Testing scalability business configuration not ready yet"
time.sleep(15)
# Wait activities
waitFor0PendingActivities()
print "Scalability business configuration building: done."
\ No newline at end of file
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