예제 #1
0
    def __init__(self,
                 serial_port,
                 baudrate=115200,
                 bytesize=8,
                 parity='N',
                 stopbits=1,
                 xonxoff=False,
                 rtscts=False,
                 dsrdtr=False,
                 username=None,
                 password=None,
                 slowness_factor=5,
                 cmd_notfound=b'command not found',
                 codec='latin_1'):
        """
        Args:
            serial_port (str): path to the tty device file. (e.g., '/dev/ttyUSB0')
            baudrate (int): baud rate of the serial line.
            bytesize (int): number of data bits. (5, 6, 7, or 8)
            parity (str): parity checking. ('N', 'O, 'E', 'M', or 'S')
            stopbits (int): number of stop bits. (1, 1.5 or 2)
            xonxoff (bool): enable software flow control.
            rtscts (bool): enable hardware (RTS/CTS) flow control.
            dsrdtr (bool): enable hardware (DSR/DTR) flow control.
            username (str): username to connect with. If None, no authentication step will be attempted.
            password (str): password related to the username.
            slowness_factor (int): characterize the slowness of the monitored system. The scale goes from
              1 (fastest) to 10 (slowest). This factor is a base metric to compute the time to wait
              for the authentication step to terminate (if `username` and `password` parameter are provided)
              and other operations involving to wait for the monitored system.
            cmd_notfound (bytes): pattern used to detect if the command does not exist on the
              monitored system.
            codec (str): codec used to send/receive information through the serial line
        """
        Backend.__init__(self, codec=codec)
        if not serial_module:
            raise eh.UnavailablePythonModule(
                'Python module for Serial is not available!')

        self.serial_port = serial_port
        self.baudrate = baudrate
        self.bytesize = bytesize
        self.parity = parity
        self.stopbits = stopbits
        self.xonxoff = xonxoff
        self.rtscts = rtscts
        self.dsrdtr = dsrdtr
        self.slowness_factor = slowness_factor
        self.cmd_notfound = cmd_notfound
        if sys.version_info[0] > 2:
            self.username = bytes(username, self.codec)
            self.password = bytes(password, self.codec)
        else:
            self.username = username
            self.password = password

        self.client = None
예제 #2
0
파일: monitor.py 프로젝트: wflk/fuddly
    def __init__(self):
        assert(self.process_name != None)
        assert(self.sshd_ip != None)
        assert(self.username != None)
        assert(self.password != None)

        if not ssh_module:
            raise eh.UnavailablePythonModule('Python module for SSH is not available!')

        Probe.__init__(self)
예제 #3
0
 def __init__(self,
              username,
              password,
              sshd_ip,
              sshd_port=22,
              codec='latin_1'):
     """
     Args:
         sshd_ip (str): IP of the SSH server.
         sshd_port (int): port of the SSH server.
         username (str): username to connect with.
         password (str): password related to the username.
         codec (str): codec used by the monitored system to answer.
     """
     Backend.__init__(self, codec=codec)
     if not ssh_module:
         raise eh.UnavailablePythonModule(
             'Python module for SSH is not available!')
     self.sshd_ip = sshd_ip
     self.sshd_port = sshd_port
     self.username = username
     self.password = password
     self.client = None