Merge lp:~gundlach/nova/server-display-name into lp:~hudson-openstack/nova/trunk

Proposed by Michael Gundlach
Status: Merged
Approved by: Michael Gundlach
Approved revision: 436
Merged at revision: 435
Proposed branch: lp:~gundlach/nova/server-display-name
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 95 lines (+16/-6)
5 files modified
nova/api/openstack/servers.py (+2/-3)
nova/compute/manager.py (+6/-0)
nova/db/sqlalchemy/api.py (+6/-0)
nova/db/sqlalchemy/models.py (+1/-2)
nova/tests/api/openstack/test_servers.py (+1/-1)
To merge this branch: bzr merge lp:~gundlach/nova/server-display-name
Reviewer Review Type Date Requested Status
Soren Hansen (community) Approve
Todd Willey (community) Approve
Review via email: mp+42410@code.launchpad.net

Commit message

Guarantee that the OpenStack API's Server-related responses will always contain a "name" value. And get rid of a redundant field in models.py.

To post a comment you must log in.
Revision history for this message
Michael Gundlach (gundlach) wrote :

Guarantee that the OpenStack API's Server-related responses will always contain a "name" value. And get rid of a redundant field in models.py.

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

LGTM. And when I say 'G', I mean 'GREAT'.

review: Approve
Revision history for this message
Soren Hansen (soren) wrote :

Yup, great stuff!

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

The attempt to merge lp:~gundlach/nova/server-display-name into lp:nova failed. Below is the output from the failed tests.

nova.tests.access_unittest
  AccessTestCase
    test_001_allow_all ... [OK]
    test_002_allow_none ... [OK]
    test_003_allow_project_manager ... [OK]
    test_004_allow_sys_and_net ... [OK]
nova.tests.api_unittest
  ApiEc2TestCase
    test_authorize_revoke_security_group_cidr ... [OK]
    test_authorize_revoke_security_group_foreign_group ... [OK]
    test_create_delete_security_group ... [OK]
    test_describe_instances ... [OK]
    test_get_all_key_pairs ... [OK]
    test_get_all_security_groups ... [OK]
  XmlConversionTestCase
    test_number_conversion ... [OK]
nova.tests.auth_unittest
  AuthManagerDbTestCase
    test_004_signature_is_valid ... [OK]
    test_005_can_get_credentials ... [OK]
    test_add_user_role_doesnt_infect_project_roles ... [OK]
    test_adding_role_to_project_is_ignored_unless_added_to_user ... [OK]
    test_can_add_and_remove_user_role ... [OK]
    test_can_add_remove_user_with_role ... [OK]
    test_can_add_user_to_project ... [OK]
    test_can_create_and_get_project ... [OK]
    test_can_create_and_get_project_with_attributes ... [OK]
    test_can_create_project_with_manager ... [OK]
    test_can_delete_project ... [OK]
    test_can_delete_user ... [OK]
    test_can_generate_x509 ... [OK]
    test_can_list_project_roles ... [OK]
    test_can_list_projects ... [OK]
    test_can_list_user_roles ... [OK]
    test_can_list_users ... [OK]
    test_can_modify_project ... [OK]
    test_can_modify_users ... [OK]
    test_can_remove_project_role_but_keep_user_role ... [OK]
    test_can_remove_user_from_project ... [OK]
    test_can_remove_user_roles ... [OK]
    test_can_retrieve_project_by_user ... [OK]
    test_create_and_find_user ... [OK]
    test_create_and_find_with_properties ... [OK]
    test_create_project_assigns_manage...

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

The attempt to merge lp:~gundlach/nova/server-display-name into lp:nova failed. Below is the output from the failed tests.

nova/compute/manager.py:109:38: E201 whitespace after '{'
                                    { 'display_name': display_name })
                                     ^
    Avoid extraneous whitespace in the following situations:

    - Immediately inside parentheses, brackets or braces.

    - Immediately before a comma, semicolon, or colon.

    Okay: spam(ham[1], {eggs: 2})
    E201: spam( ham[1], {eggs: 2})
    E201: spam(ham[ 1], {eggs: 2})
    E201: spam(ham[1], { eggs: 2})
    E202: spam(ham[1], {eggs: 2} )
    E202: spam(ham[1 ], {eggs: 2})
    E202: spam(ham[1], {eggs: 2 })

    E203: if x == 4: print x, y; x, y = y , x
    E203: if x == 4: print x, y ; x, y = y, x
    E203: if x == 4 : print x, y; x, y = y, x

