Esempio n. 1
0
 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)
Esempio n. 2
0
 def unfreeze(self):
   sudo(s("lxc-unfreeze -n ${self.name}"))
Esempio n. 3
0
 def freeze(self):
   sudo(s("lxc-freeze -n ${self.name}"))
Esempio n. 4
0
 def start(self):
   #if self.started:
   #  return
   sudo(s("lxc-start -n ${self.name} -d"))
Esempio n. 5
0
 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}"))