Skip to content

Commit

Permalink
Small "ovirt_disk" fixes.
Browse files Browse the repository at this point in the history
1. Improve "ovirt_disk::id" description to specify that "alias"
is also an option. This also makes the description to be consistent
with the "ovirt_disk::name" description.
2. Fixing warnings:
  a. Redundant "ssl" import causing "Unused import statement 'import ssl'".
  b. Several "Local variable 'XYZ' value is not used".
  c. Several "Shadows name 'disk' from outer scope".

Signed-off-by: Pavel Bar <pbar@redhat.com>
  • Loading branch information
barpavel authored and mwperina committed Nov 15, 2022
1 parent 61636bb commit 1476294
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions plugins/modules/ovirt_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
options:
id:
description:
- "ID of the disk to manage. Either C(id) or C(name) is required."
- "ID of the disk to manage. Either C(id) or C(name)/C(alias) is required."
type: str
name:
description:
Expand Down Expand Up @@ -373,7 +373,6 @@

import json
import os
import ssl
import subprocess
import time
import traceback
Expand Down Expand Up @@ -552,8 +551,8 @@ def finalize_transfer(connection, module, transfer_id):


def download_disk_image(connection, module):
transfers_service = connection.system_service().image_transfers_service()
hosts_service = connection.system_service().hosts_service()
connection.system_service().image_transfers_service()
connection.system_service().hosts_service()
transfer = start_transfer(connection, module, otypes.ImageTransferDirection.DOWNLOAD)
try:
extra_args = {}
Expand All @@ -579,8 +578,8 @@ def download_disk_image(connection, module):


def upload_disk_image(connection, module):
transfers_service = connection.system_service().image_transfers_service()
hosts_service = connection.system_service().hosts_service()
connection.system_service().image_transfers_service()
connection.system_service().hosts_service()
transfer = start_transfer(connection, module, otypes.ImageTransferDirection.UPLOAD)
try:
extra_args = {}
Expand Down Expand Up @@ -715,9 +714,9 @@ def update_storage_domains(self, disk_id):
action='copy',
entity=disk,
action_condition=(
lambda disk: new_disk_storage.id not in [sd.id for sd in disk.storage_domains]
lambda d: new_disk_storage.id not in [sd.id for sd in d.storage_domains]
),
wait_condition=lambda disk: disk.status == otypes.DiskStatus.OK,
wait_condition=lambda d: d.status == otypes.DiskStatus.OK,
storage_domain=otypes.StorageDomain(
id=new_disk_storage.id,
),
Expand Down Expand Up @@ -857,7 +856,6 @@ def main():
check_params(module)

try:
disk = None
state = module.params['state']
auth = module.params.get('auth')
connection = create_connection(auth)
Expand Down

0 comments on commit 1476294

Please sign in to comment.