[rancid] Renaming devices? (svn backend)

Daniel Schmidt daniel.schmidt at wyo.gov
Wed Apr 17 15:28:15 UTC 2013

An example: I threw something together quick (not well - quick) for the
other network guys so they could copy/paste output.  If I weren't so
lazy/busy, I would make it run the commands it's self, set a path at the
top, yada yada.  Change paths & it work 4 U.

$ cat stupid_change.py

# Just tell me how to change it!
# not written well, just written in 15 minutes
# could probably be done in bash

import sys

def check_yn(message, default):
    answer = ''
    while not ((answer == 'y') or (answer =='n')):
        answer = raw_input(message)
        answer = answer.lower()
        if answer == '':
            return default
    if answer == 'y':
        return True
        return False

def gen_crap(old_name, new_name, type):
    print ("sed -i 's/%s/%s/g' /home/rancid/var/%s/router.db"
            % (old_name, new_name, type))
    print ("cp -p /home/rancid/var/CVS/%s/configs/%s,v \
            % (type, old_name, type, new_name))
    print "cd /home/rancid/var/%s/configs" % type
    print "cvs update"
    print "/home/rancid/bin/rancid-run -r %s" % new_name
    print "cd ~\n"

def main():
    if not len(sys.argv) == 3:
        if len(sys.argv) == 4:
            gen_crap(sys.argv[1], sys.argv[2], sys.argv[3])
            print "Usage:\n./stupid_change.py old_name new_name
        if check_yn("Is this a switch?(y):", True):
            gen_crap(sys.argv[1], sys.argv[2], 'Switches')
            gen_crap(sys.argv[1], sys.argv[2], 'Routers')

if __name__ == "__main__":

-----Original Message-----
From: rancid-discuss-bounces at shrubbery.net
[mailto:rancid-discuss-bounces at shrubbery.net] On Behalf Of Howard Jones
Sent: Wednesday, April 17, 2013 7:42 AM
To: rancid-discuss at shrubbery.net
Subject: [rancid] Renaming devices? (svn backend)

Hi Folks,

I'm just about to implement a new naming scheme for all our network gear,
and I'd like to rename it in such a way that I don't lose the history in
RANCID. I found a couple of messages in the list archive for the way to do
this with a CVS backend, but I have Subversion. Does anyone know the
svn-fu necessary to do this cleanly?


Rancid-discuss mailing list
Rancid-discuss at shrubbery.net

E-Mail to and from me, in connection with the transaction 
of public business, is subject to the Wyoming Public Records 
Act and may be disclosed to third parties.

More information about the Rancid-discuss mailing list