1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
from openstack.block_store.v2 import snapshot as _snapshot
from openstack.block_store.v2 import type as _type
from openstack.block_store.v2 import volume as _volume
from openstack import proxy
class Proxy(proxy.BaseProxy):
def get_snapshot(self, snapshot):
"""Get a single snapshot
:param snapshot: The value can be the ID of a snapshot or a
:class:`~openstack.volume.v2.snapshot.Snapshot`
instance.
:returns: One :class:`~openstack.volume.v2.snapshot.Snapshot`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_snapshot.Snapshot, snapshot)
def create_snapshot(self, **attrs):
"""Create a new snapshot from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.volume.v2.snapshot.Snapshot`,
comprised of the properties on the Snapshot class.
:returns: The results of snapshot creation
:rtype: :class:`~openstack.volume.v2.snapshot.Snapshot`
"""
return self._create(_snapshot.Snapshot, **attrs)
def delete_snapshot(self, snapshot, ignore_missing=True):
"""Delete a snapshot
:param snapshot: The value can be either the ID of a snapshot or a
:class:`~openstack.volume.v2.snapshot.Snapshot`
instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the snapshot does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent snapshot.
:returns: ``None``
"""
self._delete(_snapshot.Snapshot, snapshot,
ignore_missing=ignore_missing)
def get_type(self, type):
"""Get a single type
:param type: The value can be the ID of a type or a
:class:`~openstack.volume.v2.type.Type` instance.
:returns: One :class:`~openstack.volume.v2.type.Type`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_type.Type, type)
def create_type(self, **attrs):
"""Create a new type from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.volume.v2.type.Type`,
comprised of the properties on the Type class.
:returns: The results of type creation
:rtype: :class:`~openstack.volume.v2.type.Type`
"""
return self._create(_type.Type, **attrs)
def delete_type(self, type, ignore_missing=True):
"""Delete a type
:param type: The value can be either the ID of a type or a
:class:`~openstack.volume.v2.type.Type` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the type does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent type.
:returns: ``None``
"""
self._delete(_type.Type, type, ignore_missing=ignore_missing)
def get_volume(self, volume):
"""Get a single volume
:param volume: The value can be the ID of a volume or a
:class:`~openstack.volume.v2.volume.Volume` instance.
:returns: One :class:`~openstack.volume.v2.volume.Volume`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_volume.Volume, volume)
def create_volume(self, **attrs):
"""Create a new volume from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.volume.v2.volume.Volume`,
comprised of the properties on the Volume class.
:returns: The results of volume creation
:rtype: :class:`~openstack.volume.v2.volume.Volume`
"""
return self._create(_volume.Volume, **attrs)
def delete_volume(self, volume, ignore_missing=True):
"""Delete a volume
:param volume: The value can be either the ID of a volume or a
:class:`~openstack.volume.v2.volume.Volume` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the volume does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent volume.
:returns: ``None``
"""
self._delete(_volume.Volume, volume, ignore_missing=ignore_missing)
|