Change in ovirt-engine-cli[master]: cli: Check existence of collection before adding

Michael Pasternak has submitted this change and it was merged. Change subject: cli: Check existence of collection before adding ...................................................................... cli: Check existence of collection before adding Currently when the user types a command that contains a wrong subcollection name we try to find the corresponding subcollection appending "s" to the name given by the user and using it to call the "getattr" method on the object. This fails with an internal Python error message. For example, if the user types the following command: # add snapshots --description 'My snap' --vm-identifier myvm The resulting message is the following: unknown error: 'VM' object has no attribute 'snapshotss' This happens because we are not checking with "hasattr" before calling "getattr". This patch changes the add action implementation so that it checks for the existence of the subcollection before trying to get it. The result will be just a more meaningful message: error: cannot create "snapshots" because snapshotss collection is not available or given arguments not valid. This is the same behaviour that we currently have for top level collections. Change-Id: I435314037808b99fe947ceded6d75e3129fa78e6 Bug-Url: https://bugzilla.redhat.com/1043500 Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com> --- M src/ovirtcli/command/add.py 1 file changed, 2 insertions(+), 2 deletions(-) Approvals: Michael Pasternak: Looks good to me, approved Juan Hernandez: Verified Allon Mureinik: Looks good to me, but someone else must approve -- To view, visit http://gerrit.ovirt.org/23557 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: merged Gerrit-Change-Id: I435314037808b99fe947ceded6d75e3129fa78e6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine-cli Gerrit-Branch: master Gerrit-Owner: Juan Hernandez <juan.hernandez@redhat.com> Gerrit-Reviewer: Allon Mureinik <amureini@redhat.com> Gerrit-Reviewer: Juan Hernandez <juan.hernandez@redhat.com> Gerrit-Reviewer: Michael Pasternak <mishka8520@yahoo.com> Gerrit-Reviewer: Ravi Nori <rnori@redhat.com>
participants (1)
-
mishka8520@yahoo.com