示例#1
0
 def __init__(self, hostname, ipmi_timeout = 10, ipmi_retries = 3):
     assert isinstance(hostname, basestring)
     assert isinstance(ipmi_timeout, numbers.Real)
     assert isinstance(ipmi_retries, int)
     ttbl.power.impl_c.__init__(self, paranoid = True)
     self.power_on_recovery = True
     self.paranoid_get_samples = 1
     user, password, hostname = commonl.split_user_pwd_hostname(hostname)
     self.hostname = hostname
     self.user = user
     self.bmc = None
     self.env = dict()
     # If I change the argument order, -E doesn't work ok and I get
     # password asked in the command line
     self.cmdline = [
         "ipmitool",
         "-v", "-v", "-v",
         "-N", "%d" % ipmi_timeout,
         "-R", "%d" % ipmi_retries,
         "-H", hostname
     ]
     if user:
         self.cmdline += [ "-U", user ]
     self.cmdline += [ "-E", "-I", "lanplus" ]
     if password:
         self.env['IPMI_PASSWORD'] = password
     self.timeout = 20
     self.wait = 0.1
     self.paranoid_get_samples = 1
示例#2
0
 def __init__(self, hostname,
              precheck_wait = 0.5,
              chunk_size = 5, interchunk_wait = 0.1,
              ipmi_timeout = 10, ipmi_retries = 3):
     assert isinstance(hostname, basestring)
     assert isinstance(ipmi_timeout, numbers.Real)
     assert isinstance(ipmi_retries, int)
     ttbl.console.generic_c.__init__(self, chunk_size = chunk_size,
                                     interchunk_wait = interchunk_wait)
     ttbl.power.socat_pc.__init__(
         self,
         "PTY,link=console-%(component)s.write,rawer"
         "!!CREATE:console-%(component)s.read",
         "EXEC:'/usr/bin/ipmitool -N %(ipmi_timeout)s -R %(ipmi_retries)s"
         " -H %(hostname)s -U %(username)s -E"
         " -I lanplus sol activate',sighup,sigint,sigquit",
         precheck_wait = precheck_wait,
     )
     user, password, hostname = commonl.split_user_pwd_hostname(hostname)
     # pass those fields to the socat_pc templating engine
     self.kws['hostname'] = hostname
     self.kws['username'] = user
     self.kws['password'] = password
     self.kws['ipmi_timeout'] = ipmi_timeout
     self.kws['ipmi_retries'] = ipmi_retries
     self.ipmi_timeout = ipmi_timeout
     self.ipmi_retries = ipmi_retries
     if password:
         self.env_add['IPMITOOL_PASSWORD'] = password
示例#3
0
    def __init__(self,
                 hostname,
                 ssh_port=22,
                 chunk_size=5,
                 interchunk_wait=0.1,
                 ipmi_timeout=10,
                 ipmi_retries=3,
                 **kwargs):
        assert isinstance(ipmi_timeout, numbers.Real)
        assert isinstance(ipmi_retries, int)
        ttbl.console.ssh_pc.__init__(self,
                                     hostname,
                                     port=ssh_port,
                                     chunk_size=chunk_size,
                                     interchunk_wait=interchunk_wait,
                                     **kwargs)
        _user, password, _hostname = commonl.split_user_pwd_hostname(hostname)
        self.ipmi_timeout = ipmi_timeout
        self.ipmi_retries = ipmi_retries
        if password:
            self.env_add['IPMITOOL_PASSWORD'] = password
        self.paranoid_get_samples = 1
        self.re_enable = True

        # We don't use the username because it doesn't uniquely
        # identify the physical instrument
        self.upid_set(f"console over IPMI SoL to {_hostname}",
                      name=f"IPMI@{_hostname}",
                      hostname=_hostname)
