Browse Source

enough: adapt to new format of openstack volume snapshot list

Volumes is the ID of the volume instead of its name
keep-around/37eaf5f74d6fd4bfae79473351004b6323b5f21b
Loïc Dachary 1 year ago
parent
commit
37eaf5f74d
Signed by: dachary GPG Key ID: 992D23B392F9E4F2
  1. 6
      enough/common/openstack.py

6
enough/common/openstack.py

@ -519,7 +519,7 @@ class OpenStack(OpenStackBase):
r = self.o.volume.snapshot.list(
'--format=json', '--long', '-c', 'Volume', '--limit', '5000')
volumes_with_snapshots = set([x["Volume"] for x in json.loads(r.stdout)])
r = self.o.volume.list('--format=json', '-c', 'Name', '--limit', '5000')
r = self.o.volume.list('--format=json', '-c', 'Name', '-c', 'ID', '--limit', '5000')
before = (datetime.datetime.today() - datetime.timedelta(days)).strftime('%Y-%m-%d')
info = {
'no_date_prefix': [],
@ -527,9 +527,9 @@ class OpenStack(OpenStackBase):
'deleted': [],
'recent': [],
}
for volume in set([x["Name"] for x in json.loads(r.stdout)]):
for volume, volume_id in set([(x["Name"], x["ID"]) for x in json.loads(r.stdout)]):
if re.match(r'^\d\d\d\d\-\d\d-\d\d-', volume):
if volume in volumes_with_snapshots:
if volume_id in volumes_with_snapshots:
info['has_snapshots'].append(volume)
elif volume[:10] < before:
self.o.volume.delete(volume)

Loading…
Cancel
Save