Discussion:
Delete Device function
murphybr
2012-01-06 16:28:33 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63582#63582

--------------------------------------------------------------
i was curious if anyone could point me in the direction as to where the Manage/ Delete Device function was stored in Zenoss Core. I have previously mentioned I am looking at creating a deleted devices report and would like to explore the delete device function. I have attempted to look at the following two function/classes under /opt/zenoss/Products/ZenModel/ DeviceManagerBase.py(def removeDevices) and Device .py(deleteDevice) but i can not seem to find the correct delete devie function that removes the device from Zope. could anyone please help in pointing me to the correct python sscript. thank you.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63582#63582]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-01-06 19:28:57 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63574#63574

--------------------------------------------------------------
Why is that you say Device.py(deleteDevice) is not the correct function?

It states "Delete device from the database" in the comments of the function. Is not working, or have you seen something to indicate that this is not the actual function?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63574#63574]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
murphybr
2012-01-06 19:42:24 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63575#63575

--------------------------------------------------------------
under Device.py
i added the line:

insert syslog

at the start of the code

i added 2 lines for deleteDevice to notify syslog when it hits the function so it looks like this:

def deleteDevice(self, deleteStatus=False, deleteHistory=False,
                    deletePerf=False, REQUEST=None):
        """
        Delete device from the database

        NB: deleteHistory is disabled for the 2.2 release.  In some
        circumstances it was causing many subprocesses to be spawned
        and creating a gridlock situation.

        @permission: ZEN_ADMIN_DEVICE
        """
        parent = self.getPrimaryParent()
        syslog.openlog('Y2J', 0, syslog.LOG_DAEMON)
        syslog.syslog(syslog.LOG_INFO, '%s' % parent)

        if deleteStatus:
            self.getEventManager().manage_deleteHeartbeat(self.getId())
            self.getEventManager().manage_deleteAllEvents(self.getId())
        # if deleteHistory:
        #     self.getEventManager().manage_deleteHistoricalEvents(self.getId())
        if deletePerf:
            perfserv = self.getPerformanceServer()
            if perfserv:
                perfserv.deleteRRDFiles(self.id)
        parent._delObject(self.getId())
        if REQUEST:
            if parent.getId()=='devices':
                parent = parent.getPrimaryParent()
            REQUEST['RESPONSE'].redirect(parent.absolute_url() +
                                            "/deviceOrganizerStatus"
                                            '?message=Device deleted')


Syslog never receives a message.(syslog service is started on the server.)
this is what leads me to believe that it is not going through the device.py script.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63575#63575]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-01-06 19:56:53 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63576#63576

--------------------------------------------------------------
I did a similar test just now using a file rather than syslog and it triggered just fine. Just using this:
        f = open("/tmp/test.txt",'w')
        f.write("DEVICE DELETED")
        f.close()

and see if you get the contents into the file like I did. Perhaps something is up with syslog
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63576#63576]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Shane Scott
2012-01-06 20:43:40 UTC
Permalink
Shane Scott [http://community.zenoss.org/people/hackman238] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63578#63578

--------------------------------------------------------------
murphybr:

I can confirm that deleteDevice is the correct method.

Best,
--Shane (Hackman238)
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63578#63578]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
murphybr
2012-01-06 21:59:38 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63584#63584

--------------------------------------------------------------
ok now that works..new question. using f.write how can i call the device name and the device admin from Zope?

I tried using repr(parent) results in test.txt: *parent = <ToManyContRelationship at /zport/dmd/Devices/Server/Linux/devices>*

When using parent, the results are *TypeError: cannot concatenate 'str' and 'ImplicitAcquirerWrapper' objects* in the Zenoss GUI

what am i doing wrong?
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63584#63584]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-01-06 22:14:49 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63596#63596

--------------------------------------------------------------
huh? I'm sure I really understand what you are asking, but I think your saying to that same test file can you write out the device name as well as the device administrator? If that is indeed the case, name is easy, but I have no idea where the 'admin' is stored, if you could point me at the field of interest I could probably figure it out:

For the device name:
        f = open("/tmp/test.txt",'w')
        f.write("DEVICE DELETED")
        f.write(self.id)
        f.close()
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63596#63596]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
murphybr
2012-01-09 18:56:04 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63623#63623

--------------------------------------------------------------
If you look in your upper right hand corner, it should show your user name. (in my case i am logged in as admin).
Self.id worked for the device IP/device name
I was also experimenting with the following information to log:

user loggging(upper right corner - the user account doing the deletion)
a timestamp for the time of the device deletion.

device Name: found in the bottom of the device information screen(right hand side) example found below
OS
Tag #
Serial #
HW Make     Generic
HW Model     Net-SNMP Agent
OS Make     Unknown
OS Version     Linux 2.6.18-164.el
Rack Slot     0
Name     testserver01
Contact    Root <***@localhost> (configure /etc/snmp/snmp.local.conf)
Location     Unknown (edit /etc/snmp/snmpd.conf)

Sorry if i am being a pain. but I have spent a while trying to figure this out.(with help on identifying the variable names, i can create the rest of my add-on for deleteDevice.)
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63623#63623]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-01-09 20:06:35 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63624#63624

--------------------------------------------------------------
  print item, getattr(self, item)
Something like that should dump ALL device attributes for you so you can review and see which variables you are interested in.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63624#63624]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
murphybr
2012-01-10 18:32:15 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63657#63657

--------------------------------------------------------------
I think this should be my final question. thank you for every bit of help dpetzel.

I have the self.id giving me the device Name. now in case my device name is showing up as testdev01 and just to the right of it is showing an IP address while self.id gives me the name. how do i call the ip (upper left hand corners)

I have been successful in pulling the id, a timestamp, and the user. just need this final piece.
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63657#63657]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
dpetzel
2012-01-10 18:48:59 UTC
Permalink
dpetzel [http://community.zenoss.org/people/dpetzel] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63647#63647

--------------------------------------------------------------
Untested... but this looks promising: http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py
|| 1006 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1006) |     security.declareProtected(ZEN_VIEW, 'getManageIp') |
|| 1007 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1007) |     def getManageIp(self): |
|| 1008 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1008) |         """ |
|| 1009 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1009) |         Return the management ip for this device. |
|| 1010 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1010) | |
|| 1011 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1011) |         @rtype: string |
|| 1012 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1012) |         @permission: ZEN_VIEW |
|| 1013 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1013) |         """ |
|| 1014 (http://dev.zenoss.com/trac/browser/trunk/Products/ZenModel/Device.py#L1014) |         return self.manageIp |
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63647#63647]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
murphybr
2012-01-10 18:49:49 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63658#63658

--------------------------------------------------------------
your my hero :)
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63658#63658]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
murphybr
2012-01-06 20:43:38 UTC
Permalink
murphybr [http://community.zenoss.org/people/murphybr] created the discussion

"Re: Delete Device function"

To view the discussion, visit: http://community.zenoss.org/message/63583#63583

--------------------------------------------------------------
that worked. thank you so much. now i can start looking at creating my devices deleted report.lol
--------------------------------------------------------------

Reply to this message by replying to this email -or- go to the discussion on Zenoss Community
[http://community.zenoss.org/message/63583#63583]

Start a new discussion in zenoss-users by email
[discussions-community-forums-zenoss--***@community.zenoss.org] -or- at Zenoss Community
[http://community.zenoss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2003]
Loading...