examples/tag_by_location.py
def tag_device(spc, device, tag_name):
    try:
        # Check if a tag exists already with the given name
        tag = spc.tag_management.tags.get(filter_={'name': tag_name})[0]
    except:
        # Create a new public tag with the given name
        tag = factory.make_resource('tag_management.tag', spc)
        tag.name, tag.type = tag_name, 'public'
        tag = spc.tag_management.tags.post(tag)

    """
    Create a new target for this tag, pointing to the given device.
    In other words, assign this tag to this device
    """
    target = factory.make_resource('tag_management.target', spc)
    target.href = device.href
    tag.targets.post(target)

    Create a new target for this tag, pointing to the given device.
    In other words, assign this tag to this device
    
Create a new target for this tag, pointing to the given device.
In other words, assign this tag to this device
Create a new target for this tag pointing to the given device . In other words assign this tag to this device
def tag_device(spc, device, tag_name):
    try:
        tag = spc.tag_management.tags.get(filter_={'name': tag_name})[0]
    except:
        tag = factory.make_resource('tag_management.tag', spc)
        tag.name, tag.type = tag_name, 'public'
        tag = spc.tag_management.tags.post(tag)
    target = factory.make_resource('tag_management.target', spc)
    target.href = device.href
    tag.targets.post(target)
def tag_device ( spc , device , tag_name ) : try : tag = spc . tag_management . tags . get ( filter_ = { 'name' : tag_name } ) [ 0 ] except : tag = factory . make_resource ( 'tag_management.tag' , spc ) tag . name , tag . type = tag_name , 'public' tag = spc . tag_management . tags . post ( tag ) target = factory . make_resource ( 'tag_management.target' , spc ) target . href = device . href tag . targets . post ( target )
Create a new target for this tag, pointing to the given device.
Create a new target for this tag pointing to the given device .
# Check if a tag exists already with the given name # Create a new public tag with the given name """
    Create a new target for this tag, pointing to the given device.
    In other words, assign this tag to this device
    """
spc
device
tag_name