Merge "Update cinder config files permissions"
diff --git a/.gitignore b/.gitignore
index aa8e42a..2a61b98 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,6 @@
.kitchen
tests/build/
*.swp
+*.swo
*.pyc
.ropeproject
diff --git a/cinder/controller.sls b/cinder/controller.sls
index e6af812..2e2f891 100644
--- a/cinder/controller.sls
+++ b/cinder/controller.sls
@@ -350,6 +350,9 @@
cinderng.volume_type_present:
- name: {{ backend.type_name }}
- profile: {{ credentials }}
+ {%- if controller.get('role', 'primary') == 'secondary' %}
+ - onlyif: /bin/false
+ {%- endif %}
- require:
- service: cinder_controller_services
@@ -359,6 +362,9 @@
- key: volume_backend_name
- value: {{ backend_name }}
- profile: {{ credentials }}
+ {%- if controller.get('role', 'primary') == 'secondary' %}
+ - onlyif: /bin/false
+ {%- endif %}
- require:
- cinderng: cinder_type_create_{{ backend_name }}
diff --git a/cinder/files/backend/_ceph.conf b/cinder/files/backend/_ceph.conf
index 4e06c34..8d4a8db 100644
--- a/cinder/files/backend/_ceph.conf
+++ b/cinder/files/backend/_ceph.conf
@@ -1,6 +1,10 @@
[{{ backend_name }}]
+{%- if backend.get('backend_host', False) %}
+backend_host={{ backend.backend_host }}
+{%- else %}
host={{ backend.get('host', grains.host) }}
+{%- endif %}
volume_backend_name={{ backend_name }}
volume_driver = cinder.volume.drivers.rbd.RBDDriver
#
diff --git a/cinder/map.jinja b/cinder/map.jinja
index 22fd95a..79dff75 100644
--- a/cinder/map.jinja
+++ b/cinder/map.jinja
@@ -1,8 +1,10 @@
{%- set default_params = {
- 'cacert_file': salt['grains.filter_by']({
- 'Debian': '/etc/ssl/certs/ca-certificates.crt',
- 'RedHat': '/etc/pki/tls/certs/ca-bundle.crt'
- })}
+ 'cacert_file': salt['grains.filter_by']({
+ 'Debian': '/etc/ssl/certs/ca-certificates.crt',
+ 'RedHat': '/etc/pki/tls/certs/ca-bundle.crt'
+ }),
+ 'enabled': false,
+ }
%}
{% set controller = salt['grains.filter_by']({
@@ -150,4 +152,13 @@
'services_failed_critical_threshold_percent': 0.6,
'endpoint_failed_major_threshold': 0.5,
},
-}, grain='os_family', merge=salt['pillar.get']('cinder:monitoring')) %}
+}, grain='os_family', merge=pillar.get('cinder', {}).get('monitoring')) %}
+
+{% set upgrade = pillar.get('cinder', {}).get('upgrade', {}) %}
+
+{# Only for transition untill we split backup service to separate sls #}
+{%- if controller.enabled %}
+{% set backup = controller.get('backup', {}) %}
+{%- elif volume.enabled %}
+{% set backup = volume.get('backup', {}) %}
+{%- endif %}
diff --git a/cinder/meta/salt.yml b/cinder/meta/salt.yml
index 7df3cf9..045e522 100644
--- a/cinder/meta/salt.yml
+++ b/cinder/meta/salt.yml
@@ -1,13 +1,8 @@
-orchestrate:
- controller:
- priority: 540
- batch: 1
- require:
- - salt: keystone.server
- volume:
- priority: 550
- require:
- - salt: cinder.controller
+orchestration:
+ upgrade:
+ applications:
+ cinder:
+ priority: 1200
dependency:
{% from "cinder/map.jinja" import controller, client with context %}
{%- if client.get('enabled', False) or controller.get('enabled', False) %}
diff --git a/cinder/upgrade/pkgs_latest.sls b/cinder/upgrade/pkgs_latest.sls
new file mode 100644
index 0000000..b8d690d
--- /dev/null
+++ b/cinder/upgrade/pkgs_latest.sls
@@ -0,0 +1,39 @@
+{%- from "cinder/map.jinja" import controller,volume,backup,client with context %}
+
+cinder_task_pkg_latest:
+ test.show_notification:
+ - text: "Running cinder.upgrade.pkg_latest"
+
+policy-rc.d_present:
+ file.managed:
+ - name: /usr/sbin/policy-rc.d
+ - mode: 755
+ - contents: |
+ #!/bin/sh
+ exit 101
+
+{%- set pkgs = [] %}
+{%- if controller.enabled %}
+ {%- do pkgs.extend(controller.pkgs) %}
+{%- endif %}
+{%- if volume.enabled %}
+ {%- do pkgs.extend(volume.pkgs) %}
+{%- endif %}
+{%- if backup.engine != None %}
+ {%- do pkgs.extend(backup.pkgs) %}
+{%- endif %}
+{%- if client.enabled %}
+ {%- do pkgs.extend(client.pkgs) %}
+{%- endif %}
+
+cinder_pkg_latest:
+ pkg.latest:
+ - names: {{ pkgs|unique }}
+ - require:
+ - file: policy-rc.d_present
+ - require_in:
+ - file: policy-rc.d_absent
+
+policy-rc.d_absent:
+ file.absent:
+ - name: /usr/sbin/policy-rc.d
diff --git a/cinder/upgrade/post/init.sls b/cinder/upgrade/post/init.sls
new file mode 100644
index 0000000..fcad85f
--- /dev/null
+++ b/cinder/upgrade/post/init.sls
@@ -0,0 +1,3 @@
+cinder_post:
+ test.show_notification:
+ - text: "Running cinder.upgrade.post"
diff --git a/cinder/upgrade/pre/init.sls b/cinder/upgrade/pre/init.sls
new file mode 100644
index 0000000..5dcfa90
--- /dev/null
+++ b/cinder/upgrade/pre/init.sls
@@ -0,0 +1,7 @@
+include:
+ - cinder.upgrade.verify.api
+
+
+cinder_pre:
+ test.show_notification:
+ - text: "Running cinder.upgrade.pre"
diff --git a/cinder/upgrade/render_config.sls b/cinder/upgrade/render_config.sls
new file mode 100644
index 0000000..7191084
--- /dev/null
+++ b/cinder/upgrade/render_config.sls
@@ -0,0 +1,14 @@
+{%- from "cinder/map.jinja" import controller,volume with context %}
+
+{%- if volume.enabled %}
+ {%- set _data = volume %}
+ {%- set type = 'volume' %}
+{%- elif controller.enabled %}
+ {%- set _data = controller %}
+ {%- set type = 'controller' %}
+{%- endif %}
+
+/etc/cinder/cinder.conf:
+ file.managed:
+ - source: salt://cinder/files/{{ _data.version }}/cinder.conf.{{ type }}.{{ grains.os_family }}
+ - template: jinja
diff --git a/cinder/upgrade/service_running.sls b/cinder/upgrade/service_running.sls
new file mode 100644
index 0000000..24f4c2b
--- /dev/null
+++ b/cinder/upgrade/service_running.sls
@@ -0,0 +1,29 @@
+{%- from "cinder/map.jinja" import controller,volume,backup,upgrade with context %}
+
+cinder_task_service_running:
+ test.show_notification:
+ - text: "Running cinder.upgrade.service_running"
+
+{%- set cservices = [] %}
+{%- if controller.enabled %}
+ {%- do cservices.extend(controller.services) %}
+ {#- After newton release cinder running under apache #}
+ {%- if upgrade.old_release in ['mitaka', 'newton'] %}
+ {%- do cservices.append('cinder-api') %}
+ {%- else %}
+ {%- do cservices.append('apache2') %}
+ {%- endif %}
+{%- endif %}
+{%- if volume.enabled %}
+ {%- do cservices.extend(volume.services) %}
+{%- endif %}
+{%- if backup.engine != None %}
+ {%- do cservices.extend(backup.services) %}
+{%- endif %}
+
+{%- for cservice in cservices|unique %}
+cinder_service_running_{{ cservice }}:
+ service.running:
+ - name: {{ cservice }}
+ - enable: True
+{%- endfor %}
diff --git a/cinder/upgrade/service_stopped.sls b/cinder/upgrade/service_stopped.sls
new file mode 100644
index 0000000..848c5f0
--- /dev/null
+++ b/cinder/upgrade/service_stopped.sls
@@ -0,0 +1,29 @@
+{%- from "cinder/map.jinja" import controller,volume,backup,upgrade with context %}
+
+cinder_task_service_stopped:
+ test.show_notification:
+ - text: "Running cinder.upgrade.service_stopped"
+
+{%- set cservices = [] %}
+{%- if controller.enabled %}
+ {%- do cservices.extend(controller.services) %}
+ {#- After newton release cinder running under apache #}
+ {%- if upgrade.old_release in ['mitaka', 'newton'] %}
+ {%- do cservices.append('cinder-api') %}
+ {%- else %}
+ {%- do cservices.append('apache2') %}
+ {%- endif %}
+{%- endif %}
+{%- if volume.enabled %}
+ {%- do cservices.extend(volume.services) %}
+{%- endif %}
+{%- if backup.engine != None %}
+ {%- do cservices.extend(backup.services) %}
+{%- endif %}
+
+{%- for cservice in cservices|unique %}
+cinder_service_stopped_{{ cservice }}:
+ service.dead:
+ - name: {{ cservice }}
+ - enable: False
+{%- endfor %}
diff --git a/cinder/upgrade/upgrade/init.sls b/cinder/upgrade/upgrade/init.sls
new file mode 100644
index 0000000..2a84a9a
--- /dev/null
+++ b/cinder/upgrade/upgrade/init.sls
@@ -0,0 +1,10 @@
+cinder_upgrade:
+ test.show_notification:
+ - text: "Running cinder.upgrade.upgrade"
+
+include:
+ - cinder.upgrade.service_stopped
+ - cinder.upgrade.pkgs_latest
+ - cinder.upgrade.render_config
+ - cinder.db.offline_sync
+ - cinder.upgrade.service_running
diff --git a/cinder/upgrade/verify/api.sls b/cinder/upgrade/verify/api.sls
new file mode 100644
index 0000000..afe2117
--- /dev/null
+++ b/cinder/upgrade/verify/api.sls
@@ -0,0 +1,39 @@
+{%- from "cinder/map.jinja" import controller with context %}
+{%- from "keystone/map.jinja" import client as kclient with context %}
+
+
+cinder_upgrade_verify_api:
+ test.show_notification:
+ - text: "Running cinder.upgrade.verify.api"
+
+{%- if kclient.enabled and kclient.get('os_client_config', {}).get('enabled', False) %}
+ {%- if controller.enabled %}
+ {%- if controller.get('version') not in ('mitaka', 'newton') -%}
+ {%- set volume_type_name = 'TestVolumeType' %}
+
+cinderv3_volume_list:
+ module.run:
+ - name: cinderv3.volume_list
+ - kwargs:
+ cloud_name: admin_identity
+
+cinderv3_volume_type_present:
+ cinderv3.volume_type_present:
+ - name: {{ volume_type_name }}
+ - cloud_name: admin_identity
+
+cinderv3_volume_type_key_present:
+ cinderv3.volume_type_key_present:
+ - name: {{ volume_type_name }}
+ - key: key1
+ - value: val1
+ - cloud_name: admin_identity
+
+cinderv3_volume_type_absent:
+ cinderv3.volume_type_absent:
+ - name: {{ volume_type_name }}
+ - cloud_name: admin_identity
+
+ {%- endif %}
+ {%- endif %}
+{%- endif %}