示例#4
0
    def __init__(self, hostname, ipmi_timeout=10, ipmi_retries=3, **kwargs):
        assert isinstance(hostname, str)
        assert isinstance(ipmi_timeout, numbers.Real)
        assert isinstance(ipmi_retries, int)
        ttbl.power.impl_c.__init__(self, paranoid=True, **kwargs)
        self.power_on_recovery = True
        self.paranoid_get_samples = 1
        user, password, hostname = commonl.split_user_pwd_hostname(hostname)
        self.hostname = hostname
        self.user = user
        self.bmc = None
        self.env = dict()
        # If I change the argument order, -E doesn't work ok and I get
        # password asked in the command line
        self.cmdline = [
            "ipmitool", "-v", "-v", "-v", "-N",
            "%d" % ipmi_timeout, "-R",
            "%d" % ipmi_retries, "-H", hostname
        ]
        if user:
            self.cmdline += ["-U", user]
        self.cmdline += ["-E", "-I", "lanplus"]
        if password:
            self.env['IPMI_PASSWORD'] = password
        self.timeout = 20
        self.wait = 0.1
        self.paranoid_get_samples = 1

        # We don't use the username because it doesn't uniquely
        # identify the physical instrument
        self.upid_set(f"console over IPMI SoL to {hostname}",
                      name=f"IPMI@{hostname}",
                      hostname=hostname)
示例#5
0
    def __init__(self,
                 hostname,
                 database,
                 password=None,
                 port=3307,
                 ssl=True,
                 table_name_prefix="",
                 mariadb_extra_opts=None):
        assert isinstance(hostname, str)
        assert isinstance(database, str)
        assert password == None or isinstance(password, str)
        assert isinstance(port, int)
        assert isinstance(ssl, bool)
        assert isinstance(table_name_prefix, str)
        if mariadb_extra_opts:
            commonl.assert_dict_key_strings(mariadb_extra_opts,
                                            "mariadb_extra_opts")
            self.mariadb_extra_opts = mariadb_extra_opts
        else:
            self.mariadb_extra_opts = {}

        self.user, self.password, self.host = \
            commonl.split_user_pwd_hostname(hostname)
        if password:
            self.password = commonl.password_get(self.host, self.user,
                                                 password)
        self.port = port
        self.database = database
        self.ssl = ssl
        self.table_name_prefix_raw = table_name_prefix
        self.table_name_prefix = self._sql_id_esc(table_name_prefix)
        self.docs = {}
        tcfl.tc.report_driver_c.__init__(self)
示例#6
0
 def __init__(self, hostname):
     ttbl.power.impl_c.__init__(self, paranoid = True)
     user, password, hostname = commonl.split_user_pwd_hostname(hostname)
     self.hostname = hostname
     self.user = user
     self.password = password
     self.bmc = None
     self.power_on_recovery = True
示例#7
0
 def __init__(self, hostname, ssh_port = 22,
              chunk_size = 5, interchunk_wait = 0.1):
     ttbl.console.ssh_pc.__init__(self, hostname,
                                  port = ssh_port, chunk_size = chunk_size,
                                  interchunk_wait = interchunk_wait)
     _user, password, _hostname = commonl.split_user_pwd_hostname(hostname)
     if password:
         self.env_add['IPMITOOL_PASSWORD'] = password
示例#8
0
 def __init__(self, hostname, ssh_port = 22,
              chunk_size = 5, interchunk_wait = 0.1,
              ipmi_timeout = 10, ipmi_retries = 3):
     assert isinstance(ipmi_timeout, numbers.Real)
     assert isinstance(ipmi_retries, int)
     ttbl.console.ssh_pc.__init__(self, hostname,
                                  port = ssh_port, chunk_size = chunk_size,
                                  interchunk_wait = interchunk_wait)
     _user, password, _hostname = commonl.split_user_pwd_hostname(hostname)
     self.ipmi_timeout = ipmi_timeout
     self.ipmi_retries = ipmi_retries
     if password:
         self.env_add['IPMITOOL_PASSWORD'] = password
     self.paranoid_get_samples = 1
