Letting allocated_ip_address filter by address
For Nova to filter instances by ip address we need a way for melange to return an address without being scoped by tenant. Change-Id: I9a9cddd4b86a562ac6610179776d0cdf41f1c044
This commit is contained in:
parent
aa76fce9aa
commit
9fa87241df
@ -177,7 +177,8 @@ class IpAddressController(BaseController):
|
||||
class AllocatedIpAddressesController(BaseController):
|
||||
|
||||
def index(self, request, tenant_id=None):
|
||||
filter_conditions = utils.filter_dict(request.params, 'used_by_device')
|
||||
filter_conditions = utils.filter_dict(request.params,
|
||||
'used_by_device', 'address')
|
||||
if tenant_id:
|
||||
filter_conditions['used_by_tenant'] = tenant_id
|
||||
ips = models.IpAddress.find_all_allocated_ips(**filter_conditions)
|
||||
|
@ -1002,6 +1002,24 @@ class TestAllocatedIpAddressController(ControllerTestBase):
|
||||
self.assertItemsEqual(response.json['ip_addresses'],
|
||||
_data([tnt1_device1_ip1, tnt1_device1_ip2]))
|
||||
|
||||
def test_index_returns_allocated_ips_by_address(self):
|
||||
block1 = factory_models.IpBlockFactory(cidr="10.0.0.0/24",
|
||||
tenant_id="1")
|
||||
block2 = factory_models.IpBlockFactory(cidr="20.0.0.0/24",
|
||||
tenant_id="2")
|
||||
interface1 = factory_models.InterfaceFactory(tenant_id="tnt1")
|
||||
interface2 = factory_models.InterfaceFactory(tenant_id="tnt2")
|
||||
|
||||
tenant1_ip1 = _allocate_ip(block1, interface=interface1)
|
||||
tenant1_ip2 = _allocate_ip(block2, interface=interface1)
|
||||
tenant2_ip1 = _allocate_ip(block2, interface=interface2)
|
||||
|
||||
response = self.app.get("/ipam/allocated_ip_addresses?"
|
||||
"address=" + tenant1_ip1.address)
|
||||
|
||||
self.assertItemsEqual(response.json['ip_addresses'],
|
||||
_data([tenant1_ip1]))
|
||||
|
||||
def test_index_doesnt_return_soft_deallocated_ips(self):
|
||||
block = factory_models.IpBlockFactory()
|
||||
interface = factory_models.InterfaceFactory(tenant_id="tnt1")
|
||||
|
Loading…
x
Reference in New Issue
Block a user