Beispiel #1
0
 def test_vif_get_fixed_ips(self):
     vif = fake_network_cache_model.new_vif()
     fixed_ips = vif.fixed_ips()
     ips = [fake_network_cache_model.new_ip(dict(address='10.10.0.2')),
             fake_network_cache_model.new_ip(
                     dict(address='10.10.0.3'))] * 2
     self.assertEqual(fixed_ips, ips)
Beispiel #2
0
 def test_add_dns(self):
     subnet = fake_network_cache_model.new_subnet()
     dns = fake_network_cache_model.new_ip(dict(address='9.9.9.9'))
     subnet.add_dns(dns)
     self.assertEqual(subnet['dns'],
             [fake_network_cache_model.new_ip(dict(address='1.2.3.4')),
              fake_network_cache_model.new_ip(dict(address='2.3.4.5')),
              fake_network_cache_model.new_ip(dict(address='9.9.9.9'))])
Beispiel #3
0
 def test_create_model(self):
     ninfo = model.NetworkInfo([fake_network_cache_model.new_vif(),
             fake_network_cache_model.new_vif(
                 {'address': 'bb:bb:bb:bb:bb:bb'})])
     self.assertEqual(ninfo.fixed_ips(),
             [fake_network_cache_model.new_ip({'address': '10.10.0.2'}),
              fake_network_cache_model.new_ip(
                 {'address': '10.10.0.3'})] * 4)
Beispiel #4
0
 def test_add_ip(self):
     subnet = fake_network_cache_model.new_subnet()
     subnet.add_ip(
         fake_network_cache_model.new_ip(dict(address='192.168.1.102')))
     self.assertEqual(subnet['ips'], [
         fake_network_cache_model.new_ip(dict(address='192.168.1.100')),
         fake_network_cache_model.new_ip(dict(address='192.168.1.101')),
         fake_network_cache_model.new_ip(dict(address='192.168.1.102'))
     ])
Beispiel #5
0
 def test_add_dns_a_lot(self):
     subnet = fake_network_cache_model.new_subnet()
     for i in xrange(10):
         subnet.add_dns(fake_network_cache_model.new_ip(
                 dict(address='9.9.9.9')))
     self.assertEqual(subnet['dns'],
             [fake_network_cache_model.new_ip(dict(address='1.2.3.4')),
              fake_network_cache_model.new_ip(dict(address='2.3.4.5')),
              fake_network_cache_model.new_ip(dict(address='9.9.9.9'))])
Beispiel #6
0
 def test_hydrate(self):
     ninfo = model.NetworkInfo([fake_network_cache_model.new_vif(),
             fake_network_cache_model.new_vif(
                     {'address': 'bb:bb:bb:bb:bb:bb'})])
     deserialized = model.NetworkInfo.hydrate(ninfo)
     self.assertEqual(ninfo.fixed_ips(),
             [fake_network_cache_model.new_ip({'address': '10.10.0.2'}),
              fake_network_cache_model.new_ip(
                     {'address': '10.10.0.3'})] * 4)
Beispiel #7
0
    def _test_injected_network_template(self, should_inject, use_ipv6=False,
                                        gateway=True):
        """Check that netutils properly decides whether to inject based on
           whether the supplied subnet is static or dynamic.
        """
        network = fake_network_cache_model.new_network({'subnets': []})
        subnet_dict = {}
        if not gateway:
            subnet_dict['gateway'] = None

        if not should_inject:
            subnet_dict['dhcp_server'] = '10.10.0.1'

        network.add_subnet(fake_network_cache_model.new_subnet(subnet_dict))

        if should_inject and use_ipv6:
            gateway_ip = fake_network_cache_model.new_ip(dict(
                address='1234:567::1'))
            ip = fake_network_cache_model.new_ip(dict(
                address='1234:567::2'))
            ipv6_subnet_dict = dict(
                cidr='1234:567::/48',
                gateway=gateway_ip,
                ips=[ip])
            if not gateway:
                ipv6_subnet_dict['gateway'] = None
            network.add_subnet(fake_network_cache_model.new_subnet(
                ipv6_subnet_dict))

        # Behave as though CONF.flat_injected is True
        network['meta']['injected'] = True
        vif = fake_network_cache_model.new_vif({'network': network})
        ninfo = model.NetworkInfo([vif])

        template = netutils.get_injected_network_template(ninfo,
                                                          use_ipv6=use_ipv6)

        # will just ignore the improper behavior.
        if not should_inject:
            self.assertTrue(template is None)
        else:
            self.assertTrue('auto eth0' in template)
            self.assertTrue('iface eth0 inet static' in template)
            self.assertTrue('address 10.10.0.2' in template)
            self.assertTrue('netmask 255.255.255.0' in template)
            self.assertTrue('broadcast 10.10.0.255' in template)
            if gateway:
                self.assertTrue('gateway 10.10.0.1' in template)
            else:
                self.assertFalse('gateway' in template)
            self.assertTrue('dns-nameservers 1.2.3.4 2.3.4.5' in template)
            if use_ipv6:
                self.assertTrue('iface eth0 inet6 static' in template)
                self.assertTrue('address 1234:567::2' in template)
                self.assertTrue('netmask 48' in template)
                if gateway:
                    self.assertTrue('gateway 1234:567::1' in template)
