4 class SimpleMapping(object):
6 def __init__(self, cmd, cli, vat):
8 raise Exception('{} already in cmd db!'.format(cmd))
15 def generate(self, mode, args):
17 # simply append arguments string to right command
19 s = self.vat + ' ' + args
21 s = self.cli + ' ' + args
25 class CustomMapping(SimpleMapping):
27 def generate(self, mode, args):
34 args = args.split(' ')
35 return s.format(*args)
38 class RepeatableLocators(SimpleMapping):
40 def append_locs(self, locs):
43 def generate(self, mode, args):
44 name = args[:args.index(' ')] # first word is ls name
45 locs = args[args.index(' '):]
52 s = s + ' ' + name + locs
56 SimpleMapping('lisp_state', 'lisp', 'lisp_enable_disable')
57 SimpleMapping('lisp_map_resolver', 'lisp map-resolver', 'lisp_add_del_map_resolver')
58 SimpleMapping('lisp_local_eid', 'lisp eid-table', 'lisp_add_del_local_eid')
59 SimpleMapping('lisp_remote_mapping', 'lisp remote-mapping', 'lisp_add_del_remote_mapping')
60 SimpleMapping('lisp_pitr', 'lisp pitr ls', 'lisp_pitr_set_locator_set locator-set')
61 SimpleMapping('lisp_adjacency', 'lisp adjacency', 'lisp_add_del_adjacency')
62 SimpleMapping('set_if_ip', 'set int ip address', 'sw_interface_add_del_address')
64 CustomMapping('lisp_eid_map_bd',
65 'lisp eid-table map vni {0} bd {1}',
66 'lisp_eid_table_add_del_map vni {0} bd_index {1}')
67 CustomMapping('lisp_eid_map_vrf',
68 'lisp eid-table map vni {0} vrf {1}',
69 'lisp_eid_table_add_del_map vni {0} vrf {1}')
70 CustomMapping('set_if_l2_bridge', 'set interface l2 bridge {0} {1}',
71 'sw_interface_set_l2_bridge {0} bd_id {1}')
72 CustomMapping('set_if_ip_table', 'set interface ip table {0} {1}',
73 'sw_interface_set_table {0} vrf {1}')
74 CustomMapping('lisp_locator_set_with_locator',
75 'lisp locator-set add {0} iface {1} p {2} w {3}',
76 'lisp_add_del_locator_set locator-set {0} iface {1} p {2} w {3}')
77 CustomMapping('create_host_iface',
78 'create host-interface name {0}\n'
79 'set int state host-{0} up\n'
80 'set int ip address host-{0} {1}',
82 'af_packet_create name {0}\n'
83 'sw_interface_set_flags host-{0} admin-up link-up\n'
84 'sw_interface_add_del_address host-{0} {1}')
86 CustomMapping('create_host_iface_vrf',
87 'create host-interface name {0}\n'
88 'set int state host-{0} up\n'
89 'set interface ip table host-{0} {2}\n'
90 'set int ip address host-{0} {1}',
92 'af_packet_create name {0}\n'
93 'sw_interface_set_flags host-{0} admin-up link-up\n'
94 'sw_interface_set_table host-{0} vrf {2}\n'
95 'sw_interface_add_del_address host-{0} {1}')
97 CustomMapping('create_host_iface_vrf_v6',
98 'create host-interface name {0}\n'
99 'set int state host-{0} up\n'
100 'set interface ip6 table host-{0} {2}\n'
101 'set int ip address host-{0} {1}',
103 'af_packet_create name {0}\n'
104 'sw_interface_set_flags host-{0} admin-up link-up\n'
105 'sw_interface_set_table host-{0} vrf {2} ipv6\n'
106 'sw_interface_add_del_address host-{0} {1}')
108 RepeatableLocators('lisp_ls_multiple_locs',
109 'lisp locator-set add',
110 'lisp_add_del_locator_set locator-set')