def finish(self, r=None):
     for d in self.runningjobs:
         try:
             d.callback(FAILURE)
         except defer.AlreadyCalledError:
             pass
     CyclingDaemon.finish(self, r)
Example #2
0
 def buildOptions(self):
     CyclingDaemon.buildOptions(self)
     self.parser.add_option('--device',
                            dest='rDevice',
                            type='string',
                            default='',
                            help='Run Rancid for a single device')
     self.parser.add_option(
         '--rcssys',
         dest='rancid_rcssys',
         type='string',
         default="svn",
         help=
         'Rancid repository, use either SVN or CVS - default SVN (not yet supported)'
     )
     self.parser.add_option(
         '--starttime',
         dest='starttime',
         type='string',
         default="02:00",
         help='Rancid start time. Format = HH:MM (default 02:00)')
     self.parser.add_option(
         '--repeat',
         dest='repeat',
         type='int',
         default=86400,
         help=
         'Rancid cycle time in seconds, run only once a day by default. (default 86400)'
     )
Example #3
0
 def initStandalone(self):
     CyclingDaemon.__init__(self)
     log.info("call init")
     self.name = "zenrancidtest"
     # in daemon mode we only want to run the process once a day by default
     if self.options.daemon:
         self._calcStartDelay()
     log.debug("options: %s", self.options)
 def initStandalone(self):
     CyclingDaemon.__init__(self)
     log.info("call init")
     self.name = "zenrancidtest"
     # in daemon mode we only want to run the process once a day by default
     if self.options.daemon:
         self._calcStartDelay()
     log.debug("options: %s", self.options)            
Example #5
0
 def __init__(self):
     CyclingDaemon.__init__(self)
     self.options.cycletime *= 2
     log = open(os.path.join(zenPath('log'),'install.log'))
     for line in log:
         if 'Fresh install pre steps' in line:
             self.installDate = mktime(strptime(log.next(),'%a %b %d %H:%M:%S %Z %Y\n'))
             break
     self.log.info('Started')
Example #6
0
    def buildOptions(self):
        CyclingDaemon.buildOptions(self)

        self.parser.add_option('--numSlots',
                               dest='numSlots',
                               type='int',
                               help='Number of slots in chassis',
                               default=0)
        self.parser.add_option('--maxPorts',
                               dest='maxPorts',
                               type='int',
                               help='Number of ports in chassis',
                               default=0)
        self.parser.add_option('--chassisName',
                               dest='chassisName',
                               type='string',
                               help='Number of slots in chassis',
                               default="1900")
        self.parser.add_option('--slot0_IP',
                               dest='slot0_IP',
                               type='string',
                               help='IP Address of Slot0')
        self.parser.add_option('--slot1_IP',
                               dest='slot1_IP',
                               type='string',
                               help='IP Address of Slot1')
        self.parser.add_option('--slot2_IP',
                               dest='slot2_IP',
                               type='string',
                               help='IP Address of Slot2')
        self.parser.add_option('--slot3_IP',
                               dest='slot3_IP',
                               type='string',
                               help='IP Address of Slot3')
        self.parser.add_option('--slot4_IP',
                               dest='slot4_IP',
                               type='string',
                               help='IP Address of Slot4')
        self.parser.add_option('--slot5_IP',
                               dest='slot5_IP',
                               type='string',
                               help='IP Address of Slot5')
Example #7
0
  def __init__(self, *args, **kwargs):

    CyclingDaemon.__init__(self, *args, **kwargs) 

    self.options.cycletime = 10

    self.log.info("Kicking off init")

    print "did init"

 
    self.schedule = Scheduler(self.options)

    self.schedule.sendEvent = self.dmd.ZenEventManager.sendEvent

    self.schedule.monitor = self.options.monitor


    self.sendEvent(dict(
                    device=self.options.monitor, component="zenactions",
                    eventClass='/Cmd', severity=0, summary="zenactions started"))
