[libvirt] [test-API PATCH 7/7] domain/[start|destroy]: Add a optional noping flag to skip the ping test
Martin Kletzander
mkletzan at redhat.com
Thu Mar 22 07:02:54 UTC 2012
On 03/21/2012 06:13 PM, Guannan Ren wrote:
> On 03/21/2012 08:46 PM, Peter Krempa wrote:
>> For some tests it's not needed to ping the guest in the startup process.
>> This patch adds a flag to the start and destroy test to skip such
>> attempts (that consume a lot of time)
>> ---
>> repos/domain/destroy.py | 54
>> ++++++++++++++++++++++++++--------------------
>> repos/domain/start.py | 50
>> ++++++++++++++++++++----------------------
>> 2 files changed, 54 insertions(+), 50 deletions(-)
>>
>> diff --git a/repos/domain/destroy.py b/repos/domain/destroy.py
>> index f98b602..12399d6 100644
>> --- a/repos/domain/destroy.py
>> +++ b/repos/domain/destroy.py
>> @@ -50,7 +50,10 @@ def destroy(params):
>> {'guestname': guestname}
>>
>> logger -- an object of utils/Python/log.py
>> - guestname -- same as the domain name
>> + guestname -- the domain name
>> + flags -- optional arguments:
>> + noping: Don't do the ping test
>> +
>>
>> Return 0 on SUCCESS or 1 on FAILURE
>> """
>> @@ -62,6 +65,7 @@ def destroy(params):
>> if params_check_result:
>> return 1
>> guestname = params['guestname']
>> + flags = params['flags']
>
> The 'flags' is optional, then we have to check if the
> dictionary of params has key or not
> if params.has_key('flags'):
> ...
> otherwise, it will report "KeyError: "
>
> If 'flags' is mandatory, it'd better to to check it in
> check_params function.
>
I'd rather do it using the get() method for dictionaries with some
default, i.e. params.get('flags', None).
Just my $0.02
Martin
More information about the libvir-list
mailing list