From 8de1e272f08bcc294b10ce548616f181ee7bc800 Mon Sep 17 00:00:00 2001 From: pengyuesheng Date: Mon, 8 Apr 2019 14:57:33 +0800 Subject: [PATCH] Incoming tenant id when creating a subnet on create network form On admin panel, when creating a network and creating a subnet, the tenant to which the network belongs and the tenant to which the subnet belongs are inconsistent. This patch uniform network and subnet tenant ID Change-Id: I3744d8b7a0a37918962c9d9a2ac319002de93851 Closes-Bug: #1823627 --- openstack_dashboard/dashboards/admin/networks/tests.py | 3 ++- openstack_dashboard/dashboards/project/networks/tests.py | 4 ++++ openstack_dashboard/dashboards/project/networks/workflows.py | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/openstack_dashboard/dashboards/admin/networks/tests.py b/openstack_dashboard/dashboards/admin/networks/tests.py index 38b616a8ee..f0223e965a 100644 --- a/openstack_dashboard/dashboards/admin/networks/tests.py +++ b/openstack_dashboard/dashboards/admin/networks/tests.py @@ -588,7 +588,8 @@ class NetworkTests(test.BaseAdminViewTests): 'provider:network_type': 'local'} self.mock_network_create.assert_called_once_with(test.IsHttpRequest(), **params) - subnet_params = {'name': subnet.name, + subnet_params = {'tenant_id': tenant_id, + 'name': subnet.name, 'network_id': subnet.network_id, 'cidr': subnet.cidr, 'enable_dhcp': subnet.enable_dhcp, diff --git a/openstack_dashboard/dashboards/project/networks/tests.py b/openstack_dashboard/dashboards/project/networks/tests.py index afc878af01..89b23470f2 100644 --- a/openstack_dashboard/dashboards/project/networks/tests.py +++ b/openstack_dashboard/dashboards/project/networks/tests.py @@ -493,6 +493,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): 'admin_state_up': network.admin_state_up, 'shared': False} subnet_params = {'network_id': network.id, + 'tenant_id': network.tenant_id, 'name': subnet.name, 'cidr': subnet.cidr, 'ip_version': subnet.ip_version, @@ -629,6 +630,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): self.mock_subnet_create.assert_called_once_with( test.IsHttpRequest(), network_id=network.id, + tenant_id=network.tenant_id, name=subnet.name, cidr=subnet.cidr, ip_version=subnet.ip_version, @@ -801,6 +803,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): 'admin_state_up': network.admin_state_up, 'shared': False} subnet_params = {'network_id': network.id, + 'tenant_id': network.tenant_id, 'name': subnet.name, 'cidr': cidr, 'ip_version': subnet.ip_version, @@ -930,6 +933,7 @@ class NetworkTests(test.TestCase, NetworkStubMixin): 'shared': False, 'with_subnet': True} subnet_params = {'network_id': network.id, + 'tenant_id': network.tenant_id, 'name': subnet.name, 'cidr': subnet.cidr, 'ip_version': subnet.ip_version, diff --git a/openstack_dashboard/dashboards/project/networks/workflows.py b/openstack_dashboard/dashboards/project/networks/workflows.py index dcefe988ec..b04c6239b4 100644 --- a/openstack_dashboard/dashboards/project/networks/workflows.py +++ b/openstack_dashboard/dashboards/project/networks/workflows.py @@ -600,7 +600,8 @@ class CreateNetwork(workflows.Workflow): # If we do not need to create a subnet, return here. if not data['with_subnet']: return True - subnet = self._create_subnet(request, data, network, no_redirect=True) + subnet = self._create_subnet(request, data, network, no_redirect=True, + tenant_id=network.tenant_id) if subnet: return True else: