mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Use remount() to create a clean snapshot
This commit is contained in:
parent
b025f6ed35
commit
ceae489210
2 changed files with 11 additions and 8 deletions
|
@ -28,11 +28,12 @@ def remount(volume, fn):
|
||||||
p_map.root.unmount()
|
p_map.root.unmount()
|
||||||
if not isinstance(p_map, NoPartitions):
|
if not isinstance(p_map, NoPartitions):
|
||||||
p_map.unmap(volume)
|
p_map.unmap(volume)
|
||||||
fn()
|
result = fn()
|
||||||
p_map.map(volume)
|
p_map.map(volume)
|
||||||
else:
|
else:
|
||||||
fn()
|
result = fn()
|
||||||
p_map.root.mount(root_dir)
|
p_map.root.mount(root_dir)
|
||||||
if hasattr(p_map, 'boot'):
|
if hasattr(p_map, 'boot'):
|
||||||
p_map.boot.mount(boot_dir)
|
p_map.boot.mount(boot_dir)
|
||||||
volume.mount_specials()
|
volume.mount_specials()
|
||||||
|
return result
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
from base import Task
|
from base import Task
|
||||||
from common import phases
|
from common import phases
|
||||||
from providers.ec2.tasks import ebs
|
|
||||||
from common.tasks import volume
|
from common.tasks import volume
|
||||||
from common.tasks import bootstrap
|
from common.tasks import bootstrap
|
||||||
from common.tasks import filesystem
|
from common.tasks import filesystem
|
||||||
|
from common.fs import remount
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
import os.path
|
import os.path
|
||||||
import time
|
import time
|
||||||
|
@ -11,14 +11,16 @@ import logging
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Snapshot(ebs.Snapshot):
|
class Snapshot(Task):
|
||||||
description = 'Creating a snapshot of the bootstrapped volume'
|
description = 'Creating a snapshot of the bootstrapped volume'
|
||||||
phase = phases.os_installation
|
phase = phases.os_installation
|
||||||
after = [bootstrap.Bootstrap]
|
after = [bootstrap.Bootstrap, filesystem.MountSpecials]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
super(Snapshot, self).run(info)
|
def mk_snapshot():
|
||||||
msg = 'A snapshot of the bootstrapped volume was created. ID: {id}'.format(id=info.snapshot.id)
|
return info.volume.snapshot()
|
||||||
|
snapshot = remount(info.volume, mk_snapshot)
|
||||||
|
msg = 'A snapshot of the bootstrapped volume was created. ID: {id}'.format(id=snapshot.id)
|
||||||
log.info(msg)
|
log.info(msg)
|
||||||
|
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ class CreateFromSnapshot(Task):
|
||||||
class CopyImage(Task):
|
class CopyImage(Task):
|
||||||
description = 'Creating a snapshot of the bootstrapped volume'
|
description = 'Creating a snapshot of the bootstrapped volume'
|
||||||
phase = phases.os_installation
|
phase = phases.os_installation
|
||||||
after = [bootstrap.Bootstrap]
|
after = [bootstrap.Bootstrap, filesystem.MountSpecials]
|
||||||
|
|
||||||
def run(self, info):
|
def run(self, info):
|
||||||
loopback_backup_name = 'volume-{id:x}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)
|
loopback_backup_name = 'volume-{id:x}.{ext}.backup'.format(id=info.run_id, ext=info.volume.extension)
|
||||||
|
|
Loading…
Add table
Reference in a new issue