Page tree
Skip to end of metadata
Go to start of metadata
  • No labels

3 Comments

  1. Unknown User (tsergey)

    Найти chassis first_mac для МО:

    # ./noc shell
    
    %cpaste
    from noc.inv.models.discoveryid import DiscoveryID
    from noc.sa.models.managedobject import ManagedObject
    MO = {'s564-1-1.intt'}
    for m in MO:
        id = ManagedObject.objects.get(name = m).id
        chassis = DiscoveryID.objects.get(object = id)
        print "chassis:", chassis.object, chassis.chassis_mac
        print "chassis first_mac:", chassis.chassis_mac[0].first_mac
    --
    
    
    
    
    
    :from noc.inv.models.discoveryid import DiscoveryID
    :from noc.sa.models.managedobject import ManagedObject
    :MO = {'s564-1-1.intt'}
    :for m in MO:
    :    id = ManagedObject.objects.get(name = m).id
    :    chassis = DiscoveryID.objects.get(object = id)
    :    print "chassis:", chassis.object, chassis.chassis_mac
    :    print "chassis first_mac:", chassis.chassis_mac[0].first_mac
    :--
    
    chassis: s564-1-1.intt [<MACRange: 1C:AF:F7:6C:4D:A3 - 1C:AF:F7:6C:4D:A3>]
    chassis first_mac: 1C:AF:F7:6C:4D:A3
  2. Unknown User (tsergey)

    законсервировать МО (после убирания галки "Is Managed?")

    ./noc shell
    
    %cpaste
    from noc.inv.models.discoveryid import DiscoveryID
    from noc.inv.models.interface import Interface
    from noc.inv.models.link import Link
    from noc.sa.models.managedobject import ManagedObject
    MO = {'MO1','MO2'}
    for m in MO:
        id = ManagedObject.objects.get(name = m).id
        try:
            chassis = DiscoveryID.objects.get(object = id)
            print "chassis:", chassis.object, chassis.chassis_mac, chassis.id        
            # delete chassis
            chassis.delete()
            chassis.save()
        except:
            print "chassis not found:", m
        for i in Interface.objects.filter(managed_object = id):
            if i.link:
                try:
                    l = Link.objects.get(interfaces = i)
                    print "link:", i.link
                    # delete link
                    l.delete()
                    l.save()
                except:
                    print "link not found:", i
            # delete interface
            i.delete()
            i.save()
    --
    
    quit()
  3. Unknown User (tsergey)

    проставляем Trap Source IP

    %cpaste
    from noc.sa.models.managedobject import ManagedObject
    mo = ManagedObject.objects.filter()
    for m in mo:
        if m.trap_source_ip != str(m.address):
            m.trap_source_ip = str(m.address)
            m.save()
    --