Skip to contentSkip to conversation

Add custom install option for kvm_install

PATCH In review Mike Burns 2 participants 3 messages May 12, 2009 – Jun 1, 2009 KVM

lore
Share & tools
lore

Mike Burns

author
#0 lore raw

PATCH 1/1 Add custom install option for kvm_install

From: Michael Burns <[email protected]>

---
 client/tests/kvm_runtest_2/control        |   18 +++++++++++++++++-
 client/tests/kvm_runtest_2/kvm_install.py |   15 +++++++++++++++
 2 files changed, 32 insertions(+), 1 deletions(-)
client/tests/kvm_runtest_2/control +17 -1
index fd68e94..d6e26bc 100644
@@ -41,6 +41,19 @@ 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-runtest_2 directory.
+#       Script will be executed from test.bindir (generally kvm_runtest_2)
+#       parameters for the script can be passed either as environment variables
+#       in the params array below or in the definition of install_script.
+#       If they are passed as part of params, then they will be accessible as
+#       KVM_INSTALL_<s> in the OS Environment when your script runs.  
+#
 # ---------------------
 params = {
     "name": "kvm_install",
@@ -57,7 +70,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": 'custom_kvm_install.sh param1'
 }
 
 # Comment the job.run_test line if you do not want to install kvm on the host.
client/tests/kvm_runtest_2/kvm_install.py +15 -0
index 8be5a93..234c77a 100755
@@ -77,6 +77,21 @@ 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(test.bindir,install_script)
+        if not install_script:
+            message = "Custom script filename not specified"
+            kvm_log.error(message)
+            raise error.TestError, message
+        for k in params.keys():
+	  kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k))
+          os.putenv("KVM_INSTALL_%s" % (k), str(params[k]))
+	kvm_log.info("Running " + script + " to install kvm")
+        os.system("cd %s; %s" % (test.bindir, script))
+	kvm_log.info("Completed %s" % (script))
+
     # invalid installation mode
     else:
         message = "Invalid installation mode: '%s'" % install_mode
Signature · 1 line
1.6.0.6
#1 lore raw
Quoted 20 lines · Mike Burns

From: Michael Burns<[email protected]>

---
  client/tests/kvm_runtest_2/control        |   18 +++++++++++++++++-
  client/tests/kvm_runtest_2/kvm_install.py |   15 +++++++++++++++
  2 files changed, 32 insertions(+), 1 deletions(-)
client/tests/kvm_runtest_2/control +3 -0
index fd68e94..d6e26bc 100644
@@ -41,6 +41,19 @@ link_if_not_exist(pwd, qemu_img, 'qemu-img')
 
  # ---------------------
  # Build and install kvm
+#
+# Details of Install options
+#   Mode: custom

client/tests/kvm_runtest_2/control link_if_not_exist(pwd, qemu_img, 'qemu-img') · line 56

Quoted 10 lines
client/tests/kvm_runtest_2/control +10 -0
+#   Description:  install from custom install script
+#   Parameters needed:
+#     install_script:
+#       location of script relative to the kvm-runtest_2 directory.
+#       Script will be executed from test.bindir (generally kvm_runtest_2)
+#       parameters for the script can be passed either as environment variables
+#       in the params array below or in the definition of install_script.
+#       If they are passed as part of params, then they will be accessible as
+#       KVM_INSTALL_<s>  in the OS Environment when your script runs.
+#

I think this, being the only explanation about kvm_install, can be confusing to the user. We can add a link to the wiki instead:
http://kvm.et.redhat.com/page/KVM-Autotest/ControlFile

Quoted 20 lines
client/tests/kvm_runtest_2/control +4 -1
  # ---------------------
  params = {
      "name": "kvm_install",
@@ -57,7 +70,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": 'custom_kvm_install.sh param1'
  }
 
  # Comment the job.run_test line if you do not want to install kvm on the host.
client/tests/kvm_runtest_2/kvm_install.py +0 -0
index 8be5a93..234c77a 100755

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 83

Quoted 7 lines
client/tests/kvm_runtest_2/kvm_install.py +4 -0
@@ -77,6 +77,21 @@ 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(test.bindir,install_script)

This line (script = ..) should be located below the following if statement. if "install_script" is not in params (and install_script is None), os.path.join fails.

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 88

Quoted 5 lines
client/tests/kvm_runtest_2/kvm_install.py +5 -0
+        if not install_script:
+            message = "Custom script filename not specified"
+            kvm_log.error(message)
+            raise error.TestError, message
+        for k in params.keys():

Fix white-space.

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 89

Quoted 1 line
client/tests/kvm_runtest_2/kvm_install.py +1 -0
+	  kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k))

