Child pages
  • Pyrule для Inventory, который пригодится для FM каждого

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
from noc.inv.models import *
from noc.sa.models import *
@pyrule
def set_interface_profile(timeout = None):
    uni_id = InterfaceProfile.objects.get(name="UNI").id
    nni_id = InterfaceProfile.objects.get(name="NNI").id
    default_id = InterfaceProfile.objects.get(name="default").id
    interface = Interface.objects.filter(type="physical")
    for i in interface:
        if i.link:
            i.profile = nni_id
            i.save()
            continue
        elif not i.description:
            i.profile = default_id
            i.save()
            continue
        elif i.profile.name == InterfaceProfile.objects.get(name="default").name:
            i.profile = uni_id
            i.save()
            continue
    return True

...