Merge lp:~vishvananda/nova/fix-describe-groups into lp:~hudson-openstack/nova/trunk

Proposed by Vish Ishaya
Status: Merged
Approved by: Jay Pipes
Approved revision: 712
Merged at revision: 721
Proposed branch: lp:~vishvananda/nova/fix-describe-groups
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 83 lines (+26/-17)
2 files modified
nova/api/ec2/cloud.py (+10/-4)
nova/tests/test_cloud.py (+16/-13)
To merge this branch: bzr merge lp:~vishvananda/nova/fix-describe-groups
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Todd Willey (community) Approve
Devin Carlen (community) Approve
Review via email: mp+50851@code.launchpad.net

Description of the change

Fixes and optimizes filtering for describe_security_groups. Also adds a unit test.

To post a comment you must log in.
Revision history for this message
Devin Carlen (devcamcar) wrote :

lgtm

review: Approve
Revision history for this message
Jay Pipes (jaypipes) wrote :

Hi Vish! Could I ask why the test_describe_instances() test was removed?

review: Needs Information
Revision history for this message
Vish Ishaya (vishvananda) wrote :

Jay: It was a duplicate test leftover from a bad merge. There is still a (more complete) describe_instances test in there.

Revision history for this message
Jay Pipes (jaypipes) wrote :

gotcha. approved. thx. :)

review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Attempt to merge into lp:nova failed due to conflicts:

text conflict in nova/tests/test_cloud.py

Revision history for this message
Jay Pipes (jaypipes) :
review: Approve
Revision history for this message
OpenStack Infra (hudson-openstack) wrote :
Download full text (37.8 KiB)

The attempt to merge lp:~vishvananda/nova/fix-describe-groups into lp:nova failed. Below is the output from the failed tests.

AdminAPITest
    test_admin_disabled ok
    test_admin_enabled ok
APITest
    test_exceptions_are_converted_to_faults ok
Test
    test_authorize_token ok
    test_authorize_user ok
    test_bad_token ok
    test_bad_user ok
    test_no_user ok
    test_token_expiry ok
TestLimiter
    test_authorize_token ok
LimiterTest
    test_limiter_custom_max_limit ok
    test_limiter_limit_and_offset ok
    test_limiter_limit_medium ok
    test_limiter_limit_over_max ok
    test_limiter_limit_zero ok
    test_limiter_nothing ok
    test_limiter_offset_bad ok
    test_limiter_offset_blank ok
    test_limiter_offset_medium ok
    test_limiter_offset_over_max ok
    test_limiter_offset_zero ok
TestFaults
    test_fault_parts ok
    test_raise ok
    test_retry_header ok
FlavorsTest
    test_get_flavor_by_id ok
    test_get_flavor_list ok
GlanceImageServiceTest
    test_create ok
    test_create_and_show_non_existing_image ok
    test_delete ok
    test_update ok
ImageControllerWithGlanceServiceTest
    test_get_image_details ok
    test_get_image_index ok
LocalImageServiceTest
    test_create ok
    test_create_and_show_non_existing_image ok
    test_delete ok
    test_update ok
LimiterTest
    test_minute ok
    test_one_per_period ok
    test_second ok
    test_users_get_separate_buckets ok
    test_we_can_go_indefinitely_if_we_spread_out_requests ok
WSGIAppProxyTest
    test_200 ok
    test_403 ok
    test...

711. By Vish Ishaya

merged trunk

712. By Vish Ishaya

fix for failing describe_instances test

Revision history for this message
Vish Ishaya (vishvananda) wrote :

Wow it looks like removing the extra describe instances (so that the longer, correct one runs) uncovered an error in cloud.py using the direct api. It is fixed now.

Vish
On Feb 23, 2011, at 10:45 AM, OpenStack Hudson wrote:

