summaryrefslogtreecommitdiff
path: root/novaclient/v2/volume_types.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/volume_types.py')
-rw-r--r--novaclient/v2/volume_types.py77
1 files changed, 77 insertions, 0 deletions
diff --git a/novaclient/v2/volume_types.py b/novaclient/v2/volume_types.py
new file mode 100644
index 0000000..3d1c7f5
--- /dev/null
+++ b/novaclient/v2/volume_types.py
@@ -0,0 +1,77 @@
1# Copyright (c) 2011 Rackspace US, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17"""
18Volume Type interface.
19"""
20
21from novaclient import base
22
23
24class VolumeType(base.Resource):
25 """
26 A Volume Type is the type of volume to be created
27 """
28 def __repr__(self):
29 return "<Volume Type: %s>" % self.name
30
31
32class VolumeTypeManager(base.ManagerWithFind):
33 """
34 Manage :class:`VolumeType` resources.
35 """
36 resource_class = VolumeType
37
38 def list(self):
39 """
40 Get a list of all volume types.
41
42 :rtype: list of :class:`VolumeType`.
43 """
44 return self._list("/types", "volume_types")
45
46 def get(self, volume_type):
47 """
48 Get a specific volume type.
49
50 :param volume_type: The ID of the :class:`VolumeType` to get.
51 :rtype: :class:`VolumeType`
52 """
53 return self._get("/types/%s" % base.getid(volume_type), "volume_type")
54
55 def delete(self, volume_type):
56 """
57 Delete a specific volume_type.
58
59 :param volume_type: The ID of the :class:`VolumeType` to get.
60 """
61 self._delete("/types/%s" % base.getid(volume_type))
62
63 def create(self, name):
64 """
65 Create a volume type.
66
67 :param name: Descriptive name of the volume type
68 :rtype: :class:`VolumeType`
69 """
70
71 body = {
72 "volume_type": {
73 "name": name,
74 }
75 }
76
77 return self._create("/types", body, "volume_type")