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
Ivan Tyagov
slapos
Commits
33d3246a
Commit
33d3246a
authored
Jul 12, 2021
by
Alain Takoudjou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
repman: Allow to create database slave with character sets and collate options
parent
b30539a9
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
55 additions
and
8 deletions
+55
-8
software/repman/buildout.hash.cfg
software/repman/buildout.hash.cfg
+3
-3
software/repman/instance-mariadb.cfg.jinja2.in
software/repman/instance-mariadb.cfg.jinja2.in
+1
-1
software/repman/instance-repman-slave-input-schema.json
software/repman/instance-repman-slave-input-schema.json
+30
-0
software/repman/instance-repman.cfg.jinja2.in
software/repman/instance-repman.cfg.jinja2.in
+2
-1
software/repman/templates/mariadb_initial_setup.sql.in
software/repman/templates/mariadb_initial_setup.sql.in
+19
-3
No files found.
software/repman/buildout.hash.cfg
View file @
33d3246a
...
...
@@ -18,7 +18,7 @@ md5sum = 9aeb37bd4590aa7fa746ef70d78cc0d0
[instance-repman.cfg]
_update_hash_filename_ = instance-repman.cfg.jinja2.in
md5sum =
287e446905a6905606f5e12ae38e533f
md5sum =
8e4fcaf0e76a1b8a799c671dd3ad2de9
[config-toml.in]
_update_hash_filename_ = templates/config.toml.in
...
...
@@ -34,7 +34,7 @@ md5sum = 0eeb24c6aa0760f0d33c4cc2828ddf30
[template-mariadb.cfg]
_update_hash_filename_ = instance-mariadb.cfg.jinja2.in
md5sum =
e9c62f54824d7c6b549a864f9f67d0af
md5sum =
b1344ec1c0ccd4670a87cea18b0aed53
[template-my-cnf]
_update_hash_filename_ = templates/my.cnf.in
...
...
@@ -42,7 +42,7 @@ md5sum = f3661b788099bb31d71ba6e7d36836d9
[template-mariadb-initial-setup]
_update_hash_filename_ = templates/mariadb_initial_setup.sql.in
md5sum =
c300e9c2fb67a5d41fadc572f4c02216
md5sum =
96c151c376600a90fe2a44825f2de550
[template-publish-slave-information]
_update_hash_filename_ = publish-database-slave-parameters.cfg.in
...
...
software/repman/instance-mariadb.cfg.jinja2.in
View file @
33d3246a
...
...
@@ -311,7 +311,7 @@ command = ${template-mysqld-need-start:rendered}
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = slave-db-remove
frequency = */
20
* * * *
frequency = */
5
* * * *
command = ${mysql-slave-db-cleanup:rendered}
[template-mysqld-need-start]
...
...
software/repman/instance-repman-slave-input-schema.json
View file @
33d3246a
...
...
@@ -18,6 +18,36 @@
"title"
:
"Database Password"
,
"type"
:
"string"
,
"default"
:
""
},
"db_charset"
:
{
"description"
:
"Database Character set information."
,
"title"
:
"Database Character set information"
,
"type"
:
"string"
,
"enum"
:
[
"latin1"
,
"latin2"
,
"latin5"
,
"latin7"
,
"ascii"
,
"latin5"
,
"utf8"
,
"utf8mb4"
,
"utf16"
,
"utf16le"
,
"utf32"
,
"binary"
,
"utf8_general_ci"
,
"utf8_unicode_ci"
,
"utf8_unicode_ci"
,
"utf8mb4_bin"
,
"utf8mb4_general_ci"
,
"utf8mb4_unicode_ci"
,
"latin1_general_ci"
,
"latin1_bin"
,
"ascii_general_ci"
,
"ascii_bin"
],
"default"
:
""
}
},
"title"
:
"Input Parameters"
,
...
...
software/repman/instance-repman.cfg.jinja2.in
View file @
33d3246a
...
...
@@ -66,7 +66,8 @@ mode = 755
'name': 'db_%s' % instance_dict['slave_reference'].replace('-', '_').lower(),
'user': instance_dict.get('db_user', 'user'),
'password': instance_dict.get('db_password'),
'slave_reference': instance_dict['slave_reference']
'slave_reference': instance_dict['slave_reference'],
'charset': instance_dict.get('db_charset', '')
} -%}
{{ slave_dict['name'] }} = {{ dumps(slave_dict) }}
{% do dabase_slave_list.append(slave_dict) -%}
...
...
software/repman/templates/mariadb_initial_setup.sql.in
View file @
33d3246a
...
...
@@ -10,8 +10,24 @@ DROP FUNCTION IF EXISTS sphinx_snippets;
CREATE DATABASE IF NOT EXISTS `repman_slave_definition`;
{% macro database(name, user, password) -%}
CREATE DATABASE IF NOT EXISTS `{{ name }}`;
{% macro database(name, user, password, charset="") -%}
{% set charset_collate = "" -%}
{% set charset_dict = {'utf8_general_ci': 'utf8',
'utf8_unicode_ci': 'utf8',
'utf8mb4_bin': 'utf8mb4',
'utf8mb4_general_ci': 'utf8mb4',
'utf8mb4_unicode_ci': 'utf8mb4',
'latin1_general_ci': 'latin1',
'latin1_bin': 'latin1',
'ascii_general_ci': 'ascii',
'ascii_bin': 'ascii'} -%}
{% if charset %}
{% set charset_collate = "CHARACTER SET %s" % charset -%}
{% if charset_dict.get(charset) -%}
{% set charset_collate = "CHARACTER SET %s COLLATE %s" % (charset_dict[charset], charset) -%}
{% endif -%}
{% endif -%}
CREATE DATABASE IF NOT EXISTS `{{ name }}` {{ charset_collate }};
{% if user -%}
GRANT ALL PRIVILEGES ON `{{ name }}`.* TO `{{ user }}`@`%` IDENTIFIED BY '{{ password }}';
GRANT ALL PRIVILEGES ON `{{ name }}`.* TO `{{ user }}`@localhost IDENTIFIED BY '{{ password }}';
...
...
@@ -20,5 +36,5 @@ GRANT ALL PRIVILEGES ON `{{ name }}`.* TO `{{ user }}`@'::' IDENTIFIED BY '{{ pa
{% endmacro -%}
{% for entry in parameter_dict['database-list'] -%}
{{ database(entry['name'], entry.get('user'), entry.get('password')) }}
{{ database(entry['name'], entry.get('user'), entry.get('password')
, entry.get('charset')
) }}
{% endfor -%}
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