]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Allow setting Agents description to None
authorHenry Gessau <gessau@cisco.com>
Sun, 21 Jun 2015 05:30:05 +0000 (01:30 -0400)
committerHenry Gessau <gessau@cisco.com>
Sun, 21 Jun 2015 05:40:19 +0000 (01:40 -0400)
Fix the validator for the 'description' attribute of Agents, allowing
it to be set to None.

Fix an API test that had two problems:
 1. It was not restoring the description to the agent it had updated
 2. It was retoring the description to '' instead of None.

Closes-Bug: #1466642

Change-Id: I50723e1346be0953d26216ba24907bac008ccfb6

neutron/extensions/agent.py
neutron/tests/api/admin/test_agent_management.py

index c2fab0bccaf4481749044466249abcbc127f7690..3ef07fd7ed42bcc1725951dce66cfa09e6d7a440 100644 (file)
@@ -52,7 +52,8 @@ RESOURCE_ATTRIBUTE_MAP = {
                            'is_visible': True},
         'description': {'allow_post': False, 'allow_put': True,
                         'is_visible': True,
-                        'validate': {'type:string': attr.DESCRIPTION_MAX_LEN}},
+                        'validate': {
+                            'type:string_or_none': attr.DESCRIPTION_MAX_LEN}},
     },
 }
 
index 013f3e44bbcc447d94794c0d82681b37e2c20ebb..4136c3e992a7d6a5974bc0233348886c163b7a92 100644 (file)
@@ -84,7 +84,7 @@ class AgentManagementTestJSON(base.BaseAdminNetworkTest):
         """
         Restore the agent description after update test.
         """
-        description = self.agent['description'] or ''
+        description = self.dyn_agent['description']
         origin_agent = {'description': description}
-        self.admin_client.update_agent(agent_id=self.agent['id'],
+        self.admin_client.update_agent(agent_id=self.dyn_agent['id'],
                                        agent_info=origin_agent)