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
Aurel
slapos
Commits
38395b7e
Commit
38395b7e
authored
Jul 16, 2013
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Publish mariadb connection urls for each database.
parent
3c38505e
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
27 deletions
+44
-27
slapos/recipe/erp5_test/__init__.py
slapos/recipe/erp5_test/__init__.py
+19
-6
stack/erp5/buildout.cfg
stack/erp5/buildout.cfg
+2
-2
stack/erp5/instance-erp5.cfg.in
stack/erp5/instance-erp5.cfg.in
+3
-3
stack/erp5/instance-mariadb.cfg.in
stack/erp5/instance-mariadb.cfg.in
+20
-16
No files found.
slapos/recipe/erp5_test/__init__.py
View file @
38395b7e
...
@@ -38,12 +38,25 @@ class Recipe(GenericBaseRecipe):
...
@@ -38,12 +38,25 @@ class Recipe(GenericBaseRecipe):
# XXX: assume existence of 100 test databases, because slaves are not
# XXX: assume existence of 100 test databases, because slaves are not
# functional yet in slapos: testdb_0...testdb_100, with testuser_N
# functional yet in slapos: testdb_0...testdb_100, with testuser_N
mysql_template
=
"%s@%s:%s %s %s"
mysql_template
=
"%s@%s:%s %s %s"
mysql_url_list
=
self
.
options
.
get
(
'mysql-url-list'
)
if
mysql_url_list
is
None
:
mysql_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'mysql-url'
])
mysql_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'mysql-url'
])
for
i
in
range
(
0
,
100
):
for
i
in
range
(
0
,
100
):
mysql_connection_string_list
.
append
(
mysql_template
%
(
'testdb_%s'
%
i
,
mysql_connection_string_list
.
append
(
mysql_template
%
(
'testdb_%s'
%
i
,
mysql_parsed
.
hostname
,
mysql_parsed
.
port
,
'testuser_%s'
%
i
,
mysql_parsed
.
password
))
mysql_parsed
.
hostname
,
mysql_parsed
.
port
,
'testuser_%s'
%
i
,
mysql_parsed
.
password
))
mysql_connection_string
=
mysql_template
%
(
'erp5_test'
,
mysql_parsed
.
hostname
,
mysql_connection_string
=
mysql_template
%
(
'erp5_test'
,
mysql_parsed
.
hostname
,
mysql_parsed
.
port
,
'erp5_test'
,
mysql_parsed
.
password
)
mysql_parsed
.
port
,
'erp5_test'
,
mysql_parsed
.
password
)
else
:
for
mysql_url
in
mysql_url_list
:
mysql_parsed
=
urlparse
.
urlparse
(
mysql_url
)
mysql_connection_string_list
.
append
(
mysql_template
%
(
mysql_parsed
.
path
.
lstrip
(
'/'
),
mysql_parsed
.
hostname
,
mysql_parsed
.
port
,
mysql_parsed
.
username
,
mysql_parsed
.
password
,
))
mysql_connection_string
=
mysql_connection_string_list
.
pop
()
cloudooo_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'cloudooo-url'
])
cloudooo_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'cloudooo-url'
])
memcached_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'memcached-url'
])
memcached_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'memcached-url'
])
kumofs_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'kumofs-url'
])
kumofs_parsed
=
urlparse
.
urlparse
(
self
.
options
[
'kumofs-url'
])
...
...
stack/erp5/buildout.cfg
View file @
38395b7e
...
@@ -171,7 +171,7 @@ context =
...
@@ -171,7 +171,7 @@ context =
[template-mariadb]
[template-mariadb]
< = download-base
< = download-base
filename = instance-mariadb.cfg.in
filename = instance-mariadb.cfg.in
md5sum =
cc6469a092d0b09008dca6507ae4cb02
md5sum =
917f3e96819193ac183c7ee84e650eba
[template-kumofs]
[template-kumofs]
< = download-base
< = download-base
...
@@ -269,7 +269,7 @@ extra-context =
...
@@ -269,7 +269,7 @@ extra-context =
[template-erp5]
[template-erp5]
< = download-base
< = download-base
filename = instance-erp5.cfg.in
filename = instance-erp5.cfg.in
md5sum =
4a0cd404bed41a58512396af9f964c66
md5sum =
a24bd5283599807799adb2aeea1ad7ba
[template-neo]
[template-neo]
< = download-base
< = download-base
...
...
stack/erp5/instance-erp5.cfg.in
View file @
38395b7e
...
@@ -41,7 +41,7 @@ config-{{ option }} = {{ dumps(value) }}
...
@@ -41,7 +41,7 @@ config-{{ option }} = {{ dumps(value) }}
{{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}) }}
{{ request('memcached-persistent', 'kumofs', 'kumofs', {'tcpv4-port': 2000}) }}
{{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}) }}
{{ request('memcached-volatile', 'kumofs', 'memcached', {'tcpv4-port': 2010, 'ram-storage-size': 64}) }}
{{ request('cloudooo', 'cloudooo', 'cloudooo', {'tcpv4-port': 2020}) }}
{{ request('cloudooo', 'cloudooo', 'cloudooo', {'tcpv4-port': 2020}) }}
{{ request('mariadb', 'mariadb', 'mariadb', {'tcpv4-port': 2099}) }}
{{ request('mariadb', 'mariadb', 'mariadb', {'tcpv4-port': 2099}
, {'database-list': True, 'test-database-list': True}
) }}
{{ request('zodb', 'zodb-' ~ slapparameter_dict.get('zodb-software-type', 'zeo'), 'zodb', {'tcpv4-port': 2100, 'zodb-dict': {'root': {}}}, {'zodb-storage-type': False, 'zodb-dict': False, 'tidstorage-ip': False, 'tidstorage-port': False}) }}
{{ request('zodb', 'zodb-' ~ slapparameter_dict.get('zodb-software-type', 'zeo'), 'zodb', {'tcpv4-port': 2100, 'zodb-dict': {'root': {}}}, {'zodb-storage-type': False, 'zodb-dict': False, 'tidstorage-ip': False, 'tidstorage-port': False}) }}
[request-zope-base]
[request-zope-base]
...
@@ -49,7 +49,7 @@ config-{{ option }} = {{ dumps(value) }}
...
@@ -49,7 +49,7 @@ config-{{ option }} = {{ dumps(value) }}
return =
return =
zope-address-list
zope-address-list
extra-config =
extra-config =
mysql-url
mysql-url
-list
memcached-url
memcached-url
cloudooo-url
cloudooo-url
kumofs-url
kumofs-url
...
@@ -68,7 +68,7 @@ extra-config =
...
@@ -68,7 +68,7 @@ extra-config =
longrequest-logger-interval
longrequest-logger-interval
longrequest-logger-timeout
longrequest-logger-timeout
port-base
port-base
config-mysql-url
= ${request-mariadb:connection-url
}
config-mysql-url
-list = ${request-mariadb:connection-database-list
}
config-memcached-url = ${request-memcached-volatile:connection-url}
config-memcached-url = ${request-memcached-volatile:connection-url}
config-cloudooo-url = ${request-cloudooo:connection-url}
config-cloudooo-url = ${request-cloudooo:connection-url}
config-kumofs-url = ${request-memcached-persistent:connection-url}
config-kumofs-url = ${request-memcached-persistent:connection-url}
...
...
stack/erp5/instance-mariadb.cfg.in
View file @
38395b7e
...
@@ -3,23 +3,31 @@
...
@@ -3,23 +3,31 @@
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% macro section(name) %}{% do part_list.append(name) %}{{ name }}{% endmacro -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
{% set use_ipv6 = slapparameter_dict.get('use-ipv6', False) -%}
{% set database_list = slapparameter_dict.get('database-list', [{'name': 'erp5', 'user': 'user', 'password': 'insecure'}]) -%}
{% set database_list = slapparameter_dict.get('database-list', [{'name': 'erp5', 'user': 'user', 'password': 'insecure'}]) -%}
{% set test_database_list = [] %}
{% for database_count in range(slapparameter_dict.get('test-database-amount', 30)) -%}
{% for database_count in range(slapparameter_dict.get('test-database-amount', 30)) -%}
{% do database_list.append({'name': 'erp5_test_' ~ database_count, 'user': 'testuser_' ~ database_count, 'password': 'testpassword' ~ database_count}) -%}
{% do
test_
database_list.append({'name': 'erp5_test_' ~ database_count, 'user': 'testuser_' ~ database_count, 'password': 'testpassword' ~ database_count}) -%}
{% endfor -%}
{% endfor -%}
{% set catalog_backup = slapparameter_dict.get('catalog-backup', {}) -%}
{% set catalog_backup = slapparameter_dict.get('catalog-backup', {}) -%}
{% set full_backup_retention_days = catalog_backup.get('full-retention-days', 7) -%}
{% set full_backup_retention_days = catalog_backup.get('full-retention-days', 7) -%}
{% set incremental_backup_retention_days = catalog_backup.get('incremental-retention-days', full_backup_retention_days) -%}
{% set incremental_backup_retention_days = catalog_backup.get('incremental-retention-days', full_backup_retention_days) -%}
{% set port = slapparameter_dict['tcpv4-port'] %}
[publish-mariadb-url]
recipe = slapos.cookbook:publish.serialised
{% if use_ipv6 -%}
{% if use_ipv6 -%}
{% set
address = "[${my-cnf-parameters:ip}]"
-%}
{% set
ip = (ipv6_set | list)[0]
-%}
{% else -%}
{% else -%}
{% set
address = "${my-cnf-parameters:ip}"
-%}
{% set
ip = (ipv4_set | list)[0]
-%}
{% endif -%}
{% endif -%}
{# TODO: support any number of databases -#}
{% set database = database_list[0] %}
[publish-mariadb-url]
url = mysql://{{ database['user'] }}:{{ database['password'] }}@{{ address }}:${my-cnf-parameters:port}/{{ database['name'] }}
recipe = slapos.cookbook:publish.serialised
{% macro render_database_list(database_list) -%}
{% set publish_database_list = [] -%}
{% for database in database_list -%}
{% do publish_database_list.append("mysql://" ~ database['user'] ~ ":" ~ database['password'] ~ "@" ~ ip ~ ":" ~ port ~ "/" ~ database['name']) -%}
{% endfor -%}
{{ dumps(publish_database_list) }}
{% endmacro -%}
database-list = {{ render_database_list(database_list) }}
test-database-list = {{ render_database_list(test_database_list) }}
{% if full_backup_retention_days > -1 -%}
{% if full_backup_retention_days > -1 -%}
[{{ section('cron-entry-mariadb-backup') }}]
[{{ section('cron-entry-mariadb-backup') }}]
...
@@ -49,12 +57,8 @@ command = {{ parameter_dict['findutils-location'] }}/bin/find "${directory:maria
...
@@ -49,12 +57,8 @@ command = {{ parameter_dict['findutils-location'] }}/bin/find "${directory:maria
{%- endif %}
{%- endif %}
[my-cnf-parameters]
[my-cnf-parameters]
{% if use_ipv6 -%}
ip = {{ ip }}
ip = {{ (ipv6_set | list)[0] }}
port = {{ port }}
{% else -%}
ip = {{ (ipv4_set | list)[0] }}
{% endif -%}
port = {{ slapparameter_dict['tcpv4-port'] }}
socket = ${directory:run}/mariadb.sock
socket = ${directory:run}/mariadb.sock
data-directory = ${directory:mariadb-data}
data-directory = ${directory:mariadb-data}
pid-file = ${directory:run}/mariadb.pid
pid-file = ${directory:run}/mariadb.pid
...
@@ -79,7 +83,7 @@ template = {{ parameter_dict['template-my-cnf'] }}
...
@@ -79,7 +83,7 @@ template = {{ parameter_dict['template-my-cnf'] }}
context = section parameter_dict my-cnf-parameters
context = section parameter_dict my-cnf-parameters
[init-script-parameters]
[init-script-parameters]
database-list = {{ dumps(database_list) }}
database-list = {{ dumps(database_list
+ test_database_list
) }}
[init-script]
[init-script]
recipe = slapos.recipe.template:jinja2
recipe = slapos.recipe.template:jinja2
...
...
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