File: folder.py

package info (click to toggle)
bootstrap-vz 0.9.11%2B20180121git-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,244 kB
  • sloc: python: 8,800; sh: 813; makefile: 16
file content (24 lines) | stat: -rw-r--r-- 634 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from bootstrapvz.base.fs.volume import Volume


class Folder(Volume):

    # Override the states this volume can be in (i.e. we can't "format" or "attach" it)
    events = [{'name': 'create', 'src': 'nonexistent', 'dst': 'attached'},
              {'name': 'delete', 'src': 'attached', 'dst': 'deleted'},
              ]

    extension = 'chroot'

    def create(self, path):
        self.fsm.create(path=path)

    def _before_create(self, e):
        import os
        self.path = e.path
        os.mkdir(self.path)

    def _before_delete(self, e):
        from shutil import rmtree
        rmtree(self.path)
        del self.path