質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.47%
Router

Routerは、異なるネットワーク同士を相互に接続するための通信機器。インターネットでのデータを自動的に振り分け、一つのインターネット回線を複数のコンピュータで使用することが可能です。DHCPによりIPアドレスを自動的に割振りすることもできます。

YAMAHA

YAMAHAでは1995年にISDNリモートルーターを発売以降、さまざまなネットワーク製品を販売。企業での広いシェアを獲得しています。ルーターやスイッチ、UTM/ファイアウォール、無線アクセスポイントの製品などの運用管理を簡単にし、安定且つ継承できるサービスを提供しています。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

Q&A

1回答

550閲覧

netmikoのエラーについて

lab_rtx

総合スコア0

Router

Routerは、異なるネットワーク同士を相互に接続するための通信機器。インターネットでのデータを自動的に振り分け、一つのインターネット回線を複数のコンピュータで使用することが可能です。DHCPによりIPアドレスを自動的に割振りすることもできます。

YAMAHA

YAMAHAでは1995年にISDNリモートルーターを発売以降、さまざまなネットワーク製品を販売。企業での広いシェアを獲得しています。ルーターやスイッチ、UTM/ファイアウォール、無線アクセスポイントの製品などの運用管理を簡単にし、安定且つ継承できるサービスを提供しています。

Python 3.x

Python 3はPythonプログラミング言語の最新バージョンであり、2008年12月3日にリリースされました。

0グッド

0クリップ

投稿2023/06/28 04:04

実現したいこと

  • YAMAHAのRTX1200にPythonライブラリであるnetmikoを用いてconfigを適用する。

現状

CISCO機器に対してはenable()で特権モードになりconfigを適用できるが、YAMAHA機器ではenable()で特権モードになった後から進まない。

発生している問題・エラーメッセージ

enable()でエラーが出ています。

