Example #1
0
    def __init__(self, proxy, client):
        self.proxy = proxy
        self.client = client  #note SshRunner only works with MySshClient from zencommand because of its is_expiredidden
        # run method and close_defer attr

        self.task = None
        self.deviceId = self.proxy.id
        self.manageIp = self.proxy.manageIp
        self.port = self.proxy.zCommandPort

        _username = self.proxy.zCommandUsername
        _password = self.proxy.zCommandPassword
        _loginTimeout = self.proxy.zCommandLoginTimeout
        _commandTimeout = self.proxy.zCommandCommandTimeout
        _keyPath = self.proxy.zKeyPath
        _concurrentSessions = self.proxy.zSshConcurrentSessions

        self._sshOptions = DictAsObj(
            loginTries=1,
            searchPath='',
            existenceTest=None,
            username=_username,
            password=_password,
            loginTimeout=_loginTimeout,
            commandTimeout=_commandTimeout,
            keyPath=_keyPath,
            concurrentSessions=_concurrentSessions,
        )
        self._poolkey = hash((_username, _password, self.manageIp, self.port))
        self._pool = getPool(SshRunner.POOLNAME)
Example #2
0
    def __init__(self, proxy, client):
        self.proxy = proxy
        self.client = client

        self.task = None
        self.deviceId = self.proxy.id
        self.manageIp = self.proxy.manageIp
        self.port = self.proxy.zCommandPort

        _username = self.proxy.zCommandUsername
        _password = self.proxy.zCommandPassword
        _loginTimeout = self.proxy.zCommandLoginTimeout
        _commandTimeout = self.proxy.zCommandCommandTimeout
        _keyPath = self.proxy.zKeyPath
        _concurrentSessions = self.proxy.zSshConcurrentSessions

        self._sshOptions = DictAsObj(
            loginTries=1,
            searchPath='',
            existenceTest=None,
            username=_username,
            password=_password,
            loginTimeout=_loginTimeout,
            commandTimeout=_commandTimeout,
            keyPath=_keyPath,
            concurrentSessions=_concurrentSessions,
        )
        self._poolkey = hash((_username, _password, self.manageIp, self.port))
        self._pool = getPool(SshRunner.POOLNAME)
Example #3
0
    def __init__(self, proxy, client):
        self.proxy = proxy
        # NOTE: SshRunner only works with MySshClient from zencommand because
        # of its `is_expired` and `close_defer` attributes and its run method
        # which returns a deferred object.
        self.client = client

        self.task = None
        self.deviceId = self.proxy.id
        self.manageIp = self.proxy.manageIp
        self.port = self.proxy.zCommandPort

        _username = self.proxy.zCommandUsername
        _password = self.proxy.zCommandPassword
        _loginTimeout = self.proxy.zCommandLoginTimeout
        _commandTimeout = self.proxy.zCommandCommandTimeout
        _keyPath = self.proxy.zKeyPath
        _concurrentSessions = self.proxy.zSshConcurrentSessions

        self._sshOptions = DictAsObj(
            loginTries=1,
            searchPath="",
            existenceTest=None,
            username=_username,
            password=_password,
            loginTimeout=_loginTimeout,
            commandTimeout=_commandTimeout,
            keyPath=_keyPath,
            concurrentSessions=_concurrentSessions,
        )
        self._poolkey = hash((_username, _password, self.manageIp, self.port))
        self._pool = getPool(SshRunner.POOLNAME)
Example #4
0
    def __init__(self, proxy, client):
        self.proxy = proxy
        self.client = client #note SshRunner only works with MySshClient from zencommand because of its is_expiredidden
                             # run method and close_defer attr

        self.task = None
        self.deviceId = self.proxy.id
        self.manageIp = self.proxy.manageIp
        self.port = self.proxy.zCommandPort

        _username = self.proxy.zCommandUsername
        _password = self.proxy.zCommandPassword
        _loginTimeout = self.proxy.zCommandLoginTimeout
        _commandTimeout = self.proxy.zCommandCommandTimeout
        _keyPath = self.proxy.zKeyPath
        _concurrentSessions = self.proxy.zSshConcurrentSessions

        self._sshOptions = DictAsObj(
            loginTries=1,
            searchPath='',
            existenceTest=None,
            username=_username,
            password=_password,
            loginTimeout=_loginTimeout,
            commandTimeout=_commandTimeout,
            keyPath=_keyPath,
            concurrentSessions=_concurrentSessions,
        )
        self._poolkey = hash((_username, _password, self.manageIp, self.port))
        self._pool = getPool(SshRunner.POOLNAME)
def delConnection(connectionString):
    pool = getPool('adbapi connections')
    if hash(connectionString) in pool:
        log.debug("delete pool %s", hash(connectionString))
    d = CONN_LOCK.run(pool.pop, hash(connectionString), None)
    d.addCallback(lambda conn: conn and conn.close() or None)
    return d
def getConnection(connectionString):
    pool = getPool('adbapi connections')
    if hash(connectionString) not in pool:
        log.debug("create pool %s", hash(connectionString))
    d = CONN_LOCK.run(pool.setdefault, hash(connectionString),
                            adbapiClient(connectionString))
    d.addCallback(lambda conn: conn.connect())
    return d
Example #7
0
 def __init__(self, *args, **kw):
     SshClient.__init__(self, *args, **kw)
     self.connect_defer = None
     self.defers = {}
     self._taskList = set()
     self.connection_description = '%s:*****@%s:%s' % (self.username, self.ip, self.port)
     self.pool = getPool('SSH Connections')
     self.poolkey = hash((self.username, self.password, self.ip, self.port))
     self.is_expired = False
Example #8
0
 def __init__(self, *args, **kw):
     SshClient.__init__(self, *args, **kw)
     self.connect_defer = None
     self.defers = {}
     self._taskList = set()
     self.connection_description = '%s:*****@%s:%s' % (self.username,
                                                       self.ip, self.port)
     self.pool = getPool('SSH Connections')
     self.poolkey = hash((self.username, self.password, self.ip, self.port))
     self.is_expired = False
Example #9
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
    def __init__(self, device=None, datacollector=None, plugins=[]):
        """
        Initializer

        @param device: remote device to use the datacollector
        @type device: device object
        @param datacollector: performance data collector object
        @type datacollector: datacollector object
        @param plugins: Python-based performance data collector plugin
        @type plugins: list of plugin objects
        """
        BaseClient.__init__(self, device, datacollector)
        self.device = device
        self.hostname = getattr(device, 'id', 'unknown')
        self.plugins = plugins
        self.results = []
        self._pools = getPool('adbapi executors')
Example #11
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
    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(SqlPerformanceCollectionTask, self).__init__()

        # 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._executor = None

        self._datasources = taskConfig.datasources
        self._dbapiName = taskConfig.datasources[0].connectionString.split(',',
                                                        1)[0].strip('\'"')
        self.pool = getPool('adbapi executors')
        self.executed = 0