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 generate(self, mode, args):
41 name = args[:args.index(' ')] # first word is ls name
42 locs = args[args.index(' '):]
49 s = s + ' ' + name + locs
53 SimpleMapping('lisp_state', 'lisp', 'lisp_enable_disable')
54 SimpleMapping('lisp_map_resolver', 'lisp map-resolver', 'lisp_add_del_map_resolver')
55 SimpleMapping('lisp_local_eid', 'lisp eid-table', 'lisp_add_del_local_eid')
56 SimpleMapping('lisp_remote_mapping', 'lisp remote-mapping', 'lisp_add_del_remote_mapping')
57 SimpleMapping('lisp_pitr', 'lisp pitr ls', 'lisp_pitr_set_locator_set locator-set')
58 SimpleMapping('lisp_adjacency', 'lisp adjacency', 'lisp_add_del_adjacency')
59 SimpleMapping('lisp_map_request_mode', 'lisp map-request mode', 'lisp_map_request_mode')
60 SimpleMapping('set_if_ip', 'set int ip address', 'sw_interface_add_del_address')
62 CustomMapping('lisp_eid_map_bd',
63 'lisp eid-table map vni {0} bd {1}',
64 'lisp_eid_table_add_del_map vni {0} bd_index {1}')
65 CustomMapping('lisp_eid_map_vrf',
66 'lisp eid-table map vni {0} vrf {1}',
67 'lisp_eid_table_add_del_map vni {0} vrf {1}')
68 CustomMapping('set_if_l2_bridge', 'set interface l2 bridge {0} {1}',
69 'sw_interface_set_l2_bridge {0} bd_id {1}')
70 CustomMapping('set_if_ip_table', 'set interface ip table {0} {1}',
71 'sw_interface_set_table {0} vrf {1}')
72 CustomMapping('lisp_locator_set_with_locator',
73 'lisp locator-set add {0} iface {1} p {2} w {3}',
74 'lisp_add_del_locator_set locator-set {0} iface {1} p {2} w {3}')
75 CustomMapping('create_host_iface',
76 'create host-interface name {0}\n'
77 'set int state host-{0} up\n'
78 'set int ip address host-{0} {1}',
80 'af_packet_create name {0}\n'
81 'sw_interface_set_flags host-{0} admin-up link-up\n'
82 'sw_interface_add_del_address host-{0} {1}')
84 CustomMapping('create_host_iface_vrf',
85 'create host-interface name {0}\n'
86 'set int state host-{0} up\n'
87 'set interface ip table host-{0} {2}\n'
88 'set int ip address host-{0} {1}',
90 'af_packet_create name {0}\n'
91 'sw_interface_set_flags host-{0} admin-up link-up\n'
92 'sw_interface_set_table host-{0} vrf {2}\n'
93 'sw_interface_add_del_address host-{0} {1}')
95 CustomMapping('create_host_iface_vrf_v6',
96 'create host-interface name {0}\n'
97 'set int state host-{0} up\n'
98 'set interface ip6 table host-{0} {2}\n'
99 'set int ip address host-{0} {1}',
101 'af_packet_create name {0}\n'
102 'sw_interface_set_flags host-{0} admin-up link-up\n'
103 'sw_interface_set_table host-{0} vrf {2} ipv6\n'
104 'sw_interface_add_del_address host-{0} {1}')
106 RepeatableLocators('lisp_ls_multiple_locs',
107 'lisp locator-set add',
108 'lisp_add_del_locator_set locator-set')