Traceback (most recent call last): File "C:\Users\user\netmiko\yamaha2.py", line 29, in <module> net_connect.enable() File "C:\Users\user\anaconda3\lib\site-packages\netmiko\yamaha\yamaha.py", line 28, in enable return super().enable( File "C:\Users\user\anaconda3\lib\site-packages\netmiko\base_connection.py", line 2008, in enable output += self.read_until_prompt() File "C:\Users\user\anaconda3\lib\site-packages\netmiko\base_connection.py", line 812, in read_until_prompt return self.read_until_pattern( File "C:\Users\user\anaconda3\lib\site-packages\netmiko\base_connection.py", line 721, in read_until_pattern raise ReadTimeout(msg) netmiko.exceptions.ReadTimeout: Pattern not detected: '>' in output. Things you might try to fix this: 1. Adjust the regex pattern to better identify the terminating string. Note, in many situations the pattern is automatically based on the network device's prompt. 2. Increase the read_timeout to a larger value. You can also look at the Netmiko session_log or debug log for more information.

セッションログ

RTX1200 Rev.10.01.78 (Wed Nov 13 16:29:42 2019) Copyright (c) 1994-2019 Yamaha Corporation. All Rights Reserved. Copyright (c) 1991-1997 Regents of the University of California. Copyright (c) 1995-2004 Jean-loup Gailly and Mark Adler. Copyright (c) 1998-2000 Tokyo Institute of Technology. Copyright (c) 2000 Japan Advanced Institute of Science and Technology, HOKURIKU. Copyright (c) 2002 RSA Security Inc. All rights reserved. Copyright (c) 1997-2010 University of Cambridge. All rights reserved. Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Copyright (c) 1995 Tatu Ylonen , Espoo, Finland All rights reserved. Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. Copyright (c) 2006 Digital Arts Inc. All Rights Reserved. Copyright (C) 1994-2012 Lua.org, PUC-Rio. Copyright (c) 1988-1992 Carnegie Mellon University All Rights Reserved. Copyright (C) 2004-2007 Diego Nehab. All rights reserved. Copyright (c) 2005 JSON.org 00:a0:de:69:82:9d, 00:a0:de:69:82:9e, 00:a0:de:69:82:9f Memory 128Mbytes, 3LAN, 1BRI > > > console lines infinity > ********istrator   Password: #

netmikoのログ

RTX1200 Rev.10.01.78 (Wed Nov 13 16:29:42 2019) Copyright (c) 1994-2019 Yamaha Corporation. All Rights Reserved. Copyright (c) 1991-1997 Regents of the University of California. Copyright (c) 1995-2004 Jean-loup Gailly and Mark Adler. Copyright (c) 1998-2000 Tokyo Institute of Technology. Copyright (c) 2000 Japan Advanced Institute of Science and Technology, HOKURIKU. Copyright (c) 2002 RSA Security Inc. All rights reserved. Copyright (c) 1997-2010 University of Cambridge. All rights reserved. Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Copyright (c) 1995 Tatu Ylonen , Espoo, Finland All rights reserved. Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. Copyright (c) 2006 Digital Arts Inc. All Rights Reserved. Copyright (C) 1994-2012 Lua.org, PUC-Rio. Copyright (c) 1988-1992 Carnegie Mellon University All Rights Reserved. Copyright (C) 2004-2007 Diego Nehab. All rights reserved. Copyright (c) 2005 JSON.org 00:a0:de:69:82:9d, 00:a0:de:69:82:9e, 00:a0:de:69:82:9f Memory 128Mbytes, 3LAN, 1BRI > > DEBUG:netmiko:Pattern found: ([>#]) RTX1200 Rev.10.01.78 (Wed Nov 13 16:29:42 2019) Copyright (c) 1994-2019 Yamaha Corporation. All Rights Reserved. Copyright (c) 1991-1997 Regents of the University of California. Copyright (c) 1995-2004 Jean-loup Gailly and Mark Adler. Copyright (c) 1998-2000 Tokyo Institute of Technology. Copyright (c) 2000 Japan Advanced Institute of Science and Technology, HOKURIKU. Copyright (c) 2002 RSA Security Inc. All rights reserved. Copyright (c) 1997-2010 University of Cambridge. All rights reserved. Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura, All rights reserved. Copyright (c) 1995 Tatu Ylonen , Espoo, Finland All rights reserved. Copyright (c) 1998-2004 The OpenSSL Project. All rights reserved. Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. Copyright (c) 2006 Digital Arts Inc. All Rights Reserved. Copyright (C) 1994-2012 Lua.org, PUC-Rio. Copyright (c) 1988-1992 Carnegie Mellon University All Rights Reserved. Copyright (C) 2004-2007 Diego Nehab. All rights reserved. Copyright (c) 2005 JSON.org 00:a0:de:69:82:9d, 00:a0:de:69:82:9e, 00:a0:de:69:82:9f Memory 128Mbytes, 3LAN, 1BRI > DEBUG:netmiko:read_channel: DEBUG:netmiko:Clear buffer detects data in the channel DEBUG:netmiko:read_channel: DEBUG:netmiko:write_channel: b'\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: > DEBUG:netmiko: Parenthesis found in pattern. pattern: (\#|>) This can be problemtic when used in read_until_pattern(). You should ensure that you use either non-capture groups i.e. '(?:' or that the parenthesis completely wrap the pattern '(pattern)' DEBUG:netmiko:Pattern found: (\#|>) > DEBUG:netmiko:read_channel: DEBUG:netmiko:Clear buffer detects data in the channel DEBUG:netmiko:read_channel: DEBUG:netmiko:[find_prompt()]: prompt is > DEBUG:netmiko:In disable_paging DEBUG:netmiko:Command: console lines infinity DEBUG:netmiko:write_channel: b'console lines infinity\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: console DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: lines infinity DEBUG:netmiko:Pattern found: (console\ lines\ infinity) console lines infinity DEBUG:netmiko:console lines infinity DEBUG:netmiko:Exiting disable_paging DEBUG:netmiko:read_channel: > DEBUG:netmiko:Clear buffer detects data in the channel DEBUG:netmiko:read_channel: DEBUG:netmiko:write_channel: b'********istrator\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: ********istrator DEBUG:netmiko:Pattern found: (********istrator) ********istrator DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel:   Password: DEBUG:netmiko:Pattern found: ((?:>|Password))   Password DEBUG:netmiko:write_channel: b'********\n' DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: # DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel: DEBUG:netmiko:read_channel:

該当のソースコード

ネット上に公開されているものを少し改変しました。

Python

1from __future__ import print_function, unicode_literals 2 3# Netmiko is the same as ConnectHandler 4from netmiko import Netmiko 5from getpass import getpass 6 7import datetime 8import logging 9 10logging.basicConfig(filename='netmiko_global.log', level=logging.DEBUG) 11logger = logging.getLogger("netmiko") 12 13now = datetime.datetime.today() 14filename = now.strftime('%Y%m%d_%H%M%S') + '.log' 15 16device = { 17 "host": "xxx.xxx.xxx.xxx", 18 "username": "xxx", 19 "password": "xxx", 20 "secret": "xxx", 21 "port": "xxx", 22 "global_delay_factor": 2, 23 "device_type": "yamaha", 24 "session_log": filename, 25} 26 27# connect 28net_connect = Netmiko(**device) 29net_connect.enable() 30 31#send show command (before) 32output = net_connect.send_command("show status lan1") 33print('---------------before log---------------', output, sep='\n') 34 35# change ip address 36config_commands = ['ip lan1 address 10.10.1.1/24','save','exit'] 37output = net_connect.send_config_set(config_commands) 38print('---------------change config---------------', output, sep='\n') 39 40# send show command (after) 41output = net_connect.send_command("show status lan1") 42print('---------------after log---------------', output, sep='\n') 43 44# save config 45output = net_connect.save_config() 46print('---------------save config---------------', output, sep='\n') 47 48# disconnect 49net_connect.disconnect()

試したこと

Netmikoの再インストール。

補足情報

Netmiko Version 4.2.0
Python 3.10.9
Windows11

原因が全く分からないので、アドレスお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

この回答はGPT-4による自動生成回答です

YAMAHAのRTX1200では、特権モードに移行するためのコマンドがenableではなくadministratorであるため、enable()メソッドを使用するとエラーが発生します。

そのため、send_command()メソッドを使用してadministratorコマンドを送信し、特権モードに移行することが可能です。

以下にその例を示します。

python

1from netmiko import ConnectHandler 2 3device = { 4 'device_type': 'yamaha', 5 'ip': '10.0.0.1', 6 'username': 'admin', 7 'password': 'password', 8} 9 10connection = ConnectHandler(**device) 11 12# 特権モードに移行 13connection.send_command('administrator') 14connection.send_command('password') # administratorのパスワードを入力 15 16# ここから設定変更等のコマンドを送信可能

このように、send_command()メソッドを使用して特権モードに移行することで、設定変更等のコマンドを送信することが可能となります。

投稿2023/06/28 04:04

teratail-ai

Powered by GPT-4

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.47%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問