def add_tag(ip):
    tag_group = None
    tag = None
    try:
        tag_group = api.get_tag_group_by_name('Lumeta')
        tag = tag_group.get_tag_by_name('Discovered Device')
    except PortalException as e:
        if (tag_group is None):
            tag_group = api.add_tag_group('Lumeta')
        if (tag is None):
            tag_group = api.get_tag_group_by_name('Lumeta')
            tag = tag_group.add_tag('Discovered Device')
    try:
        ip.link_entity(tag)
    except APIException as ex:
        print(ex.get_message())
def add_tag(ip):
    tag_group = None
    tag = None
    try:
        tag_group = api.get_tag_group_by_name('Lumeta')
        tag = tag_group.get_tag_by_name('Discovered Device')
    except PortalException as e:
        if (tag_group is None):
            tag_group = api.add_tag_group('Lumeta')
        if (tag is None):
            tag_group = api.get_tag_group_by_name('Lumeta')
            tag = tag_group.add_tag('Discovered Device')
    try:
        ip.link_entity(tag)
    except APIException as ex:
        print(ex.get_message())