436. By Michael Gundlach

Going for a record commits per line changes ratio

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/openstack/servers.py'
2--- nova/api/openstack/servers.py 2010-10-27 18:55:01 +0000
3+++ nova/api/openstack/servers.py 2010-12-01 22:05:45 +0000
4@@ -63,7 +63,7 @@
5 inst_dict = {}
6
7 mapped_keys = dict(status='state', imageId='image_id',
8- flavorId='instance_type', name='server_name', id='id')
9+ flavorId='instance_type', name='display_name', id='id')
10
11 for k, v in mapped_keys.iteritems():
12 inst_dict[k] = inst[v]
13@@ -78,7 +78,7 @@
14
15 def _entity_inst(inst):
16 """ Filters all model attributes save for id and name """
17- return dict(server=dict(id=inst['id'], name=inst['server_name']))
18+ return dict(server=dict(id=inst['id'], name=inst['display_name']))
19
20
21 class Controller(wsgi.Controller):
22@@ -213,7 +213,6 @@
23 if not image:
24 raise Exception("Image not found")
25
26- inst['server_name'] = env['server']['name']
27 inst['image_id'] = image_id
28 inst['user_id'] = user_id
29 inst['launch_time'] = ltime
30
31=== modified file 'nova/compute/manager.py'
32--- nova/compute/manager.py 2010-11-29 12:14:26 +0000
33+++ nova/compute/manager.py 2010-12-01 22:05:45 +0000
34@@ -101,6 +101,12 @@
35 """
36 instance_ref = self.db.instance_create(context, kwargs)
37 inst_id = instance_ref['id']
38+ # Set sane defaults if not specified
39+ if 'display_name' not in kwargs:
40+ display_name = "Server %s" % instance_ref['internal_id']
41+ instance_ref['display_name'] = display_name
42+ self.db.instance_update(context, inst_id,
43+ {'display_name': display_name})
44
45 elevated = context.elevated()
46 if not security_groups:
47
48=== modified file 'nova/db/sqlalchemy/api.py'
49--- nova/db/sqlalchemy/api.py 2010-11-18 20:04:38 +0000
50+++ nova/db/sqlalchemy/api.py 2010-12-01 22:05:45 +0000
51@@ -530,6 +530,12 @@
52 #functions between the two of them as well.
53 @require_context
54 def instance_create(context, values):
55+ """Create a new Instance record in the database.
56+
57+ context - request context object
58+ values - dict containing column values.
59+ 'internal_id' is auto-generated and should not be specified.
60+ """
61 instance_ref = models.Instance()
62 instance_ref.update(values)
63
64
65=== modified file 'nova/db/sqlalchemy/models.py'
66--- nova/db/sqlalchemy/models.py 2010-11-03 22:06:00 +0000
67+++ nova/db/sqlalchemy/models.py 2010-12-01 22:05:45 +0000
68@@ -178,8 +178,6 @@
69 kernel_id = Column(String(255))
70 ramdisk_id = Column(String(255))
71
72- server_name = Column(String(255))
73-
74 # image_id = Column(Integer, ForeignKey('images.id'), nullable=True)
75 # kernel_id = Column(Integer, ForeignKey('images.id'), nullable=True)
76 # ramdisk_id = Column(Integer, ForeignKey('images.id'), nullable=True)
77@@ -212,6 +210,7 @@
78 launched_at = Column(DateTime)
79 terminated_at = Column(DateTime)
80
81+ # User editable field for display in user-facing UIs
82 display_name = Column(String(255))
83 display_description = Column(String(255))
84
85
86=== modified file 'nova/tests/api/openstack/test_servers.py'
87--- nova/tests/api/openstack/test_servers.py 2010-11-02 19:02:42 +0000
88+++ nova/tests/api/openstack/test_servers.py 2010-12-01 22:05:45 +0000
89@@ -44,7 +44,7 @@
90
91
92 def stub_instance(id, user_id=1):
93- return Instance(id=id, state=0, image_id=10, server_name='server%s' % id,
94+ return Instance(id=id, state=0, image_id=10, display_name='server%s' % id,
95 user_id=user_id)
96
97