summaryrefslogtreecommitdiff
path: root/novaclient/v2/server_groups.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/server_groups.py')
-rw-r--r--novaclient/v2/server_groups.py71
1 files changed, 71 insertions, 0 deletions
diff --git a/novaclient/v2/server_groups.py b/novaclient/v2/server_groups.py
new file mode 100644
index 0000000..a5205e7
--- /dev/null
+++ b/novaclient/v2/server_groups.py
@@ -0,0 +1,71 @@
1# Copyright (c) 2014 VMware, Inc.
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"""
17Server group interface.
18"""
19
20from novaclient import base
21
22
23class ServerGroup(base.Resource):
24 """
25 A server group.
26 """
27 NAME_ATTR = 'server_group_name'
28
29 def __repr__(self):
30 return '<ServerGroup: %s>' % self.id
31
32 def delete(self):
33 self.manager.delete(self.id)
34
35
36class ServerGroupsManager(base.ManagerWithFind):
37 """
38 Manage :class:`ServerGroup` resources.
39 """
40 resource_class = ServerGroup
41
42 def list(self):
43 """Get a list of all server groups.
44
45 :rtype: list of :class:`ServerGroup`.
46 """
47 return self._list('/os-server-groups', 'server_groups')
48
49 def get(self, id):
50 """Get a specific server group.
51
52 :param id: The ID of the :class:`ServerGroup` to get.
53 :rtype: :class:`ServerGroup`
54 """
55 return self._get('/os-server-groups/%s' % id,
56 'server_group')
57
58 def delete(self, id):
59 """Delete a specific server group.
60
61 :param id: The ID of the :class:`ServerGroup` to delete.
62 """
63 self._delete('/os-server-groups/%s' % id)
64
65 def create(self, **kwargs):
66 """Create (allocate) a server group.
67
68 :rtype: list of :class:`ServerGroup`
69 """
70 body = {'server_group': kwargs}
71 return self._create('/os-server-groups', body, 'server_group')