Merge "Fix possible TypeError in VIF.fixed_ips"
This commit is contained in:
commit
748bb12eb2
@ -412,8 +412,11 @@ class VIF(Model):
|
||||
return not self.__eq__(other)
|
||||
|
||||
def fixed_ips(self):
|
||||
return [fixed_ip for subnet in self['network']['subnets']
|
||||
for fixed_ip in subnet['ips']]
|
||||
if self['network']:
|
||||
return [fixed_ip for subnet in self['network']['subnets']
|
||||
for fixed_ip in subnet['ips']]
|
||||
else:
|
||||
return []
|
||||
|
||||
def floating_ips(self):
|
||||
return [floating_ip for fixed_ip in self.fixed_ips()
|
||||
|
@ -423,6 +423,11 @@ class VIFTests(test.NoDBTestCase):
|
||||
] * 2
|
||||
self.assertEqual(fixed_ips, ips)
|
||||
|
||||
def test_vif_get_fixed_ips_network_is_none(self):
|
||||
vif = model.VIF()
|
||||
fixed_ips = vif.fixed_ips()
|
||||
self.assertEqual([], fixed_ips)
|
||||
|
||||
def test_vif_get_floating_ips(self):
|
||||
vif = fake_network_cache_model.new_vif()
|
||||
vif['network']['subnets'][0]['ips'][0].add_floating_ip('192.168.1.1')
|
||||
|
Loading…
x
Reference in New Issue
Block a user