Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have aproximately 100 switches that need to be renamed in zenoss and a csv file with the IP address and corresponding name. Is there a way to rename a device from the terminal so that I can knock up a quick script to parse the csv and rename the devices based on the IP address?

share|improve this question

2 Answers 2

Indeed there is. There is a zendmd CLI interface which provides a pythonic way to interact with Zenoss.

$ /usr/local/zenoss/zenoss/bin/zendmd

I'm not 100% sure, but "renaming" devices is probably akin to "moving" them in the devices hierarchy. There are logs of examples here to get you started.

share|improve this answer
    
Recommend you hit #zenoss on irc.freenode.net someone there likely knows exactly how to do this off the top of there head. –  SpacemanSpiff Jan 1 '11 at 0:42

I came across this while looking for the same solution. I took lukecyca's advice and asked on #zenoss.

The answer is to use zendmd to execute some python, either interactively or write a script to do it.

The following script was suggested by "frooderino" on #zenoos:

#file.csv is just a txt file with oldname,newname on each line
f = open('file.csv').read().split('\n')
print('starting rename')
for i in f:
  sync()
  o = i.split(',')
  d = dmd.Devices.findDevice(o[0])
  print('Current Name: %s' % d.id)
  d.renameDevice(o[1])
  commit()
  print('New Name: %s' % d.id)
print('done renames')

The input file would look like:

oldname1,newname1
oldname2,newname2
etc.

I adapted it slightly to run from a variable rather than a file but it worked just great.

you can run it in the zendmd shell using: execfile("script.py") at the >>> prompt. Alternatively, type it into the shell directly (remember to indent).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.