Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Build a Custom Cisco Configuration Repository : Page 3

You don't have to spend a fortune on CiscoWorks to store and compare your Cisco router configurations. With a little work and some help from Subversion, you can roll your own.


advertisement
Testing Your Installation
You're going to create a simple file to make sure that everything is working properly. Create a file called README.txt inside ~/tmp/depot, and put whatever content you'd like inside it.

conrad@gonzo:~/tmp/depot> echo "This is a Router Configuration Repository" > ~/tmp/depot/README.txt

Next, add that file to the repository. Without this step, the repository won't know about the new file, so this is important.

conrad@gonzo:~/tmp/depot> svn add ~/tmp/depot/README.txt A /home/conrad/tmp/depot/README.txt

Commit the file. The repository keeps a log of changes as part of the commit process. You need to define a text editor for this. Make sure your EDITOR shell environmental is set for your favorite editor. Use echo $EDITOR to display this variable. If it is not set, use EDITOR=vi; export EDITOR or setenv EDITOR vi depending on your shell. Because tastes in editors vary, simply change "vi" to reflect the launch command for your favorite editor.

By default, Subversion will send your username as your login name to the server to perform a commit. It'll simply ask for a password.



conrad@gonzo:~/tmp/depot> svn commit Adding README.txt Transmitting file data . Committed revision 5.

After typing svn commit, your text editor will launch so you can put some notes in the log for the update. Now that you know commits are working properly, here's a look at some of the basic things you can do with Subversion. First, remove the old ~/tmp/depot directory. Use rm—rf ~/tmp/depot to do this. Then, check out the repository again. The following command checks out the README.txt file you just created.

conrad@gonzo:~/tmp> svn co http://localhost/depot A depot/README.txt Checked out revision 5.

Author's Note: svn help <command name> will show some additional help for the commands you're running here.

You can view the repository log:

conrad@gonzo:~/tmp/depot> svn log ------------------------------------------------------ r1 | conrad | 2004-07-11 16:26:32 -0400 (Sun, 11 Jul 2004) | 2 lines Initial import ------------------------------------------------------

You can also list the files that are in the repository:

conrad@gonzo:~/tmp/depot> svn ls README.txt

Now, add some more content to README.txt

conrad@gonzo:~/tmp/depot> echo "Subversion is loads of fun" >> README.txt

You can tell that the file's been modified, by running svn status:

conrad@gonzo:~/tmp/depot> svn status M README.txt

Now, we're going to create a basic configuration repository structure inside of Subversion. This could be as elaborate or as simple as you want. I'm simply creating different directories for router configurations and switch configurations.

conrad@gonzo:~/tmp/depot> svn mkdir routers A routers conrad@gonzo:~/tmp/depot> svn mkdir switches A switches

The svn status command now shows us that README.txt has been modified, and these two directories have been added:

conrad@gonzo:~/tmp/depot> svn status A routers A switches M README.txt

Now, update the repository by running svn update, and then commit your changes.

conrad@gonzo:~/tmp/depot> svn commit Sending README.txt Adding routers Adding switches Transmitting file data . Committed revision 6.

Just to show a few more features, go to ~/tmp, and check out the repository again:

conrad@gonzo:~/tmp> svn co http://localhost/depot Checked out revision 6.

Now, svn log shows not only the initial import, but the subsequent entries as well:

conrad@gonzo:~/tmp/depot> svn log ------------------------------------------------------ r6 | conrad | 2004-07-11 19:24:02 -0400 (Sun, 11 Jul 2004) | 3 lines Added basic directory structure. ------------------------------------------------------ r5 | conrad | 2004-07-11 19:11:57 -0400 (Sun, 11 Jul 2004) | 2 lines Initial checkout ------------------------------------------------------

One of Subversion's nicest features is the ability to show what's changed, using svn diff.

conrad@gonzo:~/tmp/depot> svn diff -r 5:6 README.txt Index: README.txt ====================================================== --- README.txt (revision 5) +++ README.txt (revision 6) @@ -1 +1,2 @@ This is a Router Configuration Repository +Subversion is loads of fun

In the diff output shown above, you can see the changes made from revision 5 to revision 6 of the README.txt file. The plus sign (+) next to the second line ("Subversion is loads of fun") shows that that is the new line. Now, when you access the repository via a regular Web browser, it should look like this:

Revision 6: / * README.txt * routers/ * switches/ Powered by Subversion version 1.0.5 (dev build).



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap