def create(self): if exists(self.root): raise Exception(s("Cannot create snapshot: path exists: ${self.root}")) sudo(s("btrfs subvolume snapshot ${self.tpl} ${self.root}")) os.makedirs(s("/var/lib/lxc/${self.name}/")) with open(s("/var/lib/lxc/${self.name}/config"), 'w') as fd: data = s(TPL) fd.write(data) if self.cpus: strcpus = ",".join(map(lambda x: str(x), self.cpus)) fd.write("lxc.cgroup.cpuset.cpus = %s\n" % strcpus)
def unfreeze(self): sudo(s("lxc-unfreeze -n ${self.name}"))
def freeze(self): sudo(s("lxc-freeze -n ${self.name}"))
def start(self): #if self.started: # return sudo(s("lxc-start -n ${self.name} -d"))
def destroy(self): self.stop(t=1) sudo_(s("lxc-destroy -n ${self.name} -f")) if exists(self.root): sudo(s("btrfs subvolume delete ${self.root}")) sudo_(s("rm -rf ${self.root}"))