Example #1
0
    def get_shell(self):

        if hasattr(self._connection, '_shell'):
            shell_plugin = getattr(self._connection, '_shell', '')
        else:
            shell_plugin = shell_loader.get(os.path.basename(C.DEFAULT_EXECUTABLE))
            if shell_plugin is None:
                shell_plugin = shell_loader.get('sh')

        return shell_plugin
Example #2
0
    def __init__(self, play_context, new_stdin, *args, **kwargs):
        # All these hasattrs allow subclasses to override these parameters
        if not hasattr(self, '_play_context'):
            self._play_context = play_context
        if not hasattr(self, '_new_stdin'):
            self._new_stdin = new_stdin
        # Backwards compat: self._display isn't really needed, just import the global display and use that.
        if not hasattr(self, '_display'):
            self._display = display
        if not hasattr(self, '_connected'):
            self._connected = False

        self.success_key = None
        self.prompt = None
        self._connected = False

        # load the shell plugin for this action/connection
        if play_context.shell:
            shell_type = play_context.shell
        elif hasattr(self, '_shell_type'):
            shell_type = getattr(self, '_shell_type')
        else:
            shell_type = 'sh'
            shell_filename = os.path.basename(self._play_context.executable)
            for shell in shell_loader.all():
                if shell_filename in shell.COMPATIBLE_SHELLS:
                    shell_type = shell.SHELL_FAMILY
                    break

        self._shell = shell_loader.get(shell_type)
        if not self._shell:
            raise AnsibleError(
                "Invalid shell type specified (%s), or the plugin for that shell type is missing."
                % shell_type)
Example #3
0
    def __init__(self, play_context, new_stdin, *args, **kwargs):
        # All these hasattrs allow subclasses to override these parameters
        if not hasattr(self, '_play_context'):
            self._play_context = play_context
        if not hasattr(self, '_new_stdin'):
            self._new_stdin = new_stdin
        # Backwards compat: self._display isn't really needed, just import the global display and use that.
        if not hasattr(self, '_display'):
            self._display = display
        if not hasattr(self, '_connected'):
            self._connected = False

        self.success_key = None
        self.prompt = None
        self._connected = False

        # load the shell plugin for this action/connection
        if play_context.shell:
            shell_type = play_context.shell
        elif hasattr(self, '_shell_type'):
            shell_type = getattr(self, '_shell_type')
        else:
            shell_type = 'sh'
            shell_filename = os.path.basename(self._play_context.executable)
            for shell in shell_loader.all():
                if shell_filename in shell.COMPATIBLE_SHELLS:
                    shell_type = shell.SHELL_FAMILY
                    break

        self._shell = shell_loader.get(shell_type)
        if not self._shell:
            raise AnsibleError("Invalid shell type specified (%s), or the plugin for that shell type is missing." % shell_type)
Example #4
0
    def __init__(self, play_context, new_stdin, *args, **kwargs):
        # All these hasattrs allow subclasses to override these parameters
        if not hasattr(self, '_play_context'):
            self._play_context = play_context
        if not hasattr(self, '_new_stdin'):
            self._new_stdin = new_stdin
        if not hasattr(self, '_display'):
            self._display = display
        if not hasattr(self, '_connected'):
            self._connected = False

        self.success_key = None
        self.prompt = None

        # load the shell plugin for this action/connection
        if play_context.shell:
            shell_type = play_context.shell
        elif hasattr(self, '_shell_type'):
            shell_type = getattr(self, '_shell_type')
        else:
            shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        self._shell = shell_loader.get(shell_type)
        if not self._shell:
            raise AnsibleError("Invalid shell type specified (%s), or the plugin for that shell type is missing." % shell_type)

        # allocate the lockfile
        f = self._play_context.connection_lockfd
        self._lockfd = portable.LockFile(f)