Beispiel #8
0
    def _setup_injected_network_scenario(self,
                                         should_inject=True,
                                         use_ipv4=True,
                                         use_ipv6=False,
                                         gateway=True,
                                         dns=True,
                                         two_interfaces=False,
                                         libvirt_virt_type=None):
        """Check that netutils properly decides whether to inject based on
           whether the supplied subnet is static or dynamic.
        """
        network = fake_network_cache_model.new_network({'subnets': []})

        subnet_dict = {}
        if not gateway:
            subnet_dict['gateway'] = None

        if not dns:
            subnet_dict['dns'] = None

        if not should_inject:
            subnet_dict['dhcp_server'] = '10.10.0.1'

        if use_ipv4:
            network.add_subnet(
                fake_network_cache_model.new_subnet(subnet_dict))

        if should_inject and use_ipv6:
            gateway_ip = fake_network_cache_model.new_ip(
                dict(address='1234:567::1'))
            ip = fake_network_cache_model.new_ip(dict(address='1234:567::2'))
            ipv6_subnet_dict = dict(
                cidr='1234:567::/48',
                gateway=gateway_ip,
                dns=[
                    fake_network_cache_model.new_ip(
                        dict(address='2001:4860:4860::8888')),
                    fake_network_cache_model.new_ip(
                        dict(address='2001:4860:4860::8844'))
                ],
                ips=[ip])
            if not gateway:
                ipv6_subnet_dict['gateway'] = None
            network.add_subnet(
                fake_network_cache_model.new_subnet(ipv6_subnet_dict))

        # Behave as though CONF.flat_injected is True
        network['meta']['injected'] = True
        vif = fake_network_cache_model.new_vif({'network': network})
        vifs = [vif]
        if two_interfaces:
            vifs.append(vif)

        nwinfo = model.NetworkInfo(vifs)
        return netutils.get_injected_network_template(
            nwinfo, use_ipv6=use_ipv6, libvirt_virt_type=libvirt_virt_type)
Beispiel #9
0
 def test_add_ip_a_lot(self):
     subnet = fake_network_cache_model.new_subnet()
     for i in xrange(10):
         subnet.add_ip(
             fake_network_cache_model.new_ip(dict(address='192.168.1.102')))
     self.assertEqual(subnet['ips'], [
         fake_network_cache_model.new_ip(dict(address='10.10.0.2')),
         fake_network_cache_model.new_ip(dict(address='10.10.0.3')),
         fake_network_cache_model.new_ip(dict(address='192.168.1.102'))
     ])
Beispiel #10
0
 def test_vif_get_labeled_ips(self):
     vif = fake_network_cache_model.new_vif()
     labeled_ips = vif.labeled_ips()
     ip_dict = {
         'network_id': 1,
         'ips': [fake_network_cache_model.new_ip(
                     {'address': '10.10.0.2'}),
                 fake_network_cache_model.new_ip(
                     {'address': '10.10.0.3'})] * 2,
         'network_label': 'public'}
     self.assertEqual(labeled_ips, ip_dict)
Beispiel #11
0
 def test_add_ip(self):
     subnet = fake_network_cache_model.new_subnet()
     subnet.add_ip(fake_network_cache_model.new_ip(dict(address="192.168.1.102")))
     self.assertEqual(
         subnet["ips"],
         [
             fake_network_cache_model.new_fixed_ip(dict(address="10.10.0.2")),
             fake_network_cache_model.new_fixed_ip(dict(address="10.10.0.3")),
             fake_network_cache_model.new_ip(dict(address="192.168.1.102")),
         ],
     )