kvm_log.debug

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 92

Quoted 3 lines
client/tests/kvm_runtest_2/kvm_install.py +3 -0
+          os.putenv("KVM_INSTALL_%s" % (k), str(params[k]))
+	kvm_log.info("Running " + script + " to install kvm")
+        os.system("cd %s; %s" % (test.bindir, script))

if the script fails, quit (raise).

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 97

Quoted 5 lines
client/tests/kvm_runtest_2/kvm_install.py +2 -0
+	kvm_log.info("Completed %s" % (script))
+
      # invalid installation mode
      else:
          message = "Invalid installation mode: '%s'" % install_mode

Sorry for the late reply,
Uri.

author
#2 lore raw
Quoted 32 lines · Uri Lublin
Quoted 31 lines · Mike Burns

From: Michael Burns<[email protected]>

---
  client/tests/kvm_runtest_2/control        |   18 +++++++++++++++++-
  client/tests/kvm_runtest_2/kvm_install.py |   15 +++++++++++++++
  2 files changed, 32 insertions(+), 1 deletions(-)
client/tests/kvm_runtest_2/control +9 -0
index fd68e94..d6e26bc 100644
@@ -41,6 +41,19 @@ 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-runtest_2 directory.
+#       Script will be executed from test.bindir (generally
 kvm_runtest_2)
+#       parameters for the script can be passed either as

environment variables
+# in the params array below or in the definition of
install_script.

Quoted 8 lines

client/tests/kvm_runtest_2/control link_if_not_exist(pwd, qemu_img, 'qemu-img') · line 56

Quoted 4 lines

+# If they are passed as part of params, then they will be
accessible as

client/tests/kvm_runtest_2/control +2 -0
+#       KVM_INSTALL_<s>  in the OS Environment when your script runs.
+#

I think this, being the only explanation about kvm_install, can be confusing to the user. We can add a link to the wiki instead:
http://kvm.et.redhat.com/page/KVM-Autotest/ControlFile

That is a good point. I was debating whether to put them all there or not, but didn't want to clutter up my patch too much. I decided afterwards to add the page to the wiki, so I'll link there instead when I repost.

Quoted 29 lines
Quoted 29 lines
  # ---------------------
  params = {
      "name": "kvm_install",
client/tests/kvm_runtest_2/control +0 -1
@@ -57,7 +70,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',

client/tests/kvm_runtest_2/control +3 -0
+
+    ## Custom install
+    "install_script": 'custom_kvm_install.sh param1'
  }
 
  # Comment the job.run_test line if you do not want to install kvm

on the host.

client/tests/kvm_runtest_2/kvm_install.py +0 -0
index 8be5a93..234c77a 100755
@@ -77,6 +77,21 @@ def run_kvm_install(test, params, env):
      elif install_mode == "localsrc":
          __install_kvm(test, srcdir)
 
Quoted 10 lines

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 83

Quoted 4 lines
client/tests/kvm_runtest_2/kvm_install.py +4 -0
+    # install from custom script
+    elif install_mode == "custom":
+        install_script = params.get("install_script")
+        script = os.path.join(test.bindir,install_script)

This line (script = ..) should be located below the following if statement.
if "install_script" is not in params (and install_script is None), os.path.join fails.

Ok, will fix

Quoted 10 lines

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 88

Quoted 5 lines
client/tests/kvm_runtest_2/kvm_install.py +5 -0
+        if not install_script:
+            message = "Custom script filename not specified"
+            kvm_log.error(message)
+            raise error.TestError, message
+        for k in params.keys():

Fix white-space.

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 89

Quoted 1 line
client/tests/kvm_runtest_2/kvm_install.py +1 -0
+      kvm_log.info("Adding KVM_INSTALL_%s to Environment" % (k))
Quoted 8 lines

kvm_log.debug

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 92

Quoted 3 lines
client/tests/kvm_runtest_2/kvm_install.py +3 -0
+          os.putenv("KVM_INSTALL_%s" % (k), str(params[k]))
+    kvm_log.info("Running " + script + " to install kvm")
+        os.system("cd %s; %s" % (test.bindir, script))

if the script fails, quit (raise).

we're going to change this to utils.system instead to use the built-in error handling.

Quoted 10 lines

client/tests/kvm_runtest_2/kvm_install.py def run_kvm_install(test, params, env): · line 97

Quoted 5 lines
client/tests/kvm_runtest_2/kvm_install.py +2 -0
+    kvm_log.info("Completed %s" % (script))
+
      # invalid installation mode
      else:
          message = "Invalid installation mode: '%s'" % install_mode

Sorry for the late reply,
Uri.