Example #5
0
    def __init__(self, play_context, new_stdin, *args, **kwargs):
        # All these hasattrs allow subclasses to override these parameters
        if not hasattr(self, '_play_context'):
            self._play_context = play_context
        if not hasattr(self, '_new_stdin'):
            self._new_stdin = new_stdin
        if not hasattr(self, '_display'):
            self._display = display
        if not hasattr(self, '_connected'):
            self._connected = False

        self.success_key = None
        self.prompt = None

        # load the shell plugin for this action/connection
        if play_context.shell:
            shell_type = play_context.shell
        elif hasattr(self, '_shell_type'):
            shell_type = getattr(self, '_shell_type')
        else:
            shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        self._shell = shell_loader.get(shell_type)
        if not self._shell:
            raise AnsibleError("Invalid shell type specified (%s), or the plugin for that shell type is missing." % shell_type)
Example #6
0
    def __init__(self, connection_info, new_stdin, *args, **kwargs):
        # All these hasattrs allow subclasses to override these parameters
        if not hasattr(self, '_connection_info'):
            self._connection_info = connection_info
        if not hasattr(self, '_new_stdin'):
            self._new_stdin = new_stdin
        if not hasattr(self, '_display'):
            self._display = Display(verbosity=connection_info.verbosity)
        if not hasattr(self, '_connected'):
            self._connected = False

        self.success_key = None
        self.prompt = None

        # load the shell plugin for this action/connection
        if connection_info.shell:
            shell_type = connection_info.shell
        elif hasattr(self, '_shell_type'):
            shell_type = getattr(self, '_shell_type')
        else:
            shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        self._shell = shell_loader.get(shell_type)
        if not self._shell:
            raise AnsibleError(
                "Invalid shell type specified (%s), or the plugin for that shell type is missing."
                % shell_type)
Example #7
0
    def get_shell(self):

        # FIXME: no more inject, get this from the host variables?
        #default_shell = getattr(self._connection, 'default_shell', '')
        #shell_type = inject.get('ansible_shell_type')
        #if not shell_type:
        #    if default_shell:
        #        shell_type = default_shell
        #    else:
        #        shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        shell_type = getattr(self._connection, 'default_shell', '')
        if not shell_type:
            shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        shell_plugin = shell_loader.get(shell_type)
        if shell_plugin is None:
            shell_plugin = shell_loader.get('sh')

        return shell_plugin
Example #8
0
    def get_shell(self):

        # FIXME: no more inject, get this from the host variables?
        #default_shell = getattr(self._connection, 'default_shell', '')
        #shell_type = inject.get('ansible_shell_type')
        #if not shell_type:
        #    if default_shell:
        #        shell_type = default_shell
        #    else:
        #        shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        shell_type = getattr(self._connection, 'default_shell', '')
        if not shell_type:
            shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        shell_plugin = shell_loader.get(shell_type)
        if shell_plugin is None:
            shell_plugin = shell_loader.get('sh')

        return shell_plugin
Example #9
0
    def __init__(self, *args, **kwargs):

        self.has_pipelining = False
        self.default_suffixes = ['.ps1', '']
        self.protocol = None
        self.shell_id = None
        self.delegate = None

        self._shell = shell_loader.get('powershell')

        # TODO: Add runas support
        self.become_methods_supported = []

        super(Connection, self).__init__(*args, **kwargs)
Example #10
0
    def __init__(self,  *args, **kwargs):

        self.has_pipelining   = False
        self.default_suffixes = ['.ps1', '']
        self.protocol         = None
        self.shell_id         = None
        self.delegate         = None

        self._shell           = shell_loader.get('powershell')

        # TODO: Add runas support
        self.become_methods_supported=[]

        super(Connection, self).__init__(*args, **kwargs)
Example #11
0
    def __init__(self, task, connection, connection_info, loader, templar, shared_loader_obj):
        self._task              = task
        self._connection        = connection
        self._connection_info   = connection_info
        self._loader            = loader
        self._templar           = templar
        self._shared_loader_obj = shared_loader_obj

        # load the shell plugin for this action/connection
        if self._connection_info.shell:
            shell_type = self._connection_info.shell
        elif hasattr(connection, '_shell'):
            shell_type = getattr(connection, '_shell')
        else:
            shell_type = os.path.basename(C.DEFAULT_EXECUTABLE)

        self._shell = shell_loader.get(shell_type)
        if not self._shell:
            raise AnsibleError("Invalid shell type specified (%s), or the plugin for that shell type is missing." % shell_type)

        self._supports_check_mode = True