Beispiel #12
0
 def test_add_ip(self):
     subnet = fake_network_cache_model.new_subnet()
     subnet.add_ip(fake_network_cache_model.new_ip(
             dict(address='192.168.1.102')))
     self.assertEqual(subnet['ips'],
             [fake_network_cache_model.new_ip(
                     dict(address='10.10.0.2')),
              fake_network_cache_model.new_ip(
                     dict(address='10.10.0.3')),
              fake_network_cache_model.new_ip(
                     dict(address='192.168.1.102'))])
Beispiel #13
0
 def test_add_dns_a_lot(self):
     subnet = fake_network_cache_model.new_subnet()
     for i in xrange(10):
         subnet.add_dns(fake_network_cache_model.new_ip(dict(address="9.9.9.9")))
     self.assertEqual(
         subnet["dns"],
         [
             fake_network_cache_model.new_ip(dict(address="1.2.3.4")),
             fake_network_cache_model.new_ip(dict(address="2.3.4.5")),
             fake_network_cache_model.new_ip(dict(address="9.9.9.9")),
         ],
     )
Beispiel #14
0
    def test_create_async_model(self):
        def async_wrapper():
            return model.NetworkInfo(
                    [fake_network_cache_model.new_vif(),
                     fake_network_cache_model.new_vif(
                            {'address': 'bb:bb:bb:bb:bb:bb'})])

        ninfo = model.NetworkInfoAsyncWrapper(async_wrapper)
        self.assertEqual(ninfo.fixed_ips(),
                [fake_network_cache_model.new_ip({'address': '10.10.0.2'}),
                 fake_network_cache_model.new_ip(
                    {'address': '10.10.0.3'})] * 4)
Beispiel #15
0
 def test_add_dns(self):
     subnet = fake_network_cache_model.new_subnet()
     dns = fake_network_cache_model.new_ip(dict(address="9.9.9.9"))
     subnet.add_dns(dns)
     self.assertEqual(
         subnet["dns"],
         [
             fake_network_cache_model.new_ip(dict(address="1.2.3.4")),
             fake_network_cache_model.new_ip(dict(address="2.3.4.5")),
             fake_network_cache_model.new_ip(dict(address="9.9.9.9")),
         ],
     )
Beispiel #16
0
    def _test_injected_network_template(self, should_inject, use_ipv6=False,
                                        legacy=False):
        """Check that netutils properly decides whether to inject based on
           whether the supplied subnet is static or dynamic.
        """
        network = fake_network_cache_model.new_network({'subnets': []})
        if should_inject:
            network.add_subnet(fake_network_cache_model.new_subnet())
            if use_ipv6:
                gateway_ip = fake_network_cache_model.new_ip(dict(
                                                        address='1234:567::1'))
                ip = fake_network_cache_model.new_ip(dict(
                                                        address='1234:567::2'))
                subnet_dict = dict(
                        cidr='1234:567::/48',
                        gateway=gateway_ip,
                        ips=[ip])
                network.add_subnet(fake_network_cache_model.new_subnet(
                        subnet_dict))
        else:
            subnet_dict = dict(dhcp_server='10.10.0.1')
            network.add_subnet(fake_network_cache_model.new_subnet(
                    subnet_dict))
        # Behave as though CONF.flat_injected is True
        network['meta']['injected'] = True
        vif = fake_network_cache_model.new_vif({'network': network})
        ninfo = model.NetworkInfo([vif])
        if legacy:
            ninfo = ninfo.legacy()

        template = netutils.get_injected_network_template(ninfo,
                                                          use_ipv6=use_ipv6)

        # NOTE(bnemec): There is a bug with legacy network info that causes
        # it to inject regardless of whether the network is static or dynamic.
        # This can't be fixed without changes that would potentially break
        # existing code, so until legacy network info goes away this test
        # will just ignore the improper behavior.
        if not should_inject and not legacy:
            self.assertTrue(template is None)
        else:
            self.assertTrue('auto eth0' in template)
            self.assertTrue('iface eth0 inet static' in template)
            self.assertTrue('address 10.10.0.2' in template)
            self.assertTrue('netmask 255.255.255.0' in template)
            self.assertTrue('broadcast 10.10.0.255' in template)
            self.assertTrue('gateway 10.10.0.1' in template)
            self.assertTrue('dns-nameservers 1.2.3.4 2.3.4.5' in template)
            if use_ipv6:
                self.assertTrue('iface eth0 inet6 static' in template)
                self.assertTrue('address 1234:567::2' in template)
                self.assertTrue('netmask 48' in template)
                self.assertTrue('gateway 1234:567::1' in template)
