-
Notifications
You must be signed in to change notification settings - Fork 907
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes cinder aspect of LP 1027281. Use view builder pattern to only include non-extraneous volume type attributes in the representation. Change-Id: I33f1b579fd6ed4ed98fa04e9148e91eca125213e
- Loading branch information
Eoghan Glynn
committed
Jul 26, 2012
1 parent
cdaf23e
commit 95262bb
Showing
4 changed files
with
93 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# vim: tabstop=4 shiftwidth=4 softtabstop=4 | ||
|
||
# Copyright 2012 Red Hat, Inc. | ||
# 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. | ||
|
||
from cinder.api.openstack import common | ||
|
||
|
||
class ViewBuilder(common.ViewBuilder): | ||
|
||
def show(self, request, volume_type, brief=False): | ||
"""Trim away extraneous volume type attributes.""" | ||
trimmed = dict(id=volume_type.get('id'), | ||
name=volume_type.get('name'), | ||
extra_specs=volume_type.get('extra_specs')) | ||
return trimmed if brief else dict(volume_type=trimmed) | ||
|
||
def index(self, request, volume_types): | ||
"""Index over trimmed volume types""" | ||
volume_types_list = [self.show(request, volume_type, True) | ||
for volume_type in volume_types] | ||
return dict(volume_types=volume_types_list) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters