def execute(endpoint, commands, creds=("admin", ""), protocol=None, authorize=None, **kwargs): """Send exec commands :param authorize: enter enable mode :param endpoint: remote host or URI to connect to :param commands: command or commands to send :param creds: (optional) :class:`Creds <Creds>` object with authentication credentials :param protocol: (optional) Protocol name, e.g. 'ssh' or 'eapi' Usage: >>> arcomm.configure('eapi://veos', ['show version']) <ResponseStore [ok]> """ # allow an existing session to be used if not isinstance(endpoint, Session): sess = Session(endpoint, creds=creds, protocol=protocol, **kwargs) sess.connect() else: sess = endpoint if authorize is not None: sess.authorize(authorize, None) response = sess.send(commands, **kwargs) return response
def execute(endpoint, commands, **kwargs): """Send exec commands :param endpoint: remote host or URI to connect to :param commands: command or commands to send :param creds: (optional) :class:`Creds <Creds>` object with authentication credentials :param protocol: (optional) Protocol name, e.g. 'ssh' or 'eapi' Usage: >>> arcomm.configure('eapi://veos', ['show version']) <ResponseStore [ok]> """ authorize = kwargs.pop('authorize', None) # allow an existing session to be used if not isinstance(endpoint, BaseSession): sess = Session(endpoint, **kwargs) sess.connect() else: sess = endpoint if authorize: if hasattr(authorize, '__iter__'): username, password = authorize[0], authorize[1] else: username, password = ('', authorize) sess.authorize(password, username) response = sess.send(commands, **kwargs) return response
def execute(endpoint, commands, creds=("admin", ""), protocol=None, authorize=None, **kwargs): """Send exec commands :param authorize: enter enable mode :param endpoint: remote host or URI to connect to :param commands: command or commands to send :param creds: (optional) :class:`Creds <Creds>` object with authentication credentials :param protocol: (optional) Protocol name, e.g. 'ssh' or 'eapi' Usage: >>> arcomm.configure('eapi://veos', ['show version']) <ResponseStore [ok]> """ # allow an existing session to be used if not isinstance(endpoint, Session): sess = Session(endpoint, creds=creds, protocol=protocol, **kwargs) sess.connect() else: sess = endpoint if authorize is not None: sess.authorize(authorize, None) response = sess.send(commands, **kwargs) return response
def execute(endpoint, commands, **kwargs): """Send exec commands :param endpoint: remote host or URI to connect to :param commands: command or commands to send :param creds: (optional) :class:`Creds <Creds>` object with authentication credentials :param protocol: (optional) Protocol name, e.g. 'ssh' or 'eapi' Usage: >>> arcomm.configure('eapi://veos', ['show version']) <ResponseStore [ok]> """ authorize = kwargs.pop('authorize', None) # allow an existing session to be used if not isinstance(endpoint, BaseSession): sess = Session(endpoint, **kwargs) sess.connect() else: sess = endpoint if authorize: if hasattr(authorize, '__iter__'): username, password = authorize[0], authorize[1] else: username, password = ('', authorize) sess.authorize(password, username) response = sess.send(commands, **kwargs) return response
def execute(uri, commands, **kwargs): # allow an existing session to be used if not isinstance(uri, BaseSession): sess = Session() sess.connect(uri, **kwargs) else: sess = uri authorize = kwargs.pop('authorize', None) if authorize: if hasattr(authorize, '__iter__'): username, password = authorize[0], authorize[1] else: username, password = ('', authorize) sess.authorize(password, username) response = sess.execute(commands, **kwargs) return response