@@ -845,6 +845,57 @@ def test_interfaces():
845845 ' gateway 2001:db8:dead:beef::1\n ' ,
846846 ' accept_ra 2\n ' ,
847847 '\n ' ]},
848+
849+ # Command hooks
850+ {'iface_name' : 'eth_optmap_test' , 'iface_type' : 'eth' , 'enabled' : True ,
851+ 'build_interface' : {
852+ 'up_cmds' : ['echo "interface up"' ],
853+ 'down_cmds' : ['echo "interface down"' ],
854+ 'pre_up_cmds' : ['echo "pre-up"' ],
855+ 'post_up_cmds' : ['echo "post-up"' ],
856+ 'pre_down_cmds' : ['echo "pre-down"' ],
857+ 'post_down_cmds' : ['echo "post-down"' ],
858+ },
859+ 'get_interface' : odict ([('eth_optmap_test' , odict ([('enabled' , True ), ('data' , odict ([
860+ ('inet' , odict ([
861+ ('addrfam' , 'inet' ),
862+ ('filename' , None ),
863+ ('up_cmds' , ['echo "interface up"' ]),
864+ ('down_cmds' , ['echo "interface down"' ]),
865+ ('pre_up_cmds' , ['echo "pre-up"' ]),
866+ ('post_up_cmds' , ['echo "post-up"' ]),
867+ ('pre_down_cmds' , ['echo "pre-down"' ]),
868+ ('post_down_cmds' , ['echo "post-down"' ]),
869+ ])),
870+ ]))]))]),
871+ 'return' : [
872+ 'auto eth_optmap_test\n ' ,
873+ 'iface eth_optmap_test inet\n ' ,
874+ ' up echo "interface up"\n ' ,
875+ ' down echo "interface down"\n ' ,
876+ ' pre-up echo "pre-up"\n ' ,
877+ ' post-up echo "post-up"\n ' ,
878+ ' pre-down echo "pre-down"\n ' ,
879+ ' post-down echo "post-down"\n ' ,
880+ '\n ' ]},
881+
882+ # hwaddr should map to hwaddress
883+ {'iface_name' : 'eth_optmap_test' , 'iface_type' : 'eth' , 'enabled' : True ,
884+ 'build_interface' : {
885+ 'hwaddr' : '00:11:22:33:44:55' ,
886+ },
887+ 'get_interface' : odict ([('eth_optmap_test' , odict ([('enabled' , True ), ('data' , odict ([
888+ ('inet' , odict ([
889+ ('addrfam' , 'inet' ),
890+ ('filename' , None ),
891+ ('hwaddr' , '00:11:22:33:44:55' ),
892+ ])),
893+ ]))]))]),
894+ 'return' : [
895+ 'auto eth_optmap_test\n ' ,
896+ 'iface eth_optmap_test inet\n ' ,
897+ ' hwaddress 00:11:22:33:44:55\n ' ,
898+ '\n ' ]},
848899 ]
849900# fmt: on
850901
0 commit comments