(self)
Clean up any walmgr files on slave and master.
Clean up any walmgr files on slave and master.
Clean up any walmgr files on slave and master .
def walmgr_cleanup(self):
        """
        Clean up any walmgr files on slave and master.
        """

        if not self.is_master:
            # remove walshipping directory
            dirname = self.cf.getfile("walmgr_data")
            self.log.info("Removing walmgr data directory: %s", dirname)
            if not self.not_really:
                shutil.rmtree(dirname)

            # remove backup 8.3/main.X directories
            backups = glob.glob(self.cf.getfile("slave_data") + ".[0-9]")
            for dirname in backups:
                self.log.info("Removing backup main directory: %s", dirname)
                if not self.not_really:
                    shutil.rmtree(dirname)

            ssh_dir = os.path.expanduser("~/.ssh")
            auth_file = os.path.join(ssh_dir, "authorized_keys")

            if self.options.ssh_remove_key and os.path.isfile(auth_file):
                # remove master key from ssh authorized keys, simple substring match should do
                keys = ""
                for key in open(auth_file):
                    if not self.options.ssh_remove_key in key:
                        keys += key
                    else:
                        self.log.info("Removed %s from %s", self.options.ssh_remove_key, auth_file)

                self.log.info("Overwriting authorized_keys file")

                if not self.not_really:
                    tmpfile = auth_file + ".walmgr.tmp"
                    f = open(tmpfile, "w")
                    f.write(keys)
                    f.close()
                    os.rename(tmpfile, auth_file)
                else:
                    self.log.debug("authorized_keys:\n%s", keys)

            # remove password from .pgpass
            primary_conninfo = self.cf.get("primary_conninfo", "")
            if self.options.remove_password and primary_conninfo and not self.not_really:
                pg = Pgpass('~/.pgpass')
                host, port, user, _ = self.parse_conninfo(primary_conninfo)
                if pg.remove_user(host, port, user):
                    self.log.info("Removing line from .pgpass")
                    pg.write()

        # get rid of the configuration file, both master and slave
        self.log.info("Removing config file: %s", self.cfgfile)
        if not self.not_really:
            os.remove(self.cfgfile)
def walmgr_cleanup ( self ) : if not self . is_master : # remove walshipping directory dirname = self . cf . getfile ( "walmgr_data" ) self . log . info ( "Removing walmgr data directory: %s" , dirname ) if not self . not_really : shutil . rmtree ( dirname ) # remove backup 8.3/main.X directories backups = glob . glob ( self . cf . getfile ( "slave_data" ) + ".[0-9]" ) for dirname in backups : self . log . info ( "Removing backup main directory: %s" , dirname ) if not self . not_really : shutil . rmtree ( dirname ) ssh_dir = os . path . expanduser ( "~/.ssh" ) auth_file = os . path . join ( ssh_dir , "authorized_keys" ) if self . options . ssh_remove_key and os . path . isfile ( auth_file ) : # remove master key from ssh authorized keys, simple substring match should do keys = "" for key in open ( auth_file ) : if not self . options . ssh_remove_key in key : keys += key else : self . log . info ( "Removed %s from %s" , self . options . ssh_remove_key , auth_file ) self . log . info ( "Overwriting authorized_keys file" ) if not self . not_really : tmpfile = auth_file + ".walmgr.tmp" f = open ( tmpfile , "w" ) f . write ( keys ) f . close ( ) os . rename ( tmpfile , auth_file ) else : self . log . debug ( "authorized_keys:\n%s" , keys ) # remove password from .pgpass primary_conninfo = self . cf . get ( "primary_conninfo" , "" ) if self . options . remove_password and primary_conninfo and not self . not_really : pg = Pgpass ( '~/.pgpass' ) host , port , user , _ = self . parse_conninfo ( primary_conninfo ) if pg . remove_user ( host , port , user ) : self . log . info ( "Removing line from .pgpass" ) pg . write ( ) # get rid of the configuration file, both master and slave self . log . info ( "Removing config file: %s" , self . cfgfile ) if not self . not_really : os . remove ( self . cfgfile )