mirror of
https://gitlab.com/fdroid/fdroidserver.git
synced 2024-10-04 02:00:11 +02:00
Merge branch 'conform-vmtools-coding-style' into 'master'
refactor vmtools logging, pythonic binary lookup See merge request fdroid/fdroidserver!518
This commit is contained in:
commit
672df07238
@ -24,22 +24,20 @@ import tarfile
|
|||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import textwrap
|
import textwrap
|
||||||
|
import logging
|
||||||
from .common import FDroidException
|
from .common import FDroidException
|
||||||
from logging import getLogger
|
|
||||||
|
|
||||||
from fdroidserver import _
|
from fdroidserver import _
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
lock = threading.Lock()
|
lock = threading.Lock()
|
||||||
|
|
||||||
logger = getLogger('fdroidserver-vmtools')
|
|
||||||
|
|
||||||
|
|
||||||
def get_clean_builder(serverdir, reset=False):
|
def get_clean_builder(serverdir, reset=False):
|
||||||
if not os.path.isdir(serverdir):
|
if not os.path.isdir(serverdir):
|
||||||
if os.path.islink(serverdir):
|
if os.path.islink(serverdir):
|
||||||
os.unlink(serverdir)
|
os.unlink(serverdir)
|
||||||
logger.info("buildserver path does not exists, creating %s", serverdir)
|
logging.info("buildserver path does not exists, creating %s", serverdir)
|
||||||
os.makedirs(serverdir)
|
os.makedirs(serverdir)
|
||||||
vagrantfile = os.path.join(serverdir, 'Vagrantfile')
|
vagrantfile = os.path.join(serverdir, 'Vagrantfile')
|
||||||
if not os.path.isfile(vagrantfile):
|
if not os.path.isfile(vagrantfile):
|
||||||
@ -54,12 +52,12 @@ def get_clean_builder(serverdir, reset=False):
|
|||||||
"""))
|
"""))
|
||||||
vm = get_build_vm(serverdir)
|
vm = get_build_vm(serverdir)
|
||||||
if reset:
|
if reset:
|
||||||
logger.info('resetting buildserver by request')
|
logging.info('resetting buildserver by request')
|
||||||
elif not vm.vagrant_uuid_okay():
|
elif not vm.vagrant_uuid_okay():
|
||||||
logger.info('resetting buildserver, because vagrant vm is not okay.')
|
logging.info('resetting buildserver, because vagrant vm is not okay.')
|
||||||
reset = True
|
reset = True
|
||||||
elif not vm.snapshot_exists('fdroidclean'):
|
elif not vm.snapshot_exists('fdroidclean'):
|
||||||
logger.info("resetting buildserver, because snapshot 'fdroidclean' is not present.")
|
logging.info("resetting buildserver, because snapshot 'fdroidclean' is not present.")
|
||||||
reset = True
|
reset = True
|
||||||
|
|
||||||
if reset:
|
if reset:
|
||||||
@ -68,10 +66,10 @@ def get_clean_builder(serverdir, reset=False):
|
|||||||
vm.suspend()
|
vm.suspend()
|
||||||
|
|
||||||
if reset:
|
if reset:
|
||||||
logger.info('buildserver recreated: taking a clean snapshot')
|
logging.info('buildserver recreated: taking a clean snapshot')
|
||||||
vm.snapshot_create('fdroidclean')
|
vm.snapshot_create('fdroidclean')
|
||||||
else:
|
else:
|
||||||
logger.info('builserver ok: reverting to clean snapshot')
|
logging.info('builserver ok: reverting to clean snapshot')
|
||||||
vm.snapshot_revert('fdroidclean')
|
vm.snapshot_revert('fdroidclean')
|
||||||
vm.up()
|
vm.up()
|
||||||
|
|
||||||
@ -88,12 +86,12 @@ def get_clean_builder(serverdir, reset=False):
|
|||||||
|
|
||||||
|
|
||||||
def _check_call(cmd, cwd=None):
|
def _check_call(cmd, cwd=None):
|
||||||
logger.debug(' '.join(cmd))
|
logging.debug(' '.join(cmd))
|
||||||
return subprocess.check_call(cmd, shell=False, cwd=cwd)
|
return subprocess.check_call(cmd, shell=False, cwd=cwd)
|
||||||
|
|
||||||
|
|
||||||
def _check_output(cmd, cwd=None):
|
def _check_output(cmd, cwd=None):
|
||||||
logger.debug(' '.join(cmd))
|
logging.debug(' '.join(cmd))
|
||||||
return subprocess.check_output(cmd, shell=False, cwd=cwd)
|
return subprocess.check_output(cmd, shell=False, cwd=cwd)
|
||||||
|
|
||||||
|
|
||||||
@ -113,37 +111,28 @@ def get_build_vm(srvdir, provider=None):
|
|||||||
# use supplied provider
|
# use supplied provider
|
||||||
if provider:
|
if provider:
|
||||||
if provider == 'libvirt':
|
if provider == 'libvirt':
|
||||||
logger.debug('build vm provider \'libvirt\' selected')
|
logging.debug('build vm provider \'libvirt\' selected')
|
||||||
return LibvirtBuildVm(abssrvdir)
|
return LibvirtBuildVm(abssrvdir)
|
||||||
elif provider == 'virtualbox':
|
elif provider == 'virtualbox':
|
||||||
logger.debug('build vm provider \'virtualbox\' selected')
|
logging.debug('build vm provider \'virtualbox\' selected')
|
||||||
return VirtualboxBuildVm(abssrvdir)
|
return VirtualboxBuildVm(abssrvdir)
|
||||||
else:
|
else:
|
||||||
logger.warn('build vm provider not supported: \'%s\'', provider)
|
logging.warn('build vm provider not supported: \'%s\'', provider)
|
||||||
|
|
||||||
# try guessing provider from installed software
|
# try guessing provider from installed software
|
||||||
try:
|
kvm_installed = shutil.which('kvm') is not None
|
||||||
kvm_installed = 0 == _check_call(['which', 'kvm'])
|
kvm_installed |= shutil.which('qemu') is not None
|
||||||
except subprocess.CalledProcessError:
|
vbox_installed = shutil.which('VBoxHeadless') is not None
|
||||||
kvm_installed = False
|
|
||||||
try:
|
|
||||||
kvm_installed |= 0 == _check_call(['which', 'qemu'])
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
pass
|
|
||||||
try:
|
|
||||||
vbox_installed = 0 == _check_call(['which', 'VBoxHeadless'])
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
vbox_installed = False
|
|
||||||
if kvm_installed and vbox_installed:
|
if kvm_installed and vbox_installed:
|
||||||
logger.debug('both kvm and vbox are installed.')
|
logging.debug('both kvm and vbox are installed.')
|
||||||
elif kvm_installed:
|
elif kvm_installed:
|
||||||
logger.debug('libvirt is the sole installed and supported vagrant provider, selecting \'libvirt\'')
|
logging.debug('libvirt is the sole installed and supported vagrant provider, selecting \'libvirt\'')
|
||||||
return LibvirtBuildVm(abssrvdir)
|
return LibvirtBuildVm(abssrvdir)
|
||||||
elif vbox_installed:
|
elif vbox_installed:
|
||||||
logger.debug('virtualbox is the sole installed and supported vagrant provider, selecting \'virtualbox\'')
|
logging.debug('virtualbox is the sole installed and supported vagrant provider, selecting \'virtualbox\'')
|
||||||
return VirtualboxBuildVm(abssrvdir)
|
return VirtualboxBuildVm(abssrvdir)
|
||||||
else:
|
else:
|
||||||
logger.debug('could not confirm that either virtualbox or kvm/libvirt are installed')
|
logging.debug('could not confirm that either virtualbox or kvm/libvirt are installed')
|
||||||
|
|
||||||
# try guessing provider from .../srvdir/.vagrant internals
|
# try guessing provider from .../srvdir/.vagrant internals
|
||||||
has_libvirt_machine = isdir(os.path.join(abssrvdir, '.vagrant',
|
has_libvirt_machine = isdir(os.path.join(abssrvdir, '.vagrant',
|
||||||
@ -151,16 +140,16 @@ def get_build_vm(srvdir, provider=None):
|
|||||||
has_vbox_machine = isdir(os.path.join(abssrvdir, '.vagrant',
|
has_vbox_machine = isdir(os.path.join(abssrvdir, '.vagrant',
|
||||||
'machines', 'default', 'virtualbox'))
|
'machines', 'default', 'virtualbox'))
|
||||||
if has_libvirt_machine and has_vbox_machine:
|
if has_libvirt_machine and has_vbox_machine:
|
||||||
logger.info('build vm provider lookup found virtualbox and libvirt, defaulting to \'virtualbox\'')
|
logging.info('build vm provider lookup found virtualbox and libvirt, defaulting to \'virtualbox\'')
|
||||||
return VirtualboxBuildVm(abssrvdir)
|
return VirtualboxBuildVm(abssrvdir)
|
||||||
elif has_libvirt_machine:
|
elif has_libvirt_machine:
|
||||||
logger.debug('build vm provider lookup found \'libvirt\'')
|
logging.debug('build vm provider lookup found \'libvirt\'')
|
||||||
return LibvirtBuildVm(abssrvdir)
|
return LibvirtBuildVm(abssrvdir)
|
||||||
elif has_vbox_machine:
|
elif has_vbox_machine:
|
||||||
logger.debug('build vm provider lookup found \'virtualbox\'')
|
logging.debug('build vm provider lookup found \'virtualbox\'')
|
||||||
return VirtualboxBuildVm(abssrvdir)
|
return VirtualboxBuildVm(abssrvdir)
|
||||||
|
|
||||||
logger.info('build vm provider lookup could not determine provider, defaulting to \'virtualbox\'')
|
logging.info('build vm provider lookup could not determine provider, defaulting to \'virtualbox\'')
|
||||||
return VirtualboxBuildVm(abssrvdir)
|
return VirtualboxBuildVm(abssrvdir)
|
||||||
|
|
||||||
|
|
||||||
@ -203,7 +192,7 @@ class FDroidBuildVm():
|
|||||||
def suspend(self):
|
def suspend(self):
|
||||||
global lock
|
global lock
|
||||||
with lock:
|
with lock:
|
||||||
logger.info('suspending buildserver')
|
logging.info('suspending buildserver')
|
||||||
try:
|
try:
|
||||||
self.vgrnt.suspend()
|
self.vgrnt.suspend()
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@ -222,22 +211,22 @@ class FDroidBuildVm():
|
|||||||
* vagrant state informations (eg. `.vagrant` folder)
|
* vagrant state informations (eg. `.vagrant` folder)
|
||||||
* images related to this vm
|
* images related to this vm
|
||||||
"""
|
"""
|
||||||
logger.info("destroying vm '%s'", self.srvname)
|
logging.info("destroying vm '%s'", self.srvname)
|
||||||
try:
|
try:
|
||||||
self.vgrnt.destroy()
|
self.vgrnt.destroy()
|
||||||
logger.debug('vagrant destroy completed')
|
logging.debug('vagrant destroy completed')
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.exception('vagrant destroy failed: %s', e)
|
logging.exception('vagrant destroy failed: %s', e)
|
||||||
vgrntdir = os.path.join(self.srvdir, '.vagrant')
|
vgrntdir = os.path.join(self.srvdir, '.vagrant')
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(vgrntdir)
|
shutil.rmtree(vgrntdir)
|
||||||
logger.debug('deleted vagrant dir: %s', vgrntdir)
|
logging.debug('deleted vagrant dir: %s', vgrntdir)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug("could not delete vagrant dir: %s, %s", vgrntdir, e)
|
logging.debug("could not delete vagrant dir: %s, %s", vgrntdir, e)
|
||||||
try:
|
try:
|
||||||
_check_call(['vagrant', 'global-status', '--prune'])
|
_check_call(['vagrant', 'global-status', '--prune'])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.debug('pruning global vagrant status failed: %s', e)
|
logging.debug('pruning global vagrant status failed: %s', e)
|
||||||
|
|
||||||
def package(self, output=None):
|
def package(self, output=None):
|
||||||
self.vgrnt.package(output=output)
|
self.vgrnt.package(output=output)
|
||||||
@ -256,7 +245,7 @@ class FDroidBuildVm():
|
|||||||
# Vagrant 1.0 - it's a json file...
|
# Vagrant 1.0 - it's a json file...
|
||||||
with open(os.path.join(self.srvdir, '.vagrant')) as f:
|
with open(os.path.join(self.srvdir, '.vagrant')) as f:
|
||||||
id = json.load(f)['active']['default']
|
id = json.load(f)['active']['default']
|
||||||
logger.debug('vm uuid: %s', id)
|
logging.debug('vm uuid: %s', id)
|
||||||
return id
|
return id
|
||||||
elif isfile(os.path.join(self.srvdir, '.vagrant', 'machines',
|
elif isfile(os.path.join(self.srvdir, '.vagrant', 'machines',
|
||||||
'default', self.provider, 'id')):
|
'default', self.provider, 'id')):
|
||||||
@ -264,10 +253,10 @@ class FDroidBuildVm():
|
|||||||
with open(os.path.join(self.srvdir, '.vagrant', 'machines',
|
with open(os.path.join(self.srvdir, '.vagrant', 'machines',
|
||||||
'default', self.provider, 'id')) as f:
|
'default', self.provider, 'id')) as f:
|
||||||
id = f.read()
|
id = f.read()
|
||||||
logger.debug('vm uuid: %s', id)
|
logging.debug('vm uuid: %s', id)
|
||||||
return id
|
return id
|
||||||
else:
|
else:
|
||||||
logger.debug('vm uuid is None')
|
logging.debug('vm uuid is None')
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def box_add(self, boxname, boxfile, force=True):
|
def box_add(self, boxname, boxfile, force=True):
|
||||||
@ -286,11 +275,11 @@ class FDroidBuildVm():
|
|||||||
try:
|
try:
|
||||||
_check_call(['vagrant', 'box', 'remove', '--all', '--force', boxname])
|
_check_call(['vagrant', 'box', 'remove', '--all', '--force', boxname])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.debug('tried removing box %s, but is did not exist: %s', boxname, e)
|
logging.debug('tried removing box %s, but is did not exist: %s', boxname, e)
|
||||||
boxpath = os.path.join(expanduser('~'), '.vagrant',
|
boxpath = os.path.join(expanduser('~'), '.vagrant',
|
||||||
self._vagrant_file_name(boxname))
|
self._vagrant_file_name(boxname))
|
||||||
if isdir(boxpath):
|
if isdir(boxpath):
|
||||||
logger.info("attempting to remove box '%s' by deleting: %s",
|
logging.info("attempting to remove box '%s' by deleting: %s",
|
||||||
boxname, boxpath)
|
boxname, boxpath)
|
||||||
shutil.rmtree(boxpath)
|
shutil.rmtree(boxpath)
|
||||||
|
|
||||||
@ -357,19 +346,19 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
try:
|
try:
|
||||||
_check_call(('virsh', '-c', 'qemu:///system', 'destroy', self.srvname))
|
_check_call(('virsh', '-c', 'qemu:///system', 'destroy', self.srvname))
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.info("could not force libvirt domain '%s' off: %s", self.srvname, e)
|
logging.info("could not force libvirt domain '%s' off: %s", self.srvname, e)
|
||||||
try:
|
try:
|
||||||
# libvirt python bindings do not support all flags required
|
# libvirt python bindings do not support all flags required
|
||||||
# for undefining domains correctly.
|
# for undefining domains correctly.
|
||||||
_check_call(('virsh', '-c', 'qemu:///system', 'undefine', self.srvname, '--nvram', '--managed-save', '--remove-all-storage', '--snapshots-metadata'))
|
_check_call(('virsh', '-c', 'qemu:///system', 'undefine', self.srvname, '--nvram', '--managed-save', '--remove-all-storage', '--snapshots-metadata'))
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.info("could not undefine libvirt domain '%s': %s", self.srvname, e)
|
logging.info("could not undefine libvirt domain '%s': %s", self.srvname, e)
|
||||||
|
|
||||||
def package(self, output=None, keep_box_file=False):
|
def package(self, output=None, keep_box_file=False):
|
||||||
if not output:
|
if not output:
|
||||||
output = "buildserver.box"
|
output = "buildserver.box"
|
||||||
logger.debug('no output name set for packaging \'%s\','
|
logging.debug("no output name set for packaging '%s', "
|
||||||
+ 'defaulting to %s', self.srvname, output)
|
"defaulting to %s", self.srvname, output)
|
||||||
storagePool = self.conn.storagePoolLookupByName('default')
|
storagePool = self.conn.storagePoolLookupByName('default')
|
||||||
domainInfo = self.conn.lookupByName(self.srvname).info()
|
domainInfo = self.conn.lookupByName(self.srvname).info()
|
||||||
if storagePool:
|
if storagePool:
|
||||||
@ -381,12 +370,12 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
if isfile('box.img'):
|
if isfile('box.img'):
|
||||||
os.remove('box.img')
|
os.remove('box.img')
|
||||||
|
|
||||||
logger.debug('preparing box.img for box %s', output)
|
logging.debug('preparing box.img for box %s', output)
|
||||||
vol = storagePool.storageVolLookupByName(self.srvname + '.img')
|
vol = storagePool.storageVolLookupByName(self.srvname + '.img')
|
||||||
imagepath = vol.path()
|
imagepath = vol.path()
|
||||||
# TODO use a libvirt storage pool to ensure the img file is readable
|
# TODO use a libvirt storage pool to ensure the img file is readable
|
||||||
if not os.access(imagepath, os.R_OK):
|
if not os.access(imagepath, os.R_OK):
|
||||||
logger.warning(_('Cannot read "{path}"!').format(path=imagepath))
|
logging.warning(_('Cannot read "{path}"!').format(path=imagepath))
|
||||||
_check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
|
_check_call(['sudo', '/bin/chmod', '-R', 'a+rX', '/var/lib/libvirt/images'])
|
||||||
shutil.copy2(imagepath, 'box.img')
|
shutil.copy2(imagepath, 'box.img')
|
||||||
_check_call(['qemu-img', 'rebase', '-p', '-b', '', 'box.img'])
|
_check_call(['qemu-img', 'rebase', '-p', '-b', '', 'box.img'])
|
||||||
@ -397,10 +386,10 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
"virtual_size": math.ceil(img_info['virtual-size'] / (1024. ** 3)),
|
"virtual_size": math.ceil(img_info['virtual-size'] / (1024. ** 3)),
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug('preparing metadata.json for box %s', output)
|
logging.debug('preparing metadata.json for box %s', output)
|
||||||
with open('metadata.json', 'w') as fp:
|
with open('metadata.json', 'w') as fp:
|
||||||
fp.write(json.dumps(metadata))
|
fp.write(json.dumps(metadata))
|
||||||
logger.debug('preparing Vagrantfile for box %s', output)
|
logging.debug('preparing Vagrantfile for box %s', output)
|
||||||
vagrantfile = textwrap.dedent("""\
|
vagrantfile = textwrap.dedent("""\
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.ssh.username = "vagrant"
|
config.ssh.username = "vagrant"
|
||||||
@ -420,31 +409,34 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
with open('Vagrantfile', 'w') as fp:
|
with open('Vagrantfile', 'w') as fp:
|
||||||
fp.write(vagrantfile)
|
fp.write(vagrantfile)
|
||||||
with tarfile.open(output, 'w:gz') as tar:
|
with tarfile.open(output, 'w:gz') as tar:
|
||||||
logger.debug('adding metadata.json to box %s ...', output)
|
logging.debug('adding metadata.json to box %s ...', output)
|
||||||
tar.add('metadata.json')
|
tar.add('metadata.json')
|
||||||
logger.debug('adding Vagrantfile to box %s ...', output)
|
logging.debug('adding Vagrantfile to box %s ...', output)
|
||||||
tar.add('Vagrantfile')
|
tar.add('Vagrantfile')
|
||||||
logger.debug('adding box.img to box %s ...', output)
|
logging.debug('adding box.img to box %s ...', output)
|
||||||
tar.add('box.img')
|
tar.add('box.img')
|
||||||
|
|
||||||
if not keep_box_file:
|
if not keep_box_file:
|
||||||
logger.debug('box packaging complete, removing temporary files.')
|
logging.debug('box packaging complete, removing temporary files.')
|
||||||
os.remove('metadata.json')
|
os.remove('metadata.json')
|
||||||
os.remove('Vagrantfile')
|
os.remove('Vagrantfile')
|
||||||
os.remove('box.img')
|
os.remove('box.img')
|
||||||
|
|
||||||
else:
|
else:
|
||||||
logger.warn('could not connect to storage-pool \'default\','
|
logging.warn("could not connect to storage-pool 'default', "
|
||||||
+ 'skipping packaging buildserver box')
|
"skip packaging buildserver box")
|
||||||
|
|
||||||
def box_add(self, boxname, boxfile, force=True):
|
def box_add(self, boxname, boxfile, force=True):
|
||||||
boximg = '%s_vagrant_box_image_0.img' % (boxname)
|
boximg = '%s_vagrant_box_image_0.img' % (boxname)
|
||||||
if force:
|
if force:
|
||||||
try:
|
try:
|
||||||
_check_call(['virsh', '-c', 'qemu:///system', 'vol-delete', '--pool', 'default', boximg])
|
_check_call(['virsh', '-c', 'qemu:///system', 'vol-delete', '--pool', 'default', boximg])
|
||||||
logger.debug("removed old box image '%s' from libvirt storeage pool", boximg)
|
logging.debug("removed old box image '%s'"
|
||||||
|
"from libvirt storeage pool", boximg)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.debug("tried removing old box image '%s', file was not present in first place", boximg, exc_info=e)
|
logging.debug("tried removing old box image '%s',"
|
||||||
|
"file was not present in first place",
|
||||||
|
boximg, exc_info=e)
|
||||||
super().box_add(boxname, boxfile, force)
|
super().box_add(boxname, boxfile, force)
|
||||||
|
|
||||||
def box_remove(self, boxname):
|
def box_remove(self, boxname):
|
||||||
@ -452,10 +444,10 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
try:
|
try:
|
||||||
_check_call(['virsh', '-c', 'qemu:///system', 'vol-delete', '--pool', 'default', '%s_vagrant_box_image_0.img' % (boxname)])
|
_check_call(['virsh', '-c', 'qemu:///system', 'vol-delete', '--pool', 'default', '%s_vagrant_box_image_0.img' % (boxname)])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
logger.debug("tried removing '%s', file was not present in first place", boxname, exc_info=e)
|
logging.debug("tried removing '%s', file was not present in first place", boxname, exc_info=e)
|
||||||
|
|
||||||
def snapshot_create(self, snapshot_name):
|
def snapshot_create(self, snapshot_name):
|
||||||
logger.info("creating snapshot '%s' for vm '%s'", snapshot_name, self.srvname)
|
logging.info("creating snapshot '%s' for vm '%s'", snapshot_name, self.srvname)
|
||||||
try:
|
try:
|
||||||
_check_call(['virsh', '-c', 'qemu:///system', 'snapshot-create-as', self.srvname, snapshot_name])
|
_check_call(['virsh', '-c', 'qemu:///system', 'snapshot-create-as', self.srvname, snapshot_name])
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@ -480,7 +472,7 @@ class LibvirtBuildVm(FDroidBuildVm):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def snapshot_revert(self, snapshot_name):
|
def snapshot_revert(self, snapshot_name):
|
||||||
logger.info("reverting vm '%s' to snapshot '%s'", self.srvname, snapshot_name)
|
logging.info("reverting vm '%s' to snapshot '%s'", self.srvname, snapshot_name)
|
||||||
import libvirt
|
import libvirt
|
||||||
try:
|
try:
|
||||||
dom = self.conn.lookupByName(self.srvname)
|
dom = self.conn.lookupByName(self.srvname)
|
||||||
@ -498,7 +490,7 @@ class VirtualboxBuildVm(FDroidBuildVm):
|
|||||||
super().__init__(srvdir)
|
super().__init__(srvdir)
|
||||||
|
|
||||||
def snapshot_create(self, snapshot_name):
|
def snapshot_create(self, snapshot_name):
|
||||||
logger.info("creating snapshot '%s' for vm '%s'", snapshot_name, self.srvname)
|
logging.info("creating snapshot '%s' for vm '%s'", snapshot_name, self.srvname)
|
||||||
try:
|
try:
|
||||||
_check_call(['VBoxManage', 'snapshot', self.srvuuid, 'take', 'fdroidclean'], cwd=self.srvdir)
|
_check_call(['VBoxManage', 'snapshot', self.srvuuid, 'take', 'fdroidclean'], cwd=self.srvdir)
|
||||||
except subprocess.CalledProcessError as e:
|
except subprocess.CalledProcessError as e:
|
||||||
@ -524,7 +516,7 @@ class VirtualboxBuildVm(FDroidBuildVm):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
def snapshot_revert(self, snapshot_name):
|
def snapshot_revert(self, snapshot_name):
|
||||||
logger.info("reverting vm '%s' to snapshot '%s'",
|
logging.info("reverting vm '%s' to snapshot '%s'",
|
||||||
self.srvname, snapshot_name)
|
self.srvname, snapshot_name)
|
||||||
try:
|
try:
|
||||||
_check_call(['VBoxManage', 'snapshot', self.srvuuid,
|
_check_call(['VBoxManage', 'snapshot', self.srvuuid,
|
||||||
|
Loading…
Reference in New Issue
Block a user