python ile farklı projeler geliştiriyor ve onları tek bir noktadan çalıştırmak, kontrol etmek istiyorsanız kovan…
Nokia routerlarda toplu SDP oluşturma
nokia routerlarda toplu olarak sdp oluşturma ihtiyacı olurşursa aşağıdaki formatta bir excel dosyası oluşturup
| sdpid | routera | routerb | routerbip |
| 10093 | router_a | routerb_b | 10.10.10.1 |
| 4806 | router_a | routerb_d | 10.10.10.3 |
| 1078 | router_a | routerb_f | 10.10.10.5 |
aşagıdaki python kodu kullanarak oluşturduğumuz jinja formatına uygun kodları üretebiliriz… oluşturulacak routerda sdpid nin var olmaması gerekmektedir.
import pandas as pd
from jinja2 import Environment, FileSystemLoader
# Excel dosyasını oku
df = pd.read_excel('sdp_create.xlsx')
# Jinja2 ortamını ayarla (şablon dosyası ile aynı dizinde çalıştığını varsayıyoruz)
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template('sdp_create_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('sdp_create_config.txt', 'w', encoding='utf-8') as f:
f.write(output)
sdp_create_template.j2 dosyasında sdp mpls olarak oluşturulup ldp yi aktif ettiğimiz bir örnek var.
{% for item in items %}
/configure service sdp {{ item.sdpid }} mpls create
info
description "to_{{ item.routerb }} "
far-end {{ item.routerbip }}
ldp
path-mtu 2000
keep-alive
shutdown
exit
no shutdown
{% endfor %}
https://github.com/ferhatcicek/ferhatcicek.com/tree/main/nokia%20routerlarda%20toplu%20sdp%20olusturma adresinden kodlara ve örnek excel dosyasına erişebilirsiniz