The cinder.api.common Module

class METADATA_TYPES

Bases: enum.Enum

image = <METADATA_TYPES.image: 2>
user = <METADATA_TYPES.user: 1>
class MetaItemDeserializer(metadata=None)

Bases: cinder.api.openstack.wsgi.MetadataXMLDeserializer

deserialize(text)
class MetaItemTemplate

Bases: cinder.api.xmlutil.TemplateBuilder

construct()
class MetadataDeserializer(metadata=None)

Bases: cinder.api.openstack.wsgi.MetadataXMLDeserializer

deserialize(text)
class MetadataTemplate

Bases: cinder.api.xmlutil.TemplateBuilder

construct()
class MetadataTemplateElement(tag, attrib=None, selector=None, subselector=None, **extra)

Bases: cinder.api.xmlutil.TemplateElement

will_render(datum)
class MetadataXMLDeserializer(metadata=None)

Bases: cinder.api.openstack.wsgi.XMLDeserializer

create(datastring)
extract_metadata(metadata_node)

Marshal the metadata attribute of a parsed request.

update(datastring)
update_all(datastring)
class ViewBuilder

Bases: object

Model API responses as dictionaries.

get_pagination_params(params, max_limit=None)

Return marker, limit, offset tuple from request.

Parameters:paramswsgi.Request‘s GET dictionary, possibly containing ‘marker’, ‘limit’, and ‘offset’ variables. ‘marker’ is the id of the last element the client has seen, ‘limit’ is the maximum number of items to return and ‘offset’ is the number of items to skip from the marker or from the first element. If ‘limit’ is not specified, or > max_limit, we default to max_limit. Negative values for either offset or limit will cause exc.HTTPBadRequest() exceptions to be raised. If no offset is present we’ll default to 0 and if no marker is present we’ll default to None.
Max_limit:Max value ‘limit’ return value can take
Returns:Tuple (marker, limit, offset)
get_request_url(request)
get_sort_params(params, default_key='created_at', default_dir='desc')

Retrieves sort keys/directions parameters.

Processes the parameters to create a list of sort keys and sort directions that correspond to either the ‘sort’ parameter or the ‘sort_key’ and ‘sort_dir’ parameter values. The value of the ‘sort’ parameter is a comma- separated list of sort keys, each key is optionally appended with ‘:<sort_direction>’.

Note that the ‘sort_key’ and ‘sort_dir’ parameters are deprecated in kilo and an exception is raised if they are supplied with the ‘sort’ parameter.

The sort parameters are removed from the request parameters by this function.

Parameters:
  • params – webob.multidict of request parameters (from cinder.api.openstack.wsgi.Request.params)
  • default_key – default sort key value, added to the list if no sort keys are supplied
  • default_dir – default sort dir value, added to the list if the corresponding key does not have a direction specified
Returns:

list of sort keys, list of sort dirs

Raises webob.exc.HTTPBadRequest:
 

If both ‘sort’ and either ‘sort_key’ or ‘sort_dir’ are supplied parameters

limited(items, request, max_limit=None)

Return a slice of items according to requested offset and limit.

Parameters:
  • items – A sliceable entity
  • requestwsgi.Request possibly containing ‘offset’ and ‘limit’ GET variables. ‘offset’ is where to start in the list, and ‘limit’ is the maximum number of items to return. If ‘limit’ is not specified, 0, or > max_limit, we default to max_limit. Negative values for either offset or limit will cause exc.HTTPBadRequest() exceptions to be raised.
  • max_limit – The maximum number of items to return from ‘items’
limited_by_marker(items, request, max_limit=None)

Return a slice of items according to the requested marker and limit.

remove_version_from_href(href)

Removes the first api version from the href.

Given: ‘http://www.cinder.com/v1.1/123‘ Returns: ‘http://www.cinder.com/123

Given: ‘http://www.cinder.com/v1.1‘ Returns: ‘http://www.cinder.com

validate_key_names(key_names_list)

Validate each item of the list to match key name regex.

validate_policy(context, action)

Previous topic

<no title>

Next topic

The cinder.api.contrib.admin_actions Module

Project Source

This Page