Beispiel #17
0
 def test_add_ip_a_lot(self):
     subnet = fake_network_cache_model.new_subnet()
     for i in xrange(10):
         subnet.add_ip(fake_network_cache_model.new_ip(
                     dict(address='192.168.1.102')))
     self.assertEqual(subnet['ips'],
             [fake_network_cache_model.new_ip(
                     dict(address='192.168.1.100')),
              fake_network_cache_model.new_ip(
                     dict(address='192.168.1.101')),
              fake_network_cache_model.new_ip(
                     dict(address='192.168.1.102'))])
Beispiel #18
0
    def _setup_injected_network_scenario(self, should_inject=True,
                                        use_ipv4=True, use_ipv6=False,
                                        gateway=True, dns=True,
                                        two_interfaces=False,
                                        libvirt_virt_type=None):
        """Check that netutils properly decides whether to inject based on
           whether the supplied subnet is static or dynamic.
        """
        network = fake_network_cache_model.new_network({'subnets': []})

        subnet_dict = {}
        if not gateway:
            subnet_dict['gateway'] = None

        if not dns:
            subnet_dict['dns'] = None

        if not should_inject:
            subnet_dict['dhcp_server'] = '10.10.0.1'

        if use_ipv4:
            network.add_subnet(
                fake_network_cache_model.new_subnet(subnet_dict))

        if should_inject and use_ipv6:
            gateway_ip = fake_network_cache_model.new_ip(dict(
                address='1234:567::1'))
            ip = fake_network_cache_model.new_ip(dict(
                address='1234:567::2'))
            ipv6_subnet_dict = dict(
                cidr='1234:567::/48',
                gateway=gateway_ip,
                dns=[fake_network_cache_model.new_ip(
                        dict(address='2001:4860:4860::8888')),
                     fake_network_cache_model.new_ip(
                         dict(address='2001:4860:4860::8844'))],
                ips=[ip])
            if not gateway:
                ipv6_subnet_dict['gateway'] = None
            network.add_subnet(fake_network_cache_model.new_subnet(
                ipv6_subnet_dict))

        # Behave as though CONF.flat_injected is True
        network['meta']['injected'] = True
        vif = fake_network_cache_model.new_vif({'network': network})
        vifs = [vif]
        if two_interfaces:
            vifs.append(vif)

        nwinfo = model.NetworkInfo(vifs)
        return netutils.get_injected_network_template(
                nwinfo, use_ipv6=use_ipv6, libvirt_virt_type=libvirt_virt_type)
Beispiel #19
0
 def test_vif_get_labeled_ips(self):
     vif = fake_network_cache_model.new_vif()
     labeled_ips = vif.labeled_ips()
     ip_dict = {
         "network_id": 1,
         "ips": [
             fake_network_cache_model.new_ip({"address": "10.10.0.2", "type": "fixed"}),
             fake_network_cache_model.new_ip({"address": "10.10.0.3", "type": "fixed"}),
         ]
         * 2,
         "network_label": "public",
     }
     self.assertEqual(labeled_ips, ip_dict)
Beispiel #20
0
 def test_hydrate(self):
     route = model.Route.hydrate(
             {'gateway': fake_network_cache_model.new_ip(
                             dict(address='192.168.1.1'))})
     self.assertEqual(route['cidr'], None)
     self.assertEqual(route['gateway']['address'], '192.168.1.1')
     self.assertEqual(route['interface'], None)
Beispiel #21
0
    def test_create_subnet_with_attrs(self):
        subnet = fake_network_cache_model.new_subnet()

        route1 = fake_network_cache_model.new_route()

        self.assertEqual(subnet['cidr'], '10.10.0.0/24')
        self.assertEqual(subnet['dns'],
                [fake_network_cache_model.new_ip(dict(address='1.2.3.4')),
                 fake_network_cache_model.new_ip(dict(address='2.3.4.5'))])
        self.assertEqual(subnet['gateway']['address'], '10.10.0.1')
        self.assertEqual(subnet['ips'],
                [fake_network_cache_model.new_ip(
                        dict(address='10.10.0.2')),
                 fake_network_cache_model.new_ip(
                            dict(address='10.10.0.3'))])
        self.assertEqual(subnet['routes'], [route1])
        self.assertEqual(subnet['version'], 4)
