Add 'manage_service_maintenance'. Don't manage services scheduling while upgrading.

For some special cases, don't manage services scheduling both enable and
disable before and after upgrade procedure.

Change-Id: I21ab967bc147c0404dae5b010b2009931307ceaf
Related-Prod: PROD-30156
diff --git a/README.rst b/README.rst
index 4fa35ec..7991408 100644
--- a/README.rst
+++ b/README.rst
@@ -176,6 +176,23 @@
         oslo_concurrency:
           lock_path: '/var/lock/manila'
 
+Don't manage services scheduling while upgrade
+----------------------------------------------
+For some special cases, don't manage services scheduling both enable and disable
+before and after upgrade procedure.
+
+If 'manage_service_maintenance: true' or not present - default behavior, disable services
+before upgrade and enable it after upgrade.
+If 'manage_service_maintenance: false' - don't disable and don't enable upgraded services
+scheduling before and after upgrade.
+
+.. code-block:: yaml
+
+    manila:
+      upgrade:
+        manage_service_maintenance: false
+
+
 More information
 ================
 
diff --git a/manila/upgrade/upgrade/post.sls b/manila/upgrade/upgrade/post.sls
index 83e9fd7..3fded0f 100644
--- a/manila/upgrade/upgrade/post.sls
+++ b/manila/upgrade/upgrade/post.sls
@@ -1,3 +1,5 @@
+{%- from "manila/map.jinja" import upgrade with context %}
+
 manila_upgrade_uprade_post:
   test.show_notification:
     - name: "dump_message_upgrade_manila_post"
@@ -6,6 +8,7 @@
 {% set host_id = salt['network.get_hostname']() %}
 
 {%- if pillar.manila.scheduler is defined %}
+  {%- if upgrade.get('manage_service_maintenance', true) %}
 
 # It turns on every manila-scheduler instances on the host.
 manila_controller_service_enabled:
@@ -15,9 +18,11 @@
   - name: {{ host_id }}
   - microversion: '2.40'
 
+  {%- endif %}
 {%- endif %}
 
 {%- if pillar.manila.share is defined %}
+  {%- if upgrade.get('manage_service_maintenance', true) %}
 
 # It turns on every manila-share instances on the host.
 manila_share_service_enabled:
@@ -27,4 +32,5 @@
   - name: {{ host_id }}
   - microversion: '2.40'
 
+  {%- endif %}
 {%- endif %}
diff --git a/manila/upgrade/upgrade/pre.sls b/manila/upgrade/upgrade/pre.sls
index f00b1f5..3b804ad 100644
--- a/manila/upgrade/upgrade/pre.sls
+++ b/manila/upgrade/upgrade/pre.sls
@@ -1,3 +1,5 @@
+{%- from "manila/map.jinja" import upgrade with context %}
+
 manila_upgrade_upgrade_pre:
   test.show_notification:
      - name: "dump_message_upgrade_manila_pre"
@@ -6,6 +8,7 @@
 {% set host_id = salt['network.get_hostname']() %}
 
 {%- if pillar.manila.scheduler is defined %}
+  {%- if upgrade.get('manage_service_maintenance', true) %}
 
 # It turns off every manila-scheduler instances on the host.
 manila_controller_service_disabled:
@@ -15,9 +18,11 @@
   - name: {{ host_id }}
   - microversion: '2.40'
 
+  {%- endif %}
 {%- endif %}
 
 {%- if pillar.manila.share is defined %}
+  {%- if upgrade.get('manage_service_maintenance', true) %}
 
 # It turns off every manila-share instances on the host.
 manila_share_service_disabled:
@@ -27,4 +32,5 @@
   - name: {{ host_id }}
   - microversion: '2.40'
 
+  {%- endif %}
 {%- endif %}