examples/tag_by_location.py
def main(my_space):
    """
    Gets all connected Junos devices from Space. Then gets the snmp/location
    configured on each. If this configuration is present, it creates a public
    tag with this value and assign the tag to the device.
    """
    devices_list = my_space.device_management.devices.\
                   get(filter_={'deviceFamily': 'junos',
                                'connectionStatus': 'up'})
    for d in devices_list:
        print(d.name, d.ipAddr, d.platform)
        c = d.configurations.expanded.post(xpaths=['configuration/snmp/location'])
        try:
            tag_device(my_space, d, c.configuration.location)
        except AttributeError:
            print("Device %s does not have location configured" % d.name)

    Gets all connected Junos devices from Space. Then gets the snmp/location
    configured on each. If this configuration is present, it creates a public
    tag with this value and assign the tag to the device.
    
Gets all connected Junos devices from Space. Then gets the snmp/location
configured on each. If this configuration is present, it creates a public
tag with this value and assign the tag to the device.
Gets all connected Junos devices from Space . Then gets the snmp / location configured on each . If this configuration is present it creates a public tag with this value and assign the tag to the device .
def main(my_space):
    devices_list = my_space.device_management.devices.\
                   get(filter_={'deviceFamily': 'junos',
                                'connectionStatus': 'up'})
    for d in devices_list:
        print(d.name, d.ipAddr, d.platform)
        c = d.configurations.expanded.post(xpaths=['configuration/snmp/location'])
        try:
            tag_device(my_space, d, c.configuration.location)
        except AttributeError:
            print("Device %s does not have location configured" % d.name)
def main ( my_space ) : devices_list = my_space . device_management . devices . get ( filter_ = { 'deviceFamily' : 'junos' , 'connectionStatus' : 'up' } ) for d in devices_list : print ( d . name , d . ipAddr , d . platform ) c = d . configurations . expanded . post ( xpaths = [ 'configuration/snmp/location' ] ) try : tag_device ( my_space , d , c . configuration . location ) except AttributeError : print ( "Device %s does not have location configured" % d . name )
Gets all connected Junos devices from Space.
Gets all connected Junos devices from Space .
"""
    Gets all connected Junos devices from Space. Then gets the snmp/location
    configured on each. If this configuration is present, it creates a public
    tag with this value and assign the tag to the device.
    """
my_space