以下のプログラムを使って以下のコマンドを実行しようとしましたが、matchコマンドの結果ではなくconfigファイル全体を取得しています。マッチ機能はPYEZでサポートされていませんか?PYEZ - ディスプレイセット| Matchコマンド
show configuration |ディスプレイセット|一致RI- 設定を表示する|ディスプレイセット|マッチPOOL- 設定を表示する|ディスプレイセット| match SERVICE-
私の目的は、match RIコマンドのコマンドラインを取得し、setをdeleteに置き換えてデバイスにロードすることでした。
助けてください。
試し: log.debug( "ルータの設定を収集")
now = datetime.datetime.now()
datets = str(now.year) + str(now.month) + str(now.day) + "_" + str(now.hour) + str(now.minute) + str(now.second)
log.debug("timestamp set to " + str(datets))
if (format == "cnf"):
cnf = dev.cli("show configuration", warning=False)
FileName = rtName + "." + datets + ".cnf"
log.debug("The configuration will be stored in filename as %s", FileName)
# saving the configuration into a CNF file
f = open(FileName, 'w+')
f.write(cnf)
f.close
return FileName
elif (format == "set"):
cnf = dev.cli("show configuration | display set | match pool-", warning=False)
FileName = rtName + "." + datets + ".txt"
log.debug("The configuration will be stored in filename as %s", FileName)
# saving the configuration into a Text file
f = open(FileName, 'w+')
f.write(cnf)
f.close
return FileName
else: # defaults to XML
cnf = dev.rpc.get_config()
FileName = rtName + "." + datets + ".xml"
log.warn("The configuration will be stored in filename as %s", FileName)
# saving the configuration into a XML file
f = open(FileName, 'w+')
f.write(etree.tostring(cnf))
f.close
return FileName
except Exception as e:
log.error("could not collect the router configuration via RPC")
log.error(e.message)
return None
# if the execution gets here, the return will be None
return FileName