summaryrefslogtreecommitdiff
path: root/novaclient/v2/contrib/assisted_volume_snapshots.py
diff options
context:
space:
mode:
Diffstat (limited to 'novaclient/v2/contrib/assisted_volume_snapshots.py')
-rw-r--r--novaclient/v2/contrib/assisted_volume_snapshots.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/novaclient/v2/contrib/assisted_volume_snapshots.py b/novaclient/v2/contrib/assisted_volume_snapshots.py
new file mode 100644
index 0000000..ce1a041
--- /dev/null
+++ b/novaclient/v2/contrib/assisted_volume_snapshots.py
@@ -0,0 +1,48 @@
1# Copyright (C) 2013, Red Hat, Inc.
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may
4# not use this file except in compliance with the License. You may obtain
5# 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, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations
13# under the License.
14
15"""
16Assisted volume snapshots - to be used by Cinder and not end users.
17"""
18
19import json
20
21from novaclient import base
22
23
24class Snapshot(base.Resource):
25 def __repr__(self):
26 return "<Snapshot: %s>" % self.id
27
28 def delete(self):
29 """
30 Delete this snapshot.
31 """
32 self.manager.delete(self)
33
34
35class AssistedSnapshotManager(base.Manager):
36 resource_class = Snapshot
37
38 def create(self, volume_id, create_info):
39 body = {'snapshot': {'volume_id': volume_id,
40 'create_info': create_info}}
41 return self._create('/os-assisted-volume-snapshots', body, 'snapshot')
42
43 def delete(self, snapshot, delete_info):
44 self._delete("/os-assisted-volume-snapshots/%s?delete_info=%s" % (
45 base.getid(snapshot), json.dumps(delete_info)))
46
47manager_class = AssistedSnapshotManager
48name = 'assisted_volume_snapshots'