summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-27 10:51:49 +0000
committerGerrit Code Review <review@openstack.org>2013-03-27 10:51:49 +0000
commit50f2537512d016b9bbfe1e10be240a09301e2aaa (patch)
tree0815bdcaa596542b4b537119797365a19d524a0d
parenteb90ad456e6d2f642f00d55998d3988bd499190e (diff)
parent989435822e5841bc1355e75bbdb003b10a3baf58 (diff)
downloadnova-50f2537512d016b9bbfe1e10be240a09301e2aaa.tar.gz
Merge "Pass project id in quantum driver secgroup list" into milestone-proposed
-rw-r--r--nova/network/security_group/quantum_driver.py2
-rw-r--r--nova/tests/network/security_group/__init__.py0
-rw-r--r--nova/tests/network/security_group/test_quantum_driver.py47
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 9ef68fa7fb..5a24a74abf 100644
--- a/nova/network/security_group/quantum_driver.py
+++ b/nova/network/security_group/quantum_driver.py
@@ -120,6 +120,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 0000000000..e69de29bb2
--- /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 0000000000..64170fe2c1
--- /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)