Exemplo n.º 1
0
 def _save_to_disk(self):
     if self.valstr is not None:
         log.msg("%s._save_to_disk(): fname: %s" % (
             self.objname,
             self.fname,
         ))
         of = open(self.fname + ".tmp", "wb")
         of.write(self.valstr)
         of.flush()
         of.close()
         of = None
         fileutil.remove_if_possible(self.fname)
         fileutil.rename(self.fname + ".tmp", self.fname)
         log.msg(
             "%s._save_to_disk(): now, having finished write(), os.path.isfile(%s): %s"
             % (
                 self,
                 self.fname,
                 os.path.isfile(self.fname),
             ))
         self.valstr = None
         self.dirty = False
         try:
             self.savertask.callId.cancel()
         except:
             pass
         self.savertask = None
Exemplo n.º 2
0
def writekeys(slice, keys):
    import fileutil, tempfile
    keysfile = os.path.expanduser("~%s/.ssh/authorized_keys" % slice)
    temp = tempfile.mktemp()
    f = open(temp, "w")
    for k in keys:
        f.write(k + "\n")
    f.close()
    fileutil.rename(temp, keysfile)
Exemplo n.º 3
0
def writekeys(slice, keys):
    import fileutil, tempfile
    keysfile = os.path.expanduser("~%s/.ssh/authorized_keys" % slice)
    temp = tempfile.mktemp()
    f = open(temp, "w")
    for k in keys:
        f.write(k + "\n")
    f.close()
    fileutil.rename(temp, keysfile)
Exemplo n.º 4
0
 def _save_to_disk(self):
     if self.valstr is not None:
         log.msg("%s._save_to_disk(): fname: %s" % (self.objname, self.fname,))
         of = open(self.fname + ".tmp", "wb")
         of.write(self.valstr)
         of.flush()
         of.close()
         of = None
         fileutil.remove_if_possible(self.fname)
         fileutil.rename(self.fname + ".tmp", self.fname)
         log.msg("%s._save_to_disk(): now, having finished write(), os.path.isfile(%s): %s" % (self, self.fname, os.path.isfile(self.fname),))
         self.valstr = None
         self.dirty = False
         try:
             self.savertask.callId.cancel()
         except:
             pass
         self.savertask = None
Exemplo n.º 5
0
 def renameleases(self, leasesdir, vmsdir, ips):
     for ip in ips:
         oldfile = leasesdir + "/" + ip
         newfile = vmsdir + "/" + ip
         fileutil.rename(oldfile, newfile)
Exemplo n.º 6
0
 def renameleases(self, leasesdir, vmsdir, ips):
     for ip in ips:
         oldfile = leasesdir + "/" + ip
         newfile = vmsdir + "/" + ip
         fileutil.rename(oldfile, newfile)