[libvirt] [TCK][PATCH] nwfilter: implement support for --force flag

Daniel P. Berrange berrange at redhat.com
Wed Oct 6 13:09:37 UTC 2010


On Mon, Oct 04, 2010 at 09:41:50AM -0400, Stefan Berger wrote:
>  Implement support for the --force command line option to delete 
> existing VMs and nwfilters starting with 'tck'. Fix how the --no-attach 
> flag is handled.
> 
> Signed-off-by: Stefan Berger <stefanb at us.ibm.com>
> 
> diff --git a/scripts/nwfilter/nwfilter2vmtest.sh 
> b/scripts/nwfilter/nwfilter2vmtest.sh
> index b527ee8..496c220 100644
> --- a/scripts/nwfilter/nwfilter2vmtest.sh
> +++ b/scripts/nwfilter/nwfilter2vmtest.sh
> @@ -23,6 +23,7 @@ FLAG_ATTACH="$((1<<1))"
>  FLAG_VERBOSE="$((1<<2))"
>  FLAG_LIBVIRT_TEST="$((1<<3))"
>  FLAG_TAP_TEST="$((1<<4))"
> +FLAG_FORCE_CLEAN="$((1<<5))"
> 
>  failctr=0
>  passctr=0
> @@ -47,6 +48,8 @@ Options:
>   --verbose      : Verbose output
>   --libvirt-test : Use the libvirt test output format
>   --tap-test     : TAP format output
> + --force        : Allow the automatic cleaning of VMs and nwfilters
> +                  previously created by the TCK test suite
> 
>  This test will create two virtual machines. The one virtual machine
>  will use a filter called '${TESTFILTERNAME}', and reference the filter
> @@ -498,11 +501,12 @@ function main() {
>    while [ $# -ne 0 ]; do
>      case "$1" in
>      --help|-h|-\?) usage ${prgname}; exit 0;;
> -    --noattach)     ((flags ^= FLAG_ATTACH  ));;
> +    --noattach)     ((flags &= ~FLAG_ATTACH ));;
>      --wait)         ((flags |= FLAG_WAIT    ));;
>      --verbose)      ((flags |= FLAG_VERBOSE ));;
>      --libvirt-test) ((flags |= FLAG_LIBVIRT_TEST ));;
>      --tap-test)     ((flags |= FLAG_TAP_TEST ));;
> +    --force)        ((flags |= FLAG_FORCE_CLEAN ));;
>      *) usage ${prgname}; exit 1;;
>      esac
>      shift 1
> @@ -523,12 +527,14 @@ function main() {
>          exit 0
>      fi
> 
> -    for name in `virsh nwfilter-list | awk '{print $2}'`
> +    for name in `virsh list | awk '{print $2}'`
>      do
>        case ${name} in
>        tck*)
> -        if [ "x${LIBVIRT_TCK_AUTOCLEAN}" == "x1" ]; then
> -          res=$(virsh nwfilter-undefine ${name} 2>&1)
> +        if [ "x${LIBVIRT_TCK_AUTOCLEAN}" == "x1" -o \
> +             $((flags & FLAG_FORCE_CLEAN)) -ne 0 ]; then
> +          res=$(virsh destroy  ${name} 2>&1)
> +          res=$(virsh undefine ${name} 2>&1)
>            if [ $? -ne 0 ]; then
>              echo "Bail out! Could not undefine nwfiler ${name}: ${res}"
>              exit 0
> @@ -544,8 +550,9 @@ function main() {
>      do
>        case ${name} in
>        tck*)
> -        if [ "x${LIBVIRT_TCK_AUTOCLEAN}" == "x1" ]; then
> -          res=$(virsh undefine ${name} 2>&1)
> +        if [ "x${LIBVIRT_TCK_AUTOCLEAN}" == "x1" -o \
> +             $((flags & FLAG_FORCE_CLEAN)) -ne 0 ]; then
> +          res=$(virsh nwfilter-undefine ${name} 2>&1)
>            if [ $? -ne 0 ]; then
>              echo "Bail out! Could not undefine domain ${name}: ${res}"
>              exit 1

ACK

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list