summaryrefslogtreecommitdiff
path: root/extensions/kvm.write
diff options
context:
space:
mode:
authorAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-19 15:33:22 +0000
committerAdam Coldrick <adam.coldrick@codethink.co.uk>2015-06-19 15:33:22 +0000
commit53a5919884b98613a99fe7a8397e9f2f01190b8f (patch)
tree1422b88cbba6ca6da5e45bf50690d152ceb529ab /extensions/kvm.write
parentcd9e3ba567a704af2585ad5b46d5b1eb9609fdd4 (diff)
parente4c6b8a69f0df2d0b3beac46865a66e0de527151 (diff)
downloaddefinitions-53a5919884b98613a99fe7a8397e9f2f01190b8f.tar.gz
Merge branch 'baserock/adamcoldrick/remove-dependencies-v3'
This stops the deployment extensions from depending on morphlib and cliapp, as well as setting the definitions version to 5. Reviewed-by: Sam Thursfield <sam.thursfield@codethink.co.uk> Reviewed-by: Paul Sherwood <paul.sherwood@codethink.co.uk>
Diffstat (limited to 'extensions/kvm.write')
-rwxr-xr-xextensions/kvm.write25
1 files changed, 13 insertions, 12 deletions
diff --git a/extensions/kvm.write b/extensions/kvm.write
index 0d0c095b..2290725e 100755
--- a/extensions/kvm.write
+++ b/extensions/kvm.write
@@ -21,23 +21,23 @@ See file kvm.write.help for documentation
'''
-import cliapp
import os
import re
import sys
import tempfile
import urlparse
-import morphlib.writeexts
+import writeexts
-class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
+class KvmPlusSshWriteExtension(writeexts.WriteExtension):
location_pattern = '^/(?P<guest>[^/]+)(?P<path>/.+)$'
def process_args(self, args):
if len(args) != 2:
- raise cliapp.AppException('Wrong number of command line args')
+ raise writeexts.ExtensionError(
+ 'Wrong number of command line args')
temp_root, location = args
ssh_host, vm_name, vm_path = self.parse_location(location)
@@ -53,7 +53,7 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
except BaseException:
sys.stderr.write('Error deploying to libvirt')
os.remove(raw_disk)
- cliapp.ssh_runcmd(ssh_host, ['rm', '-f', vm_path])
+ writeexts.ssh_runcmd(ssh_host, ['rm', '-f', vm_path])
raise
else:
os.remove(raw_disk)
@@ -74,16 +74,16 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
self.status(msg='Transferring disk image')
- xfer_hole_path = morphlib.util.get_data_path('xfer-hole')
- recv_hole = morphlib.util.get_data('recv-hole')
+ xfer_hole_path = writeexts.get_data_path('xfer-hole')
+ recv_hole = writeexts.get_data('recv-hole')
ssh_remote_cmd = [
'sh', '-c', recv_hole, 'dummy-argv0', 'file', vm_path
]
- cliapp.runcmd(
+ subprocess.check_call(
['python', xfer_hole_path, raw_disk],
- ['ssh', ssh_host] + map(cliapp.shell_quote, ssh_remote_cmd),
+ ['ssh', ssh_host] + map(writeexts.shell_quote, ssh_remote_cmd),
stdout=None, stderr=None)
def create_libvirt_guest(self, ssh_host, vm_name, vm_path, autostart):
@@ -111,10 +111,11 @@ class KvmPlusSshWriteExtension(morphlib.writeexts.WriteExtension):
'--disk', 'path=%s,bus=ide' % vm_path] + attach_opts
if not autostart:
cmdline += ['--noreboot']
- cliapp.ssh_runcmd(ssh_host, cmdline)
+ writeexts.ssh_runcmd(ssh_host, cmdline)
if autostart:
- cliapp.ssh_runcmd(ssh_host,
- ['virsh', '--connect', 'qemu:///system', 'autostart', vm_name])
+ writeexts.ssh_runcmd(ssh_host,
+ ['virsh', '--connect', 'qemu:///system',
+ 'autostart', vm_name])
KvmPlusSshWriteExtension().run()