From 8d709b31a9e7d73deb0b0b93b974822a9d5535f0 Mon Sep 17 00:00:00 2001
From: Seungkyu Ahn <seungkyua@gmail.com>
Date: Thu, 26 Jul 2018 16:15:57 +0900
Subject: [PATCH] Fix ceph version check error in jewel version.

In a jewel version, egrep -c "12.2|luminous" returns "0",
but execution will be error.
So, add pipe and echo command to make a success.

Change-Id: I94f45855f6510e747884d8b6a629a62c3d96adbd
---
 ceph-client/values.yaml                          | 2 +-
 ceph-mon/values.yaml                             | 2 +-
 ceph-osd/values.yaml                             | 2 +-
 ceph-provisioners/values.yaml                    | 2 +-
 cinder/templates/bin/_backup-storage-init.sh.tpl | 2 +-
 cinder/templates/bin/_storage-init.sh.tpl        | 2 +-
 glance/templates/bin/_storage-init.sh.tpl        | 2 +-
 gnocchi/templates/bin/_storage-init.sh.tpl       | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/ceph-client/values.yaml b/ceph-client/values.yaml
index 3173ebbf72..66d6c5e51b 100644
--- a/ceph-client/values.yaml
+++ b/ceph-client/values.yaml
@@ -380,7 +380,7 @@ bootstrap:
     ceph -s
     function ensure_pool () {
       ceph osd pool stats $1 || ceph osd pool create $1 $2
-      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
       if [[ ${test_luminous} -gt 0 ]]; then
         ceph osd pool application enable $1 $3
       fi
diff --git a/ceph-mon/values.yaml b/ceph-mon/values.yaml
index c3f7eeef4d..d8aebb50f3 100644
--- a/ceph-mon/values.yaml
+++ b/ceph-mon/values.yaml
@@ -238,7 +238,7 @@ bootstrap:
     ceph -s
     function ensure_pool () {
       ceph osd pool stats $1 || ceph osd pool create $1 $2
-      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
       if [[ ${test_luminous} -gt 0 ]]; then
         ceph osd pool application enable $1 $3
       fi
diff --git a/ceph-osd/values.yaml b/ceph-osd/values.yaml
index ec51ae4eb3..7ee506b026 100644
--- a/ceph-osd/values.yaml
+++ b/ceph-osd/values.yaml
@@ -198,7 +198,7 @@ bootstrap:
     ceph -s
     function ensure_pool () {
       ceph osd pool stats $1 || ceph osd pool create $1 $2
-      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
       if [[ ${test_luminous} -gt 0 ]]; then
         ceph osd pool application enable $1 $3
       fi
diff --git a/ceph-provisioners/values.yaml b/ceph-provisioners/values.yaml
index f72b18a346..2b8fd166e7 100644
--- a/ceph-provisioners/values.yaml
+++ b/ceph-provisioners/values.yaml
@@ -161,7 +161,7 @@ bootstrap:
     ceph -s
     function ensure_pool () {
       ceph osd pool stats $1 || ceph osd pool create $1 $2
-      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+      local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
       if [[ ${test_luminous} -gt 0 ]]; then
         ceph osd pool application enable $1 $3
       fi
diff --git a/cinder/templates/bin/_backup-storage-init.sh.tpl b/cinder/templates/bin/_backup-storage-init.sh.tpl
index 2c619d060f..a932ef39b9 100644
--- a/cinder/templates/bin/_backup-storage-init.sh.tpl
+++ b/cinder/templates/bin/_backup-storage-init.sh.tpl
@@ -34,7 +34,7 @@ elif [ "x$STORAGE_BACKEND" == "xcinder.backup.drivers.ceph" ]; then
   ceph -s
   function ensure_pool () {
     ceph osd pool stats $1 || ceph osd pool create $1 $2
-    local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+    local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
     if [[ ${test_luminous} -gt 0 ]]; then
       ceph osd pool application enable $1 $3
     fi
diff --git a/cinder/templates/bin/_storage-init.sh.tpl b/cinder/templates/bin/_storage-init.sh.tpl
index ed3ec0a8d1..9bea1f9c02 100644
--- a/cinder/templates/bin/_storage-init.sh.tpl
+++ b/cinder/templates/bin/_storage-init.sh.tpl
@@ -31,7 +31,7 @@ if [ "x$STORAGE_BACKEND" == "xcinder.volume.drivers.rbd.RBDDriver" ]; then
   ceph -s
   function ensure_pool () {
     ceph osd pool stats $1 || ceph osd pool create $1 $2
-    local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+    local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
     if [[ ${test_luminous} -gt 0 ]]; then
       ceph osd pool application enable $1 $3
     fi
diff --git a/glance/templates/bin/_storage-init.sh.tpl b/glance/templates/bin/_storage-init.sh.tpl
index 4dd5aad6d9..4082c5222b 100644
--- a/glance/templates/bin/_storage-init.sh.tpl
+++ b/glance/templates/bin/_storage-init.sh.tpl
@@ -43,7 +43,7 @@ elif [ "x$STORAGE_BACKEND" == "xrbd" ]; then
   function ensure_pool () {
     ceph osd pool stats "$1" || ceph osd pool create "$1" "$2"
     local test_luminous
-    test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+    test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
     if [[ ${test_luminous} -gt 0 ]]; then
       ceph osd pool application enable "$1" "$3"
     fi
diff --git a/gnocchi/templates/bin/_storage-init.sh.tpl b/gnocchi/templates/bin/_storage-init.sh.tpl
index 6eb9f72bf7..6013b01574 100644
--- a/gnocchi/templates/bin/_storage-init.sh.tpl
+++ b/gnocchi/templates/bin/_storage-init.sh.tpl
@@ -28,7 +28,7 @@ set -ex
 ceph -s
 function ensure_pool () {
   ceph osd pool stats $1 || ceph osd pool create $1 $2
-  local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous")
+  local test_luminous=$(ceph tell osd.* version | egrep -c "12.2|luminous" | xargs echo)
   if [[ ${test_luminous} -gt 0 ]]; then
     ceph osd pool application enable $1 $3
   fi