diff options
| author | Jenkins <jenkins@review.openstack.org> | 2013-03-25 15:40:33 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2013-03-25 15:40:33 +0000 |
| commit | d40bdd43bc8fec44925788faf3eb32dac0ae06d2 (patch) | |
| tree | 092ec7c28180a32c0ad13cb4d22d728ba16d8b57 | |
| parent | 2d02ce3ba00c3e4300bb841483d00d18210f79ff (diff) | |
| parent | 775e3b02b2afbf101db22b87a1c3b189d68532e1 (diff) | |
| download | nova-d40bdd43bc8fec44925788faf3eb32dac0ae06d2.tar.gz nova-d40bdd43bc8fec44925788faf3eb32dac0ae06d2.tar.xz nova-d40bdd43bc8fec44925788faf3eb32dac0ae06d2.zip | |
Merge "Pass project id in quantum driver secgroup list"
| -rw-r--r-- | nova/network/security_group/quantum_driver.py | 2 | ||||
| -rw-r--r-- | nova/tests/network/security_group/__init__.py | 0 | ||||
| -rw-r--r-- | nova/tests/network/security_group/test_quantum_driver.py | 47 |
3 files changed, 49 insertions, 0 deletions
diff --git a/nova/network/security_group/quantum_driver.py b/nova/network/security_group/quantum_driver.py index e6f88e20c..1942d06ef 100644 --- a/nova/network/security_group/quantum_driver.py +++ b/nova/network/security_group/quantum_driver.py @@ -122,6 +122,8 @@ class SecurityGroupAPI(security_group_base.SecurityGroupBase): search_opts['name'] = names if ids: search_opts['id'] = ids + if project: + search_opts['tenant_id'] = project try: security_groups = quantum.list_security_groups(**search_opts).get( 'security_groups') diff --git a/nova/tests/network/security_group/__init__.py b/nova/tests/network/security_group/__init__.py new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/nova/tests/network/security_group/__init__.py diff --git a/nova/tests/network/security_group/test_quantum_driver.py b/nova/tests/network/security_group/test_quantum_driver.py new file mode 100644 index 000000000..64170fe2c --- /dev/null +++ b/nova/tests/network/security_group/test_quantum_driver.py @@ -0,0 +1,47 @@ +# Copyright 2013 OpenStack Foundation +# All Rights Reserved +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +import mox +from quantumclient.v2_0 import client + +from nova import context +from nova.network import quantumv2 +from nova.network.security_group import quantum_driver +from nova import test + + +class TestQuantumDriver(test.TestCase): + def setUp(self): + super(TestQuantumDriver, self).setUp() + self.mox.StubOutWithMock(quantumv2, 'get_client') + self.moxed_client = self.mox.CreateMock(client.Client) + quantumv2.get_client(mox.IgnoreArg()).MultipleTimes().AndReturn( + self.moxed_client) + self.context = context.RequestContext('userid', 'my_tenantid') + setattr(self.context, + 'auth_token', + 'bff4a5a6b9eb4ea2a6efec6eefb77936') + + def test_list_with_project(self): + project_id = '0af70a4d22cf4652824ddc1f2435dd85' + security_groups_list = {'security_groups': []} + self.moxed_client.list_security_groups(tenant_id=project_id).AndReturn( + security_groups_list) + self.mox.ReplayAll() + + sg_api = quantum_driver.SecurityGroupAPI() + sg_api.list(self.context, project=project_id) |
