def add_prefix_from_pool(arg, opts):
args = {}<EOL>if '<STR_LIT>' in opts:<EOL><INDENT>res = Pool.list({ '<STR_LIT:name>': opts['<STR_LIT>'] })<EOL>if len(res) == <NUM_LIT:0>:<EOL><INDENT>print("<STR_LIT>" % opts['<STR_LIT>'], file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>args['<STR_LIT>'] = res[<NUM_LIT:0>]<EOL><DEDENT>if '<STR_LIT>' not in opts:<EOL><INDENT>print("<STR_LIT>", file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if opts['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>afis = [<NUM_LIT:4>]<EOL><DEDENT>elif opts['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>afis = [<NUM_LIT:6>]<EOL><DEDENT>elif opts['<STR_LIT>'] == '<STR_LIT>':<EOL><INDENT>afis = [<NUM_LIT:4>, <NUM_LIT:6>]<EOL>if '<STR_LIT>' in opts:<EOL><INDENT>print("<STR_LIT>", file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % "<STR_LIT:U+0020>".join(valid_families), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if '<STR_LIT>' in opts:<EOL><INDENT>args['<STR_LIT>'] = int(opts['<STR_LIT>'])<EOL><DEDENT>for afi in afis:<EOL><INDENT>p = _prefix_from_opts(opts)<EOL>if opts.get('<STR_LIT>') is None:<EOL><INDENT>p.vrf = args['<STR_LIT>'].vrf<EOL><DEDENT>else:<EOL><INDENT>p.vrf = get_vrf(opts.get('<STR_LIT>'), abort=True)<EOL><DEDENT>if p.type is None:<EOL><INDENT>if args['<STR_LIT>'].default_type is None:<EOL><INDENT>print("<STR_LIT>" % opts['<STR_LIT>'], file=sys.stderr)<EOL><DEDENT>p.type = args['<STR_LIT>'].default_type<EOL><DEDENT>for avp in opts.get('<STR_LIT>', []):<EOL><INDENT>try:<EOL><INDENT>key, value = avp.split('<STR_LIT:=>', <NUM_LIT:1>)<EOL><DEDENT>except ValueError:<EOL><INDENT>print("<STR_LIT>" % avp, file=sys.stderr)<EOL>return<EOL><DEDENT>p.avps[key] = value<EOL><DEDENT>args['<STR_LIT>'] = afi<EOL>try:<EOL><INDENT>p.save(args)<EOL><DEDENT>except NipapError as exc:<EOL><INDENT>print("<STR_LIT>" % str(exc), file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>if p.type == '<STR_LIT:host>':<EOL><INDENT>print("<STR_LIT>" % (p.display_prefix,<EOL>vrf_format(p.vrf), p.node or p.description))<EOL><DEDENT>else:<EOL><INDENT>print("<STR_LIT>" % (p.display_prefix,<EOL>vrf_format(p.vrf), p.description))<EOL><DEDENT>if opts.get('<STR_LIT>') is not None:<EOL><INDENT>if p.type != '<STR_LIT>':<EOL><INDENT>print("<STR_LIT>", file=sys.stderr)<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>for host in opts.get('<STR_LIT>').split('<STR_LIT:U+002C>'):<EOL><INDENT>h_opts = {<EOL>'<STR_LIT>': p.prefix,<EOL>'<STR_LIT>': p.vrf.rt,<EOL>'<STR_LIT:type>': '<STR_LIT:host>',<EOL>'<STR_LIT>': host<EOL>}<EOL>add_prefix({}, h_opts, {})<EOL><DEDENT><DEDENT><DEDENT>
Add prefix using from-pool to NIPAP