nokia routerlar üzerinde aynı dakikalar içerisinde up/down olan portları bulmak için loglara bakmak en doğru…
nokia routerda vpls servis altındaki sapların silinmesi
nokia routerda belirli bir servis altındaki sapları silme ihtiyacı durumunda aşagıdaki kod kulllanılabilir.
import pandas as pd
from jinja2 import Environment, FileSystemLoader
# Excel dosyasını oku
df = pd.read_excel('sap_delete.xlsx')
# Jinja2 ortamını ayarla (şablon dosyası ile aynı dizinde çalıştığını varsayıyoruz)
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template('sap_delete_template.j2')
# Excel'den okunan veriyi listeye çevir
data = df.to_dict(orient='records')
# Jinja2 ile konfigürasyon dosyasını oluştur
output = template.render(items=data)
# Sonucu dosyaya yaz
with open('sap_delete_config.txt', 'w', encoding='utf-8') as f:
f.write(output)
üretilecek komut için aşagıdaki jinja template ini kullanyoruz..
{% for item in items %}
/configure service vpls {{ item.SvcId }} sap {{ item.PortId }} shutdown
/configure service vpls {{ item.SvcId }} no sap {{ item.PortId }}
{% endfor %}
sap_delete_config.txt dosyasında tempalte sonucuna uygun konfigürasyon oluşmuş olacaktır..
kullanacağımız excel ise show service sap-using komutunun çıktısına uygun olarak aşagıdaki formatta olmaldıır..
| PortId | SvcId | Ingress | Ing. | Egress | Egr. | Adm | Opr |
|---|---|---|---|---|---|---|---|
| lag-40:1011.0 | 1234 | 54 | none | 45 | none | Up | Down |
| lag-42:1011.0 | 1234 | 54 | none | 45 | none | Up | Down |
| lag-44:1011.0 | 1234 | 54 | none | 45 | none | Up | Down |
Gerekli kodları aşagdaıki github adresinden ulaşılabilir.