Disable zone checking by default

In some upgrade scenarios zones and tlds creation maybe restricted,
patch adds ability to define any zone from pillar and disbales
zone creation verification by default.

Change-Id: Ic679fad641526fd47b7656cb24b7d3149639bdd7
Related-Prod: https://mirantis.jira.com/browse/PROD-25873
diff --git a/README.rst b/README.rst
index 5c1e46d..5dd98dd 100644
--- a/README.rst
+++ b/README.rst
@@ -268,6 +268,85 @@
             name: test.zone.
             email: admin@test.zone
 
+Upgrades
+========
+
+Each openstack formula provide set of phases (logical bloks) that will help to
+build flexible upgrade orchestration logic for particular components. The list
+of phases might and theirs descriptions are listed in table below:
+
++-------------------------------+------------------------------------------------------+
+| State                         | Description                                          |
++===============================+======================================================+
+| <app>.upgrade.service_running | Ensure that all services for particular application  |
+|                               | are enabled for autostart and running                |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.service_stopped | Ensure that all services for particular application  |
+|                               | disabled for autostart and dead                      |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.pkgs_latest     | Ensure that packages used by particular application  |
+|                               | are installed to latest available version.           |
+|                               | This will not upgrade data plane packages like qemu  |
+|                               | and openvswitch as usually minimal required version  |
+|                               | in openstack services is really old. The data plane  |
+|                               | packages should be upgraded separately by `apt-get   |
+|                               | upgrade` or `apt-get dist-upgrade`                   |
+|                               | Applying this state will not autostart service.      |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.render_config   | Ensure configuration is rendered actual version.     +
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.pre             | We assume this state is applied on all nodes in the  |
+|                               | cloud before running upgrade.                        |
+|                               | Only non destructive actions will be applied during  |
+|                               | this phase. Perform service built in service check   |
+|                               | like (keystone-manage doctor and nova-status upgrade)|
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.upgrade.pre     | Mostly applicable for data plane nodes. During this  |
+|                               | phase resources will be gracefully removed from      |
+|                               | current node if it is allowed. Services for upgraded |
+|                               | application will be set to admin disabled state to   |
+|                               | make sure node will not participate in resources     |
+|                               | scheduling. For example on gtw nodes this will set   |
+|                               | all agents to admin disable state and will move all  |
+|                               | routers to other agents.                             |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.upgrade         | This state will basically upgrade application on     |
+|                               | particular target. Stop services, render             |
+|                               | configuration, install new packages, run offline     |
+|                               | dbsync (for ctl), start services. Data plane should  |
+|                               | not be affected, only OpenStack python services.     |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.upgrade.post    | Add services back to scheduling.                     |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.post            | This phase should be launched only when upgrade of   |
+|                               | the cloud is completed. Cleanup temporary files,     |
+|                               | perform other post upgrade tasks.                    |
++-------------------------------+------------------------------------------------------+
+| <app>.upgrade.verify          | Here we will do basic health checks (API CRUD        |
+|                               | operations, verify do not have dead network          |
+|                               | agents/compute services)                             |
++-------------------------------+------------------------------------------------------+
+
+
+Upgrade pillar example:
+
+.. code-block:: yaml
+
+designate:
+  upgrade:
+    enabled: true
+    old_release: pike
+    new_release: queens
+    verify:
+      zone:
+        enabled: true
+        name: upgradetest.com.
+
+.. note::
+   During upgrade zone creation testing is disabled by default,
+   because conditions for zone successfull creation, are very specific to each environment.
+   When enabling zone testing, allowed tlds in Designate should be considered.
+   More details about TLDS - https://docs.openstack.org/designate/pike/admin/tlds.html
 
 Documentation and Bugs
 ======================
diff --git a/designate/map.jinja b/designate/map.jinja
index e103006..614aaee 100644
--- a/designate/map.jinja
+++ b/designate/map.jinja
@@ -125,4 +125,13 @@
     },
 }, merge=pillar.designate.get('client', {})) %}
 
-{% set upgrade = pillar.get('designate', {}).get('upgrade', {}) %}
+{% set upgrade = salt['grains.filter_by']({
+    'default': {
+        'verify': {
+            'zone': {
+                 'enabled': false,
+                 'name': 'upgradetest.com.'
+            },
+        },
+    },
+}, merge=pillar.designate.get('upgrade', {}), base='default') %}
diff --git a/designate/upgrade/verify/_api.sls b/designate/upgrade/verify/_api.sls
index 927f4e1..9a8e4a3 100644
--- a/designate/upgrade/verify/_api.sls
+++ b/designate/upgrade/verify/_api.sls
@@ -1,4 +1,4 @@
-{%- from "designate/map.jinja" import server with context %}
+{%- from "designate/map.jinja" import server,upgrade with context %}
 
 designate_upgrade_verify_api:
   test.show_notification:
@@ -6,36 +6,37 @@
     - text: "Running designate.upgrade.verify.api"
 
 {%- if server.get('role', 'primary') == 'primary' %}
-{% set Designate_Test_Zone = 'upgradetest.tld.' %}
+  {%- if upgrade.verify.zone.enabled %}
+
 designatev2_zone_present:
   designatev2.zone_present:
   - cloud_name: admin_identity
-  - name: {{ Designate_Test_Zone }}
+  - name: {{ upgrade.verify.zone.name }}
   - email: 'example@doc.com'
 
-designatev2_zone_list:
-  module.run:
-    - name: designatev2.zone_list
-    - kwargs:
-        cloud_name: admin_identity
-
 designatev2_zone_get_details:
   module.run:
     - name: designatev2.zone_get_details
     - kwargs:
         cloud_name: admin_identity
-        zone_id: {{ Designate_Test_Zone }}
+        zone_id: {{ upgrade.verify.zone.name }}
 
 designatev2_zone_get_name_servers:
   module.run:
     - name: designatev2.zone_get_name_servers
     - kwargs:
         cloud_name: admin_identity
-        zone_id: {{ Designate_Test_Zone }}
-
+        zone_id: {{ upgrade.verify.zone.name }}
 
 designatev2_zone_absent:
   designatev2.zone_absent:
   - cloud_name: admin_identity
-  - name: {{ Designate_Test_Zone }}
-{%- endif %}
\ No newline at end of file
+  - name: {{ upgrade.verify.zone.name }}
+  {%- endif %}
+
+designatev2_zone_list:
+  module.run:
+    - name: designatev2.zone_list
+    - kwargs:
+        cloud_name: admin_identity
+{%- endif %}