[Erp5-report] r35022 rafael - /erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/kvm.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Wed May 5 20:01:19 CEST 2010
Author: rafael
Date: Wed May 5 20:01:17 2010
New Revision: 35022
URL: http://svn.erp5.org?rev=35022&view=rev
Log:
Supports snapshot definition.
Modified:
erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/kvm.py
Modified: erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/kvm.py
URL: http://svn.erp5.org/erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/kvm.py?rev=35022&r1=35021&r2=35022&view=diff
==============================================================================
--- erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/kvm.py [utf8] (original)
+++ erp5/trunk/utils/erp5.recipe.kvm/src/erp5/recipe/kvm/kvm.py [utf8] Wed May 5 20:01:17 2010
@@ -2,10 +2,10 @@
import os
import signal
-BASE_COMMAND = "kvm -snapshot -net nic,model=ne2k_pci -redir tcp:%s::22 -k fr -net user,hostname=mdv2010 -m 1024 -hda %s -daemonize -nographic -pidfile %s $@"
+BASE_COMMAND = "kvm -net nic,model=ne2k_pci -redir tcp:%s::22 -k fr -net user,hostname=%s -m 1024 -hda %s -daemonize -nographic -pidfile %s %s "
class Kvm:
- def __init__(self, image, port, pid_file, hostname):
+ def __init__(self, image, port, pid_file, hostname, snapshot=True):
""" Handle the KVM command for a certain image, and
start ssh in a certain port.
@@ -13,14 +13,22 @@
"""
self.image = image
self.ssh_port = port
- self.kvm_pid_file = ""
- self.kvm_hostname = ""
+ self.kvm_pid_file = pid_file
+ self.kvm_hostname = hostname
+ self.kvm_extra_args = ""
+ if snapshot:
+ self.kvm_extra_args += " -snapshot "
+
def start(self):
""" Start Kvm in background."""
- subprocess.call(BASE_COMMAND % ( self.ssh_port,
- self.image,
- self.kvm_pid_file))
+ command = BASE_COMMAND % ( self.ssh_port,
+ self.kvm_hostname,
+ self.image,
+ self.kvm_pid_file,
+ self.kvm_extra_args)
+ print command
+ subprocess.call(command, shell=True)
def stop(self):
""" Stop Kvm in the server """
@@ -51,10 +59,10 @@
self.stop()
self.start()
-def ctl(image, port, pid_file, hostname, command):
+def ctl(image, port, pid_file, hostname, snapshot, command):
""" Control KVM Command
"""
- handler = Kvm(image, port, pid_file, hostname)
+ handler = Kvm(image, port, pid_file, hostname, snapshot)
command = getattr(handler, command, None)
if command is not None:
return command()
More information about the Erp5-report
mailing list