summaryrefslogtreecommitdiff
path: root/morphlib/exts/kvm.write
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/exts/kvm.write')
-rwxr-xr-xmorphlib/exts/kvm.write40
1 files changed, 11 insertions, 29 deletions
diff --git a/morphlib/exts/kvm.write b/morphlib/exts/kvm.write
index 16f188b5..0d0c095b 100755
--- a/morphlib/exts/kvm.write
+++ b/morphlib/exts/kvm.write
@@ -1,5 +1,5 @@
#!/usr/bin/python
-# Copyright (C) 2012-2014 Codethink Limited
+# Copyright (C) 2012-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -11,11 +11,14 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# with this program. If not, see <http://www.gnu.org/licenses/>.
-'''A Morph deployment write extension for deploying to KVM+libvirt.'''
+'''A Morph deployment write extension for deploying to KVM+libvirt.
+
+See file kvm.write.help for documentation
+
+'''
import cliapp
@@ -30,40 +33,20 @@ import morphlib.writeexts
class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
- '''Create a KVM/LibVirt virtual machine during Morph's deployment.
-
- The location command line argument is the pathname of the disk image
- to be created. The user is expected to provide the location argument
- using the following syntax:
-
- kvm+ssh://HOST/GUEST/PATH
-
- where:
-
- * HOST is the host on which KVM/LibVirt is running
- * GUEST is the name of the guest virtual machine on that host
- * PATH is the path to the disk image that should be created,
- on that host
-
- The extension will connect to HOST via ssh to run libvirt's
- command line management tools.
-
- '''
-
location_pattern = '^/(?P<guest>[^/]+)(?P<path>/.+)$'
def process_args(self, args):
if len(args) != 2:
raise cliapp.AppException('Wrong number of command line args')
-
+
temp_root, location = args
ssh_host, vm_name, vm_path = self.parse_location(location)
autostart = self.get_environment_boolean('AUTOSTART')
-
+
fd, raw_disk = tempfile.mkstemp()
os.close(fd)
self.create_local_system(temp_root, raw_disk)
-
+
try:
self.transfer(raw_disk, ssh_host, vm_path)
self.create_libvirt_guest(ssh_host, vm_name, vm_path, autostart)
@@ -105,7 +88,7 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
def create_libvirt_guest(self, ssh_host, vm_name, vm_path, autostart):
'''Create the libvirt virtual machine.'''
-
+
self.status(msg='Creating libvirt/kvm virtual machine')
attach_disks = self.parse_attach_disks()
@@ -135,4 +118,3 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
['virsh', '--connect', 'qemu:///system', 'autostart', vm_name])
KvmPlusSshWriteExtension().run()
-