def main(): if not options.host: options.host = raw_input('Enter a hostname: ') if not options.username: options.username = raw_input('Enter a valid username: '******'Enter Password: '******'config', 'no int swp10', 'no int swp11', 'no int swp12', 'no int swp13', 'commit', 'end'] result = m.execute(config_list, cli=options.cli) if result.error == None: print('Message: {}'.format(result.message)) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): if not options.host: options.host = raw_input('Enter a hostname: ') if not options.username: options.username = raw_input('Enter a valid username: '******'Enter Password: '******'Login Banner: {}'.format(parse(result.message, encoding))) except NotImplementedError: print('Error: Parsing support not available for cli output') else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): if not options.host: options.host = raw_input('Enter a hostname: ') if not options.username: options.username = raw_input('Enter a valid username: '******'Enter Password: '******'show version', encoding=encoding, cli=options.cli) if result.error == None: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): m = manager.connect(handler=Handler.CLI) encoding = Encoding.TEXT if options.xml: encoding = Encoding.XML if options.json: encoding = Encoding.JSON result = m.command(command='show interface', encoding=encoding, cli=True) if result.error == None: try: result = parse(result.message, encoding) print('%-15s %-35s %-15s %-15s' % ('Interface', 'Description', 'Admin Status', 'Oper Status')) print('-' * 85) sorted_result = sorted( result, key=lambda x: int(x.lower().lstrip(string.ascii_lowercase))) for interface in sorted_result: print('%-15s %-35s %-15s %-15s' % (interface, result[interface]['description'], result[interface]['admin-status'], result[interface]['oper-status'])) except NotImplementedError: print('Error: Parsing support not available for cli output') else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): if not options.host: options.host = raw_input('Enter a hostname: ') if not options.filename: options.filename = raw_input('Enter a configuration filename: ') if not options.username: options.username = raw_input('Enter a valid username: '******'Enter Password: '******'Message: {}'.format(result.message)) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): if not options.host: options.host = raw_input('Enter a hostname: ') if not options.username: options.username = raw_input('Enter a valid username: '******'Enter Password: '******'ls -la', shell=True) if result.error == None: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message)) print('-' * 80) result = m.command(command='uname -a', shell=True) if result.error == None: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): m = manager.connect() config_list = [ 'config', 'no int swp10', 'no int swp11', 'no int swp12', 'no int swp13', 'commit', 'end' ] result = m.execute(config_list, cli=True) if result.error == None: print('Message: {}'.format(result.message)) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def connect(self): logger.info('Connecting to host %s', self.hostname) if self.__is_connected: return self.__is_connected self.manager = manager.connect(host=self.host, handler=Handler.CLI, port=self.__port, username=self.__credential['username'], password=self.__credential['password'], hostkey_add=True) self.__is_connected = True
def main(): m = manager.connect() encoding = Encoding.TEXT if options.xml: encoding = Encoding.XML if options.json: encoding = Encoding.JSON result = m.get_config(encoding=encoding, cli=True) if result.error == None: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): m = manager.connect(handler=Handler.CLI) result = m.command(command='ls -la', shell=True) if result.error == None: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message)) print('-' * 80) result = m.command(command='uname -a', shell=True) if result.error == None: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): m = manager.connect() encoding = Encoding.TEXT if options.xml: encoding = Encoding.XML if options.json: encoding = Encoding.JSON result = m.get_config(encoding=encoding, cli=True) if result.error == None: try: print('Login Banner: {}'.format(parse(result.message, encoding))) except NotImplementedError: print('Error: Parsing support not available for cli output') else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): m = manager.connect(host='localhost', handler=Handler.CLI) encoding = Encoding.TEXT if options.xml: encoding = Encoding.XML if options.json: encoding = Encoding.JSON result = m.command(command='show version', encoding=encoding, cli=True, timeout=120) if result.error == None: if result.message == '': print('No output returned') else: print(result.message) else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))
def main(): if not options.host: options.host = raw_input('Enter a hostname: ') if not options.username: options.username = raw_input('Enter a valid username: '******'Enter Password: '******'show interface', encoding=encoding, cli=options.cli) if result.error == None: try: result = parse(result.message, encoding) print('%-15s %-35s %-15s %-15s' % ('Interface', 'Description', 'Admin Status', 'Oper Status')) print('-' * 85) sorted_result = sorted(result, key=lambda x: int(x.lower().lstrip(string.ascii_lowercase))) for interface in sorted_result: print('%-15s %-35s %-15s %-15s' % ( interface, result[interface]['description'], result[interface]['admin-status'], result[interface]['oper-status'])) except NotImplementedError: print('Error: Parsing support not available for cli output') else: print('Error: {}'.format(errors.name(result.error))) print('Message: {}'.format(result.message))