try:
result = cloud.delete_image(image.name)
except OpenStackCloudException as e:
- if str(e).startswith("Multiple matches found for"):
- log.warning("{}. Skipping image...".format(str(e)))
+ error_msg = str(e)
+ if error_msg.startswith("Multiple matches found for") or error_msg.startswith(
+ "More than one Image exists with the name"
+ ):
+ log.warning("{}. Skipping image...".format(error_msg))
continue
else:
- log.error("Unexpected exception: {}".format(str(e)))
+ log.error("Unexpected exception: {}".format(error_msg))
raise
if not result:
"""Filter server data and return list."""
filtered = []
for server in servers:
- if days and (datetime.strptime(server.created, "%Y-%m-%dT%H:%M:%SZ") >= datetime.now() - timedelta(days=days)):
+ if days and (
+ datetime.strptime(server.created_at, "%Y-%m-%dT%H:%M:%SZ") >= datetime.now() - timedelta(days=days)
+ ):
continue
filtered.append(server)
print("ERROR: Server not found.")
sys.exit(1)
- if datetime.strptime(server.created, "%Y-%m-%dT%H:%M:%SZ") >= datetime.utcnow() - timedelta(minutes=minutes):
+ if datetime.strptime(server.created_at, "%Y-%m-%dT%H:%M:%SZ") >= datetime.utcnow() - timedelta(minutes=minutes):
print('WARN: Server "{}" is not older than {} minutes.'.format(server.name, minutes))
else:
cloud.delete_server(server.name)
try:
result = cloud.delete_volume(volume.name)
except OpenStackCloudException as e:
- if str(e).startswith("Multiple matches found for"):
- print("WARNING: {}. Skipping volume...".format(str(e)))
+ error_msg = str(e)
+ if error_msg.startswith("Multiple matches found for") or error_msg.startswith(
+ "More than one Volume exists with the name"
+ ):
+ print("WARNING: {}. Skipping volume...".format(error_msg))
continue
else:
- print("ERROR: Unexpected exception: {}".format(str(e)))
+ print("ERROR: Unexpected exception: {}".format(error_msg))
raise
if not result:
"tabulate",
"toml",
"tqdm",
- "urllib3<2.1.0",
+ "urllib3>=1.26.15,<3.0.0",
"websocket-client",
"wrapt",
"xdg"