Add Ironic pinning support

The patch adds pinning support which is
mandatory for upgrades

Change-Id: Ifea1f5133a0c71e2ff62bf61f69d658b9c816cb6
Related-PROD: PROD-21936
diff --git a/ironic/files/pike/ironic.conf b/ironic/files/pike/ironic.conf
index 3083ce9..9066e2d 100644
--- a/ironic/files/pike/ironic.conf
+++ b/ironic/files/pike/ironic.conf
@@ -1,4 +1,4 @@
-{%- from "ironic/map.jinja" import api,conductor with context -%}
+{%- from "ironic/map.jinja" import api,conductor,upgrade with context -%}
 {%- if api.get("enabled", False) %}
   {%- set ironic = api %}
 {%- elif conductor.get('enabled', False) %}
@@ -454,6 +454,20 @@
 # value)
 # host = localhost
 
+# Used for rolling upgrades. Setting this option downgrades
+# (or pins) the internal ironic RPC communication and database
+# objects to their respective versions, so they are compatible
+# with older services. When doing a rolling upgrade from
+# version N to version N+1, set (to pin) this to N. To unpin
+# (default), leave it unset and the latest versions of RPC
+# communication and database objects will be used. (string
+# value)
+# Allowed values: pike, ocata, 9.1, 9.0, 8.0, 7.0
+#pin_release_version = <None>
+{%- if upgrade.get('enabled', False) %}
+pin_release_version = {{ upgrade.old_release }}
+{%- endif %}
+
 # Path to the rootwrap configuration file to use for running
 # commands as root. (string value)
 #rootwrap_config = /etc/ironic/rootwrap.conf
diff --git a/ironic/files/queens/ironic.conf b/ironic/files/queens/ironic.conf
index c302819..207032b 100644
--- a/ironic/files/queens/ironic.conf
+++ b/ironic/files/queens/ironic.conf
@@ -1,4 +1,4 @@
-{%- from "ironic/map.jinja" import api,conductor with context -%}
+{%- from "ironic/map.jinja" import api,conductor,upgrade with context -%}
 {%- if api.get("enabled", False) %}
   {%- set ironic = api %}
 {%- elif conductor.get('enabled', False) %}
@@ -534,6 +534,9 @@
 # 10.1 - <No description provided>
 # 10.0 - <No description provided>
 #pin_release_version = <None>
+{%- if upgrade.get('enabled', False) %}
+pin_release_version = {{ upgrade.old_release }}
+{%- endif %}
 
 # Path to the rootwrap configuration file to use for running
 # commands as root. (string value)
diff --git a/ironic/map.jinja b/ironic/map.jinja
index 4e86047..a82a3c6 100644
--- a/ironic/map.jinja
+++ b/ironic/map.jinja
@@ -83,3 +83,5 @@
 
 {%set deploy = pillar.ironic.get('deploy', {'enabled': false})%}
 {% set ironic = pillar.get('ironic', {}) %}
+
+{% set upgrade = pillar.get('ironic', {}).get('upgrade', {}) %}