Merge "trivial: Correct docstrings for 'delete' proxy calls" into feature/r1

This commit is contained in:
Zuul 2021-11-25 17:40:35 +00:00 committed by Gerrit Code Review
commit 112fbf641a
2 changed files with 46 additions and 32 deletions

View File

@ -98,11 +98,13 @@ class Proxy(proxy.Proxy):
""" """
return self._create(_device_profile.DeviceProfile, **attrs) return self._create(_device_profile.DeviceProfile, **attrs)
def delete_device_profile(self, name_or_id, ignore_missing=True): def delete_device_profile(self, device_profile, ignore_missing=True):
"""Delete a device profile """Delete a device profile
:param name_or_id: The value can be either the ID or name of :param device_profile: The value can be either the ID of a device
a device profile. profile or a
:class:`~openstack.accelerator.v2.device_profile.DeviceProfile`
instance.
:param bool ignore_missing: When set to ``False`` :param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be :class:`~openstack.exceptions.ResourceNotFound` will be
raised when the device profile does not exist. raised when the device profile does not exist.
@ -110,8 +112,10 @@ class Proxy(proxy.Proxy):
attempting to delete a nonexistent device profile. attempting to delete a nonexistent device profile.
:returns: ``None`` :returns: ``None``
""" """
return self._delete(_device_profile.DeviceProfile, return self._delete(
name_or_id, ignore_missing=ignore_missing) _device_profile.DeviceProfile,
device_profile,
ignore_missing=ignore_missing)
def get_device_profile(self, uuid, fields=None): def get_device_profile(self, uuid, fields=None):
"""Get a single device profile. """Get a single device profile.
@ -141,19 +145,25 @@ class Proxy(proxy.Proxy):
""" """
return self._create(_arq.AcceleratorRequest, **attrs) return self._create(_arq.AcceleratorRequest, **attrs)
def delete_accelerator_request(self, name_or_id, ignore_missing=True): def delete_accelerator_request(
"""Delete a device profile. self, accelerator_request, ignore_missing=True,
):
"""Delete a device profile
:param name_or_id: The value can be either the ID or name of :param device_profile: The value can be either the ID of a device
an accelerator request. profile or a
:class:`~openstack.accelerator.v2.device_profile.DeviceProfile`
instance.
:param bool ignore_missing: When set to ``False`` :param bool ignore_missing: When set to ``False``
:class:`~openstack.exceptions.ResourceNotFound` will be :class:`~openstack.exceptions.ResourceNotFound` will be raised when
raised when the device profile does not exist. the device profile does not exist.
When set to ``True``, no exception will be set when When set to ``True``, no exception will be set when attempting to
attempting to delete a nonexistent accelerator request. delete a nonexistent accelerator request.
:returns: ``None`` :returns: ``None``
""" """
return self._delete(_arq.AcceleratorRequest, name_or_id, return self._delete(
_arq.AcceleratorRequest,
accelerator_request,
ignore_missing=ignore_missing) ignore_missing=ignore_missing)
def get_accelerator_request(self, uuid, fields=None): def get_accelerator_request(self, uuid, fields=None):

View File

@ -21,10 +21,10 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
def list_deployables(self, filters=None): def list_deployables(self, filters=None):
"""List all available deployables. """List all available deployables.
:param filters: (optional) dict of filter conditions to push down :param filters: (optional) dict of filter conditions to push down
:returns: A list of deployable info. :returns: A list of deployable info.
""" """
# Translate None from search interface to empty {} for kwargs below # Translate None from search interface to empty {} for kwargs below
if not filters: if not filters:
filters = {} filters = {}
@ -32,10 +32,10 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
def list_devices(self, filters=None): def list_devices(self, filters=None):
"""List all devices. """List all devices.
:param filters: (optional) dict of filter conditions to push down :param filters: (optional) dict of filter conditions to push down
:returns: A list of device info. :returns: A list of device info.
""" """
# Translate None from search interface to empty {} for kwargs below # Translate None from search interface to empty {} for kwargs below
if not filters: if not filters:
filters = {} filters = {}
@ -43,10 +43,10 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
def list_device_profiles(self, filters=None): def list_device_profiles(self, filters=None):
"""List all device_profiles. """List all device_profiles.
:param filters: (optional) dict of filter conditions to push down :param filters: (optional) dict of filter conditions to push down
:returns: A list of device profile info. :returns: A list of device profile info.
""" """
# Translate None from search interface to empty {} for kwargs below # Translate None from search interface to empty {} for kwargs below
if not filters: if not filters:
filters = {} filters = {}
@ -54,19 +54,20 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
def create_device_profile(self, attrs): def create_device_profile(self, attrs):
"""Create a device_profile. """Create a device_profile.
:param attrs: The info of device_profile to be created. :param attrs: The info of device_profile to be created.
:returns: A ``munch.Munch`` of the created device_profile. :returns: A ``munch.Munch`` of the created device_profile.
""" """
return self.accelerator.create_device_profile(**attrs) return self.accelerator.create_device_profile(**attrs)
def delete_device_profile(self, name_or_id, filters): def delete_device_profile(self, name_or_id, filters):
"""Delete a device_profile. """Delete a device_profile.
:param name_or_id: The Name(or uuid) of device_profile to be deleted.
:param name_or_id: The name or uuid of the device profile to be
deleted.
:param filters: dict of filter conditions to push down :param filters: dict of filter conditions to push down
:returns: True if delete succeeded, False otherwise. :returns: True if delete succeeded, False otherwise.
""" """
device_profile = self.accelerator.get_device_profile( device_profile = self.accelerator.get_device_profile(
name_or_id, name_or_id,
filters filters
@ -74,20 +75,20 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
if device_profile is None: if device_profile is None:
self.log.debug( self.log.debug(
"device_profile %s not found for deleting", "device_profile %s not found for deleting",
name_or_id name_or_id,
) )
return False return False
self.accelerator.delete_device_profile(name_or_id=name_or_id) self.accelerator.delete_device_profile(device_profile=device_profile)
return True return True
def list_accelerator_requests(self, filters=None): def list_accelerator_requests(self, filters=None):
"""List all accelerator_requests. """List all accelerator_requests.
:param filters: (optional) dict of filter conditions to push down :param filters: (optional) dict of filter conditions to push down
:returns: A list of accelerator request info. :returns: A list of accelerator request info.
""" """
# Translate None from search interface to empty {} for kwargs below # Translate None from search interface to empty {} for kwargs below
if not filters: if not filters:
filters = {} filters = {}
@ -95,11 +96,12 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
def delete_accelerator_request(self, name_or_id, filters): def delete_accelerator_request(self, name_or_id, filters):
"""Delete a accelerator_request. """Delete a accelerator_request.
:param name_or_id: The Name(or uuid) of accelerator_request.
:param name_or_id: The name or UUID of the accelerator request to
be deleted.
:param filters: dict of filter conditions to push down :param filters: dict of filter conditions to push down
:returns: True if delete succeeded, False otherwise. :returns: True if delete succeeded, False otherwise.
""" """
accelerator_request = self.accelerator.get_accelerator_request( accelerator_request = self.accelerator.get_accelerator_request(
name_or_id, name_or_id,
filters filters
@ -107,29 +109,31 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
if accelerator_request is None: if accelerator_request is None:
self.log.debug( self.log.debug(
"accelerator_request %s not found for deleting", "accelerator_request %s not found for deleting",
name_or_id name_or_id,
) )
return False return False
self.accelerator.delete_accelerator_request(name_or_id=name_or_id) self.accelerator.delete_accelerator_request(
accelerator_request=accelerator_request,
)
return True return True
def create_accelerator_request(self, attrs): def create_accelerator_request(self, attrs):
"""Create an accelerator_request. """Create an accelerator_request.
:param attrs: The info of accelerator_request to be created. :param attrs: The info of accelerator_request to be created.
:returns: A ``munch.Munch`` of the created accelerator_request. :returns: A ``munch.Munch`` of the created accelerator_request.
""" """
return self.accelerator.create_accelerator_request(**attrs) return self.accelerator.create_accelerator_request(**attrs)
def bind_accelerator_request(self, uuid, properties): def bind_accelerator_request(self, uuid, properties):
"""Bind an accelerator to VM. """Bind an accelerator to VM.
:param uuid: The uuid of the accelerator_request to be binded. :param uuid: The uuid of the accelerator_request to be binded.
:param properties: The info of VM that will bind the accelerator. :param properties: The info of VM that will bind the accelerator.
:returns: True if bind succeeded, False otherwise. :returns: True if bind succeeded, False otherwise.
""" """
accelerator_request = self.accelerator.get_accelerator_request(uuid) accelerator_request = self.accelerator.get_accelerator_request(uuid)
if accelerator_request is None: if accelerator_request is None:
self.log.debug( self.log.debug(
@ -141,11 +145,11 @@ class AcceleratorCloudMixin(_normalize.Normalizer):
def unbind_accelerator_request(self, uuid, properties): def unbind_accelerator_request(self, uuid, properties):
"""Unbind an accelerator from VM. """Unbind an accelerator from VM.
:param uuid: The uuid of the accelerator_request to be unbinded. :param uuid: The uuid of the accelerator_request to be unbinded.
:param properties: The info of VM that will unbind the accelerator. :param properties: The info of VM that will unbind the accelerator.
:returns: True if unbind succeeded, False otherwise. :returns: True if unbind succeeded, False otherwise.
""" """
accelerator_request = self.accelerator.get_accelerator_request(uuid) accelerator_request = self.accelerator.get_accelerator_request(uuid)
if accelerator_request is None: if accelerator_request is None:
self.log.debug( self.log.debug(