diff mbox

[KVM-AUTOTEST] Add custom install option for kvm_install

Message ID 1241808930-20782-1-git-send-email-mburns@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Mike Burns May 8, 2009, 6:55 p.m. UTC
From: Michael Burns <mburns@redhat.com>


Signed-off-by: Michael Burns <mburns@redhat.com>
---
 client/tests/kvm_runtest_2/control        |   14 +++++++++++++-
 client/tests/kvm_runtest_2/kvm_install.py |   11 +++++++++++
 2 files changed, 24 insertions(+), 1 deletions(-)

Comments

Eduardo Habkost May 11, 2009, 1:49 p.m. UTC | #1
Hi,

Excerpts from Michael Burns's message of Fri May 08 15:55:30 -0300 2009:
> --- a/client/tests/kvm_runtest_2/kvm_install.py
> +++ b/client/tests/kvm_runtest_2/kvm_install.py
> @@ -77,6 +77,17 @@ def run_kvm_install(test, params, env):
>      elif install_mode == "localsrc":
>          __install_kvm(test, srcdir)
>  
> +    # install from custom script
> +    elif install_mode == "custom":
> +        install_script = params.get("install_script")
> +        script = os.path.join(os.environ['AUTODIR'],install_script)
> +        if not install_script:
> +            message = "Custom script filename not specified"
> +            kvm_log.error(message)
> +            raise error.TestError, message
> +    kvm_log.info("Running " + script + " to install kvm")
> +        os.system(script)

What if we had some way to pass the other parameters from 'params' to
the custom script?

Maybe something like (untested):

  for k in params.keys():
      os.putenv("KVM_INSTALL_%s" % (k), params[k])

Are all values on 'params' guaranteed to be strings, or they can be set
to any python value? In the latter case, we could use str(params[k]), or
export only the string parameters.
Mike Burns May 11, 2009, 3:06 p.m. UTC | #2
Eduardo Habkost wrote:
> Hi,
>
> Excerpts from Michael Burns's message of Fri May 08 15:55:30 -0300 2009:
>   
>> --- a/client/tests/kvm_runtest_2/kvm_install.py
>> +++ b/client/tests/kvm_runtest_2/kvm_install.py
>> @@ -77,6 +77,17 @@ def run_kvm_install(test, params, env):
>>      elif install_mode == "localsrc":
>>          __install_kvm(test, srcdir)
>>  
>> +    # install from custom script
>> +    elif install_mode == "custom":
>> +        install_script = params.get("install_script")
>> +        script = os.path.join(os.environ['AUTODIR'],install_script)
>> +        if not install_script:
>> +            message = "Custom script filename not specified"
>> +            kvm_log.error(message)
>> +            raise error.TestError, message
>> +    kvm_log.info("Running " + script + " to install kvm")
>> +        os.system(script)
>>     
>
> What if we had some way to pass the other parameters from 'params' to
> the custom script?
>
> Maybe something like (untested):
>
>   for k in params.keys():
>       os.putenv("KVM_INSTALL_%s" % (k), params[k])
>
> Are all values on 'params' guaranteed to be strings, or they can be set
> to any python value? In the latter case, we could use str(params[k]), or
> export only the string parameters.
>   
That's a good idea.  I'm not sure about whether the params are all 
strings.  I'll try it out and respin the patch after. 

Mike
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/client/tests/kvm_runtest_2/control b/client/tests/kvm_runtest_2/control
index fd68e94..c28dc67 100644
--- a/client/tests/kvm_runtest_2/control
+++ b/client/tests/kvm_runtest_2/control
@@ -41,6 +41,15 @@  link_if_not_exist(pwd, qemu_img, 'qemu-img')
 
 # ---------------------
 # Build and install kvm
+#
+# Details of Install options
+#   Mode: custom
+#   Description:  install from custom install script
+#   Parameters needed:
+#     install_script: 
+#       location of script relative to the 
+#       kvm-autotest/client directory
+#
 # ---------------------
 params = {
     "name": "kvm_install",
@@ -57,7 +66,10 @@  params = {
 
     ## Install from git
     "git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm.git',
-    "user_git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm-userspace.git'
+    "user_git_repo": 'git://git.kernel.org/pub/scm/linux/kernel/git/avi/kvm-userspace.git',
+    
+    ## Custom install
+    "install_script": 'tests/kvm_runtest/custom_kvm_install.sh'
 }
 
 # Comment the job.run_test line if you do not want to install kvm on the host.
diff --git a/client/tests/kvm_runtest_2/kvm_install.py b/client/tests/kvm_runtest_2/kvm_install.py
index 8be5a93..0e077ae 100755
--- a/client/tests/kvm_runtest_2/kvm_install.py
+++ b/client/tests/kvm_runtest_2/kvm_install.py
@@ -77,6 +77,17 @@  def run_kvm_install(test, params, env):
     elif install_mode == "localsrc":
         __install_kvm(test, srcdir)
 
+    # install from custom script
+    elif install_mode == "custom":
+        install_script = params.get("install_script")
+        script = os.path.join(os.environ['AUTODIR'],install_script)
+        if not install_script:
+            message = "Custom script filename not specified"
+            kvm_log.error(message)
+            raise error.TestError, message
+	kvm_log.info("Running " + script + " to install kvm")
+        os.system(script)
+
     # invalid installation mode
     else:
         message = "Invalid installation mode: '%s'" % install_mode