def test_nova_to_osvif_subnets(self): subnets = [ model.Subnet(cidr="192.168.1.0/24", dns=[ model.IP( address="192.168.1.1", type="dns"), model.IP( address="192.168.1.2", type="dns"), ], gateway=model.IP( address="192.168.1.254", type='gateway'), ips=[ model.FixedIP( address="192.168.1.100", ), model.FixedIP( address="192.168.1.101", ), ], routes=[ model.Route( cidr="10.0.0.1/24", gateway=model.IP( address="192.168.1.254", type="gateway"), interface="eth0"), ]), model.Subnet(dns=[ model.IP( address="192.168.1.1", type="dns"), model.IP( address="192.168.1.2", type="dns"), ], ips=[ model.FixedIP( address="192.168.1.100", ), model.FixedIP( address="192.168.1.101", ), ], routes=[ model.Route( cidr="10.0.0.1/24", gateway=model.IP( address="192.168.1.254", type="gateway"), interface="eth0"), ]), model.Subnet(dns=[ model.IP( address="192.168.1.1", type="dns"), model.IP( address="192.168.1.2", type="dns"), ], gateway=model.IP( type='gateway'), ips=[ model.FixedIP( address="192.168.1.100", ), model.FixedIP( address="192.168.1.101", ), ], routes=[ model.Route( cidr="10.0.0.1/24", gateway=model.IP( address="192.168.1.254", type="gateway"), interface="eth0"), ]), ] expect = osv_objects.subnet.SubnetList( objects=[ osv_objects.subnet.Subnet( cidr="192.168.1.0/24", dns=["192.168.1.1", "192.168.1.2"], gateway="192.168.1.254", ips=osv_objects.fixed_ip.FixedIPList( objects=[ osv_objects.fixed_ip.FixedIP( address="192.168.1.100", floating_ips=[]), osv_objects.fixed_ip.FixedIP( address="192.168.1.101", floating_ips=[]), ]), routes=osv_objects.route.RouteList( objects=[ osv_objects.route.Route( cidr="10.0.0.1/24", gateway="192.168.1.254", interface="eth0") ]), ), osv_objects.subnet.Subnet( dns=["192.168.1.1", "192.168.1.2"], ips=osv_objects.fixed_ip.FixedIPList( objects=[ osv_objects.fixed_ip.FixedIP( address="192.168.1.100", floating_ips=[]), osv_objects.fixed_ip.FixedIP( address="192.168.1.101", floating_ips=[]), ]), routes=osv_objects.route.RouteList( objects=[ osv_objects.route.Route( cidr="10.0.0.1/24", gateway="192.168.1.254", interface="eth0") ]), ), osv_objects.subnet.Subnet( dns=["192.168.1.1", "192.168.1.2"], ips=osv_objects.fixed_ip.FixedIPList( objects=[ osv_objects.fixed_ip.FixedIP( address="192.168.1.100", floating_ips=[]), osv_objects.fixed_ip.FixedIP( address="192.168.1.101", floating_ips=[]), ]), routes=osv_objects.route.RouteList( objects=[ osv_objects.route.Route( cidr="10.0.0.1/24", gateway="192.168.1.254", interface="eth0") ]), ), ]) actual = os_vif_util._nova_to_osvif_subnets(subnets) self.assertObjEqual(expect, actual)
def test_nova_to_osvif_subnets(self): subnets = [ model.Subnet(cidr="192.168.1.0/24", dns=[ model.IP( address="192.168.1.1", type="dns"), model.IP( address="192.168.1.2", type="dns"), ], gateway=model.IP( address="192.168.1.254", type='gateway'), ips=[ model.FixedIP( address="192.168.1.100", ), model.FixedIP( address="192.168.1.101", ), ], routes=[ model.Route( cidr="10.0.0.1/24", gateway=model.IP( address="192.168.1.254", type="gateway"), interface="eth0"), ]), model.Subnet(dns=[ model.IP( address="192.168.1.1", type="dns"), model.IP( address="192.168.1.2", type="dns"), ], ips=[ model.FixedIP( address="192.168.1.100", ), model.FixedIP( address="192.168.1.101", ), ], routes=[ model.Route( cidr="10.0.0.1/24", gateway=model.IP( address="192.168.1.254", type="gateway"), interface="eth0"), ]), model.Subnet(dns=[ model.IP( address="192.168.1.1", type="dns"), model.IP( address="192.168.1.2", type="dns"), ], gateway=model.IP( type='gateway'), ips=[ model.FixedIP( address="192.168.1.100", ), model.FixedIP( address="192.168.1.101", ), ], routes=[ model.Route( cidr="10.0.0.1/24", gateway=model.IP( address="192.168.1.254", type="gateway"), interface="eth0"), ]), ] expect = osv_objects.subnet.SubnetList( objects=[ osv_objects.subnet.Subnet( cidr="192.168.1.0/24", dns=["192.168.1.1", "192.168.1.2"], gateway="192.168.1.254", ips=osv_objects.fixed_ip.FixedIPList( objects=[ osv_objects.fixed_ip.FixedIP( address="192.168.1.100", floating_ips=[]), osv_objects.fixed_ip.FixedIP( address="192.168.1.101", floating_ips=[]), ]), routes=osv_objects.route.RouteList( objects=[ osv_objects.route.Route( cidr="10.0.0.1/24", gateway="192.168.1.254", interface="eth0") ]), ), osv_objects.subnet.Subnet( dns=["192.168.1.1", "192.168.1.2"], ips=osv_objects.fixed_ip.FixedIPList( objects=[ osv_objects.fixed_ip.FixedIP( address="192.168.1.100", floating_ips=[]), osv_objects.fixed_ip.FixedIP( address="192.168.1.101", floating_ips=[]), ]), routes=osv_objects.route.RouteList( objects=[ osv_objects.route.Route( cidr="10.0.0.1/24", gateway="192.168.1.254", interface="eth0") ]), ), osv_objects.subnet.Subnet( dns=["192.168.1.1", "192.168.1.2"], ips=osv_objects.fixed_ip.FixedIPList( objects=[ osv_objects.fixed_ip.FixedIP( address="192.168.1.100", floating_ips=[]), osv_objects.fixed_ip.FixedIP( address="192.168.1.101", floating_ips=[]), ]), routes=osv_objects.route.RouteList( objects=[ osv_objects.route.Route( cidr="10.0.0.1/24", gateway="192.168.1.254", interface="eth0") ]), ), ]) actual = os_vif_util._nova_to_osvif_subnets(subnets) self.assertObjEqual(expect, actual)