示例#9
0
    def __init__(self,
                 hostname,
                 port=22,
                 chunk_size=0,
                 interchunk_wait=0.1,
                 extra_opts=None,
                 command_sequence=None):
        assert isinstance(hostname, basestring)
        assert port > 0
        assert extra_opts == None \
            or ( isinstance(extra_opts, dict) \
                 and all(isinstance(k, str) and isinstance(v, str)
                         for k, v in extra_opts.items())), \
            "extra_opts: expected dict of string:string; got %s" \
            % type(extra_opts)

        generic_c.__init__(self,
                           chunk_size=chunk_size,
                           interchunk_wait=interchunk_wait,
                           command_sequence=command_sequence)
        ttbl.power.socat_pc.__init__(
            self,
            "PTY,link=console-%(component)s.write,rawer"
            "!!CREATE:console-%(component)s.read",
            # Configuf file is generated during on().
            # -tt: (yeah, double) force TTY allocation even w/o
            # controlly TTY
            "EXEC:'sshpass -e ssh -v -F %(component)s-ssh-config -tt"
            # don't use ssh://USER@HOST:PORT, some versions do not grok it
            "  -p %(port)s %(username)s@%(hostname)s'"
            ",sighup,sigint,sigquit")
        user, password, hostname = commonl.split_user_pwd_hostname(hostname)
        self.parameters_default = {
            'user': user,
        }
        self.parameters.update(self.parameters_default)
        # pass those fields to the socat_pc templating engine
        self.kws['hostname'] = hostname
        self.kws['username'] = user
        self.kws['port'] = port
        # this is used for sshpass to send the password; we dont' keep
        # the password in the default parameters because then it'd
        # leak easily to anyone
        self.password = password
        # SSHPASS always has to be defined
        self.env_add['SSHPASS'] = password if password else ""
        self.extra_opts = extra_opts
        self.paranoid_get_samples = 1
示例#10
0
 def __init__(self, kvm_hostname, **kwargs):
     _, _, hostname = commonl.split_user_pwd_hostname(kvm_hostname)
     ttbl.capture.generic_snapshot.__init__(
         self,
         # dont set the port for the name, otherwise the UPID keeps
         # changing when the instrument is actually the same
         "Spider KVM %s" % hostname,
         # NOTE: there is no way to enable screenshots with
         # username/password -- they just don't work -- need to dig
         # more into the auth mechanism
         "timeout 40"
         " curl -s -k https://%s/screenshot.jpg --output %%(output_file_name)s"
         % hostname,
         mimetype="image/jpeg",
         extension=".jpg",
         **kwargs)
     self.upid_set("Spider KVM %s" % hostname, hostname=hostname)
示例#11
0
 def __init__(self, hostname):
     ttbl.tt_power_control_impl.__init__(self)
     ttbl.power.impl_c.__init__(self, paranoid = True)
     user, password, hostname = commonl.split_user_pwd_hostname(hostname)
     self.hostname = hostname
     self.user = user
     self.bmc = None
     self.env = dict()
     # If I change the argument order, -E doesn't work ok and I get
     # password asked in the command line
     self.cmdline = [
         "ipmitool",
         "-H", hostname
     ]
     if user:
         self.cmdline += [ "-U", user ]
     self.cmdline += [ "-E", "-I", "lanplus" ]
     if password:
         self.env['IPMI_PASSWORD'] = password
     self.timeout = 20
     self.wait = 0.5
示例#12
0
    def __init__(self,
                 bmc_hostname,
                 ipmi_timeout=10,
                 ipmi_retries=3,
                 extra_ipmitool_cmdline=None,
                 **kwargs):
        ttbl.power.impl_c.__init__(self, paranoid=True, **kwargs)
        user, password, hostname \
            = commonl.split_user_pwd_hostname(bmc_hostname)
        commonl.assert_none_or_list_of_strings(extra_ipmitool_cmdline,
                                               "extra_ipmitool_cmdline",
                                               "command line option")
        self.hostname = hostname
        self.user = user
        self.bmc = None
        self.env = dict()
        # If I change the argument order, -E doesn't work ok and I get
        # password asked in the command line
        self.cmdline = [
            "ipmitool", "-N",
            "%d" % ipmi_timeout, "-R",
            "%d" % ipmi_retries, "-H", hostname
        ]
        if user:
            self.cmdline += ["-U", user]
        self.cmdline += ["-E", "-I", "lanplus"]
        if extra_ipmitool_cmdline:
            self.cmdline += extra_ipmitool_cmdline
        if password:
            self.env['IPMI_PASSWORD'] = password
        self.paranoid_get_samples = 3
        self.timeout = 30
        self.wait = 2

        # We don't use the username because it doesn't uniquely
        # identify the physical instrument
        self.upid_set(f"console over IPMI SoL to {hostname}",
                      name=f"IPMI@{hostname}",
                      hostname=hostname)
