2003 Triumph Speedmaster modifications #1

profilebetty

  1. Mirrors replaced
  2. Turn signals relocated
  3. Turn signal lens color changed
  4. Gas tank kneepads

birdseyebetty

Continue reading » · Rating: · Written on: 08-17-10 · No Comments »

2003 Triumph Speedmaster

3,000 Miles

2004 tank paint job

2004 windshield

dresser bars, knee pads, mirrors, and signal relocators to come.

tank

Picture-2

trailer

Picture-1

Picture-3

Continue reading » · Rating: · Written on: 08-02-10 · No Comments »

Pexpect, Python, and Managing Devices — Tratto

tratto-logo
A few months ago I decided to write a web application that would essentially run like RANCID, I named it “tratto.”  Since then I decided that it would be better to nail down a basic python framework first, then integrate it into say.. a django application.  In all of my years as an engineer I had never leveraged expect to accomplish simple and repetitive tasks. I am a recent python “convert” and wanted to write a simple app that could be used as a framework for managing and monitoring network connected devices and hosts.  Tratto uses pexpect to connect and parse ssh and telnet sessions.

This framework provides an easy way to connect to remote devices and issue commands and store the output. I also wanted an easy way to “extend” this framework and be able to add ways to connect to any operating system (or at least use default shell behavior as a baseline).  I manage a wide variety of devices and I wanted to support at least the default implementations of Cisco IOS, OpenBSD, Mac OS X, and Aruba OS.  Here is how you would add an operating system’s parameters to Tratto (Systems.py):

class ArubaOS(OperatingSystem):
	'''aruba configs'''
	PROMPTLINE	='#'
	PAGINATES 	=True
	DISABLE_PAGINATION = 'terminal length 0'
	GET_CONFIG	="show run"

There are 3 files included in Tratto right now:

  1. Connectivity.py — This is a class which manages sessions using pexpect
  2. Systems.py — This is the class which manages all the operating parameters
  3. driver.py — This is an example file of how to use Tratto to fetch whatever info you want

Here is an example of how to use the framework to connect to devices and issue commands:

#!/usr/bin/env python

import Connectivity
import Systems

#telnet to a cisco switch
m = Systems.OperatingSystems['IOS']
s = Connectivity.Session("192.168.6.1",23,telnet,m)
s.login("akonkol", "mypass")
s.sendcommand("show ver")
s.sendcommand("show clock")
s.sendcommand("show run")
s.logout()

#ssh to a apple machine
m = Systems.OperatingSystems['OSX']
s = Connectivity.Session("127.0.0.1",22,"ssh",m)
s.login("akonkol", "mypass")
#sendcommand will echo response by default, you can store that
#response in a variable if you wish
result = s.sendcommand("df -h")
print result
s.getversion()
s.logout()

#ssh to openbsd box
m = Systems.OperatingSystems['OBSD']
s = Connectivity.Session("192.168.5.1",22,"ssh",m)
s.login("akonkol", "mypass")
print s.sendcommand("cat /etc/passwd")
print s.sendcommand("arp -a")
s.logout()

The Future

With Tratto you can technically pull information from any networked device and use that data for whatever you please. Current ideas are integrating Tratto into

  • a config repository application with a web frontend (like RANCID)
  • a network mapping application using cdp neighbors
  • monitoring platform which performs different commands based on certain scenarios (”show interfaces” when IP SLA shows latency)

This is my first attempt at releasing python software, so if you think something could be better let me know.
Download Tratto

Continue reading » · Rating: · Written on: 01-26-10 · 1 Comment »

New phone, New Development, New Instructions

I recently won a Motorola Droid phone in the “claw event” promotion held by Verizon.  That being said I wanted to take a stab at some development on it.  I was trying to use the SimpleCursorAdaptor method to bind results from sqlite to a listview.. and it just wasn’t happening.

To create the database I had a line like this:

private static final String DATABASE_CREATE =
             "create table decks (id integer primary key autoincrement, "
             + "name text not null);";

My application would throw an exception and I had no idea why until I wrote  a simple debug method.  It’s the equivalent of  “alert();” in javascript.

public void createAlert(String message){
      AlertDialog alertDialog = new AlertDialog.Builder(this).create();
      alertDialog.setTitle("Message");
      alertDialog.setMessage(message);
      alertDialog.setButton("OK", new DialogInterface.OnClickListener(){
      public void onClick(DialogInterface dialog, int which){
                    return; }
      });
      alertDialog.show();
}

I simply threw my code in a java try-catch and received the error: “column _id does not exist.”  Did you catch that?  I didn’t declare my column name with an underscore.

I guess it is always good to read the documentation.

Adapter that exposes data from a Cursor to a ListView widget. The Cursor must include a column named “_id” or this class will not work.

Now why would I post this lame crap? Because after googling the problem… it seems that a lot of beginners are running into this issue.

Continue reading » · Rating: · Written on: 12-01-09 · 1 Comment »

Maintaining Sanity Through Insanity

Last month was a spirit crusher due to an increased workload. Every once in a while I decide to run into the woods and get lost in something that I’ve never done. It’s been a while since I’ve had the chance to develop something selfishly.

Last year I wrote an intranet site using ruby on rails for what I call “personal enrichment.” Rails went OK, but whenever I wanted to achieve something that wasn’t textbook I found myself writing code that was like a trick/hack… needless to say it didn’t give me a good feeling.

About 6 months ago i started to force myself to use Python for all shell script tasks that were thrown my way. I love python. If you are used to scripting or actually enjoy scripting python is great. Now one of my pet peeves is when people say things like “lightweight, efficient, clean, easy to read.” Now all of those things are great.. but what does it really mean? Visual Basic is almost like writing english and developers think its the fisher-price of languages (including me). I have no answer to why I like python except a few little things:

  • whitespace is used to terminate directives, which forces everyone to use similar formatting
  • smtplib is the best email library I’ve ever worked with
  • django doesn’t assume as much as rails does, you still have some tedious work but I find it the perfect balance.

So I built my first site in django it’s currently running in my dev enviornment. What does the app do? It’s an app that uses the power of expect (one of my favorites), diff (another favorite), and a repository model. Simply put, the app connects to a device (via ssh/telnet) logs in and issues a command, stores the output in a database, does a diff between the last retrieved output and does a diff, if there is a diff it emails the system owner.

What does this achieve? Automatic change control and a configuration repository. I’ve used RANCID to do this before and I love the concept. RANCID doesn’t have a front end, but it also uses cvs/svn so you can install cvs/svn frontends.

I re-invented the wheel, but I like this wheel… it’s dead simple… and it helps out those admins that suck at cli.

Like I said, I haven’t deployed it yet… but I think I may want to release it. So my next problem I’m thinking about is how to package up and release a distribution. I’ve never used/installed a django driven web app… how do people usually release their django projects to the public? VMs?

tratto-screenshot

Continue reading » · Rating: · Written on: 08-08-09 · No Comments »