#NEWLINE# def test_filters( site , client ) : #NEWLINE# #INDENT# 'Test field filters for Interfaces.' #NEWLINE# ifc_uri = site . list_uri ( 'interface' ) #NEWLINE# attr_uri = site . list_uri ( 'attribute' ) #NEWLINE# dev_uri = site . list_uri ( 'device' ) #NEWLINE# net_uri = site . list_uri ( 'network' ) #NEWLINE# client . create ( attr_uri , name = 'vlan' , resource_name = 'Interface' ) #NEWLINE# dev1_resp = client . create ( dev_uri , hostname = 'foo-bar1' ) #NEWLINE# dev2_resp = client . create ( dev_uri , hostname = 'foo-bar2' ) #NEWLINE# dev1 = get_result ( dev1_resp ) #NEWLINE# dev2 = get_result ( dev2_resp ) #NEWLINE# dev1_eth0_resp = client . create ( ifc_uri , device = dev1 [ 'id' ] , name = 'eth0' , attributes = { #NEWLINE# #INDENT# 'vlan' : '100' , #NEWLINE# #UNINDENT# } , mac_address = 0 ) #NEWLINE# dev1_eth0 = get_result ( dev1_eth0_resp ) #NEWLINE# dev1_eth1_resp = client . create ( ifc_uri , device = dev1 [ 'id' ] , name = 'eth1' , speed = 40000 , type = 161 , mac_address = 1 ) #NEWLINE# dev1_eth1 = get_result ( dev1_eth1_resp ) #NEWLINE# dev2_eth0_resp = client . create ( ifc_uri , device = dev2 [ 'id' ] , name = 'eth0' , description = 'foo-bar2:eth0' , mac_address = 3 ) #NEWLINE# dev2_eth0 = get_result ( dev2_eth0_resp ) #NEWLINE# dev2_eth1_resp = client . create ( ifc_uri , device = dev2 [ 'id' ] , name = 'eth1' , type = 161 , parent_id = dev2_eth0 [ 'id' ] , mac_address = 4 ) #NEWLINE# dev2_eth1 = get_result ( dev2_eth1_resp ) #NEWLINE# interfaces_resp = client . get ( ifc_uri ) #NEWLINE# interfaces = get_result ( interfaces_resp ) #NEWLINE# wanted = [ dev1_eth0 , dev2_eth0 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , name = 'eth0' ) , expected ) #NEWLINE# wanted = [ dev1_eth0 , dev1_eth1 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , device = dev1 [ 'id' ] ) , expected ) #NEWLINE# wanted = [ dev1_eth0 , dev1_eth1 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , device__hostname = dev1 [ 'hostname' ] ) , expected ) #NEWLINE# wanted = [ dev1_eth1 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , speed = 40000 ) , expected ) #NEWLINE# wanted = [ dev1_eth1 , dev2_eth1 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , type = 161 ) , expected ) #NEWLINE# wanted = [ dev2_eth0 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , description = 'foo-bar2:eth0' ) , expected ) #NEWLINE# wanted = [ dev2_eth1 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , parent_id = dev2_eth0 [ 'id' ] ) , expected ) #NEWLINE# wanted = [ dev1_eth0 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# assert_success ( client . retrieve ( ifc_uri , attributes = [ 'vlan=100' ] ) , expected ) #NEWLINE# wanted = [ dev1_eth1 ] #NEWLINE# expected = filter_interfaces ( interfaces , wanted ) #NEWLINE# mac_tests = ( 1 , '00:00:00:00:00:01' ) #NEWLINE# for mac in mac_tests : #NEWLINE# #INDENT# assert_success ( client . retrieve ( ifc_uri , mac_address = mac ) , expected )