The nova.api.openstack.common Module

class ViewBuilder

Bases: object

Model API responses as dictionaries.

check_cells_enabled(function)
check_img_metadata_properties_quota(context, metadata)
check_snapshots_enabled(f)
get_flavor(context, flavor_id)
get_id_from_href(href)

Return the id or uuid portion of a url.

Given: ‘http://www.foo.com/bar/123?q=4‘ Returns: ‘123’

Given: ‘http://www.foo.com/bar/abc123?q=4‘ Returns: ‘abc123’

get_instance(compute_api, context, instance_id, expected_attrs=None)

Fetch an instance from the compute API, handling error checking.

get_limit_and_marker(request, max_limit=1000)

get limited parameter from request.

get_networks_for_instance(context, instance)

Returns a prepared nw_info list for passing into the view builders

We end up with a data structure like:

{'public': {'ips': [{'address': '10.0.0.1',
                     'version': 4,
                     'mac_address': 'aa:aa:aa:aa:aa:aa'},
                    {'address': '2001::1',
                     'version': 6,
                     'mac_address': 'aa:aa:aa:aa:aa:aa'}],
            'floating_ips': [{'address': '172.16.0.1',
                              'version': 4,
                              'mac_address': 'aa:aa:aa:aa:aa:aa'},
                             {'address': '172.16.2.1',
                              'version': 4,
                              'mac_address': 'aa:aa:aa:aa:aa:aa'}]},
 ...}
get_networks_for_instance_from_nw_info(nw_info)
get_pagination_params(request)

Return marker, limit tuple from request.

Parameters:requestwsgi.Request possibly containing ‘marker’ and ‘limit’ GET variables. ‘marker’ is the id of the last element the client has seen, 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 marker or limit will cause exc.HTTPBadRequest() exceptions to be raised.
get_sort_params(input_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 the ‘sort_key’ and ‘sort_dir’ parameter values. These sorting parameters can be specified multiple times in order to generate the list of sort keys and directions.

The input parameters are not modified.

Parameters:
  • input_params – webob.multidict of request parameters (from nova.wsgi.Request.params)
  • default_key – default sort key value, added to the list if no ‘sort_key’ parameters are supplied
  • default_dir – default sort dir value, added to the list if no ‘sort_dir’ parameters are supplied
Returns:

list of sort keys, list of sort dirs

is_all_tenants(search_opts)

Checks to see if the all_tenants flag is in search_opts

Parameters:search_opts (dict) – The search options for a request
Returns:boolean indicating if all_tenants are being requested or not
limited(items, request, max_limit=1000)

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’
normalize_name(name)
raise_feature_not_supported(msg=None)
raise_http_conflict_for_instance_invalid_state(exc, action, server_id)

Raises a webob.exc.HTTPConflict instance containing a message appropriate to return via the API based on the original InstanceInvalidState exception.

remove_trailing_version_from_href(href)

Removes the api version from the href.

Given: ‘http://www.nova.com/compute/v1.1‘ Returns: ‘http://www.nova.com/compute

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

status_from_state(vm_state, task_state='default')

Given vm_state and task_state, return a status string.

task_and_vm_state_from_status(statuses)

Map the server’s multiple status strings to list of vm states and list of task states.

url_join(*parts)

Convenience method for joining parts of a URL

Any leading and trailing ‘/’ characters are removed, and the parts joined together with ‘/’ as a separator. If last element of ‘parts’ is an empty string, the returned URL will have a trailing slash.

Previous topic

The nova.api.openstack.auth Module

Next topic

The nova.api.openstack.compute.access_ips Module

Project Source

This Page