e82a60a43e8770d3d731f48d2f47a066e7244dd9
[snaps.git] / snaps / domain / volume.py
1 # Copyright (c) 2017 Cable Television Laboratories, Inc. ("CableLabs")
2 #                    and others.  All rights reserved.
3 #
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:
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,
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
16
17 class VolumeType:
18     """
19     SNAPS domain object for Volume Types. Should contain attributes that
20     are shared amongst cloud providers
21     """
22     def __init__(self, name, volume_type_id, public, encryption, qos_spec):
23         """
24         Constructor
25         :param name: the volume's name
26         :param volume_type_id: the volume type's id
27         :param public: True if public
28         :param encryption: instance of a VolumeTypeEncryption domain object
29         :param qos_spec: instance of a QoSSpec domain object
30         """
31         self.name = name
32         self.id = volume_type_id
33         self.public = public
34         self.encryption = encryption
35         self.qos_spec = qos_spec
36
37     def __eq__(self, other):
38         return (self.name == other.name and self.id == other.id
39                 and self.public == other.public
40                 and self.encryption == other.encryption
41                 and self.qos_spec == other.qos_spec)
42
43
44 class VolumeTypeEncryption:
45     """
46     SNAPS domain object for Volume Types. Should contain attributes that
47     are shared amongst cloud providers
48     """
49     def __init__(self, volume_encryption_id, volume_type_id,
50                  control_location, provider, cipher, key_size):
51         """
52         Constructor
53         :param volume_encryption_id: the encryption id
54         :param volume_type_id: the associated volume type's id
55         :param control_location: front-end | back-end
56         :param provider: the encryption provider class
57         :param cipher: the encryption cipher
58         :param key_size: the encryption key size
59         """
60         self.id = volume_encryption_id
61         self.volume_type_id = volume_type_id
62         self.control_location = control_location
63         self.provider = provider
64         self.cipher = cipher
65         self.key_size = key_size
66
67     def __eq__(self, other):
68         return (self.id == other.id
69                 and self.volume_type_id == other.volume_type_id
70                 and self.control_location == other.control_location
71                 and self.provider == other.provider
72                 and self.cipher == other.cipher
73                 and self.key_size == other.key_size)
74
75
76 class QoSSpec:
77     """
78     SNAPS domain object for Volume Types. Should contain attributes that
79     are shared amongst cloud providers
80     """
81     def __init__(self, name, spec_id, consumer):
82         """
83         Constructor
84         :param name: the volume's name
85         :param spec_id: the QoS Spec's id
86         """
87         self.name = name
88         self.id = spec_id
89         self.consumer = consumer
90
91     def __eq__(self, other):
92         return (self.name == other.name and self.id == other.id
93                 and self.consumer == other.consumer)