示例#13
0
文件: lantronix.py 项目: inakypg/tcf
 def __init__(self, kvm_hostname, power_controller=None, **kwargs):
     assert power_controller == None or isinstance(power_controller, str), \
         "power_controller: expected string naming power rail component;" \
         f" got {type(power_controller)}"
     _, _, hostname = commonl.split_user_pwd_hostname(kvm_hostname)
     ttbl.capture.generic_snapshot.__init__(
         self,
         # dont set the port for the name, otherwise the UPID keeps
         # changing when the instrument is actually the same
         "Spider KVM %s" % hostname,
         # NOTE: there is no way to enable screenshots with
         # username/password -- they just don't work -- need to dig
         # more into the auth mechanism
         "timeout 40"
         " curl -s -k https://%s/screenshot.jpg --output %%(output_file_name)s"
         % hostname,
         mimetype="image/jpeg",
         extension=".jpg",
         **kwargs)
     self.upid_set(f"Lantronix Spider KVM @{hostname}",
                   power_controller=power_controller,
                   hostname=hostname)
     self.name = "lantronix_spider"
示例#14
0
文件: lantronix.py 项目: inakypg/tcf
    def __init__(self,
                 kvm_hostname,
                 crlf='\r',
                 power_controller=None,
                 **kwargs):
        assert power_controller == None or isinstance(power_controller, str), \
            "power_controller: expected string naming power rail component;" \
            f" got {type(power_controller)}"
        ttbl.console.ssh_pc.__init__(
            self,
            kvm_hostname,
            # before this command sequence tried to use 'set serial
            # mode config' and 'set serial mode passhtrough" to flip
            # the serial port between modes to kick out other users,
            # but we found out that in many cases, this was rendering
            # the serial port unusable in a random way, so it was removed
            command_sequence=[
                ## Welcome to the Lantronix SLSLP^M$
                ## Firmware: version 030031, build 38120^M$
                ## Last login: Thu Jan  1 00:04:20 1970 from 10.24.11.35^M$
                ## Current time: Thu Jan  1 00:02:03 1970^M$
                ## For a list of commands, type 'help'^M$

                # command prompt, 'CR[USERNAME@IP]> '... or not, so just
                # look for 'SOMETHING> '
                # ^ will not match because we are getting a CR
                ("", re.compile("For a list of commands")),
                (
                    "\x1bexit",  # send a disconnect just in case
                    # wait for nothing, the prompt expect will be done by
                    # the next one -- somehow this works better, otherwise
                    # sometimes it doesn't see the prompt if there actually
                    # was no need for the exit command
                    ""),
                (
                    "\r\n",  # just get us a prompt
                    re.compile("[^>]+> ")),
                ("connect serial\r\n",
                 "To exit serial port connection, type 'ESC exit'."),
            ],
            extra_opts={
                # Lantronix dropbear 0.45 server (or its configuration)
                # needs this setting for it to work. old, but nothing we
                # can do.
                # KEX works for FW 3.x and 4.x; if you just append it,
                # FW 3.x cuts the negotiation short and it does not
                # work
                "KexAlgorithms": "diffie-hellman-group1-sha1",
                # Ciphers needed for FW 3.x
                "Ciphers": "+aes128-cbc,3des-cbc,aes128-ctr,aes256-ctr",
            },
            **kwargs)
        # it is reliable on reporting state
        self.get_samples = 1
        # power interface
        self.timeout = 40
        self.wait = 1
        # if the connection dies (network blip, who knows), restart it
        self.re_enable_if_dead = True
        # This is running over a Lantronix KVM, which needs to be escaped
        # when we send an escape character -- it uses ESCexit as a
        # sequence to leave the console mode and we don't want this to
        # happen if we type ESCexit...so we escape ESC :P
        self.escape_chars['\x1b'] = '\x1b'
        # depending on how this serial console sometimes drops stuff, so we feed it
        # carefully (not sure which piece of the HW has the issue)
        self.chunk_size = 5
        self.interchunk_wait = 0.2
        _, _, hostname = commonl.split_user_pwd_hostname(kvm_hostname)
        self.upid_set(f"Lantronix Spider KVM @{hostname}",
                      power_controller=power_controller,
                      hostname=hostname)
        self.name = "lantronix_spider"