examples/collect_inventory.py
def process_device(spc, device):
    """
    Process inventory collection for a given device.
    """
    try:
        d = device.get();
        print("Processing device: ", device.name)
        me_href = d['managed-elements']['managed-element'].get('href')
        me = factory.fetch_resource(spc, me_href)

        # Fetch Physical Termination Points
        ptps = me.ptps.get()
        for p in ptps:
            p.get()

        # Fetch equipment inventory
        ehs = me.equipment_holders.get()
        for eh in ehs:
            eh.get()

        # Fetch software inventory
        me.software_identities.get()

        # Fetch relevant configuration
        try:
            device.configurations.expanded.post(xpaths=[
                    '/configuration/version',
                    '/configuration/routing-instances',
                    '/configuration/access/radius-server',
                    '/configuration/system/domain-name',
                    '/configuration/routing-options/router-id',
                    '/configuration/interfaces/interface[name="lo0"]'])
        except:
            pass

        return device.name
    except:
        raise Exception("Failed to process %s due to %s" % (device.name, sys.exc_info()[1]))

    Process inventory collection for a given device.
    
Process inventory collection for a given device.
Process inventory collection for a given device .
def process_device(spc, device):
    try:
        d = device.get();
        print("Processing device: ", device.name)
        me_href = d['managed-elements']['managed-element'].get('href')
        me = factory.fetch_resource(spc, me_href)
        ptps = me.ptps.get()
        for p in ptps:
            p.get()
        ehs = me.equipment_holders.get()
        for eh in ehs:
            eh.get()
        me.software_identities.get()
        try:
            device.configurations.expanded.post(xpaths=[
                    '/configuration/version',
                    '/configuration/routing-instances',
                    '/configuration/access/radius-server',
                    '/configuration/system/domain-name',
                    '/configuration/routing-options/router-id',
                    '/configuration/interfaces/interface[name="lo0"]'])
        except:
            pass
        return device.name
    except:
        raise Exception("Failed to process %s due to %s" % (device.name, sys.exc_info()[1]))
def process_device ( spc , device ) : try : d = device . get ( ) ; print ( "Processing device: " , device . name ) me_href = d [ 'managed-elements' ] [ 'managed-element' ] . get ( 'href' ) me = factory . fetch_resource ( spc , me_href ) ptps = me . ptps . get ( ) for p in ptps : p . get ( ) ehs = me . equipment_holders . get ( ) for eh in ehs : eh . get ( ) me . software_identities . get ( ) try : device . configurations . expanded . post ( xpaths = [ '/configuration/version' , '/configuration/routing-instances' , '/configuration/access/radius-server' , '/configuration/system/domain-name' , '/configuration/routing-options/router-id' , '/configuration/interfaces/interface[name="lo0"]' ] ) except : pass return device . name except : raise Exception ( "Failed to process %s due to %s" % ( device . name , sys . exc_info ( ) [ 1 ] ) )
Process inventory collection for a given device.
Process inventory collection for a given device .
"""
    Process inventory collection for a given device.
    """ # Fetch Physical Termination Points # Fetch equipment inventory # Fetch software inventory # Fetch relevant configuration
spc
device