Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jean-Paul Smets
slapos
Commits
7d1e2d89
Commit
7d1e2d89
authored
Jul 24, 2013
by
Benjamin Blanc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_bootstrap: change way to bootstrap scalability business configuration
parent
b70fdde8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
64 deletions
+52
-64
slapos/recipe/erp5_bootstrap/template/erp5_bootstrap.in
slapos/recipe/erp5_bootstrap/template/erp5_bootstrap.in
+52
-64
No files found.
slapos/recipe/erp5_bootstrap/template/erp5_bootstrap.in
View file @
7d1e2d89
...
@@ -6,14 +6,7 @@ import base64
...
@@ -6,14 +6,7 @@ import base64
import time
import time
MAX_INSTALLATION_TIME = 60*30
MAX_INSTALLATION_TIME = 60*30
MAX_TESTING_TIME = 60
def getConnection(protocol, host):
if protocol == 'https':
return httplib.HTTPSConnection(host)
elif protocol == 'http':
return httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
user = "%(user)s"
user = "%(user)s"
password = "%(password)s"
password = "%(password)s"
...
@@ -22,24 +15,50 @@ site_id = "%(site_id)s"
...
@@ -22,24 +15,50 @@ site_id = "%(site_id)s"
mysql_url = "%(sql_connection_string)s"
mysql_url = "%(sql_connection_string)s"
protocol = "%(protocol)s"
protocol = "%(protocol)s"
scalability = "%(scalability)s" == "True"
scalability = "%(scalability)s" == "True"
erp5_catalog_storage = 'erp5_mysql_innodb_catalog'
erp5_catalog_storage = 'erp5_mysql_innodb_catalog'
header_dict = {'Authorization': 'Basic %%s' %% \
header_dict = {'Authorization': 'Basic %%s' %% \
base64.encodestring('%%s:%%s' %% (user, password)).strip()}
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
# 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
# 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)
zope_connection.request('GET', '/isERP5SitePresent', headers=header_dict)
result = zope_connection.getresponse()
result = zope_connection.getresponse()
if result.status == 204: # and (result.read() == "False"):
if result.status == 204: # and (result.read() == "False"):
# Use a new connection
# Use a new connection
zope_connection = getConnection(protocol,host)
zope_connection = getConnection()
# Create the expected ERP5 instance
# Create the expected ERP5 instance
zope_connection.request(
zope_connection.request(
'POST', '/manage_addProduct/ERP5/manage_addERP5Site',
'POST', '/manage_addProduct/ERP5/manage_addERP5Site',
...
@@ -60,64 +79,33 @@ if result.status == 204: # and (result.read() == "False"):
...
@@ -60,64 +79,33 @@ if result.status == 204: # and (result.read() == "False"):
print "ERP5 site created."
print "ERP5 site created."
#dirty way to wait erp5 site creation
# Scalability case
time.sleep(30)
# Scalability: Install and configure small buisiness
if scalability:
if scalability:
print "Scalability case"
# Here check if configurator is available
# Fix site consistency
configurator_available = False
if not testIfExist("/%%s/portal_configurator/" %site_id):
if not configurator_available:
zope_connection = getConnection()
# Fix site consistency
zope_connection = getConnection(protocol,host)
zope_connection.request(
zope_connection.request(
'GET', '/%%s/ERP5Site_launchFixConfigurationConsistency' %%(site_id),
'GET', '/%%s/ERP5Site_launchFixConfigurationConsistency' %%(site_id),
headers=header_dict
headers=header_dict
)
)
print "Check consistency..."
print "Check consistency sent"
result = zope_connection.getresponse()
result = zope_connection.getresponse()
print result.read()
print result.read()
print "Response read"
# Wait activities
waitFor0PendingActivities()
# Dirty way to wait configurator availability
print "Site consistency checking: done."
time.sleep(30)
# Install testing scalability business configuration if not exists
# Here check if configurator is available
if testIfExist("/%%s/portal_configurator/" %site_id) \
# Send a request ? How to know if it is ready/available ?
and not testIfExist("/%%s/sale_order_module/" %site_id):
configurator_available = False
zope_connection = getConnection()
# 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)
zope_connection.request(
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
headers=header_dict
)
)
print "Bu
siness building sent
"
print "Bu
ild scalability business configuration...
"
print result.read()
print result.read()
print "Response read"
# Wait activities
waitFor0PendingActivities()
# Wait for 0-pending activities
print "Scalability business configuration building: done."
start_time = time.time()
\ No newline at end of file
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)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment