Skip to content

nokia routerda 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 {{ item.SvcId }} sap {{ item.PortId }} shutdown
/configure service {{ 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..

PortIdSvcIdIngressIng.EgressEgr.AdmOpr
lag-40:1011.0123454none45noneUpDown
lag-42:1011.0123454none45noneUpDown
lag-44:1011.0123454none45noneUpDown

Gerekli kodları aşagdaıki github adresinden ulaşılabilir.

https://github.com/ferhatcicek/nokia-service-sap-delete

Back To Top