Beispiel #22
0
    def test_hydrate(self):
        subnet_dict = {
            "cidr": "255.255.255.0",
            "dns": [fake_network_cache_model.new_ip(dict(address="1.1.1.1"))],
            "ips": [fake_network_cache_model.new_fixed_ip(dict(address="2.2.2.2"))],
            "routes": [fake_network_cache_model.new_route()],
            "version": 4,
            "gateway": fake_network_cache_model.new_ip(dict(address="3.3.3.3")),
        }
        subnet = model.Subnet.hydrate(subnet_dict)

        self.assertEqual(subnet["cidr"], "255.255.255.0")
        self.assertEqual(subnet["dns"], [fake_network_cache_model.new_ip(dict(address="1.1.1.1"))])
        self.assertEqual(subnet["gateway"]["address"], "3.3.3.3")
        self.assertEqual(subnet["ips"], [fake_network_cache_model.new_fixed_ip(dict(address="2.2.2.2"))])
        self.assertEqual(subnet["routes"], [fake_network_cache_model.new_route()])
        self.assertEqual(subnet["version"], 4)
Beispiel #23
0
    def _setup_injected_network_scenario(
        self,
        should_inject=True,
        use_ipv4=True,
        use_ipv6=False,
        gateway=True,
        dns=True,
        two_interfaces=False,
        libvirt_virt_type=None,
    ):
        """Check that netutils properly decides whether to inject based on
           whether the supplied subnet is static or dynamic.
        """
        network = fake_network_cache_model.new_network({"subnets": []})

        subnet_dict = {}
        if not gateway:
            subnet_dict["gateway"] = None

        if not dns:
            subnet_dict["dns"] = None

        if not should_inject:
            subnet_dict["dhcp_server"] = "10.10.0.1"

        if use_ipv4:
            network.add_subnet(fake_network_cache_model.new_subnet(subnet_dict))

        if should_inject and use_ipv6:
            gateway_ip = fake_network_cache_model.new_ip(dict(address="1234:567::1"))
            ip = fake_network_cache_model.new_ip(dict(address="1234:567::2"))
            ipv6_subnet_dict = dict(cidr="1234:567::/48", gateway=gateway_ip, ips=[ip])
            if not gateway:
                ipv6_subnet_dict["gateway"] = None
            network.add_subnet(fake_network_cache_model.new_subnet(ipv6_subnet_dict))

        # Behave as though CONF.flat_injected is True
        network["meta"]["injected"] = True
        vif = fake_network_cache_model.new_vif({"network": network})
        vifs = [vif]
        if two_interfaces:
            vifs.append(vif)

        nwinfo = model.NetworkInfo(vifs)
        return netutils.get_injected_network_template(nwinfo, use_ipv6=use_ipv6, libvirt_virt_type=libvirt_virt_type)
Beispiel #24
0
    def test_hydrate(self):
        subnet_dict = {
            'cidr': '255.255.255.0',
            'dns': [fake_network_cache_model.new_ip(dict(address='1.1.1.1'))],
            'ips': [fake_network_cache_model.new_ip(dict(address='2.2.2.2'))],
            'routes': [fake_network_cache_model.new_route()],
            'version': 4,
            'gateway': fake_network_cache_model.new_ip(
                            dict(address='3.3.3.3'))}
        subnet = model.Subnet.hydrate(subnet_dict)

        self.assertEqual(subnet['cidr'], '255.255.255.0')
        self.assertEqual(subnet['dns'], [fake_network_cache_model.new_ip(
                                         dict(address='1.1.1.1'))])
        self.assertEqual(subnet['gateway']['address'], '3.3.3.3')
        self.assertEqual(subnet['ips'], [fake_network_cache_model.new_ip(
                                         dict(address='2.2.2.2'))])
        self.assertEqual(subnet['routes'], [
                    fake_network_cache_model.new_route()])
        self.assertEqual(subnet['version'], 4)
