Sep 27, 2011 5:32 AM
Trying to clean mess with devices corrupted (corrupted by me)
-
Like (0)
I did a discovery of about 350 ToIP devices, and then tried to move them from Discovered to ToIP, via moveObject (EPIC FAIL, some minutes later i saw changeDeviceClass ).
Instead of coming back to the normal situation doing moveObject to Discovered, tried to delete the devices from there, it couldn’t... Then did some zenchkrels via CLI and zendmd, with its repairs...
Well, the thing is... i left a mess. And in some point I got to move the objects back via moveObjects, but it seems it didn’t feel alright, cause, as you can see on the screenshot, those devices are now at dmd/Devices/Discovered instead of the relationship dmd/Devices/Discovered/devices. Every device is now kind of a container or Device class (at least is represented as that on zope).
The devices are not listed on Discovered.getSubDevices(), but they are listed on Discovered.getSubObjects(). The Device is also accessible via getattr(dmd.Devices.Discovered,<deviceip>).
>>> find('w.x.y.z')
>>> dev=getattr(dmd.Devices.Discovered,'w.x.y.z')
>>> dev
<Device at /zport/dmd/Devices/Discovered/w.x.y.z>
>>> dev.deviceClass()
>>> dmd.Devices.Discovered.devices()
[<Device at /zport/dmd/Devices/Discovered/devices/awelo>]
>>> #awelo is a test Device for comparing attributes
>>> dmd.Devices.Discovered.devices._add(dev)
>>> dev.deviceClass._add(dmd.Devices.Discovered)
>>> dmd.Devices.Discovered.devices()
[<Device at /zport/dmd/Devices/Discovered/devices/w.x.y.z>, <Device at /zport/dmd/Devices/Discovered/devices/awelo>]
>>> commit()
>>> dev.deleteDevice()
Traceback (most recent call last):
File "<console>", line 1, in <module>
File "/opt/zenoss/Products/ZenModel/Device.py", line 1842, in deleteDevice
parent = self.getPrimaryParent()
File "/opt/zenoss/Products/ZenRelations/PrimaryPathObjectManager.py", line 85, in getPrimaryParent
return self.__primary_parent__.primaryAq()
AttributeError: 'NoneType' object has no attribute 'primaryAq'
>>> dev.__primary_parent__
>>> dmd.Devices.Discovered.getSubDevices()
[<Device at /zport/dmd/Devices/Discovered/devices/awelo>]
>>> dmd.Devices.Discovered.devices()
[<Device at /zport/dmd/Devices/Discovered/devices/w.x.y.z>, <Device at /zport/dmd/Devices/Discovered/devices/awelo>]
>>>
I wish i could delete all this phantom elements... any hint, please?
I would also check with ZMI (Zenoss Management Interface). Point your browser at <your zenoss>:8080/zport/manage and navigate around that way.
If you have a backup (hopefully), then you can move some stuff with the ZMI - but your mileage may vary with this
Cheers,
Jane
Hi, Jane,
It's the same stuff. zmi gives same errors than deleting on zendmd
thanks for the fast response, anyway
I feel your pain luizz. Alot of methods in zenoss are a oneway street to despair. A better backup and roll back system would really help alleviate much of these problems. I too lost an installation to this type of thing.
Luizzmizz:
Ignore Tito, he's a troll.
I'd be happy to try to help you delete these objects. You could try using the ._delOb method on them. If you don't have success with that, jump on to the #zenoss channel on freenode and I'll help you out interactively.
Best,
--Shane
well just for anyone who gets into the same situation (hope no one uses moveObject without knowing what it does)... and after a long session with Shane on IRC, we decided it was better zendevicedump and zendeviceload the remaining devices and begin on a fresh install. I will mark this issue as solved, as it's not a traumatic solution .
At last, I would like to add...
in this case, (I assume) the catalog got so weird that zendevicedump got killed for having consumed all memory system.
I didn't want to loose those devices so i wrote a little dmd script for generating a zenbatchload file, i post it here in case anyone needs it. It respects heritance of zproperties and tries to get the most resumed. It's a kind script done for generating the batch load file and then REVISING before zenbatchload it.
Here it goes:
And here goes the paste (i'm a newbie with python, so i'm anticipatedly sorry for my sins on this script):
def zPrint(zProperty):
if type(zProperty[1])<>type('list'):
c=' %s=%s,'%(zProperty[0],zProperty[1])
else:
c=" %s='%s',"%(zProperty[0],zProperty[1])
return c
def vBatchLoadFile(dC,dG,dL,dS,dCZ,dDZ):
for k in dC.keys():
print ''
classtring='%s '%k
for zprop in dCZ[k]:
classtring+=zPrint(zprop)
print classtring
print ''
for dev in dC[k]:
devstring='%s'%dev
if dG.has_key(dev):
devstring+=" setGroups=%s,"%dG[dev]
if dS.has_key(dev):
devstring+=" setSystems=%s,"%dS[dev]
if dL.has_key(dev):
devstring+=" setLocation=%s,"%dL[dev]
for zprop in dDZ[dev]:
devstring+=zPrint(zprop)
print devstring
def getBatchLoadFile(root):
dC={}
dG={}
dL={}
dS={}
dCZ={}
dDZ={}
dCZ[root.urlLink().split('"')[1].replace('/zport/dmd','')]=[ i for i in root.zenPropertyItems()]
for dV in root.getSubDevices():
if '10.102' not in dV.id:
name=dV.name()
print name
key=dV.deviceClass().urlLink().split('"')[1].replace('/zport/dmd','')
zen=[i for i in dV.zenPropertyItems() if i not in dV.getPrimaryParent().getPrimaryParent().zenPropertyItems()]
zen.append(('setManageIP' , dV.manageIp))
dDZ[name]= zen
if dC.has_key(key):
dC[key].append(name)
else:
dC[key]=[ name ]
devClass=dV.getPrimaryParent().getPrimaryParent()
dCZ[key]= [ i for i in devClass.zenPropertyItems() if i not in devClass.getPrimaryParent().zenPropertyItems()]
for s in dV.systems():
key=s.urlLink().split('"')[1].replace('/zport/dmd','')
if dS.has_key(name):
dS[name].append(key)
else:
dS[name]=[ key ]
for g in dV.groups():
key=g.urlLink().split('"')[1].replace('/zport/dmd','')
if dG.has_key(name):
dG[name].append(key)
else:
dG[name]=[ key ]
try:
key=dV.location().urlLink().split('"')[1].replace('/zport/dmd','')
if dL.has_key(name):
dL[name].append(key)
else:
dL[name]= [ key ]
except:pass
vBatchLoadFile(dC,dG,dL,dS,dCZ,dDZ)
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||