cloud: Replace use of aliased exceptions
Change-Id: I273e7554af766b15deb5ac8f38a6793b119a3bb9 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
parent
e2940efea6
commit
621b561c6c
@ -17,7 +17,7 @@ import warnings
|
||||
import jsonpatch
|
||||
|
||||
from openstack.baremetal.v1._proxy import Proxy
|
||||
from openstack.cloud import exc
|
||||
from openstack import exceptions
|
||||
from openstack import warnings as os_warnings
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ class BaremetalCloudMixin:
|
||||
"""
|
||||
try:
|
||||
return self.baremetal.find_node(name_or_id, ignore_missing=False)
|
||||
except exc.OpenStackCloudResourceNotFound:
|
||||
except exceptions.NotFoundException:
|
||||
return None
|
||||
|
||||
def get_machine_by_mac(self, mac):
|
||||
@ -130,7 +130,7 @@ class BaremetalCloudMixin:
|
||||
# we need to move the machine back to manageable first.
|
||||
if node.provision_state == 'available':
|
||||
if node.instance_id:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Refusing to inspect available machine %(node)s "
|
||||
"which is associated with an instance "
|
||||
"(instance_uuid %(inst)s)"
|
||||
@ -146,7 +146,7 @@ class BaremetalCloudMixin:
|
||||
)
|
||||
|
||||
if node.provision_state not in ('manageable', 'inspect failed'):
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Machine %(node)s must be in 'manageable', 'inspect failed' "
|
||||
"or 'available' provision state to start inspection, the "
|
||||
"current state is %(state)s"
|
||||
@ -215,29 +215,24 @@ class BaremetalCloudMixin:
|
||||
]
|
||||
|
||||
Alternatively, you can provide an array of MAC addresses.
|
||||
|
||||
:param wait: Boolean value, defaulting to false, to wait for the node
|
||||
to reach the available state where the node can be provisioned. It
|
||||
must be noted, when set to false, the method will still wait for
|
||||
locks to clear before sending the next required command.
|
||||
|
||||
:param timeout: Integer value, defautling to 3600 seconds, for the wait
|
||||
state to reach completion.
|
||||
|
||||
:param lock_timeout: Integer value, defaulting to 600 seconds, for
|
||||
locks to clear.
|
||||
|
||||
:param provision_state: The expected provision state, one of "enroll"
|
||||
"manageable" or "available". Using "available" results in automated
|
||||
cleaning.
|
||||
|
||||
:param kwargs: Key value pairs to be passed to the Ironic API,
|
||||
including uuid, name, chassis_uuid, driver_info, properties.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:rtype: :class:`~openstack.baremetal.v1.node.Node`.
|
||||
:returns: Current state of the node.
|
||||
:rtype: :class:`~openstack.baremetal.v1.node.Node`.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
if provision_state not in ('enroll', 'manageable', 'available'):
|
||||
raise ValueError(
|
||||
@ -301,14 +296,13 @@ class BaremetalCloudMixin:
|
||||
:param nics: An array of strings that consist of MAC addresses
|
||||
to be removed.
|
||||
:param string uuid: The UUID of the node to be deleted.
|
||||
|
||||
:param wait: DEPRECATED, do not use.
|
||||
|
||||
:param timeout: Integer value, representing seconds with a default
|
||||
value of 600, which controls the maximum amount of time to block
|
||||
until a lock is released on machine.
|
||||
|
||||
:raises: OpenStackCloudException on operation failure.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
failure.
|
||||
"""
|
||||
if wait is not None:
|
||||
warnings.warn(
|
||||
@ -319,7 +313,7 @@ class BaremetalCloudMixin:
|
||||
machine = self.get_machine(uuid)
|
||||
invalid_states = ['active', 'cleaning', 'clean wait', 'clean failed']
|
||||
if machine['provision_state'] in invalid_states:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Error unregistering node '%s' due to current provision "
|
||||
"state '%s'" % (uuid, machine['provision_state'])
|
||||
)
|
||||
@ -330,8 +324,8 @@ class BaremetalCloudMixin:
|
||||
# failure, and resubitted the request in python-ironicclient.
|
||||
try:
|
||||
self.baremetal.wait_for_node_reservation(machine, timeout)
|
||||
except exc.OpenStackCloudException as e:
|
||||
raise exc.OpenStackCloudException(
|
||||
except exceptions.SDKException as e:
|
||||
raise exceptions.SDKException(
|
||||
"Error unregistering node '%s': Exception occured while"
|
||||
" waiting to be able to proceed: %s" % (machine['uuid'], e)
|
||||
)
|
||||
@ -375,10 +369,10 @@ class BaremetalCloudMixin:
|
||||
'value': 'administrator'
|
||||
})
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: Current state of the node.
|
||||
:rtype: :class:`~openstack.baremetal.v1.node.Node`.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
return self.baremetal.patch_node(name_or_id, patch)
|
||||
|
||||
@ -391,16 +385,16 @@ class BaremetalCloudMixin:
|
||||
:param string name_or_id: A machine name or UUID to be updated.
|
||||
:param attrs: Attributes to updated on the machine.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: Dictionary containing a machine sub-dictonary consisting
|
||||
of the updated data returned from the API update operation, and a
|
||||
list named changes which contains all of the API paths that
|
||||
received updates.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
machine = self.get_machine(name_or_id)
|
||||
if not machine:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Machine update failed to find Machine: %s. " % name_or_id
|
||||
)
|
||||
|
||||
@ -411,7 +405,7 @@ class BaremetalCloudMixin:
|
||||
machine._to_munch(), new_config
|
||||
)
|
||||
except Exception as e:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Machine update failed - Error generating JSON patch object "
|
||||
"for submission to the API. Machine: %s Error: %s"
|
||||
% (name_or_id, e)
|
||||
@ -504,10 +498,10 @@ class BaremetalCloudMixin:
|
||||
representing the amount of time to wait for the desire end state to
|
||||
be reached.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: Current state of the machine upon exit of the method.
|
||||
:rtype: :class:`~openstack.baremetal.v1.node.Node`.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
node = self.baremetal.set_node_provision_state(
|
||||
name_or_id,
|
||||
@ -534,9 +528,9 @@ class BaremetalCloudMixin:
|
||||
the baremetal API to allow for notation as to why the node is in
|
||||
maintenance state.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: None
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
if state:
|
||||
self.baremetal.set_node_maintenance(name_or_id, reason)
|
||||
@ -554,9 +548,9 @@ class BaremetalCloudMixin:
|
||||
:param string name_or_id: The Name or UUID value representing the
|
||||
baremetal node.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: None
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.baremetal.unset_node_maintenance(name_or_id)
|
||||
|
||||
@ -568,9 +562,9 @@ class BaremetalCloudMixin:
|
||||
:params string name_or_id: A string representing the baremetal
|
||||
node to have power turned to an "on" state.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: None
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.baremetal.set_node_power_state(name_or_id, 'power on')
|
||||
|
||||
@ -582,9 +576,9 @@ class BaremetalCloudMixin:
|
||||
:params string name_or_id: A string representing the baremetal
|
||||
node to have power turned to an "off" state.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns:
|
||||
:returns: None
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.baremetal.set_node_power_state(name_or_id, 'power off')
|
||||
|
||||
@ -598,9 +592,9 @@ class BaremetalCloudMixin:
|
||||
:params string name_or_id: A string representing the baremetal
|
||||
node to have power turned to an "off" state.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
|
||||
:returns: None
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.baremetal.set_node_power_state(name_or_id, 'rebooting')
|
||||
|
||||
@ -637,7 +631,8 @@ class BaremetalCloudMixin:
|
||||
|
||||
DEPRECATED, use ``wait_for_node_reservation`` on the `baremetal` proxy.
|
||||
|
||||
:raises: OpenStackCloudException upon client failure.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` upon client
|
||||
failure.
|
||||
:returns: None
|
||||
"""
|
||||
warnings.warn(
|
||||
|
@ -15,7 +15,6 @@ import warnings
|
||||
from openstack.block_storage.v3._proxy import Proxy
|
||||
from openstack.block_storage.v3 import quota_set as _qs
|
||||
from openstack.cloud import _utils
|
||||
from openstack.cloud import exc
|
||||
from openstack import exceptions
|
||||
from openstack import warnings as os_warnings
|
||||
|
||||
@ -134,9 +133,12 @@ class BlockStorageCloudMixin:
|
||||
:param bootable: (optional) Make this volume bootable. If set, wait
|
||||
will also be set to true.
|
||||
:param kwargs: Keyword arguments as expected for cinder client.
|
||||
|
||||
:returns: The created volume ``Volume`` object.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
if bootable is not None:
|
||||
wait = True
|
||||
@ -144,7 +146,7 @@ class BlockStorageCloudMixin:
|
||||
if image:
|
||||
image_obj = self.get_image(image)
|
||||
if not image_obj:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Image {image} was requested as the basis for a new"
|
||||
" volume, but was not found on the cloud".format(
|
||||
image=image
|
||||
@ -157,7 +159,7 @@ class BlockStorageCloudMixin:
|
||||
volume = self.block_storage.create_volume(**kwargs)
|
||||
|
||||
if volume['status'] == 'error':
|
||||
raise exc.OpenStackCloudException("Error in creating volume")
|
||||
raise exceptions.SDKException("Error in creating volume")
|
||||
|
||||
if wait:
|
||||
self.block_storage.wait_for_status(volume, wait=timeout)
|
||||
@ -177,9 +179,7 @@ class BlockStorageCloudMixin:
|
||||
|
||||
volume = self.get_volume(name_or_id)
|
||||
if not volume:
|
||||
raise exc.OpenStackCloudException(
|
||||
"Volume %s not found." % name_or_id
|
||||
)
|
||||
raise exceptions.SDKException("Volume %s not found." % name_or_id)
|
||||
|
||||
volume = self.block_storage.update_volume(volume, **kwargs)
|
||||
|
||||
@ -192,15 +192,17 @@ class BlockStorageCloudMixin:
|
||||
:param bool bootable: Whether the volume should be bootable.
|
||||
(Defaults to True)
|
||||
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:returns: None
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
|
||||
volume = self.get_volume(name_or_id)
|
||||
|
||||
if not volume:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Volume {name_or_id} does not exist".format(
|
||||
name_or_id=name_or_id
|
||||
)
|
||||
@ -222,9 +224,12 @@ class BlockStorageCloudMixin:
|
||||
:param timeout: Seconds to wait for volume deletion. None is forever.
|
||||
:param force: Force delete volume even if the volume is in deleting
|
||||
or error_deleting state.
|
||||
|
||||
:returns: True if deletion was successful, else False.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
volume = self.block_storage.find_volume(name_or_id)
|
||||
|
||||
@ -272,7 +277,7 @@ class BlockStorageCloudMixin:
|
||||
if name_or_id:
|
||||
project = self.get_project(name_or_id)
|
||||
if not project:
|
||||
raise exc.OpenStackCloudException("project does not exist")
|
||||
raise exceptions.SDKException("project does not exist")
|
||||
params['project'] = project
|
||||
return self.block_storage.get_limits(**params)
|
||||
|
||||
@ -317,9 +322,12 @@ class BlockStorageCloudMixin:
|
||||
:param volume: The volume dict to detach.
|
||||
:param wait: If true, waits for volume to be detached.
|
||||
:param timeout: Seconds to wait for volume detachment. None is forever.
|
||||
|
||||
:returns: None
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.compute.delete_volume_attachment(
|
||||
server=server['id'],
|
||||
@ -354,19 +362,22 @@ class BlockStorageCloudMixin:
|
||||
:param device: The device name where the volume will attach.
|
||||
:param wait: If true, waits for volume to be attached.
|
||||
:param timeout: Seconds to wait for volume attachment. None is forever.
|
||||
|
||||
:returns: a volume attachment object.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
dev = self.get_volume_attach_device(volume, server['id'])
|
||||
if dev:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Volume %s already attached to server %s on device %s"
|
||||
% (volume['id'], server['id'], dev)
|
||||
)
|
||||
|
||||
if volume['status'] != 'available':
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Volume %s is not available. Status is '%s'"
|
||||
% (volume['id'], volume['status'])
|
||||
)
|
||||
@ -422,9 +433,12 @@ class BlockStorageCloudMixin:
|
||||
:param wait: If true, waits for volume snapshot to be created.
|
||||
:param timeout: Seconds to wait for volume snapshot creation. None is
|
||||
forever.
|
||||
|
||||
:returns: The created volume ``Snapshot`` object.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
kwargs = self._get_volume_kwargs(kwargs)
|
||||
payload = {'volume_id': volume_id, 'force': force}
|
||||
@ -500,9 +514,12 @@ class BlockStorageCloudMixin:
|
||||
forever.
|
||||
:param incremental: If set to true, the backup will be incremental.
|
||||
:param snapshot_id: The UUID of the source snapshot to back up.
|
||||
|
||||
:returns: The created volume ``Backup`` object.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
payload = {
|
||||
'name': name,
|
||||
@ -596,12 +613,14 @@ class BlockStorageCloudMixin:
|
||||
:param force: Allow delete in state other than error or available.
|
||||
:param wait: If true, waits for volume backup to be deleted.
|
||||
:param timeout: Seconds to wait for volume backup deletion. None is
|
||||
forever.
|
||||
:returns: True if deletion was successful, else False.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
"""
|
||||
forever.
|
||||
|
||||
:returns: True if deletion was successful, else False.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
volume_backup = self.get_volume_backup(name_or_id)
|
||||
|
||||
if not volume_backup:
|
||||
@ -627,9 +646,12 @@ class BlockStorageCloudMixin:
|
||||
:param wait: If true, waits for volume snapshot to be deleted.
|
||||
:param timeout: Seconds to wait for volume snapshot deletion. None is
|
||||
forever.
|
||||
|
||||
:returns: True if deletion was successful, else False.
|
||||
:raises: OpenStackCloudTimeout if wait time exceeded.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.ResourceTimeout` if wait time
|
||||
exceeded.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
volumesnapshot = self.get_volume_snapshot(name_or_id)
|
||||
|
||||
@ -764,11 +786,12 @@ class BlockStorageCloudMixin:
|
||||
|
||||
:param name_or_id: Name or unique ID of the volume type.
|
||||
:returns: A volume ``Type`` object if found, else None.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
volume_type = self.get_volume_type(name_or_id)
|
||||
if not volume_type:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"VolumeType not found: %s" % name_or_id
|
||||
)
|
||||
|
||||
@ -781,12 +804,14 @@ class BlockStorageCloudMixin:
|
||||
|
||||
:param name_or_id: ID or name of a volume_type
|
||||
:param project_id: A project id
|
||||
|
||||
:returns: None
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
volume_type = self.get_volume_type(name_or_id)
|
||||
if not volume_type:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"VolumeType not found: %s" % name_or_id
|
||||
)
|
||||
|
||||
@ -797,12 +822,14 @@ class BlockStorageCloudMixin:
|
||||
|
||||
:param name_or_id: ID or name of a volume_type
|
||||
:param project_id: A project id
|
||||
|
||||
:returns: None
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
volume_type = self.get_volume_type(name_or_id)
|
||||
if not volume_type:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"VolumeType not found: %s" % name_or_id
|
||||
)
|
||||
self.block_storage.remove_type_access(volume_type, project_id)
|
||||
@ -812,9 +839,10 @@ class BlockStorageCloudMixin:
|
||||
|
||||
:param name_or_id: project name or id
|
||||
:param kwargs: key/value pairs of quota name and quota value
|
||||
|
||||
:returns: None
|
||||
:raises: OpenStackCloudException if the resource to set the
|
||||
quota does not exist.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if the resource to
|
||||
set the quota does not exist.
|
||||
"""
|
||||
|
||||
proj = self.identity.find_project(name_or_id, ignore_missing=False)
|
||||
@ -827,8 +855,10 @@ class BlockStorageCloudMixin:
|
||||
"""Get volume quotas for a project
|
||||
|
||||
:param name_or_id: project name or id
|
||||
|
||||
:returns: A volume ``QuotaSet`` object with the quotas
|
||||
:raises: OpenStackCloudException if it's not a valid project
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if it's not a
|
||||
valid project
|
||||
"""
|
||||
proj = self.identity.find_project(name_or_id, ignore_missing=False)
|
||||
|
||||
@ -838,9 +868,10 @@ class BlockStorageCloudMixin:
|
||||
"""Delete volume quotas for a project
|
||||
|
||||
:param name_or_id: project name or id
|
||||
|
||||
:returns: The deleted volume ``QuotaSet`` object.
|
||||
:raises: OpenStackCloudException if it's not a valid project or the
|
||||
call failed
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if it's not a
|
||||
valid project or the call failed
|
||||
"""
|
||||
proj = self.identity.find_project(name_or_id, ignore_missing=False)
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
# limitations under the License.
|
||||
|
||||
from openstack.cloud import _utils
|
||||
from openstack.cloud import exc
|
||||
from openstack import exceptions
|
||||
|
||||
|
||||
class CoeCloudMixin:
|
||||
@ -20,8 +20,8 @@ class CoeCloudMixin:
|
||||
|
||||
:returns: A list of container infrastructure management ``Cluster``
|
||||
objects.
|
||||
:raises: ``OpenStackCloudException``: if something goes wrong during
|
||||
the OpenStack API call.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call.
|
||||
"""
|
||||
return list(self.container_infrastructure_management.clusters())
|
||||
|
||||
@ -35,8 +35,8 @@ class CoeCloudMixin:
|
||||
|
||||
:returns: A list of container infrastructure management ``Cluster``
|
||||
objects.
|
||||
:raises: ``OpenStackCloudException``: if something goes wrong during
|
||||
the OpenStack API call.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call.
|
||||
"""
|
||||
coe_clusters = self.list_coe_clusters()
|
||||
return _utils._filter_list(coe_clusters, name_or_id, filters)
|
||||
@ -77,11 +77,10 @@ class CoeCloudMixin:
|
||||
:param string cluster_template_id: ID of the cluster template to use.
|
||||
:param dict kwargs: Any other arguments to pass in.
|
||||
|
||||
:returns: a dict containing the cluster description
|
||||
:returns: The created container infrastructure management ``Cluster``
|
||||
object.
|
||||
:raises: ``OpenStackCloudException`` if something goes wrong during
|
||||
the OpenStack API call
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call
|
||||
"""
|
||||
cluster = self.container_infrastructure_management.create_cluster(
|
||||
name=name,
|
||||
@ -95,10 +94,11 @@ class CoeCloudMixin:
|
||||
"""Delete a COE cluster.
|
||||
|
||||
:param name_or_id: Name or unique ID of the cluster.
|
||||
|
||||
:returns: True if the delete succeeded, False if the
|
||||
cluster was not found.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
|
||||
cluster = self.get_coe_cluster(name_or_id)
|
||||
@ -122,11 +122,12 @@ class CoeCloudMixin:
|
||||
|
||||
:returns: The updated cluster ``Cluster`` object.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
cluster = self.get_coe_cluster(name_or_id)
|
||||
if not cluster:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"COE cluster %s not found." % name_or_id
|
||||
)
|
||||
|
||||
@ -158,8 +159,8 @@ class CoeCloudMixin:
|
||||
certificate that client will use to communicate with the cluster.
|
||||
|
||||
:returns: a dict representing the signed certs.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
return self.container_infrastructure_management.create_cluster_certificate( # noqa: E501
|
||||
cluster_uuid=cluster_id, csr=csr
|
||||
@ -172,9 +173,8 @@ class CoeCloudMixin:
|
||||
ClusterTemplates are always returned with full details.
|
||||
|
||||
:returns: a list of dicts containing the cluster template details.
|
||||
|
||||
:raises: ``OpenStackCloudException``: if something goes wrong during
|
||||
the OpenStack API call.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call.
|
||||
"""
|
||||
return list(
|
||||
self.container_infrastructure_management.cluster_templates()
|
||||
@ -191,9 +191,8 @@ class CoeCloudMixin:
|
||||
detailed output.
|
||||
|
||||
:returns: a list of dict containing the cluster templates
|
||||
|
||||
:raises: ``OpenStackCloudException``: if something goes wrong during
|
||||
the OpenStack API call.
|
||||
:raises: :class:`~openstack.exceptions.SDKException`: if something goes
|
||||
wrong during the OpenStack API call.
|
||||
"""
|
||||
cluster_templates = self.list_cluster_templates(detail=detail)
|
||||
return _utils._filter_list(cluster_templates, name_or_id, filters)
|
||||
@ -240,9 +239,8 @@ class CoeCloudMixin:
|
||||
Other arguments will be passed in kwargs.
|
||||
|
||||
:returns: a dict containing the cluster template description
|
||||
|
||||
:raises: ``OpenStackCloudException`` if something goes wrong during
|
||||
the OpenStack API call
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call
|
||||
"""
|
||||
cluster_template = (
|
||||
self.container_infrastructure_management.create_cluster_template(
|
||||
@ -260,10 +258,11 @@ class CoeCloudMixin:
|
||||
"""Delete a cluster template.
|
||||
|
||||
:param name_or_id: Name or unique ID of the cluster template.
|
||||
|
||||
:returns: True if the delete succeeded, False if the
|
||||
cluster template was not found.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
|
||||
cluster_template = self.get_cluster_template(name_or_id)
|
||||
@ -287,12 +286,12 @@ class CoeCloudMixin:
|
||||
:param name_or_id: Name or ID of the cluster template being updated.
|
||||
|
||||
:returns: an update cluster template.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
cluster_template = self.get_cluster_template(name_or_id)
|
||||
if not cluster_template:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Cluster template %s not found." % name_or_id
|
||||
)
|
||||
|
||||
@ -306,8 +305,9 @@ class CoeCloudMixin:
|
||||
|
||||
def list_magnum_services(self):
|
||||
"""List all Magnum services.
|
||||
:returns: a list of dicts containing the service details.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:returns: a list of dicts containing the service details.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
return list(self.container_infrastructure_management.services())
|
||||
|
@ -99,8 +99,9 @@ class ComputeCloudMixin:
|
||||
:param string include: If given, will return a flavor whose name
|
||||
contains this string as a substring.
|
||||
:param get_extra:
|
||||
|
||||
:returns: A compute ``Flavor`` object.
|
||||
:raises: :class:`~openstack.exceptions.OpenStackCloudException` if no
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if no
|
||||
matching flavour could be found.
|
||||
"""
|
||||
flavors = self.list_flavors(get_extra=get_extra)
|
||||
@ -109,7 +110,7 @@ class ComputeCloudMixin:
|
||||
not include or include in flavor['name']
|
||||
):
|
||||
return flavor
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Could not find a flavor with {ram} and '{include}'".format(
|
||||
ram=ram, include=include
|
||||
)
|
||||
@ -175,10 +176,11 @@ class ComputeCloudMixin:
|
||||
|
||||
:param name_or_id: Name or unique ID of the server group(s).
|
||||
:param filters: A dict containing additional filters to use.
|
||||
|
||||
:returns: A list of compute ``ServerGroup`` objects matching the search
|
||||
criteria.
|
||||
:raises: ``OpenStackCloudException``: if something goes wrong during
|
||||
the OpenStack API call.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call.
|
||||
"""
|
||||
server_groups = self.list_server_groups()
|
||||
return _utils._filter_list(server_groups, name_or_id, filters)
|
||||
@ -283,7 +285,8 @@ class ComputeCloudMixin:
|
||||
|
||||
:returns: False if server or security groups are undefined, True
|
||||
otherwise.
|
||||
:raises: ``OpenStackCloudException``, on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
server, security_groups = self._get_server_security_groups(
|
||||
server, security_groups
|
||||
@ -306,7 +309,8 @@ class ComputeCloudMixin:
|
||||
|
||||
:returns: False if server or security groups are undefined, True
|
||||
otherwise.
|
||||
:raises: ``OpenStackCloudException``, on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
server, security_groups = self._get_server_security_groups(
|
||||
server, security_groups
|
||||
@ -378,16 +382,18 @@ class ComputeCloudMixin:
|
||||
|
||||
:param name_or_id: (optional) project name or ID to get limits for
|
||||
if different from the current project
|
||||
:raises: OpenStackCloudException if it's not a valid project
|
||||
|
||||
:returns: A compute
|
||||
:class:`~openstack.compute.v2.limits.Limits.AbsoluteLimits` object.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if it's not a
|
||||
valid project
|
||||
"""
|
||||
params = {}
|
||||
project_id = None
|
||||
if name_or_id:
|
||||
proj = self.get_project(name_or_id)
|
||||
if not proj:
|
||||
raise exc.OpenStackCloudException("project does not exist")
|
||||
raise exceptions.SDKException("project does not exist")
|
||||
project_id = proj.id
|
||||
params['tenant_id'] = project_id
|
||||
return self.compute.get_limits(**params).absolute
|
||||
@ -468,21 +474,21 @@ class ComputeCloudMixin:
|
||||
|
||||
:returns: A string containing the text of the console log or an
|
||||
empty string if the cloud does not support console logs.
|
||||
:raises: OpenStackCloudException if an invalid server argument is given
|
||||
or if something else unforseen happens
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if an invalid
|
||||
server argument is given or if something else unforseen happens
|
||||
"""
|
||||
|
||||
if not isinstance(server, dict):
|
||||
server = self.get_server(server, bare=True)
|
||||
|
||||
if not server:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Console log requested for invalid server"
|
||||
)
|
||||
|
||||
try:
|
||||
return self._get_server_console_output(server['id'], length)
|
||||
except exc.OpenStackCloudBadRequest:
|
||||
except exceptions.BadRequestException:
|
||||
return ""
|
||||
|
||||
def _get_server_console_output(self, server_id, length=None):
|
||||
@ -582,8 +588,10 @@ class ComputeCloudMixin:
|
||||
|
||||
:param name: Name of the keypair being created.
|
||||
:param public_key: Public key for the new keypair.
|
||||
|
||||
:returns: The created compute ``Keypair`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
keypair = {
|
||||
'name': name,
|
||||
@ -598,8 +606,8 @@ class ComputeCloudMixin:
|
||||
:param name: Name of the keypair to delete.
|
||||
|
||||
:returns: True if delete succeeded, False otherwise.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
try:
|
||||
self.compute.delete_keypair(name, ignore_missing=False)
|
||||
@ -630,13 +638,15 @@ class ComputeCloudMixin:
|
||||
:param wait: If true, waits for image to be created.
|
||||
:param timeout: Seconds to wait for image creation. None is forever.
|
||||
:param metadata: Metadata to give newly-created image entity
|
||||
|
||||
:returns: The created image ``Image`` object.
|
||||
:raises: OpenStackCloudException if there are problems uploading
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if there are
|
||||
problems uploading
|
||||
"""
|
||||
if not isinstance(server, dict):
|
||||
server_obj = self.get_server(server, bare=True)
|
||||
if not server_obj:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Server {server} could not be found and therefore"
|
||||
" could not be snapshotted.".format(server=server)
|
||||
)
|
||||
@ -800,8 +810,10 @@ class ComputeCloudMixin:
|
||||
:param group: ServerGroup dict, name or id to boot the server in.
|
||||
If a group is provided in both scheduler_hints and in the group
|
||||
param, the group param will win. (Optional, defaults to None)
|
||||
|
||||
:returns: The created compute ``Server`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
# TODO(shade) Image is optional but flavor is not - yet flavor comes
|
||||
# after image in the argument list. Doh.
|
||||
@ -840,7 +852,7 @@ class ComputeCloudMixin:
|
||||
if group:
|
||||
group_obj = self.get_server_group(group)
|
||||
if not group_obj:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Server Group {group} was requested but was not found"
|
||||
" on the cloud".format(group=group)
|
||||
)
|
||||
@ -856,7 +868,7 @@ class ComputeCloudMixin:
|
||||
# Be nice and help the user out
|
||||
kwargs['nics'] = [kwargs['nics']]
|
||||
else:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'nics parameter to create_server takes a list of dicts.'
|
||||
' Got: {nics}'.format(nics=kwargs['nics'])
|
||||
)
|
||||
@ -871,7 +883,7 @@ class ComputeCloudMixin:
|
||||
else:
|
||||
network_obj = self.get_network(name_or_id=net_name)
|
||||
if not network_obj:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Network {network} is not a valid network in'
|
||||
' {cloud}:{region}'.format(
|
||||
network=network,
|
||||
@ -899,7 +911,7 @@ class ComputeCloudMixin:
|
||||
net_name = nic.pop('net-name')
|
||||
nic_net = self.get_network(net_name)
|
||||
if not nic_net:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Requested network {net} could not be found.".format(
|
||||
net=net_name
|
||||
)
|
||||
@ -908,7 +920,7 @@ class ComputeCloudMixin:
|
||||
for ip_key in ('v4-fixed-ip', 'v6-fixed-ip', 'fixed_ip'):
|
||||
fixed_ip = nic.pop(ip_key, None)
|
||||
if fixed_ip and net.get('fixed_ip'):
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Only one of v4-fixed-ip, v6-fixed-ip or fixed_ip"
|
||||
" may be given"
|
||||
)
|
||||
@ -923,7 +935,7 @@ class ComputeCloudMixin:
|
||||
utils.require_microversion(self.compute, '2.42')
|
||||
net['tag'] = nic.pop('tag')
|
||||
if nic:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Additional unsupported keys given for server network"
|
||||
" creation: {keys}".format(keys=nic.keys())
|
||||
)
|
||||
@ -1018,7 +1030,7 @@ class ComputeCloudMixin:
|
||||
if boot_volume:
|
||||
volume = self.get_volume(boot_volume)
|
||||
if not volume:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Volume {boot_volume} is not a valid volume'
|
||||
' in {cloud}:{region}'.format(
|
||||
boot_volume=boot_volume,
|
||||
@ -1041,7 +1053,7 @@ class ComputeCloudMixin:
|
||||
else:
|
||||
image_obj = self.get_image(image)
|
||||
if not image_obj:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Image {image} is not a valid image in'
|
||||
' {cloud}:{region}'.format(
|
||||
image=image,
|
||||
@ -1074,7 +1086,7 @@ class ComputeCloudMixin:
|
||||
for volume in volumes:
|
||||
volume_obj = self.get_volume(volume)
|
||||
if not volume_obj:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Volume {volume} is not a valid volume'
|
||||
' in {cloud}:{region}'.format(
|
||||
volume=volume,
|
||||
@ -1126,7 +1138,7 @@ class ComputeCloudMixin:
|
||||
# and pass it down into the IP stack.
|
||||
remaining_timeout = timeout - int(time.time() - start_time)
|
||||
if remaining_timeout <= 0:
|
||||
raise exc.OpenStackCloudTimeout(timeout_message)
|
||||
raise exceptions.ResourceTimeout(timeout_message)
|
||||
|
||||
server = self.get_active_server(
|
||||
server=server,
|
||||
@ -1159,7 +1171,7 @@ class ComputeCloudMixin:
|
||||
and server['fault'] is not None
|
||||
and 'message' in server['fault']
|
||||
):
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Error in creating the server."
|
||||
" Compute service reports fault: {reason}".format(
|
||||
reason=server['fault']['message']
|
||||
@ -1167,7 +1179,7 @@ class ComputeCloudMixin:
|
||||
extra_data=dict(server=server),
|
||||
)
|
||||
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Error in creating the server"
|
||||
" (no further information available)",
|
||||
extra_data=dict(server=server),
|
||||
@ -1195,13 +1207,13 @@ class ComputeCloudMixin:
|
||||
try:
|
||||
self._delete_server(server=server, wait=wait, timeout=timeout)
|
||||
except Exception as e:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Server reached ACTIVE state without being'
|
||||
' allocated an IP address AND then could not'
|
||||
' be deleted: {0}'.format(e),
|
||||
extra_data=dict(server=server),
|
||||
)
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Server reached ACTIVE state without being'
|
||||
' allocated an IP address.',
|
||||
extra_data=dict(server=server),
|
||||
@ -1253,12 +1265,14 @@ class ComputeCloudMixin:
|
||||
:param dict metadata: A dictionary with the key=value pairs
|
||||
to set in the server instance. It only updates the key=value pairs
|
||||
provided. Existing ones will remain untouched.
|
||||
|
||||
:returns: None
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
server = self.get_server(name_or_id, bare=True)
|
||||
if not server:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Invalid Server {server}'.format(server=name_or_id)
|
||||
)
|
||||
|
||||
@ -1271,12 +1285,14 @@ class ComputeCloudMixin:
|
||||
to update.
|
||||
:param metadata_keys: A list with the keys to be deleted
|
||||
from the server instance.
|
||||
|
||||
:returns: None
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
server = self.get_server(name_or_id, bare=True)
|
||||
if not server:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
'Invalid Server {server}'.format(server=name_or_id)
|
||||
)
|
||||
|
||||
@ -1301,9 +1317,11 @@ class ComputeCloudMixin:
|
||||
associated with the instance.
|
||||
:param int delete_ip_retry: Number of times to retry deleting
|
||||
any floating ips, should the first try be unsuccessful.
|
||||
|
||||
:returns: True if delete succeeded, False otherwise if the
|
||||
server does not exist.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
# If delete_ips is True, we need the server to not be bare.
|
||||
server = self.compute.find_server(name_or_id, ignore_missing=True)
|
||||
@ -1332,7 +1350,7 @@ class ComputeCloudMixin:
|
||||
ip = self.get_floating_ip(
|
||||
id=None, filters={'floating_ip_address': fip['addr']}
|
||||
)
|
||||
except exc.OpenStackCloudURINotFound:
|
||||
except exceptions.NotFoundException:
|
||||
# We're deleting. If it doesn't exist - awesome
|
||||
# NOTE(mordred) If the cloud is a nova FIP cloud but
|
||||
# floating_ip_source is set to neutron, this
|
||||
@ -1342,7 +1360,7 @@ class ComputeCloudMixin:
|
||||
continue
|
||||
deleted = self.delete_floating_ip(ip['id'], retry=delete_ip_retry)
|
||||
if not deleted:
|
||||
raise exc.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Tried to delete floating ip {floating_ip}"
|
||||
" associated with server {id} but there was"
|
||||
" an error deleting it. Not deleting server.".format(
|
||||
@ -1396,8 +1414,10 @@ class ComputeCloudMixin:
|
||||
detailed = False.
|
||||
:param name: New name for the server
|
||||
:param description: New description for the server
|
||||
|
||||
:returns: The updated compute ``Server`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
server = self.compute.find_server(name_or_id, ignore_missing=False)
|
||||
|
||||
@ -1410,8 +1430,10 @@ class ComputeCloudMixin:
|
||||
|
||||
:param name: Name of the server group being created
|
||||
:param policies: List of policies for the server group.
|
||||
|
||||
:returns: The created compute ``ServerGroup`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
sg_attrs = {'name': name}
|
||||
if policies:
|
||||
@ -1424,8 +1446,10 @@ class ComputeCloudMixin:
|
||||
"""Delete a server group.
|
||||
|
||||
:param name_or_id: Name or ID of the server group to delete
|
||||
|
||||
:returns: True if delete succeeded, False otherwise
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
server_group = self.get_server_group(name_or_id)
|
||||
if not server_group:
|
||||
@ -1462,8 +1486,10 @@ class ComputeCloudMixin:
|
||||
:param swap: Swap space in MB
|
||||
:param rxtx_factor: RX/TX factor
|
||||
:param is_public: Make flavor accessible to the public
|
||||
|
||||
:returns: The created compute ``Flavor`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
attrs = {
|
||||
'disk': disk,
|
||||
@ -1486,8 +1512,10 @@ class ComputeCloudMixin:
|
||||
"""Delete a flavor
|
||||
|
||||
:param name_or_id: ID or name of the flavor to delete.
|
||||
|
||||
:returns: True if delete succeeded, False otherwise.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
try:
|
||||
flavor = self.compute.find_flavor(name_or_id)
|
||||
@ -1497,7 +1525,7 @@ class ComputeCloudMixin:
|
||||
self.compute.delete_flavor(flavor)
|
||||
return True
|
||||
except exceptions.SDKException:
|
||||
raise exceptions.OpenStackCloudException(
|
||||
raise exceptions.SDKException(
|
||||
"Unable to delete flavor {name}".format(name=name_or_id)
|
||||
)
|
||||
|
||||
@ -1507,8 +1535,10 @@ class ComputeCloudMixin:
|
||||
:param string flavor_id: ID of the flavor to update.
|
||||
:param dict extra_specs: Dictionary of key-value pairs.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: OpenStackCloudResourceNotFound if flavor ID is not found.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
:raises: :class:`~openstack.exceptions.BadRequestException` if flavor
|
||||
ID is not found.
|
||||
"""
|
||||
self.compute.create_flavor_extra_specs(flavor_id, extra_specs)
|
||||
|
||||
@ -1518,8 +1548,10 @@ class ComputeCloudMixin:
|
||||
:param string flavor_id: ID of the flavor to update.
|
||||
:param keys: List of spec keys to delete.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: OpenStackCloudResourceNotFound if flavor ID is not found.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
:raises: :class:`~openstack.exceptions.BadRequestException` if flavor
|
||||
ID is not found.
|
||||
"""
|
||||
for key in keys:
|
||||
self.compute.delete_flavor_extra_specs_property(flavor_id, key)
|
||||
@ -1530,7 +1562,8 @@ class ComputeCloudMixin:
|
||||
:param string flavor_id: ID of the private flavor.
|
||||
:param string project_id: ID of the project/tenant.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.compute.flavor_add_tenant_access(flavor_id, project_id)
|
||||
|
||||
@ -1540,7 +1573,8 @@ class ComputeCloudMixin:
|
||||
:param string flavor_id: ID of the private flavor.
|
||||
:param string project_id: ID of the project/tenant.
|
||||
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
self.compute.flavor_remove_tenant_access(flavor_id, project_id)
|
||||
|
||||
@ -1548,8 +1582,10 @@ class ComputeCloudMixin:
|
||||
"""List access from a private flavor for a project/tenant.
|
||||
|
||||
:param string flavor_id: ID of the private flavor.
|
||||
|
||||
:returns: List of dicts with flavor_id and tenant_id attributes.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
return self.compute.get_flavor_access(flavor_id)
|
||||
|
||||
@ -1569,10 +1605,11 @@ class ComputeCloudMixin:
|
||||
|
||||
:param name: aggregate name or id.
|
||||
:param filters: a dict containing additional filters to use.
|
||||
|
||||
:returns: A list of compute ``Aggregate`` objects matching the search
|
||||
criteria.
|
||||
:raises: ``OpenStackCloudException``: if something goes wrong during
|
||||
the OpenStack API call.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` if something goes
|
||||
wrong during the OpenStack API call.
|
||||
"""
|
||||
aggregates = self.list_aggregates()
|
||||
return _utils._filter_list(aggregates, name_or_id, filters)
|
||||
@ -1612,8 +1649,10 @@ class ComputeCloudMixin:
|
||||
|
||||
:param name: Name of the host aggregate being created
|
||||
:param availability_zone: Availability zone to assign hosts
|
||||
|
||||
:returns: The created compute ``Aggregate`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on operation
|
||||
error.
|
||||
"""
|
||||
return self.compute.create_aggregate(
|
||||
name=name, availability_zone=availability_zone
|
||||
@ -1626,8 +1665,10 @@ class ComputeCloudMixin:
|
||||
:param name_or_id: Name or ID of the aggregate being updated.
|
||||
:param name: New aggregate name
|
||||
:param availability_zone: Availability zone to assign to hosts
|
||||
|
||||
:returns: The updated compute ``Aggregate`` object.
|
||||
:raises: OpenStackCloudException on operation error.
|
||||
:raises: :class:`~openstack.exceptions.SDKException` on |