def post_collect(self, config):
     self._executor = TwistedExecutor(self.conn_params['consess'])
     d = maybeDeferred(self._connect)
     d.addCallbacks(self.connectCallback, self.connectionFailed)
     # do not return internal connection handling deferred, but global
     # tasks deferred.
     self._task_defer = Deferred()
     return self._task_defer
예제 #2
0
    def __init__(self, taskName, configId, scheduleIntervalSeconds,
                 taskConfig):
        """
        @param taskName: the unique identifier for this task
        @type taskName: string
        @param configId: configuration to watch
        @type configId: string
        @param scheduleIntervalSeconds: the interval at which this task will be
               collected
        @type scheduleIntervalSeconds: int
        @param taskConfig: the configuration for this task
        """
        super(SshPerformanceCollectionTask,
              self).__init__(taskName, configId, scheduleIntervalSeconds,
                             taskConfig)

        # Needed for interface
        self.name = taskName
        self.configId = configId
        self.state = TaskStates.STATE_IDLE
        self.interval = scheduleIntervalSeconds

        # The taskConfig corresponds to a DeviceProxy
        self._device = taskConfig
        self._devId = taskConfig.id
        self._manageIp = taskConfig.manageIp
        self._datasources = taskConfig.datasources

        self._useSsh = taskConfig.datasources[0].useSsh
        client = MySshClient if self._useSsh else None
        self._runner = partial(runner.getRunner, taskConfig, client)
        self._connector = self._runner()

        self._dataService = zope.component.queryUtility(IDataService)
        self._eventService = zope.component.queryUtility(IEventService)

        preferences = zope.component.queryUtility(ICollectorPreferences,
                                                  COLLECTOR_NAME)
        self._maxbackoffseconds = preferences.options.maxbackoffminutes * 60
        self._showfullcommand = preferences.options.showfullcommand
        self._chosenDatasource = preferences.options.datasource

        self._executor = TwistedExecutor(taskConfig.zSshConcurrentSessions)

        self.executed = 0
        self._lastErrorMsg = ''

        self.manage_ip_event = {
            'eventClass': Cmd_Fail,
            'device': self._devId,
            'summary': 'IP address not set, collection will be attempted\
                        with host name',
            'component': COLLECTOR_NAME,
            'eventKey': 'Empty_IP_address'
        }
예제 #3
0
 def post_collect(self, device, log):
     """
         Should get called from collect in subclass before finishing.
     """
     log.debug("%s: DDN collection for device", device.id)
     # prepare the connection
     d = self._internal_defer = maybeDeferred(self._connect)
     d.addCallbacks(self.connectCallback, self.connectionFailed)
     # prepare concurrent executor context
     self._executor = TwistedExecutor(self._conn_params['consess'])
     return self._task_defer
예제 #4
0
    def __init__(self, taskName, configId, scheduleIntervalSeconds,
                 taskConfig):
        """
        @param taskName: the unique identifier for this task
        @type taskName: string
        @param configId: configuration to watch
        @type configId: string
        @param scheduleIntervalSeconds: the interval at which this task will be
               collected
        @type scheduleIntervalSeconds: int
        @param taskConfig: the configuration for this task
        """
        super(SshPerformanceCollectionTask,
              self).__init__(taskName, configId, scheduleIntervalSeconds,
                             taskConfig)

        # Needed for interface
        self.name = taskName
        self.configId = configId
        self.state = TaskStates.STATE_IDLE
        self.interval = scheduleIntervalSeconds

        # The taskConfig corresponds to a DeviceProxy
        self._device = taskConfig

        self._devId = self._device.id
        self._manageIp = self._device.manageIp

        self._dataService = zope.component.queryUtility(IDataService)
        self._eventService = zope.component.queryUtility(IEventService)

        self._preferences = zope.component.queryUtility(
            ICollectorPreferences, COLLECTOR_NAME)
        self._lastErrorMsg = ''

        self._maxbackoffseconds = self._preferences.options.maxbackoffminutes * 60

        self._concurrentSessions = taskConfig.zSshConcurrentSessions
        self._executor = TwistedExecutor(self._concurrentSessions)
        self._useSsh = taskConfig.datasources[0].useSsh
        self._connection = None

        self._datasources = taskConfig.datasources
        self.pool = getPool('SSH Connections')
        self.executed = 0
        self._task_defer = None
예제 #5
0
    def __init__(self, callableTaskFactory=CallableTaskFactory()):
        self._loopingCalls = {}
        self._tasks = {}
        self._taskCallback = {}
        self._taskStats = {}
        self._callableTaskFactory = callableTaskFactory
        self._shuttingDown = False
        # create a cleanup task that will periodically sweep the
        # cleanup dictionary for tasks that need to be cleaned
        self._tasksToCleanup = KeyedSet(getConfigId)
        self._cleanupTask = task.LoopingCall(self._cleanupTasks)
        self._cleanupTask.start(Scheduler.CLEANUP_TASKS_INTERVAL)

        self._executor = TwistedExecutor(1)

        # Ensure that we can cleanly shutdown all of our tasks
        reactor.addSystemEventTrigger('before', 'shutdown', self.shutdown, 'before')
        reactor.addSystemEventTrigger('during', 'shutdown', self.shutdown, 'during')
        reactor.addSystemEventTrigger('after', 'shutdown', self.shutdown, 'after')