From eea490e604dea4e0f93c8429551dc39c1c1b4bfc Mon Sep 17 00:00:00 2001
From: Paul Bourke <paul.bourke@oracle.com>
Date: Fri, 24 Feb 2017 18:07:30 +0000
Subject: [PATCH] Update cinder sanity check to use built in shade

The current module 'kolla_sanity' was written as a shim before full
shade support was added to Ansible. This should now no longer be needed,
we can implement the checks using Ansible provided modules.

Change-Id: If212243e42615d7725201ee577bec40a1305887d
Depends-On: I6e3f4b72243da1cfa76d32822ec4f75f689f7317
Partially-implements: blueprint sanity-check-container
---
 ansible/roles/cinder/tasks/check.yml | 36 +++++++++++++++-------------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/ansible/roles/cinder/tasks/check.yml b/ansible/roles/cinder/tasks/check.yml
index c4f9065508..939ca6d34c 100644
--- a/ansible/roles/cinder/tasks/check.yml
+++ b/ansible/roles/cinder/tasks/check.yml
@@ -1,19 +1,23 @@
 ---
-- name: Cinder sanity checks
-  command: docker exec -t kolla_toolbox /usr/bin/ansible localhost
-    -m kolla_sanity
-    -a "service=cinder
-        project=service
-        user={{ openstack_auth.username }}
-        password={{ cinder_keystone_password }}
-        role=admin
-        region_name={{ openstack_region_name }}
-        auth={{ '{{ openstack_cinder_auth }}' }}"
-    -e "{'openstack_cinder_auth':{{ openstack_cinder_auth }}}"
-  register: cinder_sanity
-  changed_when: "{{ cinder_sanity.stdout.find('localhost | SUCCESS => ') != -1 and (cinder_sanity.stdout.split('localhost | SUCCESS => ')[1]|from_json).changed }}"
-  until: cinder_sanity.stdout.split()[2] == 'SUCCESS'
-  retries: 10
-  delay: 5
+- name: Cinder sanity check - create volume
+  kolla_toolbox:
+    module_name: os_volume
+    module_args:
+      auth: "{{ openstack_cinder_auth }}"
+      state: present
+      size: 1
+      display_name: kolla_test_volume
   run_once: True
+  delegate_to: "{{ groups['cinder-api'][0] }}"
+  when: kolla_enable_sanity_cinder | bool
+
+- name: Cinder sanity check - cleanup volume
+  kolla_toolbox:
+    module_name: os_volume
+    module_args:
+      auth: "{{ openstack_cinder_auth }}"
+      state: absent
+      display_name: kolla_test_volume
+  run_once: True
+  delegate_to: "{{ groups['cinder-api'][0] }}"
   when: kolla_enable_sanity_cinder | bool