Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

add "if" conditional to avoid looping with a non-existent attribute #737

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Trenthani
Copy link

@Trenthani Trenthani commented Jan 13, 2021

To help us process your pull request efficiently, please include:

  • Added in a hasattr check for the list_virtual_hardware_section. Current behaviour, when running the function with a VM without any disk's an AttributeError is returned. This changes avoids the error and in turn returns no results.

  • Testing:
    code snip

def __init__(self, client, vm):
       self.obj = VM(client=client, resource=vm)
       self.vm_resources = self.obj.get_resource()
       virtual_hardware = \
           self.obj.list_virtual_hardware_section(
               is_cpu=True,
               is_memory=True,
               is_disk=True,
               is_media=True,
               is_networkCards=True
               )

Before the change on a vm with no disk, AttributeError was returned.

After, no excetions were raised and the correct info returned.


This change is Reviewable

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant