@@ -34,21 +34,22 @@ def _translate_snapshot_detail_view(context, vol):
3434 return _translate_snapshot_summary_view (context , vol )
3535
3636
37- def _translate_snapshot_summary_view (context , vol ):
37+ def _translate_snapshot_summary_view (context , snapshot ):
3838 """Maps keys for snapshots summary view."""
3939 d = {}
4040
41- d ['id' ] = vol ['id' ]
42- d ['volumeId' ] = vol ['volume_id' ]
43- d ['status' ] = vol ['status' ]
41+ d ['id' ] = snapshot ['id' ]
42+ d ['volumeId' ] = snapshot ['volume_id' ]
43+ d ['status' ] = snapshot ['status' ]
4444 # NOTE(gagupta): We map volume_size as the snapshot size
45- d ['size' ] = vol ['volume_size' ]
46- d ['createdAt' ] = vol ['created_at' ]
47- d ['displayName' ] = vol ['display_name' ]
48- d ['displayDescription' ] = vol ['display_description' ]
45+ d ['size' ] = snapshot ['volume_size' ]
46+ d ['createdAt' ] = snapshot ['created_at' ]
47+ d ['displayName' ] = snapshot ['display_name' ]
48+ d ['displayDescription' ] = snapshot ['display_description' ]
4949 return d
5050
5151
52+ @validation .validated
5253class SnapshotController (wsgi .Controller ):
5354 """The Snapshots API controller for the OpenStack API."""
5455
@@ -59,6 +60,7 @@ def __init__(self):
5960 @wsgi .api_version ("2.1" , MAX_PROXY_API_SUPPORT_VERSION )
6061 @wsgi .expected_errors (404 )
6162 @validation .query_schema (schema .show_query )
63+ @validation .response_body_schema (schema .show_response )
6264 def show (self , req , id ):
6365 """Return data about the given snapshot."""
6466 context = req .environ ['nova.context' ]
@@ -76,6 +78,7 @@ def show(self, req, id):
7678 @wsgi .api_version ("2.1" , MAX_PROXY_API_SUPPORT_VERSION )
7779 @wsgi .response (202 )
7880 @wsgi .expected_errors (404 )
81+ @validation .response_body_schema (schema .delete_response )
7982 def delete (self , req , id ):
8083 """Delete a snapshot."""
8184 context = req .environ ['nova.context' ]
@@ -91,6 +94,7 @@ def delete(self, req, id):
9194 @wsgi .api_version ("2.1" , MAX_PROXY_API_SUPPORT_VERSION )
9295 @wsgi .expected_errors (())
9396 @validation .query_schema (schema .index_query )
97+ @validation .response_body_schema (schema .index_response )
9498 def index (self , req ):
9599 """Returns a summary list of snapshots."""
96100 context = req .environ ['nova.context' ]
@@ -102,6 +106,7 @@ def index(self, req):
102106 @wsgi .api_version ("2.1" , MAX_PROXY_API_SUPPORT_VERSION )
103107 @wsgi .expected_errors (())
104108 @validation .query_schema (schema .detail_query )
109+ @validation .response_body_schema (schema .detail_response )
105110 def detail (self , req ):
106111 """Returns a detailed list of snapshots."""
107112 context = req .environ ['nova.context' ]
@@ -122,6 +127,7 @@ def _items(self, req, entity_maker):
122127 @wsgi .api_version ("2.1" , MAX_PROXY_API_SUPPORT_VERSION )
123128 @wsgi .expected_errors ((400 , 403 ))
124129 @validation .schema (schema .create )
130+ @validation .response_body_schema (schema .create_response )
125131 def create (self , req , body ):
126132 """Creates a new snapshot."""
127133 context = req .environ ['nova.context' ]
0 commit comments