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
Xiaohe Cao
slapos
Commits
b3938bf6
Commit
b3938bf6
authored
Jun 20, 2014
by
Cédric Le Ninivin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
apache-frontend: Root: slave configuration is read and saved in instance
parent
e2f33e64
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
1 deletion
+58
-1
software/apache-frontend/instance-apache-replicate.cfg.in
software/apache-frontend/instance-apache-replicate.cfg.in
+47
-1
software/apache-frontend/instance.cfg
software/apache-frontend/instance.cfg
+11
-0
No files found.
software/apache-frontend/instance-apache-replicate.cfg.in
View file @
b3938bf6
...
...
@@ -57,6 +57,52 @@ sla-{{ parameter }} = {{ slapparameter_dict.pop( sla_key + parameter ) }}
{% endif -%}
{% endfor -%}
# Prepare states
{% set slave_deploy = slave_list_parameter.get('deploy') %}
{% set slave_test = slave_list_parameter.get('test') %}
{% set slave_ignore = slave_list_parameter.get('ignore') %}
{% set slave_stop = slave_list_parameter.get('stop') %}
{% set default_slave_state = slapparameter_dict.pop('default-slave-state', slave_deploy ) %}
# Prepare slave list
{% set slave_deploy_list = [] %}
{% set slave_test_list = [] %}
{% set slave_configuration_path = slave_list_parameter.get('configuration-path') %}
{% set slave_configuration_json = builtin.open(slave_configuration_path, 'w+').read() %}
{% if slave_configuration_json == '' %}
{% set slave_configuration = {} %}
{% else %}
{% set slave_configuration = json_module.loads(slave_configuration_json) %}
{% endif %}
{% for slave in slave_instance_list %}
{% set slave_reference = slave.get('slave_reference') %}
## Update slave information if slave is new or have changed
{% if slave_configuration.has_key(slave_reference) %}
{% if slave.get('timestamp') != slave_configuration.get(slave_reference).get('timestamp') %}
{% do slave_configuration.get(slave_reference).__setitem__('timestamp', slave.get('timestamp')) %}
{% do slave_configuration.get(slave_reference).__setitem__('configuration', slave) %}
{% do slave_configuration.get(slave_reference).__setitem__('status', default_slave_state) %}
{% endif %}
{% else %}
{% do slave_configuration.__setitem__(slave_reference, {}) %}
{% do slave_configuration.get(slave_reference).__setitem__('timestamp', slave.get('timestamp')) %}
{% do slave_configuration.get(slave_reference).__setitem__('configuration', slave) %}
{% do slave_configuration.get(slave_reference).__setitem__('state', default_slave_state) %}
{% endif %}
## Put slave in the list according to its status
{% set slave_state = slave_configuration.get(slave_reference).get('state') %}
{% if slave_state == slave_deploy %}
{% do slave_configuration.get(slave_reference).__setitem__('deploy_configuration', slave_configuration.get(slave_reference).get('configuration')) %}
{% elif slave_state == slave_test %}
{% do slave_test_list.append(slave_configuration.get(slave_reference, 'configuration')) %}
{% endif %}
{% if slave_state != slave_stop and slave_configuration.get(slave_reference).has_key('deploy_configuration') %}
{% do slave_deploy_list.append(slave_configuration.get(slave_reference, 'configuration')) %}
{% endif %}
{% endfor %}
{% do json_module.dump(slave_configuration, builtin.open(slave_configuration_path, 'w')) %}
[replicate]
<= slap-connection
recipe = slapos.cookbook:requestoptional
...
...
@@ -67,7 +113,7 @@ config = {{ ' '.join(slapparameter_dict.keys()) + ' ' + slave_list_name }}
{% for parameter, value in slapparameter_dict.iteritems() -%}
config-{{parameter}} = {{ value }}
{% endfor -%}
config-{{ slave_list_name }} = {{ json_module.dumps(slave_
instance
_list) }}
config-{{ slave_list_name }} = {{ json_module.dumps(slave_
deploy
_list) }}
connection-monitor_url =
[publish-information]
...
...
software/apache-frontend/instance.cfg
View file @
b3938bf6
...
...
@@ -44,6 +44,17 @@ template = ${template-apache-replicate:target}
filename = instance-apache-replicate.cfg
extensions = jinja2.ext.do
extra-context =
import builtin __builtin__
import configparser_module ConfigParser
key root_directory buildout:directory
section slave_list_parameter slave-list-parameter
raw template_publish_slave_information ${template-replicate-publish-slave-information:target}
# Must match the key id in [switch-softwaretype] which uses this section.
raw software_type RootSoftwareInstance-default-custom-personal-custom-group-replicate
[slave-list-parameter]
configuration-path = $${buildout:directory}/slave_configuration.json
deploy = DEPLOY
test = TEST
ignore = IGNORE
stop = STOP
\ 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