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
abc220fa
Commit
abc220fa
authored
Jul 23, 2013
by
Benjamin Blanc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
erp5_bootstrap: factorize code of connections
parent
4b3b304d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
46 deletions
+15
-46
slapos/recipe/erp5_bootstrap/template/erp5_bootstrap.in
slapos/recipe/erp5_bootstrap/template/erp5_bootstrap.in
+15
-46
No files found.
slapos/recipe/erp5_bootstrap/template/erp5_bootstrap.in
View file @
abc220fa
...
...
@@ -5,6 +5,16 @@ import urllib
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")
user = "%(user)s"
password = "%(password)s"
host = "%(host)s"
...
...
@@ -18,12 +28,7 @@ erp5_catalog_storage = 'erp5_mysql_innodb_catalog'
header_dict = {'Authorization': 'Basic %%s' %% \
base64.encodestring('%%s:%%s' %% (user, password)).strip()}
if protocol == 'https':
zope_connection = httplib.HTTPSConnection(host)
elif protocol == 'http':
zope_connection = httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
zope_connection = getConnection(protocol,host)
# 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
...
...
@@ -33,12 +38,7 @@ result = zope_connection.getresponse()
if result.status == 204: # and (result.read() == "False"):
# Use a new connection
if protocol == 'https':
zope_connection = httplib.HTTPSConnection(host)
elif protocol == 'http':
zope_connection = httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
zope_connection = getConnection(protocol,host)
# Create the expected ERP5 instance
zope_connection.request(
...
...
@@ -71,12 +71,7 @@ if scalability:
configurator_available = False
if not configurator_available:
# Fix site consistency
if protocol == 'https':
zope_connection = httplib.HTTPSConnection(host)
elif protocol == 'http':
zope_connection = httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
zope_connection = getConnection(protocol,host)
zope_connection.request(
'GET', '/%%s/ERP5Site_launchFixConfigurationConsistency' %%(site_id),
headers=header_dict
...
...
@@ -96,16 +91,10 @@ if scalability:
# Here check if S&MB not already installed
configurator_already_applied = False
business_object_name = "
default_standard_configuration
"
business_object_name = "
1
"
if configurator_available and not configurator_already_applied:
# install small and medium business via configurator
if protocol == 'https':
zope_connection = httplib.HTTPSConnection(host)
elif protocol == 'http':
zope_connection = httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
#https://192.168.241.110:2153/erp5/business_configuration_module/view
zope_connection = getConnection(protocol,host)
zope_connection.request(
'GET', '/%%s/business_configuration_module/%%s/build' %%(business_object_name, site_id),
headers=header_dict
...
...
@@ -113,23 +102,3 @@ if scalability:
print "Business building sent"
print result.read()
print "Response read"
time.sleep(20)
# install small and medium business via configurator
if protocol == 'https':
zope_connection = httplib.HTTPSConnection(host)
elif protocol == 'http':
zope_connection = httplib.HTTPConnection(host)
else:
raise ValueError("Protocol not implemented")
#https://192.168.241.110:2153/erp5/business_configuration_module/view
zope_connection.request(
'GET', '/%%s/business_configuration_module/%%s/install' %%(business_object_name, site_id),
headers=header_dict
)
print "Business building sent"
print result.read()
print "Response read"
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