Beispiel #25
0
    def test_create_subnet_with_attrs(self):
        subnet = fake_network_cache_model.new_subnet()

        route1 = fake_network_cache_model.new_route()

        self.assertEqual(subnet["cidr"], "10.10.0.0/24")
        self.assertEqual(
            subnet["dns"],
            [
                fake_network_cache_model.new_ip(dict(address="1.2.3.4")),
                fake_network_cache_model.new_ip(dict(address="2.3.4.5")),
            ],
        )
        self.assertEqual(subnet["gateway"]["address"], "10.10.0.1")
        self.assertEqual(
            subnet["ips"],
            [
                fake_network_cache_model.new_fixed_ip(dict(address="10.10.0.2")),
                fake_network_cache_model.new_fixed_ip(dict(address="10.10.0.3")),
            ],
        )
        self.assertEqual(subnet["routes"], [route1])
        self.assertEqual(subnet["version"], 4)
Beispiel #26
0
    def _test_injected_network_template(self,
                                        should_inject,
                                        use_ipv4=True,
                                        use_ipv6=False,
                                        gateway=True):
        """Check that netutils properly decides whether to inject based on
           whether the supplied subnet is static or dynamic.
        """
        network = fake_network_cache_model.new_network({'subnets': []})
        subnet_dict = {}
        if not gateway:
            subnet_dict['gateway'] = None

        if not should_inject:
            subnet_dict['dhcp_server'] = '10.10.0.1'

        if use_ipv4:
            network.add_subnet(
                fake_network_cache_model.new_subnet(subnet_dict))

        if should_inject and use_ipv6:
            gateway_ip = fake_network_cache_model.new_ip(
                dict(address='1234:567::1'))
            ip = fake_network_cache_model.new_ip(dict(address='1234:567::2'))
            ipv6_subnet_dict = dict(cidr='1234:567::/48',
                                    gateway=gateway_ip,
                                    ips=[ip])
            if not gateway:
                ipv6_subnet_dict['gateway'] = None
            network.add_subnet(
                fake_network_cache_model.new_subnet(ipv6_subnet_dict))

        # Behave as though CONF.flat_injected is True
        network['meta']['injected'] = True
        vif = fake_network_cache_model.new_vif({'network': network})
        ninfo = model.NetworkInfo([vif])

        template = netutils.get_injected_network_template(ninfo,
                                                          use_ipv6=use_ipv6)

        # will just ignore the improper behavior.
        if not should_inject:
            self.assertTrue(template is None)
        else:
            if use_ipv4:
                self.assertIn('auto eth0', template)
                self.assertIn('iface eth0 inet static', template)
                self.assertIn('address 10.10.0.2', template)
                self.assertIn('netmask 255.255.255.0', template)
                self.assertIn('broadcast 10.10.0.255', template)
                if gateway:
                    self.assertIn('gateway 10.10.0.1', template)
                else:
                    self.assertNotIn('gateway', template)
                self.assertIn('dns-nameservers 1.2.3.4 2.3.4.5', template)
            if use_ipv6:
                self.assertIn('iface eth0 inet6 static', template)
                self.assertIn('address 1234:567::2', template)
                self.assertIn('netmask 48', template)
                if gateway:
                    self.assertIn('gateway 1234:567::1', template)
            if not use_ipv4 and not use_ipv6:
                self.assertTrue(template is None)
Beispiel #27
0
 def test_create_route_with_attrs(self):
     route = fake_network_cache_model.new_route()
     fake_network_cache_model.new_ip(dict(address="192.168.1.1"))
     self.assertEqual(route["cidr"], "0.0.0.0/24")
     self.assertEqual(route["gateway"]["address"], "192.168.1.1")
     self.assertEqual(route["interface"], "eth0")
Beispiel #28
0
 def test_hydrate(self):
     route = model.Route.hydrate({"gateway": fake_network_cache_model.new_ip(dict(address="192.168.1.1"))})
     self.assertIsNone(route["cidr"])
     self.assertEqual(route["gateway"]["address"], "192.168.1.1")
     self.assertIsNone(route["interface"])
Beispiel #29
0
 def test_create_route_with_attrs(self):
     route = fake_network_cache_model.new_route()
     ip = fake_network_cache_model.new_ip(dict(address='192.168.1.1'))
     self.assertEqual(route['cidr'], '0.0.0.0/24')
     self.assertEqual(route['gateway']['address'], '192.168.1.1')
     self.assertEqual(route['interface'], 'eth0')