Exemple #1
0
    def _connect(self):
        """Connections to the device and sets the terminal type"""
        super(Connection, self)._connect()

        display.debug('starting network_cli._connect()')

        network_os = self._play_context.network_os
        if not network_os:
            for cls in terminal_loader.all(class_only=True):
                try:
                    network_os = cls.guess_network_os(self.ssh)
                    if network_os:
                        break
                except:
                    raise AnsibleConnectionFailure(
                        'Unable to automatically determine host network os. '
                        'Please manually configure ansible_network_os value '
                        'for this host')

        if not network_os:
            raise AnsibleConnectionFailure(
                'Unable to automatically determine host network os. Please '
                'manually configure ansible_network_os value for this host')

        self._terminal = terminal_loader.get(network_os, self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' %
                                           network_os)

        self._connected = True
Exemple #2
0
    def _connect(self):
        """Connections to the device and sets the terminal type"""

        if self._play_context.password and not self._play_context.private_key_file:
            C.PARAMIKO_LOOK_FOR_KEYS = False

        super(Connection, self)._connect()

        display.display('ssh connection done, setting terminal', log_only=True)

        self._shell = self.ssh.invoke_shell()
        self._shell.settimeout(self._play_context.timeout)

        network_os = self._play_context.network_os
        if not network_os:
            raise AnsibleConnectionFailure(
                'Unable to automatically determine host network os. Please '
                'manually configure ansible_network_os value for this host')

        self._terminal = terminal_loader.get(network_os, self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' %
                                           network_os)

        display.display('loaded terminal plugin for network_os %s' %
                        network_os,
                        log_only=True)

        self._cliconf = cliconf_loader.get(network_os, self)
        if self._cliconf:
            self._rpc.add(self._cliconf)
            display.display('loaded cliconf plugin for network_os %s' %
                            network_os,
                            log_only=True)
        else:
            display.display('unable to load cliconf for network_os %s' %
                            network_os)

        self.receive()

        display.display('firing event: on_open_shell()', log_only=True)
        self._terminal.on_open_shell()

        if getattr(self._play_context, 'become', None):
            display.display('firing event: on_authorize', log_only=True)
            auth_pass = self._play_context.become_pass
            self._terminal.on_authorize(passwd=auth_pass)

        self._connected = True
        display.display('ssh connection has completed successfully',
                        log_only=True)
Exemple #3
0
    def __init__(self, play_context, new_stdin, *args, **kwargs):
        super(Connection, self).__init__(play_context, new_stdin, *args,
                                         **kwargs)

        assert self._play_context.network_os, 'ansible_network_os must be set'

        self._terminal = terminal_loader.get(self._play_context.network_os,
                                             self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' %
                                           self._play_context.network_os)

        self._shell = None

        self._matched_prompt = None
        self._matched_pattern = None
        self._last_response = None
        self._history = list()
Exemple #4
0
    def _connect(self):
        """Connections to the device and sets the terminal type"""
        super(Connection, self)._connect()

        display.debug('starting network_cli._connect()')
        display.vvvv('starting network_cli._connect()')

        network_os = self._play_context.network_os
        if not network_os:
            raise AnsibleConnectionFailure(
                'Unable to automatically determine host network os. Please '
                'manually configure ansible_network_os value for this host')

        self._terminal = terminal_loader.get(network_os, self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' %
                                           network_os)

        self._connected = True
Exemple #5
0
    def _connect(self):
        """Connections to the device and sets the terminal type"""
        super(Connection, self)._connect()

        display.display('ssh connection done, setting terminal', log_only=True)

        network_os = self._play_context.network_os
        if not network_os:
            raise AnsibleConnectionFailure(
                'Unable to automatically determine host network os. Please '
                'manually configure ansible_network_os value for this host'
            )

        self._terminal = terminal_loader.get(network_os, self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' % network_os)

        self._connected = True
        display.display('ssh connection has completed successfully', log_only=True)
Exemple #6
0
    def _connect(self):
        super(Connection, self)._connect()

        network_os = self._play_context.network_os
        if not network_os:
            for cls in terminal_loader.all(class_only=True):
                network_os = cls.guess_network_os(self.ssh)
                if network_os:
                    break

        if not network_os:
            raise AnsibleConnectionFailure(
                'unable to determine device network os.  Please configure '
                'ansible_network_os value')

        self._terminal = terminal_loader.get(network_os, self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' %
                                           network_os)

        return (0, 'connected', '')
Exemple #7
0
    def _connect(self):
        """Connections to the device and sets the terminal type"""
        super(Connection, self)._connect()

        network_os = self._play_context.network_os
        if not network_os:
            for cls in terminal_loader.all(class_only=True):
                network_os = cls.guess_network_os(self.ssh)
                if network_os:
                    break

        if not network_os:
            raise AnsibleConnectionFailure(
                'unable to determine device network os.  Please configure '
                'ansible_network_os value'
            )

        self._terminal = terminal_loader.get(network_os, self)
        if not self._terminal:
            raise AnsibleConnectionFailure('network os %s is not supported' % network_os)

        return (0, 'connected', '')