
On Wed, Sep 23, 2015 at 09:53:36AM +0200, Cédric Bosdonnat wrote:
Formatting a disk is a generic operation that will be needed by other sources, at least a virt-builder one. --- libvirt-sandbox/image/sources/DockerSource.py | 14 +------------- libvirt-sandbox/image/sources/Source.py | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 13 deletions(-)
ACK
diff --git a/libvirt-sandbox/image/sources/Source.py b/libvirt-sandbox/image/sources/Source.py index 20f4af0..444baa3 100644 --- a/libvirt-sandbox/image/sources/Source.py +++ b/libvirt-sandbox/image/sources/Source.py @@ -21,6 +21,7 @@ # Author: Eren Yagdiran <erenyagdiran@gmail.com>
from abc import ABCMeta, abstractmethod +import subprocess
class Source(): '''The Source class defines the base interface for @@ -114,3 +115,18 @@ class Source(): cleanup. """ pass + + + # Utility functions to share between the sources. + + def format_disk(self,disk,format,connect): + cmd = ['virt-sandbox'] + if connect is not None: + cmd.append("-c") + cmd.append(connect) + cmd.append("-p") + params = ['--disk=file:disk_image=%s,format=%s' %(disk,format), + '/sbin/mkfs.ext3',
This reminds me we should switch to mkfs.ext4 to be consistent with our previous switch to ext4 mount by default.
+ '/dev/disk/by-tag/disk_image'] + cmd = cmd + params + subprocess.call(cmd)
Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|