Has anyone created an Expect script to backup the configuration file of the ZoneDirector?

  • 1
  • Question
  • Updated 4 weeks ago
I would like to run this as a daily job from my Unix server.
Photo of Dave Hackenberg

Dave Hackenberg

  • 2 Posts
  • 0 Reply Likes

Posted 4 years ago

  • 1
Photo of Keith - Pack Leader

Keith - Pack Leader

  • 860 Posts
  • 51 Reply Likes
Here's a sample using the expect library in Ruby, and involving other commands, but it should give you a good framework to expand on:

http://pivotallabs.com/using-ruby-exp...
Photo of Keith - Pack Leader

Keith - Pack Leader

  • 860 Posts
  • 51 Reply Likes
You got me curious so here's a very simple python script (which in this case grabs my standalone AP syslog, then turn control of the session over to me). Uses pexpect which is a very simple python library to provide expect-like controls.


#!/usr/bin/env python
import pexpect #
child = pexpect.spawn ('ssh 192.168.1.10')
child.expect ('Please login:')
child.sendline ('myuserid)
child.expect ('password :')
child.sendline ('mypassword')
child.expect ('rkscli:') # the normal AP prompt
child.sendline ('get syslog log')
print child.before #this object refers to the output of the last child call
child.interact() #puts me on the AP CLI


I used this to verify that 9.7 corrects the "channel 165 blocked" issue (it does)

I think this would be easily adaptable to your need. Pexpect is easy to find on google and installation was trivial.

If you haven't scripted before, python is a pretty gentle introduction with clean syntax and not too many rules about typing variables and such. Lot's of tutorials online as well. Almost any major scripting language will do, so if you already are comfortable with one, most have expect or a variant already installed or installable.
Photo of Bill Burns

Bill Burns, AlphaDog

  • 203 Posts
  • 38 Reply Likes
Photo of Joel Baltazor

Joel Baltazor

  • 6 Posts
  • 1 Reply Like
I'm a little dense, what would actual command line usage of this tool look like to download or backup a config from an AP and ZoneDirector ?

Thanks,
Joel
Photo of Bill Burns

Bill Burns, AlphaDog

  • 203 Posts
  • 38 Reply Likes
hmm.. yes. I should have included a much simpler example.
Try this:

./ruckusconf --enable --command "show conf"
Let me know how that works for you.

If you need it to do more/other things, let me know.
There are *lots* of other options.
Photo of Joel Baltazor

Joel Baltazor

  • 6 Posts
  • 1 Reply Like
Hi Bill!
Thanks for the quick reply (and for the tool)
I'm a fairly new Ruckus user so forgive all my questions:

I can't seem to get my stand alone access points (I have both ZD and some stand alone APs) to work with this. They don't seem to have "show conf" so this won't work right? Do you (or does anyone else) happen to know the equivalent command line syntax?

I'm trying this against my zonedirector:
./ruckusconf --enable --command "show conf" --quite --outfile /some/path/on/server/output. MY_ZD_IP_HERE

I must misunderstand how --quiet is supposed to work, when I include it I do not get any relevant data in my output file. If I do not include --quiet, I get the output correctly saved into the outfile, but also on screen. My goal was to be able to cron the script up in order to automatically download/save a copy of the configuration.

Not necessarily a question for Bill but:
The output I see doesn't appear to be restoreable in any way, it's not like my network switches that output a list of commands that I could paste back into a shell session of a replacement device. Am I wrong about this?

Thanks,
Joel
Photo of Bill Burns

Bill Burns, AlphaDog

  • 203 Posts
  • 38 Reply Likes
Joel: Sorry if I'm a little rusty on this but here are my answers:
(Last question answered first)

1)
You're right, you can't re-enter the output of "show conf" to restore a config.
If I were you, I would enter a feature request on this site for a "show" command that provides "usable"/enterable configuration as its output.
Open a support ticket and ask for them to recognize/add the feature request.
Then, call your sales person and ask for that feature request to be given a priority.

I'm not saying that'll get you anywhere but we shouldn't get too upset about things being broken if we're not willing to push for a solution.

2)
re: --quiet:
Yea. that's not doing what you want.
(and I don't recall what the use-case for it was)

3)
re: cronfiles:
My approach would be to write a wrapper that calls ruckusconf and sends output to /dev/null
Also: you probably want to put the --outfile parameter before the --command parameter.

note: if you're going to schedule ruckusconf in cron you probably have to use the --password option. Embedded passwords are difficult to secure in a linux/unix environment.
Make sure your linux box can only be used by trusted people.

note: I was working on a solution to the embedded passwords for scheduled jobs problem that involved using the --repeatevery option to avoid the use of cron.
I don't recall if it was in a working state but feel free to play w/ it.

4)
re: downloading information from standalone access points:
that's what the --ap option is for.
type:
"./ruckusconf --example"
to see an example.

Let me know how that works for you.
Photo of Matthew Cooper

Matthew Cooper

  • 2 Posts
  • 0 Reply Likes
Has anyone been able to get Bill's ruckusconf script working? I am getting a syntax error returned:

sh ruckusconf.sh --enable --command "show conf" x.x.x.x
ruckusconf.sh: line 64: syntax error near unexpected token `}'
ruckusconf.sh: line 64: `  } else {

Any help appreciated.
Photo of Matthew Cooper

Matthew Cooper

  • 2 Posts
  • 0 Reply Likes
If anyone stumbles across this I got it working. I was running the script without 'expect' - d'oh! 

expect ruckusconf.sh --enable --outfile /path/to/outputdir/ --command "show conf" x.x.x.x

Obviously update username and password within the script. 

Matt