From b627ccb68689945f97cf74fdfc0911d59903dcef Mon Sep 17 00:00:00 2001
From: Lee Yarwood <lyarwood@redhat.com>
Date: Mon, 4 Dec 2017 12:10:33 +0000
Subject: [PATCH] ffu: Introduce Swift fast-forward upgrade tasks

fast_forward_upgrade_tasks for swift covering Ocata and Pike.
- Service status check
- Stop service when updating from Ocata to Pike
- Update swift packages

bp fast-forward-upgrades
Change-Id: I66879669cead2f7b5b2cd1398f344c063d771628
---
 docker/services/swift-proxy.yaml   | 15 +++++++++++++
 docker/services/swift-storage.yaml | 34 ++++++++++++++++++++++++++++++
 2 files changed, 49 insertions(+)

diff --git a/docker/services/swift-proxy.yaml b/docker/services/swift-proxy.yaml
index 35d340ccb9..661b2b1902 100644
--- a/docker/services/swift-proxy.yaml
+++ b/docker/services/swift-proxy.yaml
@@ -180,3 +180,18 @@ outputs:
             - remove_swift_proxy_package|bool
       metadata_settings:
         get_attr: [SwiftProxyBase, role_data, metadata_settings]
+      fast_forward_upgrade_tasks:
+        - name: Check if swift-proxy or swift-object-expirer are deployed
+          command: systemctl is-enabled --quiet "{{ item }}"
+          register: swift_proxy_services_enabled
+          with_items:
+            - openstack-swift-proxy
+            - openstack-swift-object-expirer
+          ignore_errors: True
+        - name: Stop swift-proxy and swift-object-expirer services
+          service: name={{ item.item }} state=stopped enabled=no
+          with_items: "{{ swift_proxy_services_enabled.results }}"
+          when:
+            - step|int == 2
+            - release == 'ocata'
+            - item.rc == 0
diff --git a/docker/services/swift-storage.yaml b/docker/services/swift-storage.yaml
index b9ada58e2a..810e6f31bf 100644
--- a/docker/services/swift-storage.yaml
+++ b/docker/services/swift-storage.yaml
@@ -538,3 +538,37 @@ outputs:
           file:
             path: /var/run/rsyncd.pid
             state: absent
+      fast_forward_upgrade_tasks:
+        - name: Check if swift storage services are deployed
+          command: systemctl is-enabled --quiet "{{ item }}"
+          register: swift_services_enabled
+          with_items:
+            - openstack-swift-account-auditor
+            - openstack-swift-account-reaper
+            - openstack-swift-account-replicator
+            - openstack-swift-account
+            - openstack-swift-container-auditor
+            - openstack-swift-container-replicator
+            - openstack-swift-container-updater
+            - openstack-swift-container
+            - openstack-swift-object-auditor
+            - openstack-swift-object-replicator
+            - openstack-swift-object-updater
+            - openstack-swift-object
+          ignore_errors: True
+        - name: Stop swift storage services
+          service: name={{ item.item }} state=stopped enabled=no
+          with_items: "{{ swift_services_enabled.results }}"
+          when:
+            - step|int == 2
+            - release == 'ocata'
+            - item.rc == 0
+        - name: Update swift storage services
+          yum: name={{ item }} state=latest
+          with_items:
+            - openstack-swift-container
+            - openstack-swift-object
+            - openstack-swift-account
+          when:
+            - step|int == 6
+            - is_bootstrap_node|bool