code: def connect(self):
          if self.conn_type == 'paramiko':
              self._session = paramiko.SSHClient()
              logger = logging.Logger.manager.getLogger('paramiko.transport')
              logger.setLevel(logging.CRITICAL)
              self._session.set_missing_host_key_policy(
                  paramiko.AutoAddPolicy())
              self._session.connect(hostname=self.host,
                                    username=self.username,
                                    password=self.password,
                                    port=self.port,
                                    timeout=self.connect_timeout)
          if self.conn_type == 'scp':
              self._scp_session = paramiko.SSHClient()
              logger = logging.Logger.manager.getLogger('paramiko.transport')
              logger.setLevel(logging.CRITICAL)
              self._scp_session.set_missing_host_key_policy(
                  paramiko.AutoAddPolicy())
              self._scp_session.connect(hostname=self.host,
                                        username=self.username,
                                        password=self.password,
                                        port=self.port,
                                        timeout=self.connect_timeout)
              self._scp = SCPClient(self._scp_session.get_transport())
          elif self.conn_type == "ncclient":
              self._session = manager.connect(
                  host=self.host,
                  port=self.port,
                  username=self.username,
                  password=self.password,
                  timeout=self.connect_timeout,
                  device_params={'name': 'junos'},
                  hostkey_verify=False
              )
          elif self.conn_type == 'shell':
              if not self._session:
                  self.conn_type = 'paramiko'
                  self.connect()
                  self.conn_type = 'shell'
              if not self._shell:
                  self._shell = self._session.invoke_shell()
                  time.sleep(2)
                  if self.username != 'root' and not self._in_cli:
                      self._in_cli = True
              if not self.cli_to_shell():
                  self._shell.recv(9999)
          elif self.conn_type == 'root':
              if not self._shell:
                  self._shell = self._session.invoke_shell()
                  time.sleep(2)
              if not self.shell_to_cli():
                  self._shell.recv(9999)
          self._update_timeout(self.session_timeout)