Example #8
0
 def buildOptions(self):
     CyclingDaemon.buildOptions(self)
     self.parser.add_option('--duration', dest='duration', type='int', default=60, help='Duration of evaluation period')
 def buildOptions(self):
     CyclingDaemon.buildOptions(self)
     self.parser.add_option( '--device', dest='rDevice', type='string', default='', help='Run Rancid for a single device')
     self.parser.add_option( '--rcssys', dest='rancid_rcssys', type='string', default="svn", help='Rancid repository, use either SVN or CVS - default SVN (not yet supported)')
     self.parser.add_option( '--starttime', dest='starttime', type='string', default="02:00", help='Rancid start time. Format = HH:MM (default 02:00)')
     self.parser.add_option( '--repeat', dest='repeat', type='int', default=86400, help='Rancid cycle time in seconds, run only once a day by default. (default 86400)')
 def __init__(self, *args, **kwargs):
     CyclingDaemon.__init__(self, *args, **kwargs)
     self.jm = self.dmd.JobManager
     self.runningjobs = []
Example #11
0
    def __init__(self, *args, **kwargs):

        CyclingDaemon.__init__(self, *args, **kwargs)

        log.info("zxchassisdaemon __init__")

        # Set up slots dictionary
        self.slots = [None] * self.options.numSlots
        for slotNum in range(0, len(self.slots)):
            self.slots[slotNum] = {
                'ip': eval("self.options.slot%s_IP" % slotNum)
            }

        # Set up ports dictionary
# self.ports = [x[:] for x in [["down"]*self.options.maxPorts]*self.options.numSlots]

# Set up current model of the chassis using data from Shelf Manager
        self.setup_chassis(self.slots)

        # Either do first-time initialization or get device properties.

        doInit = True
        devices = self.dmd.Devices.getSubDevices()
        if devices:
            for device in self.dmd.Devices.getSubDevices():
                groups = device.getDeviceGroupNames()
                for a in range(0, len(groups)):
                    if groups[a].find(self.options.chassisName) != -1:
                        doInit = False
                        break
                if doInit == False:
                    break

#if os.path.isfile(self.zxdevicesFileName) or os.path.isfile(self.zxchassisFileName):
#self.doInit = False

        if (doInit == True):
            log.info("__init__ first-time initialization")

            # Determine the class of the device in each slot.
            # NOTE: Must call setup_chassis first. See above.

            self.get_device_classes(self.slots)

            # Generate a name for each device
            # NOTE: Class needed to generate name.
            for slotNum in range(0, len(self.slots)):
                self.get_device_name(self.slots[slotNum])

            # If zxdevice.xml doesn't exist, have Zenoss generate it.

            if (os.path.isfile(self.zxdevicesFileName) == False):
                os.system(self.cmdPrefix +
                          "/bin/zendevicedump -o %s" % self.zxdevicesFileName)

            # Read and parse zxdevice.xml.

            deviceFile = open(self.zxdevicesFileName)
            deviceDoc = parse(deviceFile)
            deviceFile.close()

            # Generate device for each IP address.

            for slotNum in range(0, len(self.slots)):
                self.add_device(deviceDoc, self.slots[slotNum])

            # Output document.

            tempFile = open(self.tempdevicesFileName, 'w')
            deviceDoc.writexml(tempFile)
            tempFile.close()

            # Upload zxdevice.xml to Zenoss
            if (os.path.isfile(self.tempdevicesFileName) == True):
                os.system(self.cmdPrefix + "/bin/zendeviceload -i %s" %
                          self.tempdevicesFileName)

            # Delete the temporary file.
            os.remove(self.tempdevicesFileName)

            # Need to commit changes prior to setting properties.
            commit()

            # Set device properties via Zenoss: SLOT, NAME, SERIAL NUMBER.
            self.set_device_properties()

            # Generate zxdevices.xml to reflect new configuration.
            os.system(self.cmdPrefix +
                      "/bin/zendevicedump -o %s" % self.zxdevicesFileName)
        else:
            log.info("__init__ not first-time initialization")

            # Use Zenoss device info to set up slots.
            self.get_device_properties()

# Initialize the ports dictionary
        log.info("before setup_znyxSlot")
        self.setup_znyxSlot(self.slots)

        self.schedule = Scheduler(self.options)

        self.schedule.sendEvent = self.dmd.ZenEventManager.sendEvent

        self.schedule.monitor = self.options.monitor

        self.sendEvent(
            dict(device=self.options.monitor,
                 component="zxchassisdaemon",
                 eventClass='/App/Znyx',
                 severity=0,
                 summary="zxchassisdaemon started"))