
Cinder volume services will perform cleanup on start, but when we have multiple volume services grouped in a cluster, we may want to trigger cleanup of services that are down. This patch adds command `work-cleanup` to trigger server cleanups and prints service nodes that will be cleaned and those that didn't have an alternative service in the cluster to do the cleanup. This command will only work on servers supporting API version 3.24 or higher. New command: cinder work-cleanup [--cluster <cluster-name>] [--host <hostname>] [--binary <binary>] [--is-up <True|true|False|false>] [--disabled <True|true|False|false>] [--resource-id <resource-id>] [--resource-type <Volume|Snapshot>] Specs: https://specs.openstack.org/openstack/cinder-specs/specs/newton/ha-aa-cleanup.html Change-Id: I1c33ffbffcb14f34ee2bda9042e706937b1147d7 Depends-On: If336b6569b171846954ed6eb73f5a4314c6c7e2e Implements: blueprint cinder-volume-active-active-support
45 lines
1.5 KiB
Python
45 lines
1.5 KiB
Python
# Copyright (c) 2016 Red Hat, Inc.
|
|
# All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
"""
|
|
Interface to workers API
|
|
"""
|
|
from cinderclient.apiclient import base as common_base
|
|
from cinderclient import base
|
|
|
|
|
|
class Service(base.Resource):
|
|
def __repr__(self):
|
|
return "<Service (%s): %s in cluster %s>" % (self.id, self.host,
|
|
self.cluster_name or '-')
|
|
|
|
@classmethod
|
|
def list_factory(cls, mngr, elements):
|
|
return [cls(mngr, element, loaded=True) for element in elements]
|
|
|
|
|
|
class WorkerManager(base.Manager):
|
|
base_url = '/workers'
|
|
|
|
def clean(self, **filters):
|
|
url = self.base_url + '/cleanup'
|
|
resp, body = self.api.client.post(url, body=filters)
|
|
|
|
cleaning = Service.list_factory(self, body['cleaning'])
|
|
unavailable = Service.list_factory(self, body['unavailable'])
|
|
|
|
result = common_base.TupleWithMeta((cleaning, unavailable), resp)
|
|
return result
|