> The proposal to merge lp:~vishvananda/nova/fix-describe-groups into lp:nova has been updated.
>
> Status: Approved => Needs review
>
> For more details, see:
> https://code.launchpad.net/~vishvananda/nova/fix-describe-groups/+merge/50851
> --
> https://code.launchpad.net/~vishvananda/nova/fix-describe-groups/+merge/50851
> You are the owner of lp:~vishvananda/nova/fix-describe-groups.

Revision history for this message
Todd Willey (xtoddx) wrote :

lgtm

review: Approve
Revision history for this message
Jay Pipes (jaypipes) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/ec2/cloud.py'
2--- nova/api/ec2/cloud.py 2011-02-23 18:11:35 +0000
3+++ nova/api/ec2/cloud.py 2011-02-23 19:30:27 +0000
4@@ -318,14 +318,19 @@
5
6 def describe_security_groups(self, context, group_name=None, **kwargs):
7 self.compute_api.ensure_default_security_group(context)
8- if context.is_admin:
9+ if group_name:
10+ groups = []
11+ for name in group_name:
12+ group = db.security_group_get_by_name(context,
13+ context.project_id,
14+ name)
15+ groups.append(group)
16+ elif context.is_admin:
17 groups = db.security_group_get_all(context)
18 else:
19 groups = db.security_group_get_by_project(context,
20 context.project_id)
21 groups = [self._format_security_group(context, g) for g in groups]
22- if not group_name is None:
23- groups = [g for g in groups if g.name in group_name]
24
25 return {'securityGroupInfo':
26 list(sorted(groups,
27@@ -670,7 +675,8 @@
28 instances = []
29 for ec2_id in instance_id:
30 internal_id = ec2_id_to_id(ec2_id)
31- instance = self.compute_api.get(context, internal_id)
32+ instance = self.compute_api.get(context,
33+ instance_id=internal_id)
34 instances.append(instance)
35 else:
36 instances = self.compute_api.get_all(context, **kwargs)
37
38=== modified file 'nova/tests/test_cloud.py'
39--- nova/tests/test_cloud.py 2011-02-23 07:21:01 +0000
40+++ nova/tests/test_cloud.py 2011-02-23 19:30:27 +0000
41@@ -136,6 +136,22 @@
42 db.instance_destroy(self.context, inst['id'])
43 db.floating_ip_destroy(self.context, address)
44
45+ def test_describe_security_groups(self):
46+ """Makes sure describe_security_groups works and filters results."""
47+ sec = db.security_group_create(self.context,
48+ {'project_id': self.context.project_id,
49+ 'name': 'test'})
50+ result = self.cloud.describe_security_groups(self.context)
51+ # NOTE(vish): should have the default group as well
52+ self.assertEqual(len(result['securityGroupInfo']), 2)
53+ result = self.cloud.describe_security_groups(self.context,
54+ group_name=[sec['name']])
55+ self.assertEqual(len(result['securityGroupInfo']), 1)
56+ self.assertEqual(
57+ result['securityGroupInfo'][0]['groupName'],
58+ sec['name'])
59+ db.security_group_destroy(self.context, sec['id'])
60+
61 def test_describe_volumes(self):
62 """Makes sure describe_volumes works and filters results."""
63 vol1 = db.volume_create(self.context, {})
64@@ -294,19 +310,6 @@
65 LOG.debug(_("Terminating instance %s"), instance_id)
66 rv = self.compute.terminate_instance(instance_id)
67
68- def test_describe_instances(self):
69- """Makes sure describe_instances works."""
70- instance1 = db.instance_create(self.context, {'host': 'host2'})
71- comp1 = db.service_create(self.context, {'host': 'host2',
72- 'availability_zone': 'zone1',
73- 'topic': "compute"})
74- result = self.cloud.describe_instances(self.context)
75- self.assertEqual(result['reservationSet'][0]
76- ['instancesSet'][0]
77- ['placement']['availabilityZone'], 'zone1')
78- db.instance_destroy(self.context, instance1['id'])
79- db.service_destroy(self.context, comp1['id'])
80-
81 @staticmethod
82 def _fake_set_image_description(ctxt, image_id, description):
83 from nova.objectstore import handler