Merge "Create pool in lbaas context with correct tenant_id"
This commit is contained in:
@@ -68,6 +68,7 @@ class Lbaas(context.Context):
|
|||||||
if self.config["lbaas_version"] == 1:
|
if self.config["lbaas_version"] == 1:
|
||||||
network.setdefault("lb_pools", []).append(
|
network.setdefault("lb_pools", []).append(
|
||||||
net_wrapper.create_v1_pool(
|
net_wrapper.create_v1_pool(
|
||||||
|
tenant_id,
|
||||||
subnet,
|
subnet,
|
||||||
**self.config["pool"]))
|
**self.config["pool"]))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -245,15 +245,17 @@ class NeutronWrapper(NetworkWrapper):
|
|||||||
"network_id": net["id"], "enable_snat": True}
|
"network_id": net["id"], "enable_snat": True}
|
||||||
return self.client.create_router({"router": kwargs})["router"]
|
return self.client.create_router({"router": kwargs})["router"]
|
||||||
|
|
||||||
def create_v1_pool(self, subnet_id, **kwargs):
|
def create_v1_pool(self, tenant_id, subnet_id, **kwargs):
|
||||||
"""Create LB Pool (v1).
|
"""Create LB Pool (v1).
|
||||||
|
|
||||||
|
:param tenant_id: str, pool tenant id
|
||||||
:param subnet_id: str, neutron subnet-id
|
:param subnet_id: str, neutron subnet-id
|
||||||
:param **kwargs: extra options
|
:param **kwargs: extra options
|
||||||
:returns: neutron lb-pool dict
|
:returns: neutron lb-pool dict
|
||||||
"""
|
"""
|
||||||
pool_args = {
|
pool_args = {
|
||||||
"pool": {
|
"pool": {
|
||||||
|
"tenant_id": tenant_id,
|
||||||
"name": utils.generate_random_name("rally_pool_"),
|
"name": utils.generate_random_name("rally_pool_"),
|
||||||
"subnet_id": subnet_id,
|
"subnet_id": subnet_id,
|
||||||
"lb_method": kwargs.get("lb_method", self.LB_METHOD),
|
"lb_method": kwargs.get("lb_method", self.LB_METHOD),
|
||||||
|
|||||||
@@ -21,8 +21,10 @@ NET = "rally.plugins.openstack.wrappers.network."
|
|||||||
class LbaasTestCase(test.TestCase):
|
class LbaasTestCase(test.TestCase):
|
||||||
def get_context(self, **kwargs):
|
def get_context(self, **kwargs):
|
||||||
foo_tenant = {"networks": [{"id": "foo_net",
|
foo_tenant = {"networks": [{"id": "foo_net",
|
||||||
|
"tenant_id": "foo_tenant",
|
||||||
"subnets": ["foo_subnet"]}]}
|
"subnets": ["foo_subnet"]}]}
|
||||||
bar_tenant = {"networks": [{"id": "bar_net",
|
bar_tenant = {"networks": [{"id": "bar_net",
|
||||||
|
"tenant_id": "bar_tenant",
|
||||||
"subnets": ["bar_subnet"]}]}
|
"subnets": ["bar_subnet"]}]}
|
||||||
return {"task": {"uuid": "foo_task"},
|
return {"task": {"uuid": "foo_task"},
|
||||||
"admin": {"endpoint": "foo_admin"},
|
"admin": {"endpoint": "foo_admin"},
|
||||||
@@ -62,15 +64,20 @@ class LbaasTestCase(test.TestCase):
|
|||||||
("foo_user", "foo_tenant"),
|
("foo_user", "foo_tenant"),
|
||||||
("bar_user", "bar_tenant")]
|
("bar_user", "bar_tenant")]
|
||||||
foo_net = {"id": "foo_net",
|
foo_net = {"id": "foo_net",
|
||||||
|
"tenant_id": "foo_tenant",
|
||||||
"subnets": ["foo_subnet"],
|
"subnets": ["foo_subnet"],
|
||||||
"lb_pools": [{"pool": {"id": "foo_pool"}}]}
|
"lb_pools": [{"pool": {"id": "foo_pool",
|
||||||
|
"tenant_id": "foo_tenant"}}]}
|
||||||
bar_net = {"id": "bar_net",
|
bar_net = {"id": "bar_net",
|
||||||
|
"tenant_id": "bar_tenant",
|
||||||
"subnets": ["bar_subnet"],
|
"subnets": ["bar_subnet"],
|
||||||
"lb_pools": [{"pool": {"id": "bar_pool"}}]}
|
"lb_pools": [{"pool": {"id": "bar_pool",
|
||||||
|
"tenant_id": "bar_tenant"}}]}
|
||||||
expected_net = [bar_net, foo_net]
|
expected_net = [bar_net, foo_net]
|
||||||
mock_create = mock.Mock(
|
mock_create = mock.Mock(
|
||||||
side_effect=lambda t,
|
side_effect=lambda t, s,
|
||||||
**kw: {"pool": {"id": str(t.split("_")[0]) + "_pool"}})
|
**kw: {"pool": {"id": str(t.split("_")[0]) + "_pool",
|
||||||
|
"tenant_id": t}})
|
||||||
actual_net = []
|
actual_net = []
|
||||||
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
mock_wrap.return_value = mock.Mock(create_v1_pool=mock_create)
|
||||||
net_wrapper = mock_wrap(mock_clients.return_value)
|
net_wrapper = mock_wrap(mock_clients.return_value)
|
||||||
|
|||||||
@@ -226,16 +226,19 @@ class NeutronWrapperTestCase(test.TestCase):
|
|||||||
def test_create_v1_pool(self, mock_generate_random_name):
|
def test_create_v1_pool(self, mock_generate_random_name):
|
||||||
mock_generate_random_name.return_value = "foo_name"
|
mock_generate_random_name.return_value = "foo_name"
|
||||||
subnet = "subnet_id"
|
subnet = "subnet_id"
|
||||||
|
tenant = "foo_tenant"
|
||||||
service = self.get_wrapper()
|
service = self.get_wrapper()
|
||||||
expected_pool = {"pool": {
|
expected_pool = {"pool": {
|
||||||
"id": "pool_id",
|
"id": "pool_id",
|
||||||
"name": "foo_name",
|
"name": "foo_name",
|
||||||
"subnet_id": subnet}}
|
"subnet_id": subnet,
|
||||||
|
"tenant_id": tenant}}
|
||||||
service.client.create_pool.return_value = expected_pool
|
service.client.create_pool.return_value = expected_pool
|
||||||
resultant_pool = service.create_v1_pool(subnet)
|
resultant_pool = service.create_v1_pool(tenant, subnet)
|
||||||
service.client.create_pool.assert_called_once_with({
|
service.client.create_pool.assert_called_once_with({
|
||||||
"pool": {"lb_method": "ROUND_ROBIN",
|
"pool": {"lb_method": "ROUND_ROBIN",
|
||||||
"subnet_id": subnet,
|
"subnet_id": subnet,
|
||||||
|
"tenant_id": tenant,
|
||||||
"protocol": "HTTP",
|
"protocol": "HTTP",
|
||||||
"name": "foo_name"}})
|
"name": "foo_name"}})
|
||||||
self.assertEqual(resultant_pool, expected_pool)
|
self.assertEqual(resultant_pool, expected_pool)
|
||||||
|
|||||||
Reference in New Issue
Block a user