1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 # and others. All rights reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at:
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 from neutronclient.common.utils import str2bool
18 class VolumeConfig(object):
19 def __init__(self, **kwargs):
22 :param name: the volume's name (required)
23 :param project_name: the name of the project to associate (optional)
24 note: due to a bug in the Cinder API, this functionality will not
25 work. see https://bugs.launchpad.net/cinder/+bug/1641982
26 :param description: the volume's name (optional)
27 :param size: the volume's size in GB (default 1)
28 :param image_name: when a glance image is used for the image source
30 :param type_name: the associated volume's type name (optional)
31 :param availability_zone: the name of the compute server on which to
32 deploy the volume (optional)
33 :param multi_attach: when true, volume can be attached to more than one
34 server (default False)
37 self.name = kwargs.get('name')
38 self.project_name = kwargs.get('project_name')
39 self.description = kwargs.get('description')
40 self.size = int(kwargs.get('size', 1))
41 self.image_name = kwargs.get('image_name')
42 self.type_name = kwargs.get('type_name')
43 self.availability_zone = kwargs.get('availability_zone')
45 if kwargs.get('multi_attach'):
46 self.multi_attach = str2bool(str(kwargs.get('multi_attach')))
48 self.multi_attach = False
51 raise VolumeConfigError("The attribute name is required")
54 class VolumeConfigError(Exception):
56 Exception to be thrown when an volume settings are incorrect
59 def __init__(self, message):
60 Exception.__init__(self, message)