def prefix_attr_add(arg, opts, shell_opts):
    """ Add attributes to a prefix
    """

    spec = { 'prefix': arg }
    v = get_vrf(opts.get('vrf_rt'), abort=True)
    spec['vrf_rt'] = v.rt

    res = Prefix.list(spec)
    if len(res) == 0:
        print >> sys.stderr, "Prefix %s not found in %s." % (arg, vrf_format(v))
        return

    p = res[0]

    for avp in opts.get('extra-attribute', []):
        try:
            key, value = avp.split('=', 1)
        except __HOLE__:
            print >> sys.stderr, "ERROR: Incorrect extra-attribute: %s. Accepted form: 'key=value'\n" % avp
            sys.exit(1)

        if key in p.avps:
            print >> sys.stderr, "Unable to add extra-attribute: '%s' already exists." % key
            sys.exit(1)

        p.avps[key] = value

    try:
        p.save()
    except NipapError as exc:
        print >> sys.stderr, "Could not save prefix changes: %s" % str(exc)
        sys.exit(1)

    print "Prefix %s in %s saved." % (p.display_prefix, vrf_format(p.vrf))
dataset/ETHPy150Open SpriteLink/NIPAP/nipap-cli/nipap_cli/nipap_cli.py/prefix_attr_add