(self)
Initialize configuration file, generate SSH key pair if needed.
Initialize configuration file, generate SSH key pair if needed.
Initialize configuration file generate SSH key pair if needed .
def walmgr_init_master(self):
        """
        Initialize configuration file, generate SSH key pair if needed.
        """

        self.guess_locations()

        if not self.options.slave:
            die(1, 'Specify slave host name with "--slave" option.')

        self.override_cf_option('master_bin', self.postgres_bin)
        self.override_cf_option('master_config', self.postgres_conf)
        self.override_cf_option('master_data', self.pgdata)

        # assume that slave config is in the same location as master's
        # can override with --set slave_config=
        slave_walmgr_dir = os.path.abspath(os.path.expanduser(self.options.config_dir))
        self.override_cf_option('slave_config', os.path.join(slave_walmgr_dir, "wal-slave.ini"))

        master_config = """[walmgr]
job_name            = %(job_name)s
logfile             = %(logfile)s
pidfile             = %(pidfile)s
use_skylog          = 1

master_db           = %(master_db)s
master_data         = %(master_data)s
master_config       = %(master_config)s
master_bin          = %(master_bin)s

slave               = %(slave)s
slave_config        = %(slave_config)s

walmgr_data         = %(walmgr_data)s
completed_wals      = %(completed_wals)s
partial_wals        = %(partial_wals)s
full_backup         = %(full_backup)s
config_backup       = %(config_backup)s

keep_symlinks       = %(keep_symlinks)s
compression         = %(compression)s
"""

        try:
            opt_dict = dict([(k, self.cf.get(k)) for k in self.cf.options()])
            opt_dict['slave'] = self.options.slave
            master_config = master_config % opt_dict
        except KeyError, e:
            die(1, 'Required setting missing: %s' % e)

        self.write_walmgr_config(master_config)

        # generate SSH key pair if requested
        if self.options.ssh_keygen:
            keyfile = os.path.expanduser("~/.ssh/id_dsa")
            if os.path.isfile(keyfile):
                self.log.info("SSH key %s already exists, skipping", keyfile)
            else:
                self.log.info("Generating ssh key: %s", keyfile)
                cmdline = ["ssh-keygen", "-t", "dsa", "-N", "", "-q", "-f", keyfile ]
                self.log.debug(' '.join(cmdline))
                if not self.not_really:
                    subprocess.call(cmdline)
                key = open(keyfile + ".pub").read().strip()
                self.log.info("public key: %s", key)
def walmgr_init_master ( self ) : self . guess_locations ( ) if not self . options . slave : die ( 1 , 'Specify slave host name with "--slave" option.' ) self . override_cf_option ( 'master_bin' , self . postgres_bin ) self . override_cf_option ( 'master_config' , self . postgres_conf ) self . override_cf_option ( 'master_data' , self . pgdata ) # assume that slave config is in the same location as master's # can override with --set slave_config= slave_walmgr_dir = os . path . abspath ( os . path . expanduser ( self . options . config_dir ) ) self . override_cf_option ( 'slave_config' , os . path . join ( slave_walmgr_dir , "wal-slave.ini" ) ) master_config = """[walmgr]
job_name            = %(job_name)s
logfile             = %(logfile)s
pidfile             = %(pidfile)s
use_skylog          = 1

master_db           = %(master_db)s
master_data         = %(master_data)s
master_config       = %(master_config)s
master_bin          = %(master_bin)s

slave               = %(slave)s
slave_config        = %(slave_config)s

walmgr_data         = %(walmgr_data)s
completed_wals      = %(completed_wals)s
partial_wals        = %(partial_wals)s
full_backup         = %(full_backup)s
config_backup       = %(config_backup)s

keep_symlinks       = %(keep_symlinks)s
compression         = %(compression)s
""" try : opt_dict = dict ( [ ( k , self . cf . get ( k ) ) for k in self . cf . options ( ) ] ) opt_dict [ 'slave' ] = self . options . slave master_config = master_config % opt_dict except KeyError , e : die ( 1 , 'Required setting missing: %s' % e ) self . write_walmgr_config ( master_config ) # generate SSH key pair if requested if self . options . ssh_keygen : keyfile = os . path . expanduser ( "~/.ssh/id_dsa" ) if os . path . isfile ( keyfile ) : self . log . info ( "SSH key %s already exists, skipping" , keyfile ) else : self . log . info ( "Generating ssh key: %s" , keyfile ) cmdline = [ "ssh-keygen" , "-t" , "dsa" , "-N" , "" , "-q" , "-f" , keyfile ] self . log . debug ( ' ' . join ( cmdline ) ) if not self . not_really : subprocess . call ( cmdline ) key = open ( keyfile + ".pub" ) . read ( ) . strip ( ) self . log . info ( "public key: %s" , key )