From: Vladimir Khlyunev Date: Mon, 25 Apr 2022 17:21:33 +0000 (+0400) Subject: Cycle all attachments while cleaninig up volumes X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=ae2ae6d03907bdd6d5ad814d07b3d5b93f51b3f9;p=tools%2Fsustaining.git Cycle all attachments while cleaninig up volumes Change-Id: I12f6dffae4b3daaab0c7055588d49ae0390bba8b --- diff --git a/os_cloud_cleaner/os_connector.py b/os_cloud_cleaner/os_connector.py index d45779e..2277014 100644 --- a/os_cloud_cleaner/os_connector.py +++ b/os_cloud_cleaner/os_connector.py @@ -122,6 +122,10 @@ class OpenStackActions(object): def get_volume(self, uuid): return self.cinder.volumes.get(uuid) + def get_volume_attachments(self, volume_uuid): + volume = self.cinder.volumes.get(volume_uuid) + return volume.attachments + def get_keypairs(self): keypairs = self.nova.keypairs.list() resp = [] @@ -381,8 +385,9 @@ class OpenStackActions(object): existing_volumes.append(uuid) for uuid in existing_volumes: if self.check_volume_attached(uuid): - logger.info("Detaching volume {}".format(uuid)) - self.cinder.volumes.detach(uuid) + for attachment in self.get_volume_attachments(uuid): + logger.info("Detaching volume {}".format(uuid)) + self.cinder.volumes.detach(uuid, attachment['attachment_id']) try: helpers.wait_false(self.check_any_volume_attached, interval=3,