Design question for new module development

From: Kurt T.
Sent on: Saturday, November 26, 2011 8:34 PM
I'm designing a module to wrap around EMC's Celerra NAS CLI.  This CLI is accessed by SSH session to the control station of the NAS, which is really a modified RHEL box.  I have a ridiculous amount of Perl automation that I wrote a few years back around this CLI but never standardized it.  There's copy/paste code all OVER the place.   Being as the new version of the automation webapp is Flask based, it makes sense to rewrite the backend perl code with Python.   Python is version 2.3 on recent versions of the gear, newer revs of the gear appear to have Python 2.4, so I'm stuck with the 2.x series.

One of the key design points is that I want to be able to utilize the module whether I'm running it from a python script on a remote server, the control station itself, or another control station of another NAS (at a remote site for example)  

Once I wrap the CLI itself I'm going to also implement a submodule in the package of 'helpers' which do common tasks that are done from the CLI (like actually creating a filesystem is a 3 step process, make the FS, make the mountpoint, mount the FS)

I'm a bit torn now on how to structure this.  I envision a class for the actual connection to the Celerra CS (be it local, or remote) however am not sure how to wrap the commands I wish to run around that connection object.

Pseudo Code:


from celerra import Celerra

local_connection = Celerra('local')  # A connection to myself (running on local CS)
local_connection.connect()           #  This seems to be the recommended pattern, as it makes it easier to mock out the connection?

remote_connection = Celerra('[masked]',user='nasadmin',password='mypass')  # A connection to a remote CS
remote_connection.connect()      

Now should I do something like this (where nas_fs is a function of the connection object)

remote_connection.nas_fs('create',name='Test',size='300G')

or like this, where nas_fs stands alone and isn't really a part of the connection itself, I believe it would be easier to mock out the connection object in this case for testing??

celerra.nas_fs('create',remote_connection,name='Test',size='300G')   



Also, any experienced pythonistas in the Limerick/KOP area that might be willing to do some code review with me as I get further into this?  It's really my first "big" python project.

Thanks!
Kurt Telep

Our Sponsors

People in this
Meetup are also in:

Sign up

Meetup members, Log in

By clicking "Sign up" or "Sign up using Facebook", you confirm that you accept our Terms of Service & Privacy Policy