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
|
# 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.image.v1 import image as _image
from openstack import proxy
class Proxy(proxy.BaseProxy):
def upload_image(self, **attrs):
"""Upload a new image from attributes
:param dict attrs: Keyword arguments which will be used to create
a :class:`~openstack.image.v1.image.Image`,
comprised of the properties on the Image class.
:returns: The results of image creation
:rtype: :class:`~openstack.image.v1.image.Image`
"""
return self._create(_image.Image, **attrs)
def delete_image(self, image, ignore_missing=True):
"""Delete an image
:param image: The value can be either the ID of an image or a
:class:`~openstack.image.v1.image.Image` instance.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the image does not exist.
When set to ``True``, no exception will be set when
attempting to delete a nonexistent image.
:returns: ``None``
"""
self._delete(_image.Image, image, ignore_missing=ignore_missing)
def find_image(self, name_or_id, ignore_missing=True):
"""Find a single image
:param name_or_id: The name or ID of a image.
:param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be
raised when the resource does not exist.
When set to ``True``, None will be returned when
attempting to find a nonexistent resource.
:returns: One :class:`~openstack.image.v1.image.Image` or None
"""
return self._find(_image.Image, name_or_id,
ignore_missing=ignore_missing)
def get_image(self, image):
"""Get a single image
:param image: The value can be the ID of an image or a
:class:`~openstack.image.v1.image.Image` instance.
:returns: One :class:`~openstack.image.v1.image.Image`
:raises: :class:`~openstack.exceptions.ResourceNotFound`
when no resource can be found.
"""
return self._get(_image.Image, image)
def images(self, **query):
"""Return a generator of images
:param kwargs \*\*query: Optional query parameters to be sent to limit
the resources being returned.
:returns: A generator of image objects
:rtype: :class:`~openstack.image.v1.image.Image`
"""
return self._list(_image.Image, paginated=True, **query)
def update_image(self, image, **attrs):
"""Update a image
:param image: Either the ID of a image or a
:class:`~openstack.image.v1.image.Image` instance.
:attrs kwargs: The attributes to update on the image represented
by ``value``.
:returns: The updated image
:rtype: :class:`~openstack.image.v1.image.Image`
"""
return self._update(_image.Image, image, **attrs)
|