Skip to content

Commit

Permalink
Fix f-strings for one_image
Browse files Browse the repository at this point in the history
  • Loading branch information
abakanovskii committed Sep 20, 2024
1 parent 2d3abbf commit 5f46d7d
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions plugins/modules/one_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,9 @@ def run(self, one, module, result):
if not image and desired_state != 'absent':
# Using 'if id:' doesn't work properly when id=0
if id is not None:
module.fail_json(msg=f"There is no image with id={id}")
module.fail_json(msg="There is no image with id=" + str(id))
elif name is not None:
module.fail_json(msg=f"There is no image with name={name}")
module.fail_json(msg="There is no image with name=" + name)

if desired_state == 'absent':
self.result = self.delete_image(image)
Expand Down Expand Up @@ -473,7 +473,7 @@ def wait_for_ready(self, image_id, wait_timeout=60):
state = image.STATE

if state in [IMAGE_STATES.index('ERROR')]:
self.module.fail_json(msg=f"Got an ERROR state: {image.TEMPLATE['ERROR']}")
self.module.fail_json(msg="Got an ERROR state: " + image.TEMPLATE['ERROR'])

if state in [IMAGE_STATES.index('READY')]:
return True
Expand Down Expand Up @@ -511,9 +511,9 @@ def enable_image(self, image, enable):

if state not in [IMAGE_STATES.index('READY'), IMAGE_STATES.index('DISABLED'), IMAGE_STATES.index('ERROR')]:
if enable:
self.module.fail_json(msg=f"Cannot enable {IMAGE_STATES[state]} image!")
self.module.fail_json(msg="Cannot enable " + IMAGE_STATES[state] + " image!")
else:
self.module.fail_json(msg=f"Cannot disable {IMAGE_STATES[state]} image!")
self.module.fail_json(msg="Cannot disable " + IMAGE_STATES[state] + " image!")

if ((enable and state != IMAGE_STATES.index('READY')) or
(not enable and state != IMAGE_STATES.index('DISABLED'))):
Expand All @@ -535,9 +535,9 @@ def change_persistence(self, image, enable):

if state not in [IMAGE_STATES.index('READY'), IMAGE_STATES.index('DISABLED'), IMAGE_STATES.index('ERROR')]:
if enable:
self.module.fail_json(msg=f"Cannot enable persistence for {IMAGE_STATES[state]} image!")
self.module.fail_json(msg="Cannot enable persistence for " + IMAGE_STATES[state] + " image!")
else:
self.module.fail_json(msg=f"Cannot disable persistence {IMAGE_STATES[state]} image!")
self.module.fail_json(msg="Cannot disable persistence for " + IMAGE_STATES[state] + " image!")

if ((enable and state != IMAGE_STATES.index('READY')) or
(not enable and state != IMAGE_STATES.index('DISABLED'))):
Expand All @@ -553,7 +553,7 @@ def change_persistence(self, image, enable):

def clone_image(self, image, new_name):
if new_name is None:
new_name = f"Copy of {image.NAME}"
new_name = "Copy of " + image.NAME

tmp_image = self.get_image_by_name(new_name)
if tmp_image:
Expand Down Expand Up @@ -585,7 +585,7 @@ def rename_image(self, image, new_name):

tmp_image = self.get_image_by_name(new_name)
if tmp_image:
self.module.fail_json(msg=f"Name '{new_name}' is already taken by IMAGE with id={tmp_image.ID}")
self.module.fail_json(msg="Name '" + new_name + "' is already taken by IMAGE with id=" + str(tmp_image.ID))

if not self.module.check_mode:
self.one.image.rename(image.ID, new_name)
Expand All @@ -599,7 +599,7 @@ def delete_image(self, image):
return {'changed': False}

if image.RUNNING_VMS > 0:
self.module.fail_json(msg=f"Cannot delete image. There are {image.RUNNING_VMS} VMs using it.")
self.module.fail_json(msg="Cannot delete image. There are " + str(image.RUNNING_VMS) + " VMs using it.")

if not self.module.check_mode:
self.one.image.delete(image.ID)
Expand Down

0 comments on commit 5f46d7d

Please sign in to comment.