Merge "Glance cache pruner/cleaner operations via salt"
diff --git a/glance/files/ocata/glance-api.conf.Debian b/glance/files/ocata/glance-api.conf.Debian
index a29833a..978030b 100644
--- a/glance/files/ocata/glance-api.conf.Debian
+++ b/glance/files/ocata/glance-api.conf.Debian
@@ -440,7 +440,7 @@
#
# (boolean value)
#enable_v1_api = true
-enable_v1_api=False
+enable_v1_api={{ server.get('enable_v1_api', 'False')|lower }}
#
# Deploy the v2 OpenStack Images API.
@@ -2027,7 +2027,7 @@
default_store = file
stores = file,http
{%- else %}
-default_store = {{ storage_engines[0] }}
+default_store = {{ server.storage.get('default_store', storage_engines[0]) }}
stores = {{ server.storage.engine }}
{%- endif %}
#
diff --git a/glance/files/ocata/glance-glare.conf.Debian b/glance/files/ocata/glance-glare.conf.Debian
index c9e79d6..9a43951 100644
--- a/glance/files/ocata/glance-glare.conf.Debian
+++ b/glance/files/ocata/glance-glare.conf.Debian
@@ -692,7 +692,7 @@
default_store = file
stores = file,http
{%- else %}
-default_store = {{ storage_engines[0] }}
+default_store = {{ server.storage.get('default_store', storage_engines[0]) }}
stores = {{ server.storage.engine }}
{%- endif %}
#
diff --git a/glance/files/ocata/glance-registry.conf.Debian b/glance/files/ocata/glance-registry.conf.Debian
index d5b34e4..9693894 100644
--- a/glance/files/ocata/glance-registry.conf.Debian
+++ b/glance/files/ocata/glance-registry.conf.Debian
@@ -391,6 +391,7 @@
#
# (boolean value)
#enable_v1_api = true
+enable_v1_api={{ server.get('enable_v1_api', 'False')|lower }}
#
# Deploy the v2 OpenStack Images API.
@@ -444,6 +445,7 @@
#
# (boolean value)
#enable_v1_registry = true
+enable_v1_registry={{ server.get('enable_v1_api', 'False')|lower }}
#
# Deploy the v2 API Registry service.
diff --git a/glance/map.jinja b/glance/map.jinja
index ca65640..2d82750 100644
--- a/glance/map.jinja
+++ b/glance/map.jinja
@@ -91,14 +91,20 @@
},
}, merge=pillar.glance.get('server', {}), base='BaseDefaults') %}
+{%- set client_default_params = {
+ 'enabled': false
+ }
+%}
+
{% set client = salt['grains.filter_by']({
+ 'BaseDefaults': client_default_params,
'Debian': {
'pkgs': ['python-glanceclient', 'python-keystoneclient']
},
'RedHat': {
'pkgs': ['python-glanceclient', 'python-keystoneclient']
},
-}, merge=pillar.glance.get('client', {})) %}
+}, merge=pillar.glance.get('client', {}), base='BaseDefaults') %}
{% set monitoring = salt['grains.filter_by']({
'default': {
@@ -106,3 +112,5 @@
'endpoint_failed_major_threshold': 0.5,
},
}, grain='os_family', merge=salt['pillar.get']('glance:monitoring')) %}
+
+{% set upgrade = pillar.get('glance', {}).get('upgrade', {}) %}
diff --git a/glance/meta/salt.yml b/glance/meta/salt.yml
index ae564cf..ab4fad7 100644
--- a/glance/meta/salt.yml
+++ b/glance/meta/salt.yml
@@ -1,7 +1,5 @@
-orchestrate:
- server:
- priority: 530
- batch: 1
- require:
- - salt: keystone.server
-
+orchestration:
+ upgrade:
+ applications:
+ glance:
+ priority: 1050
diff --git a/glance/server.sls b/glance/server.sls
index 22a4bf5..64254dd 100644
--- a/glance/server.sls
+++ b/glance/server.sls
@@ -416,14 +416,4 @@
{%- endif %}
{%- endif %}
-correct_permissions_files:
- cmd.run:
- - name: find /etc/glance/ -type f \( \! -perm 640 -o \! -user root -o \! -group glance \) -execdir chmod 640 {} + -execdir chown root:glance {} +
- - onlyif: find /etc/glance/ -type f \( \! -perm 640 -o \! -user root -o \! -group glance \) -printf found | grep -q found
-
-correct_permissions_dirs:
- cmd.run:
- - name: find /etc/glance/ -type d \( \! -perm 750 -o \! -user root -o \! -group glance \) -execdir chmod 750 {} + -execdir chown root:glance {} +
- - onlyif: find /etc/glance/ -type d \( \! -perm 750 -o \! -user root -o \! -group glance \) -printf found | grep -q found
-
{%- endif %}
diff --git a/glance/upgrade/pkgs_latest.sls b/glance/upgrade/pkgs_latest.sls
new file mode 100644
index 0000000..69624cc
--- /dev/null
+++ b/glance/upgrade/pkgs_latest.sls
@@ -0,0 +1,36 @@
+{%- from "glance/map.jinja" import server,client,upgrade with context %}
+
+glance_task_pkg_latest:
+ test.show_notification:
+ - text: "Running glance.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 server.enabled %}
+ {%- do pkgs.extend(server.pkgs) %}
+ {%- if upgrade.new_release in ['newton', 'ocata'] %}
+ {%- do pkgs.append('glance-glare') %}
+ {%- endif %}
+{%- endif %}
+{%- if client.enabled %}
+ {%- do pkgs.extend(client.pkgs) %}
+{%- endif %}
+
+glance_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/glance/upgrade/post/init.sls b/glance/upgrade/post/init.sls
new file mode 100644
index 0000000..a11375e
--- /dev/null
+++ b/glance/upgrade/post/init.sls
@@ -0,0 +1,5 @@
+{%- from "glance/map.jinja" import server with context %}
+
+glance_post:
+ test.show_notification:
+ - text: "Running glance.upgrade.post"
diff --git a/glance/upgrade/pre/init.sls b/glance/upgrade/pre/init.sls
new file mode 100644
index 0000000..d362737
--- /dev/null
+++ b/glance/upgrade/pre/init.sls
@@ -0,0 +1,8 @@
+{%- from "glance/map.jinja" import server with context %}
+
+include:
+ - glance.upgrade.verify.api
+
+glance_pre:
+ test.show_notification:
+ - text: "Running glance.upgrade.pre"
diff --git a/glance/upgrade/render_config.sls b/glance/upgrade/render_config.sls
new file mode 100644
index 0000000..b63a913
--- /dev/null
+++ b/glance/upgrade/render_config.sls
@@ -0,0 +1,17 @@
+{%- from "glance/map.jinja" import server with context %}
+
+glance_render_config:
+ test.show_notification:
+ - text: "Running glance.upgrade.render_config"
+
+{%- if server.enabled %}
+/etc/glance/glance-api.conf:
+ file.managed:
+ - source: salt://glance/files/{{ server.version }}/glance-api.conf.{{ grains.os_family }}
+ - template: jinja
+
+/etc/glance/glance-registry.conf:
+ file.managed:
+ - source: salt://glance/files/{{ server.version }}/glance-registry.conf.{{ grains.os_family }}
+ - template: jinja
+{%- endif %}
diff --git a/glance/upgrade/service_running.sls b/glance/upgrade/service_running.sls
new file mode 100644
index 0000000..a188835
--- /dev/null
+++ b/glance/upgrade/service_running.sls
@@ -0,0 +1,19 @@
+{%- from "glance/map.jinja" import server,upgrade with context %}
+
+glance_task_service_running:
+ test.show_notification:
+ - text: "Running glance.upgrade.service_running"
+
+{%- if server.enabled %}
+ {%- set gservices = server.services %}
+ {%- if upgrade.new_release in ['newton','ocata'] %}
+ {%- do gservices.append('glance-glare') %}
+ {%- endif %}
+
+ {%- for gservice in gservices %}
+glance_running_stopped_{{ gservice }}:
+ service.running:
+ - name: {{ gservice }}
+ - enable: True
+ {%- endfor %}
+{%- endif %}
diff --git a/glance/upgrade/service_stopped.sls b/glance/upgrade/service_stopped.sls
new file mode 100644
index 0000000..3778ee7
--- /dev/null
+++ b/glance/upgrade/service_stopped.sls
@@ -0,0 +1,19 @@
+{%- from "glance/map.jinja" import server,upgrade with context %}
+
+glance_task_service_stopped:
+ test.show_notification:
+ - text: "Running glance.upgrade.service_stopped"
+
+{%- if server.enabled %}
+ {%- set gservices = server.services %}
+ {%- if upgrade.old_release in ['newton','ocata'] %}
+ {%- do gservices.append('glance-glare') %}
+ {%- endif %}
+
+ {%- for gservice in gservices %}
+glance_service_stopped_{{ gservice }}:
+ service.dead:
+ - name: {{ gservice }}
+ - enable: False
+ {%- endfor %}
+{%- endif %}
diff --git a/glance/upgrade/upgrade/init.sls b/glance/upgrade/upgrade/init.sls
new file mode 100644
index 0000000..2242144
--- /dev/null
+++ b/glance/upgrade/upgrade/init.sls
@@ -0,0 +1,8 @@
+{%- from "glance/map.jinja" import server with context %}
+
+include:
+ - glance.upgrade.service_stopped
+ - glance.upgrade.pkgs_latest
+ - glance.upgrade.render_config
+ - glance.db.offline_sync
+ - glance.upgrade.service_running
diff --git a/glance/upgrade/verify/api.sls b/glance/upgrade/verify/api.sls
new file mode 100644
index 0000000..e8fc0b5
--- /dev/null
+++ b/glance/upgrade/verify/api.sls
@@ -0,0 +1,62 @@
+{%- from "glance/map.jinja" import server with context %}
+{%- from "keystone/map.jinja" import client as kclient with context %}
+
+
+glance_upgrade_verify_api:
+ test.show_notification:
+ - text: "Running glance.upgrade.verify.api"
+
+{%- if kclient.enabled and kclient.get('os_client_config', {}).get('enabled', False) %}
+
+ {%- if server.get('version') not in ('mitaka', 'newton') %}
+ {%- set image_name = 'TestImage' %}
+ {%- set image_properties = "[{'op':'add', 'path':'/test_property', 'value': 'test'},]" %}
+glancev2_image_create:
+ module.run:
+ - name: glancev2.image_create
+ - kwargs:
+ container_format: bare
+ disk_format: qcow2
+ name: {{ image_name }}
+ cloud_name: admin_identity
+
+glancev2_image_list:
+ module.run:
+ - name: glancev2.image_list
+ - kwargs:
+ cloud_name: admin_identity
+ - require:
+ - glancev2_image_create
+
+glancev2_image_get_details:
+ module.run:
+ - name: glancev2.image_get_details
+ - args:
+ - {{ image_name }}
+ - kwargs:
+ cloud_name: admin_identity
+ - require:
+ - glancev2_image_list
+
+glancev2_image_update:
+ module.run:
+ - name: glancev2.image_update
+ - args:
+ - {{ image_name }}
+ - {{ image_properties }}
+ - kwargs:
+ cloud_name: admin_identity
+ - require:
+ - glancev2_image_get_details
+
+glancev2_image_delete:
+ module.run:
+ - name: glancev2.image_delete
+ - args:
+ - {{ image_name }}
+ - kwargs:
+ cloud_name: admin_identity
+ - require:
+ - glancev2_image_update
+ {%- endif %}
+{%- endif %}