OpenStack Compute (Nova) Client
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

assisted_volume_snapshots.py 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. Assisted volume snapshots - to be used by Cinder and not end users.
  16. """
  17. import json
  18. from novaclient import base
  19. class Snapshot(base.Resource):
  20. def __repr__(self):
  21. return "<Snapshot: %s>" % self.id
  22. def delete(self):
  23. """
  24. Delete this snapshot.
  25. """
  26. self.manager.delete(self)
  27. class AssistedSnapshotManager(base.Manager):
  28. resource_class = Snapshot
  29. def create(self, volume_id, create_info):
  30. body = {'snapshot': {'volume_id': volume_id,
  31. 'create_info': create_info}}
  32. return self._create('/os-assisted-volume-snapshots', body, 'snapshot')
  33. def delete(self, snapshot, delete_info):
  34. self._delete("/os-assisted-volume-snapshots/%s?delete_info=%s" % (
  35. base.getid(snapshot), json.dumps(delete_info)))
  36. manager_class = AssistedSnapshotManager
  37. name = 'assisted_volume_snapshots'