Home | Trees | Indices | Help |
---|
|
1 # Copyright 2014-2017 by Akira Yoshiyama <akirayoshiyama@gmail.com>. 2 # All Rights Reserved. 3 # 4 # Licensed under the Apache License, Version 2.0 (the "License"); you may 5 # not use this file except in compliance with the License. You may obtain 6 # a copy of the License at 7 # 8 # http://www.apache.org/licenses/LICENSE-2.0 9 # 10 # Unless required by applicable law or agreed to in writing, software 11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 # License for the specific language governing permissions and limitations 14 # under the License. 15 16 """ 17 Resource class and its manager for QoS specifications on Block Storage V2 API 18 """ 19 20 from yakumo import base 21 from yakumo.constant import UNDEF 22 from yakumo import mapper 23 24 25 ATTRIBUTE_MAPPING = [ 26 ('id', 'id', mapper.Noop), 27 ('name', 'name', mapper.Noop), 28 ('consumer', 'consumer', mapper.Noop), 29 ] 30 3133 """resource class for QoS specifications on Block Storage V2 API""" 34 35 _stable_state = ['available', 'error', 'error_deleting'] 36118 11938 """ 39 Aquire specs of a QoS Specs 40 41 @return: specs in key=value format 42 @rtype: dict 43 """ 44 return self.get_attrs()4547 """ 48 Add or update specs into a QoS specification 49 50 name can't be altered. 51 52 @keyword kwargs: key=value style specs 53 @type kwargs: str=str 54 @rtype: None 55 """ 56 self.update(**kwargs)5759 """ 60 Remove specs from a QoS specification 61 62 @keyword keys: List of keys to be deleted 63 @type keys: [str] 64 @rtype: None 65 """ 66 self._http.put(self._url_resource_path, self._id, 'delete_keys', 67 data={"keys": keys}) 68 self.reload()6971 """ 72 Get associated volume types for a QoS specs 73 74 @return: List of associated volume types 75 @rtype: [yakumo.cinder.v2.volume_types.Resource] 76 """ 77 volume_types = [] 78 ret = self._http.get(self._url_resource_path, self._id, 'associations') 79 for vt in ret['qos_associations']: 80 volume_types.append( 81 self._client.cinder.volume_type.get_empty(vt['id'])) 82 return volume_types8385 """ 86 Associate QoS specs with a volume type 87 88 @param volume_type: Volume type to be associated 89 @type volume_type: [yakumo.cinder.v2.volume_type.Resource] 90 @rtype: None 91 """ 92 for volume_type in volume_types: 93 self._http.get(self._url_resource_path, self._id, 'associate', 94 params={'vol_type_id': volume_type.get_id()}) 95 self.reload()9698 """ 99 Dissociate QoS specs from a volume type 100 101 @param volume_type: Volume type to be dissociated 102 @type volume_type: yakumo.cinder.v2.volume_type.Resource 103 @rtype: None 104 """ 105 for volume_type in volume_types: 106 self._http.get(self._url_resource_path, self._id, 'disassociate', 107 params={'vol_type_id': volume_type.get_id()}) 108 self.reload()109111 """ 112 Disassociate QoS specs from all associations 113 114 @rtype: None 115 """ 116 self._http.get(self._url_resource_path, self._id, 'disassociate_all') 117 self.reload()121 """manager class for QoS specifications on Block Storage V2 API""" 122 123 resource_class = Resource 124 service_type = 'volume' 125 _attr_mapping = ATTRIBUTE_MAPPING 126 _has_extra_attr = True 127 _json_resource_key = 'qos_specs' 128 _json_resources_key = 'qos_specs' 129 _url_resource_list_path = '/qos-specs' 130 _url_resource_path = '/qos-specs' 131153133 specs = kwargs.pop('specs') 134 kwargs.update(specs) 135 return super(Manager, self)._json2attr(kwargs)136138 """ 139 Create a snapshot of a volume 140 141 @keyword name: QoS specification name 142 @type name: str 143 @keyword consumer: Consumer of the QoS specification 144 @type consumer: str 145 @keyword kwargs: key=value style spec 146 @type kwargs: str=str 147 @return: Created QoS specs 148 @rtype: yakumo.cinder.v2.qos.Resource 149 """ 150 return super(Manager, self).create(name=name, 151 consumer=consumer, 152 **kwargs)
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Thu Apr 27 11:48:55 2017 | http://epydoc.sourceforge.net |