Esempio 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
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)
Esempio 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)
Esempio 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
Esempio n. 5
0
 def renameleases(self, leasesdir, vmsdir, ips):
     for ip in ips:
         oldfile = leasesdir + "/" + ip
         newfile = vmsdir + "/" + ip
         fileutil.rename(oldfile, newfile)
Esempio n. 6
0
 def renameleases(self, leasesdir, vmsdir, ips):
     for ip in ips:
         oldfile = leasesdir + "/" + ip
         newfile = vmsdir + "/" + ip
         fileutil.rename(oldfile, newfile)