<s> from oslo_config import cfg <EOL> from nova import exception <EOL> from nova . network import model <EOL> from nova import test <EOL> from nova . tests . unit import fake_network_cache_model <EOL> from nova . virt import netutils <EOL> class RouteTests ( test . NoDBTestCase ) : <EOL> def test_create_route_with_attrs ( self ) : <EOL> route = fake_network_cache_model . new_route ( ) <EOL> fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) <EOL> self . assertEqual ( '<STR_LIT>' , route [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , route [ '<STR_LIT>' ] [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , route [ '<STR_LIT>' ] ) <EOL> def test_routes_equal ( self ) : <EOL> route1 = model . Route ( ) <EOL> route2 = model . Route ( ) <EOL> self . assertEqual ( route1 , route2 ) <EOL> def test_routes_not_equal ( self ) : <EOL> route1 = model . Route ( cidr = '<STR_LIT>' ) <EOL> route2 = model . Route ( cidr = '<STR_LIT>' ) <EOL> self . assertNotEqual ( route1 , route2 ) <EOL> route1 = model . Route ( cidr = '<STR_LIT>' , gateway = '<STR_LIT>' ) <EOL> route2 = model . Route ( cidr = '<STR_LIT>' , gateway = '<STR_LIT>' ) <EOL> self . assertNotEqual ( route1 , route2 ) <EOL> route1 = model . Route ( cidr = '<STR_LIT>' , interface = '<STR_LIT>' ) <EOL> route2 = model . Route ( cidr = '<STR_LIT>' , interface = '<STR_LIT>' ) <EOL> self . assertNotEqual ( route1 , route2 ) <EOL> def test_hydrate ( self ) : <EOL> route = model . Route . hydrate ( <EOL> { '<STR_LIT>' : fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) } ) <EOL> self . assertIsNone ( route [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , route [ '<STR_LIT>' ] [ '<STR_LIT:address>' ] ) <EOL> self . assertIsNone ( route [ '<STR_LIT>' ] ) <EOL> class IPTests ( test . NoDBTestCase ) : <EOL> def test_ip_equal ( self ) : <EOL> ip1 = model . IP ( address = '<STR_LIT:127.0.0.1>' ) <EOL> ip2 = model . IP ( address = '<STR_LIT:127.0.0.1>' ) <EOL> self . assertEqual ( ip1 , ip2 ) <EOL> def test_ip_not_equal ( self ) : <EOL> ip1 = model . IP ( address = '<STR_LIT:127.0.0.1>' ) <EOL> ip2 = model . IP ( address = '<STR_LIT>' ) <EOL> self . assertNotEqual ( ip1 , ip2 ) <EOL> ip1 = model . IP ( address = '<STR_LIT:127.0.0.1>' , type = <NUM_LIT:1> ) <EOL> ip2 = model . IP ( address = '<STR_LIT>' , type = <NUM_LIT:2> ) <EOL> self . assertNotEqual ( ip1 , ip2 ) <EOL> ip1 = model . IP ( address = '<STR_LIT:127.0.0.1>' , version = <NUM_LIT:4> ) <EOL> ip2 = model . IP ( address = '<STR_LIT>' , version = <NUM_LIT:6> ) <EOL> self . assertNotEqual ( ip1 , ip2 ) <EOL> class FixedIPTests ( test . NoDBTestCase ) : <EOL> def test_createnew_fixed_ip_with_attrs ( self ) : <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , fixed_ip [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( [ ] , fixed_ip [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , fixed_ip [ '<STR_LIT:type>' ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , fixed_ip [ '<STR_LIT:version>' ] ) <EOL> def test_create_fixed_ipv6 ( self ) : <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' ) <EOL> self . assertEqual ( '<STR_LIT>' , fixed_ip [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( [ ] , fixed_ip [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , fixed_ip [ '<STR_LIT:type>' ] ) <EOL> self . assertEqual ( <NUM_LIT:6> , fixed_ip [ '<STR_LIT:version>' ] ) <EOL> def test_create_fixed_bad_ip_fails ( self ) : <EOL> self . assertRaises ( exception . InvalidIpAddressError , <EOL> model . FixedIP , <EOL> address = '<STR_LIT>' ) <EOL> def test_equate_two_fixed_ips ( self ) : <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' ) <EOL> fixed_ip2 = model . FixedIP ( address = '<STR_LIT>' ) <EOL> self . assertEqual ( fixed_ip , fixed_ip2 ) <EOL> def test_equate_two_dissimilar_fixed_ips_fails ( self ) : <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' ) <EOL> fixed_ip2 = model . FixedIP ( address = '<STR_LIT>' ) <EOL> self . assertNotEqual ( fixed_ip , fixed_ip2 ) <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' , type = '<STR_LIT:1>' ) <EOL> fixed_ip2 = model . FixedIP ( address = '<STR_LIT>' , type = '<STR_LIT:2>' ) <EOL> self . assertNotEqual ( fixed_ip , fixed_ip2 ) <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> fixed_ip2 = model . FixedIP ( address = '<STR_LIT>' , version = '<STR_LIT:4>' ) <EOL> self . assertNotEqual ( fixed_ip , fixed_ip2 ) <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' , floating_ips = '<STR_LIT>' ) <EOL> fixed_ip2 = model . FixedIP ( address = '<STR_LIT>' , floating_ips = '<STR_LIT>' ) <EOL> self . assertNotEqual ( fixed_ip , fixed_ip2 ) <EOL> def test_hydrate ( self ) : <EOL> fixed_ip = model . FixedIP . hydrate ( { } ) <EOL> self . assertEqual ( [ ] , fixed_ip [ '<STR_LIT>' ] ) <EOL> self . assertIsNone ( fixed_ip [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , fixed_ip [ '<STR_LIT:type>' ] ) <EOL> self . assertIsNone ( fixed_ip [ '<STR_LIT:version>' ] ) <EOL> def test_add_floating_ip ( self ) : <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' ) <EOL> fixed_ip . add_floating_ip ( '<STR_LIT>' ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] , fixed_ip [ '<STR_LIT>' ] ) <EOL> def test_add_floating_ip_repeatedly_only_one_instance ( self ) : <EOL> fixed_ip = model . FixedIP ( address = '<STR_LIT>' ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> fixed_ip . add_floating_ip ( '<STR_LIT>' ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] , fixed_ip [ '<STR_LIT>' ] ) <EOL> class SubnetTests ( test . NoDBTestCase ) : <EOL> def test_create_subnet_with_attrs ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> route1 = fake_network_cache_model . new_route ( ) <EOL> self . assertEqual ( '<STR_LIT>' , subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) ] , <EOL> subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , subnet [ '<STR_LIT>' ] [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( [ route1 ] , subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , subnet [ '<STR_LIT:version>' ] ) <EOL> def test_subnet_equal ( self ) : <EOL> subnet1 = fake_network_cache_model . new_subnet ( ) <EOL> subnet2 = fake_network_cache_model . new_subnet ( ) <EOL> self . assertEqual ( subnet1 , subnet2 ) <EOL> def test_subnet_not_equal ( self ) : <EOL> subnet1 = model . Subnet ( cidr = '<STR_LIT>' ) <EOL> subnet2 = model . Subnet ( cidr = '<STR_LIT>' ) <EOL> self . assertNotEqual ( subnet1 , subnet2 ) <EOL> subnet1 = model . Subnet ( dns = '<STR_LIT>' ) <EOL> subnet2 = model . Subnet ( dns = '<STR_LIT>' ) <EOL> self . assertNotEqual ( subnet1 , subnet2 ) <EOL> subnet1 = model . Subnet ( gateway = '<STR_LIT>' ) <EOL> subnet2 = model . Subnet ( gateway = '<STR_LIT>' ) <EOL> self . assertNotEqual ( subnet1 , subnet2 ) <EOL> subnet1 = model . Subnet ( ips = '<STR_LIT>' ) <EOL> subnet2 = model . Subnet ( ips = '<STR_LIT>' ) <EOL> self . assertNotEqual ( subnet1 , subnet2 ) <EOL> subnet1 = model . Subnet ( routes = '<STR_LIT>' ) <EOL> subnet2 = model . Subnet ( routes = '<STR_LIT>' ) <EOL> self . assertNotEqual ( subnet1 , subnet2 ) <EOL> subnet1 = model . Subnet ( version = '<STR_LIT:4>' ) <EOL> subnet2 = model . Subnet ( version = '<STR_LIT>' ) <EOL> self . assertNotEqual ( subnet1 , subnet2 ) <EOL> def test_add_route ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> route1 = fake_network_cache_model . new_route ( ) <EOL> route2 = fake_network_cache_model . new_route ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> subnet . add_route ( route2 ) <EOL> self . assertEqual ( [ route1 , route2 ] , subnet [ '<STR_LIT>' ] ) <EOL> def test_add_route_a_lot ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> route1 = fake_network_cache_model . new_route ( ) <EOL> route2 = fake_network_cache_model . new_route ( { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> subnet . add_route ( route2 ) <EOL> self . assertEqual ( [ route1 , route2 ] , subnet [ '<STR_LIT>' ] ) <EOL> def test_add_dns ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> dns = fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) <EOL> subnet . add_dns ( dns ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) ] , <EOL> subnet [ '<STR_LIT>' ] ) <EOL> def test_add_dns_a_lot ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> subnet . add_dns ( fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) ] , <EOL> subnet [ '<STR_LIT>' ] ) <EOL> def test_add_ip ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> subnet . add_ip ( fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , subnet [ '<STR_LIT>' ] ) <EOL> def test_add_ip_a_lot ( self ) : <EOL> subnet = fake_network_cache_model . new_subnet ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> subnet . add_ip ( fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , subnet [ '<STR_LIT>' ] ) <EOL> def test_hydrate ( self ) : <EOL> subnet_dict = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ fake_network_cache_model . new_ip ( dict ( address = '<STR_LIT>' ) ) ] , <EOL> '<STR_LIT>' : [ fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , <EOL> '<STR_LIT>' : [ fake_network_cache_model . new_route ( ) ] , <EOL> '<STR_LIT:version>' : <NUM_LIT:4> , <EOL> '<STR_LIT>' : fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) } <EOL> subnet = model . Subnet . hydrate ( subnet_dict ) <EOL> self . assertEqual ( '<STR_LIT>' , subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( [ fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , subnet [ '<STR_LIT>' ] [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( [ fake_network_cache_model . new_fixed_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( [ fake_network_cache_model . new_route ( ) ] , <EOL> subnet [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( <NUM_LIT:4> , subnet [ '<STR_LIT:version>' ] ) <EOL> class NetworkTests ( test . NoDBTestCase ) : <EOL> def test_create_network ( self ) : <EOL> network = fake_network_cache_model . new_network ( ) <EOL> self . assertEqual ( <NUM_LIT:1> , network [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , network [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , network [ '<STR_LIT:label>' ] ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_subnet ( ) , <EOL> fake_network_cache_model . new_subnet ( <EOL> dict ( cidr = '<STR_LIT>' ) ) ] , network [ '<STR_LIT>' ] ) <EOL> def test_add_subnet ( self ) : <EOL> network = fake_network_cache_model . new_network ( ) <EOL> network . add_subnet ( fake_network_cache_model . new_subnet ( <EOL> dict ( cidr = '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_subnet ( ) , <EOL> fake_network_cache_model . new_subnet ( <EOL> dict ( cidr = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_subnet ( dict ( cidr = '<STR_LIT>' ) ) ] , <EOL> network [ '<STR_LIT>' ] ) <EOL> def test_add_subnet_a_lot ( self ) : <EOL> network = fake_network_cache_model . new_network ( ) <EOL> for i in range ( <NUM_LIT:10> ) : <EOL> network . add_subnet ( fake_network_cache_model . new_subnet ( <EOL> dict ( cidr = '<STR_LIT>' ) ) ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_subnet ( ) , <EOL> fake_network_cache_model . new_subnet ( <EOL> dict ( cidr = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_subnet ( dict ( cidr = '<STR_LIT>' ) ) ] , <EOL> network [ '<STR_LIT>' ] ) <EOL> def test_network_equal ( self ) : <EOL> network1 = model . Network ( ) <EOL> network2 = model . Network ( ) <EOL> self . assertEqual ( network1 , network2 ) <EOL> def test_network_not_equal ( self ) : <EOL> network1 = model . Network ( id = '<STR_LIT:1>' ) <EOL> network2 = model . Network ( id = '<STR_LIT:2>' ) <EOL> self . assertNotEqual ( network1 , network2 ) <EOL> network1 = model . Network ( bridge = '<STR_LIT>' ) <EOL> network2 = model . Network ( bridge = '<STR_LIT>' ) <EOL> self . assertNotEqual ( network1 , network2 ) <EOL> network1 = model . Network ( label = '<STR_LIT>' ) <EOL> network2 = model . Network ( label = '<STR_LIT>' ) <EOL> self . assertNotEqual ( network1 , network2 ) <EOL> network1 = model . Network ( subnets = '<STR_LIT>' ) <EOL> network2 = model . Network ( subnets = '<STR_LIT>' ) <EOL> self . assertNotEqual ( network1 , network2 ) <EOL> def test_hydrate ( self ) : <EOL> fake_network_cache_model . new_subnet ( ) <EOL> fake_network_cache_model . new_subnet ( dict ( cidr = '<STR_LIT>' ) ) <EOL> network = model . Network . hydrate ( fake_network_cache_model . new_network ( ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , network [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , network [ '<STR_LIT>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , network [ '<STR_LIT:label>' ] ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_subnet ( ) , <EOL> fake_network_cache_model . new_subnet ( <EOL> dict ( cidr = '<STR_LIT>' ) ) ] , network [ '<STR_LIT>' ] ) <EOL> class VIFTests ( test . NoDBTestCase ) : <EOL> def test_create_vif ( self ) : <EOL> vif = fake_network_cache_model . new_vif ( ) <EOL> self . assertEqual ( <NUM_LIT:1> , vif [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , vif [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( fake_network_cache_model . new_network ( ) , <EOL> vif [ '<STR_LIT>' ] ) <EOL> def test_vif_equal ( self ) : <EOL> vif1 = model . VIF ( ) <EOL> vif2 = model . VIF ( ) <EOL> self . assertEqual ( vif1 , vif2 ) <EOL> def test_vif_not_equal ( self ) : <EOL> vif1 = model . VIF ( id = <NUM_LIT:1> ) <EOL> vif2 = model . VIF ( id = <NUM_LIT:2> ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( address = '<STR_LIT>' ) <EOL> vif2 = model . VIF ( address = '<STR_LIT>' ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( network = '<STR_LIT>' ) <EOL> vif2 = model . VIF ( network = '<STR_LIT>' ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( type = '<STR_LIT>' ) <EOL> vif2 = model . VIF ( type = '<STR_LIT>' ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( devname = '<STR_LIT>' ) <EOL> vif2 = model . VIF ( devname = '<STR_LIT>' ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( qbh_params = <NUM_LIT:1> ) <EOL> vif2 = model . VIF ( qbh_params = None ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( qbg_params = <NUM_LIT:1> ) <EOL> vif2 = model . VIF ( qbg_params = None ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( active = True ) <EOL> vif2 = model . VIF ( active = False ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( vnic_type = model . VNIC_TYPE_NORMAL ) <EOL> vif2 = model . VIF ( vnic_type = model . VNIC_TYPE_DIRECT ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( profile = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> vif2 = model . VIF ( profile = { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> vif1 = model . VIF ( preserve_on_delete = True ) <EOL> vif2 = model . VIF ( preserve_on_delete = False ) <EOL> self . assertNotEqual ( vif1 , vif2 ) <EOL> def test_create_vif_with_type ( self ) : <EOL> vif_dict = dict ( <EOL> id = <NUM_LIT:1> , <EOL> address = '<STR_LIT>' , <EOL> network = fake_network_cache_model . new_network ( ) , <EOL> type = '<STR_LIT>' ) <EOL> vif = fake_network_cache_model . new_vif ( vif_dict ) <EOL> self . assertEqual ( <NUM_LIT:1> , vif [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , vif [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , vif [ '<STR_LIT:type>' ] ) <EOL> self . assertEqual ( fake_network_cache_model . new_network ( ) , <EOL> vif [ '<STR_LIT>' ] ) <EOL> def test_vif_get_fixed_ips ( self ) : <EOL> vif = fake_network_cache_model . new_vif ( ) <EOL> fixed_ips = vif . fixed_ips ( ) <EOL> ips = [ <EOL> fake_network_cache_model . new_fixed_ip ( dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_fixed_ip ( dict ( address = '<STR_LIT>' ) ) <EOL> ] * <NUM_LIT:2> <EOL> self . assertEqual ( fixed_ips , ips ) <EOL> def test_vif_get_floating_ips ( self ) : <EOL> vif = fake_network_cache_model . new_vif ( ) <EOL> vif [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . add_floating_ip ( '<STR_LIT>' ) <EOL> floating_ips = vif . floating_ips ( ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] , floating_ips ) <EOL> def test_vif_get_labeled_ips ( self ) : <EOL> vif = fake_network_cache_model . new_vif ( ) <EOL> labeled_ips = vif . labeled_ips ( ) <EOL> ip_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : [ fake_network_cache_model . new_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } ) , <EOL> fake_network_cache_model . new_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } ) ] * <NUM_LIT:2> , <EOL> '<STR_LIT>' : '<STR_LIT>' } <EOL> self . assertEqual ( ip_dict , labeled_ips ) <EOL> def test_hydrate ( self ) : <EOL> fake_network_cache_model . new_network ( ) <EOL> vif = model . VIF . hydrate ( fake_network_cache_model . new_vif ( ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , vif [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , vif [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( fake_network_cache_model . new_network ( ) , <EOL> vif [ '<STR_LIT>' ] ) <EOL> def test_hydrate_vif_with_type ( self ) : <EOL> vif_dict = dict ( <EOL> id = <NUM_LIT:1> , <EOL> address = '<STR_LIT>' , <EOL> network = fake_network_cache_model . new_network ( ) , <EOL> type = '<STR_LIT>' ) <EOL> vif = model . VIF . hydrate ( fake_network_cache_model . new_vif ( vif_dict ) ) <EOL> self . assertEqual ( <NUM_LIT:1> , vif [ '<STR_LIT:id>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , vif [ '<STR_LIT:address>' ] ) <EOL> self . assertEqual ( '<STR_LIT>' , vif [ '<STR_LIT:type>' ] ) <EOL> self . assertEqual ( fake_network_cache_model . new_network ( ) , <EOL> vif [ '<STR_LIT>' ] ) <EOL> class NetworkInfoTests ( test . NoDBTestCase ) : <EOL> def test_create_model ( self ) : <EOL> ninfo = model . NetworkInfo ( [ fake_network_cache_model . new_vif ( ) , <EOL> fake_network_cache_model . new_vif ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_fixed_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] * <NUM_LIT:4> , ninfo . fixed_ips ( ) ) <EOL> def test_create_async_model ( self ) : <EOL> def async_wrapper ( ) : <EOL> return model . NetworkInfo ( <EOL> [ fake_network_cache_model . new_vif ( ) , <EOL> fake_network_cache_model . new_vif ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] ) <EOL> ninfo = model . NetworkInfoAsyncWrapper ( async_wrapper ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_fixed_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] * <NUM_LIT:4> , ninfo . fixed_ips ( ) ) <EOL> def test_create_async_model_exceptions ( self ) : <EOL> def async_wrapper ( ) : <EOL> raise test . TestingException ( ) <EOL> ninfo = model . NetworkInfoAsyncWrapper ( async_wrapper ) <EOL> self . assertRaises ( test . TestingException , ninfo . wait ) <EOL> self . assertIsNone ( ninfo . wait ( ) ) <EOL> ninfo = model . NetworkInfoAsyncWrapper ( async_wrapper ) <EOL> self . assertIsNone ( ninfo . wait ( do_raise = False ) ) <EOL> ninfo = model . NetworkInfoAsyncWrapper ( async_wrapper ) <EOL> self . assertRaises ( test . TestingException , ninfo . fixed_ips ) <EOL> def test_get_floating_ips ( self ) : <EOL> vif = fake_network_cache_model . new_vif ( ) <EOL> vif [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] . add_floating_ip ( '<STR_LIT>' ) <EOL> ninfo = model . NetworkInfo ( [ vif , <EOL> fake_network_cache_model . new_vif ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] ) <EOL> self . assertEqual ( [ '<STR_LIT>' ] , ninfo . floating_ips ( ) ) <EOL> def test_hydrate ( self ) : <EOL> ninfo = model . NetworkInfo ( [ fake_network_cache_model . new_vif ( ) , <EOL> fake_network_cache_model . new_vif ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] ) <EOL> model . NetworkInfo . hydrate ( ninfo ) <EOL> self . assertEqual ( <EOL> [ fake_network_cache_model . new_fixed_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) , <EOL> fake_network_cache_model . new_fixed_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ] * <NUM_LIT:4> , ninfo . fixed_ips ( ) ) <EOL> def _setup_injected_network_scenario ( self , should_inject = True , <EOL> use_ipv4 = True , use_ipv6 = False , <EOL> gateway = True , dns = True , <EOL> two_interfaces = False , <EOL> libvirt_virt_type = None ) : <EOL> """<STR_LIT>""" <EOL> network = fake_network_cache_model . new_network ( { '<STR_LIT>' : [ ] } ) <EOL> subnet_dict = { } <EOL> if not gateway : <EOL> subnet_dict [ '<STR_LIT>' ] = None <EOL> if not dns : <EOL> subnet_dict [ '<STR_LIT>' ] = None <EOL> if not should_inject : <EOL> subnet_dict [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> if use_ipv4 : <EOL> network . add_subnet ( <EOL> fake_network_cache_model . new_subnet ( subnet_dict ) ) <EOL> if should_inject and use_ipv6 : <EOL> gateway_ip = fake_network_cache_model . new_ip ( dict ( <EOL> address = '<STR_LIT>' ) ) <EOL> ip = fake_network_cache_model . new_ip ( dict ( <EOL> address = '<STR_LIT>' ) ) <EOL> ipv6_subnet_dict = dict ( <EOL> cidr = '<STR_LIT>' , <EOL> gateway = gateway_ip , <EOL> dns = [ fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) , <EOL> fake_network_cache_model . new_ip ( <EOL> dict ( address = '<STR_LIT>' ) ) ] , <EOL> ips = [ ip ] ) <EOL> if not gateway : <EOL> ipv6_subnet_dict [ '<STR_LIT>' ] = None <EOL> network . add_subnet ( fake_network_cache_model . new_subnet ( <EOL> ipv6_subnet_dict ) ) <EOL> network [ '<STR_LIT>' ] [ '<STR_LIT>' ] = True <EOL> vif = fake_network_cache_model . new_vif ( { '<STR_LIT>' : network } ) <EOL> vifs = [ vif ] <EOL> if two_interfaces : <EOL> vifs . append ( vif ) <EOL> nwinfo = model . NetworkInfo ( vifs ) <EOL> return netutils . get_injected_network_template ( <EOL> nwinfo , use_ipv6 = use_ipv6 , libvirt_virt_type = libvirt_virt_type ) <EOL> def test_injection_dynamic ( self ) : <EOL> expected = None <EOL> template = self . _setup_injected_network_scenario ( should_inject = False ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static_no_gateway ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( gateway = False ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static_no_dns ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( dns = False ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static_overriden_template ( self ) : <EOL> cfg . CONF . set_override ( <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static_ipv6 ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( use_ipv6 = True ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static_ipv6_no_gateway ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( use_ipv6 = True , <EOL> gateway = False ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_static_with_ipv4_off ( self ) : <EOL> expected = None <EOL> template = self . _setup_injected_network_scenario ( use_ipv4 = False ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_ipv6_two_interfaces ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( use_ipv6 = True , <EOL> two_interfaces = True ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_ipv6_with_lxc ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( <EOL> use_ipv6 = True , two_interfaces = True , libvirt_virt_type = '<STR_LIT>' ) <EOL> self . assertEqual ( expected , template ) <EOL> def test_injection_ipv6_with_lxc_no_gateway ( self ) : <EOL> expected = """<STR_LIT>""" <EOL> template = self . _setup_injected_network_scenario ( <EOL> use_ipv6 = True , gateway = False , two_interfaces = True , <EOL> libvirt_virt_type = '<STR_LIT>' ) <EOL> self . assertEqual ( expected , template ) <EOL> class TestNetworkMetadata ( test . NoDBTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestNetworkMetadata , self ) . setUp ( ) <EOL> self . netinfo = model . NetworkInfo ( [ fake_network_cache_model . new_vif ( <EOL> { '<STR_LIT:type>' : '<STR_LIT>' } ) ] ) <EOL> ipv4_subnet = fake_network_cache_model . new_subnet ( version = <NUM_LIT:4> ) <EOL> ipv6_subnet = fake_network_cache_model . new_subnet ( version = <NUM_LIT:6> ) <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] = ipv4_subnet <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] = ipv6_subnet <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT> <EOL> def test_get_network_metadata_json ( self ) : <EOL> net_metadata = netutils . get_network_metadata ( self . netinfo , <EOL> use_ipv6 = True ) <EOL> self . assertEqual ( <EOL> { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } , <EOL> net_metadata [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <EOL> { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ] , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } , <EOL> net_metadata [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <EOL> { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> ] , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } , <EOL> net_metadata [ '<STR_LIT>' ] [ <NUM_LIT:1> ] ) <EOL> def test_get_network_metadata_json_dhcp ( self ) : <EOL> ipv4_subnet = fake_network_cache_model . new_subnet ( <EOL> subnet_dict = dict ( dhcp_server = '<STR_LIT>' ) , version = <NUM_LIT:4> ) <EOL> ipv6_subnet = fake_network_cache_model . new_subnet ( <EOL> subnet_dict = dict ( dhcp_server = '<STR_LIT>' ) , version = <NUM_LIT:6> ) <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] = ipv4_subnet <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] = ipv6_subnet <EOL> net_metadata = netutils . get_network_metadata ( self . netinfo , <EOL> use_ipv6 = True ) <EOL> self . assertEqual ( <EOL> { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } , <EOL> net_metadata [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( <EOL> { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> <EOL> } , <EOL> net_metadata [ '<STR_LIT>' ] [ <NUM_LIT:1> ] ) <EOL> def test__get_nets ( self ) : <EOL> expected_net = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : [ <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ] , <EOL> '<STR_LIT:type>' : '<STR_LIT>' <EOL> } <EOL> net = netutils . _get_nets ( <EOL> self . netinfo [ <NUM_LIT:0> ] , self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] , <NUM_LIT:4> , <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> self . assertEqual ( expected_net , net ) <EOL> def test__get_eth_link ( self ) : <EOL> expected_link = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT:type>' ] = '<STR_LIT>' <EOL> link = netutils . _get_eth_link ( self . netinfo [ <NUM_LIT:0> ] , <NUM_LIT:0> ) <EOL> self . assertEqual ( expected_link , link ) <EOL> def test__get_eth_link_physical ( self ) : <EOL> expected_link = { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT:type>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : <NUM_LIT> <EOL> } <EOL> link = netutils . _get_eth_link ( self . netinfo [ <NUM_LIT:0> ] , <NUM_LIT:1> ) <EOL> self . assertEqual ( expected_link , link ) <EOL> def test__get_default_route ( self ) : <EOL> v4_expected = [ { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } ] <EOL> v6_expected = [ { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } ] <EOL> v4 = netutils . _get_default_route ( <EOL> <NUM_LIT:4> , self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( v4_expected , v4 ) <EOL> v6 = netutils . _get_default_route ( <EOL> <NUM_LIT:6> , self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:1> ] ) <EOL> self . assertEqual ( v6_expected , v6 ) <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] = None <EOL> no_route = netutils . _get_default_route ( <EOL> <NUM_LIT:4> , self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( [ ] , no_route ) <EOL> def test__get_dns_services ( self ) : <EOL> expected_dns = [ <EOL> { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:address>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:address>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:address>' : '<STR_LIT>' } <EOL> ] <EOL> subnet = fake_network_cache_model . new_subnet ( version = <NUM_LIT:4> ) <EOL> subnet [ '<STR_LIT>' ] . append ( fake_network_cache_model . new_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) ) <EOL> dns = netutils . _get_dns_services ( subnet ) <EOL> self . assertEqual ( expected_dns , dns ) <EOL> def test_get_network_metadata ( self ) : <EOL> expected_json = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT>" : <NUM_LIT> <EOL> } , <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> "<STR_LIT:type>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> '<STR_LIT:id>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : [ { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } ] , <EOL> '<STR_LIT:type>' : '<STR_LIT>' <EOL> } , <EOL> { <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> "<STR_LIT:type>" : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> '<STR_LIT>' : [ <EOL> { '<STR_LIT:address>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:address>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:address>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } , <EOL> { '<STR_LIT:address>' : '<STR_LIT>' , '<STR_LIT:type>' : '<STR_LIT>' } <EOL> ] <EOL> } <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] = ( <EOL> '<STR_LIT>' ) <EOL> self . netinfo . append ( fake_network_cache_model . new_vif ( { <EOL> '<STR_LIT:type>' : '<STR_LIT>' , '<STR_LIT:address>' : '<STR_LIT>' } ) ) <EOL> address = fake_network_cache_model . new_ip ( { '<STR_LIT:address>' : '<STR_LIT>' } ) <EOL> gateway_address = fake_network_cache_model . new_ip ( <EOL> { '<STR_LIT:address>' : '<STR_LIT>' } ) <EOL> ipv4_subnet = fake_network_cache_model . new_subnet ( <EOL> { '<STR_LIT>' : '<STR_LIT>' , '<STR_LIT>' : gateway_address , <EOL> '<STR_LIT>' : [ address ] , '<STR_LIT>' : [ ] } ) <EOL> self . netinfo [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] = ( <EOL> '<STR_LIT>' ) <EOL> self . netinfo [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] [ <NUM_LIT:0> ] = ipv4_subnet <EOL> self . netinfo [ <NUM_LIT:1> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] = <NUM_LIT> <EOL> network_json = netutils . get_network_metadata ( self . netinfo ) <EOL> self . assertEqual ( expected_json , network_json ) <EOL> def test_get_network_metadata_no_ipv4 ( self ) : <EOL> expected_json = { <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT:address>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT:address>" : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : <NUM_LIT:1> , <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } , <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT:id>" : "<STR_LIT>" <EOL> } <EOL> ] , <EOL> "<STR_LIT>" : [ <EOL> { <EOL> "<STR_LIT>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT> , <EOL> "<STR_LIT:type>" : "<STR_LIT>" , <EOL> "<STR_LIT:id>" : "<STR_LIT>" , <EOL> "<STR_LIT>" : <NUM_LIT:1> <EOL> } <EOL> ] <EOL> } <EOL> self . netinfo [ <NUM_LIT:0> ] [ '<STR_LIT>' ] [ '<STR_LIT>' ] . pop ( <NUM_LIT:0> ) <EOL> network_json = netutils . get_network_metadata ( self . netinfo ) <EOL> self . assertEqual ( expected_json , network_json ) </s>
