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 <[email protected]>
---
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 <[email protected]>
Gerrit-Reviewer: Allon Mureinik <[email protected]>
Gerrit-Reviewer: Juan Hernandez <[email protected]>
Gerrit-Reviewer: Michael Pasternak <[email protected]>
Gerrit-Reviewer: Ravi Nori <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to