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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Paul Graydon
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
Show 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
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)
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 "Bu
siness building sent
"
print "Bu
ild 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
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