Merge "Change the format of some inconsistent docstring"
This commit is contained in:
commit
625269f114
@ -105,7 +105,7 @@ def get_remaining_quota(context, db_api, image_id=None):
|
||||
:param context:
|
||||
:param db_api: The db_api in use for this configuration
|
||||
:param image_id: The image that will be replaced with this new data size
|
||||
:return: The number of bytes the user has remaining under their quota.
|
||||
:returns: The number of bytes the user has remaining under their quota.
|
||||
None means infinity
|
||||
"""
|
||||
|
||||
@ -151,7 +151,7 @@ def check_quota(context, image_size, db_api, image_id=None):
|
||||
:param image_size: The size of the image we hope to store
|
||||
:param db_api: The db_api in use for this configuration
|
||||
:param image_id: The image that will be replaced with this new data size
|
||||
:return:
|
||||
:returns:
|
||||
"""
|
||||
|
||||
remaining = get_remaining_quota(context, db_api, image_id=image_id)
|
||||
|
@ -78,7 +78,7 @@ class CacheFilter(wsgi.Middleware):
|
||||
def _match_request(request):
|
||||
"""Determine the version of the url and extract the image id
|
||||
|
||||
:returns tuple of version and image id if the url is a cacheable,
|
||||
:returns: tuple of version and image id if the url is a cacheable,
|
||||
otherwise None
|
||||
"""
|
||||
for ((version, method), pattern) in PATTERNS.items():
|
||||
|
@ -79,9 +79,10 @@ class ContextMiddleware(BaseContextMiddleware):
|
||||
of the req object.
|
||||
|
||||
:param req: wsgi request object that will be given the context object
|
||||
:raises webob.exc.HTTPUnauthorized: when value of the X-Identity-Status
|
||||
header is not 'Confirmed' and
|
||||
anonymous access is disallowed
|
||||
:raises: webob.exc.HTTPUnauthorized: when value of the
|
||||
X-Identity-Status header is not
|
||||
'Confirmed' and anonymous access
|
||||
is disallowed
|
||||
"""
|
||||
if req.headers.get('X-Identity-Status') == 'Confirmed':
|
||||
req.context = self._get_authenticated_context(req)
|
||||
|
@ -77,8 +77,8 @@ class VersionNegotiationFilter(wsgi.Middleware):
|
||||
minor version number.
|
||||
|
||||
:param subject: The string to check
|
||||
:returns version found in the subject
|
||||
:raises ValueError if no acceptable version could be found
|
||||
:returns: version found in the subject
|
||||
:raises: ValueError if no acceptable version could be found
|
||||
"""
|
||||
if subject in ('v1', 'v1.0', 'v1.1') and CONF.enable_v1_api:
|
||||
major_version = 1
|
||||
|
@ -35,7 +35,7 @@ class BaseController(object):
|
||||
:param request: The WSGI/Webob Request object
|
||||
:param image_id: The opaque image identifier
|
||||
|
||||
:raises HTTPNotFound if image does not exist
|
||||
:raises: HTTPNotFound if image does not exist
|
||||
"""
|
||||
context = request.context
|
||||
try:
|
||||
|
@ -233,7 +233,7 @@ class Controller(controller.BaseController):
|
||||
:param create_props: List of properties to check
|
||||
:param req: The WSGI/Webob Request object
|
||||
|
||||
:raises HTTPForbidden if request forbidden to create a property
|
||||
:raises: HTTPForbidden if request forbidden to create a property
|
||||
"""
|
||||
if property_utils.is_property_protection_enabled():
|
||||
for key in create_props:
|
||||
@ -273,7 +273,7 @@ class Controller(controller.BaseController):
|
||||
:param orig_meta: Mapping of existing metadata about image
|
||||
:param req: The WSGI/Webob Request object
|
||||
|
||||
:raises HTTPForbidden if request forbidden to create a property
|
||||
:raises: HTTPForbidden if request forbidden to create a property
|
||||
"""
|
||||
if property_utils.is_property_protection_enabled():
|
||||
for key in update_props:
|
||||
@ -305,7 +305,7 @@ class Controller(controller.BaseController):
|
||||
:param orig_meta: Mapping of existing metadata about image
|
||||
:param req: The WSGI/Webob Request object
|
||||
|
||||
:raises HTTPForbidden if request forbidden to create a property
|
||||
:raises: HTTPForbidden if request forbidden to create a property
|
||||
"""
|
||||
if property_utils.is_property_protection_enabled():
|
||||
for key in delete_props:
|
||||
@ -448,7 +448,7 @@ class Controller(controller.BaseController):
|
||||
:param id: The opaque image identifier
|
||||
:retval similar to 'show' method but without image_data
|
||||
|
||||
:raises HTTPNotFound if image metadata is not available to user
|
||||
:raises: HTTPNotFound if image metadata is not available to user
|
||||
"""
|
||||
self._enforce(req, 'get_image')
|
||||
image_meta = self.get_image_meta_or_404(req, id)
|
||||
@ -517,7 +517,7 @@ class Controller(controller.BaseController):
|
||||
:param req: The WSGI/Webob Request object
|
||||
:param id: The opaque image identifier
|
||||
|
||||
:raises HTTPNotFound if image is not available to user
|
||||
:raises: HTTPNotFound if image is not available to user
|
||||
"""
|
||||
|
||||
self._enforce(req, 'get_image')
|
||||
@ -559,8 +559,8 @@ class Controller(controller.BaseController):
|
||||
:param id: The opaque image identifier
|
||||
:param image_meta: The image metadata
|
||||
|
||||
:raises HTTPConflict if image already exists
|
||||
:raises HTTPBadRequest if image metadata is not valid
|
||||
:raises: HTTPConflict if image already exists
|
||||
:raises: HTTPBadRequest if image metadata is not valid
|
||||
"""
|
||||
location = self._external_source(image_meta, req)
|
||||
scheme = image_meta.get('store')
|
||||
@ -630,7 +630,7 @@ class Controller(controller.BaseController):
|
||||
:param req: The WSGI/Webob Request object
|
||||
:param image_meta: Mapping of metadata about image
|
||||
|
||||
:raises HTTPConflict if image already exists
|
||||
:raises: HTTPConflict if image already exists
|
||||
:retval The location where the image was stored
|
||||
"""
|
||||
|
||||
@ -894,7 +894,7 @@ class Controller(controller.BaseController):
|
||||
:param image_meta: Mapping of metadata about image
|
||||
:param image_data: Actual image data that is to be stored
|
||||
|
||||
:raises HTTPBadRequest if x-image-meta-location is missing
|
||||
:raises: HTTPBadRequest if x-image-meta-location is missing
|
||||
and the request body is not application/octet-stream
|
||||
image data.
|
||||
"""
|
||||
@ -1099,9 +1099,9 @@ class Controller(controller.BaseController):
|
||||
:param req: The WSGI/Webob Request object
|
||||
:param id: The opaque image identifier
|
||||
|
||||
:raises HttpBadRequest if image registry is invalid
|
||||
:raises HttpNotFound if image or any chunk is not available
|
||||
:raises HttpUnauthorized if image or any chunk is not
|
||||
:raises: HttpBadRequest if image registry is invalid
|
||||
:raises: HttpNotFound if image or any chunk is not available
|
||||
:raises: HttpUnauthorized if image or any chunk is not
|
||||
deleteable by the requesting user
|
||||
"""
|
||||
self._enforce(req, 'delete_image')
|
||||
@ -1190,7 +1190,7 @@ class Controller(controller.BaseController):
|
||||
:param request: The WSGI/Webob Request object
|
||||
:param scheme: The backend store scheme
|
||||
|
||||
:raises HTTPBadRequest if store does not exist
|
||||
:raises: HTTPBadRequest if store does not exist
|
||||
"""
|
||||
try:
|
||||
return store.get_store_from_scheme(scheme)
|
||||
|
@ -246,7 +246,7 @@ def load_paste_app(app_name, flavor=None, conf_file=None):
|
||||
:param flavor: name of the variant of the application to load
|
||||
:param conf_file: path to the paste config file
|
||||
|
||||
:raises RuntimeError when config file cannot be located or application
|
||||
:raises: RuntimeError when config file cannot be located or application
|
||||
cannot be loaded from config file
|
||||
"""
|
||||
# append the deployment flavor to the application name,
|
||||
|
@ -38,7 +38,7 @@ def urlsafe_encrypt(key, plaintext, blocksize=16):
|
||||
:param plaintext: Input text to be encrypted
|
||||
:param blocksize: Non-zero integer multiple of AES blocksize in bytes (16)
|
||||
|
||||
:returns : Resulting ciphertext
|
||||
:returns: Resulting ciphertext
|
||||
"""
|
||||
def pad(text):
|
||||
"""
|
||||
@ -71,7 +71,7 @@ def urlsafe_decrypt(key, ciphertext):
|
||||
:param key: AES secret key
|
||||
:param ciphertext: The encrypted text to decrypt
|
||||
|
||||
:returns : Resulting plaintext
|
||||
:returns: Resulting plaintext
|
||||
"""
|
||||
# Cast from unicode
|
||||
if isinstance(ciphertext, six.text_type):
|
||||
|
@ -92,7 +92,7 @@ def get_ordered_locations(locations, **kwargs):
|
||||
|
||||
:param locations: The original image location list.
|
||||
:param kwargs: Strategy-specific arguments for under layer strategy module.
|
||||
:return: The image location list with strategy-specific order.
|
||||
:returns: The image location list with strategy-specific order.
|
||||
"""
|
||||
if not locations:
|
||||
return []
|
||||
@ -107,7 +107,7 @@ def choose_best_location(locations, **kwargs):
|
||||
|
||||
:param locations: The original image location list.
|
||||
:param kwargs: Strategy-specific arguments for under layer strategy module.
|
||||
:return: The best location from image location list.
|
||||
:returns: The best location from image location list.
|
||||
"""
|
||||
locations = get_ordered_locations(locations, **kwargs)
|
||||
if locations:
|
||||
|
@ -31,6 +31,6 @@ def get_ordered_locations(locations, **kwargs):
|
||||
Order image location list.
|
||||
|
||||
:param locations: The original image location list.
|
||||
:return: The image location list with original natural order.
|
||||
:returns: The image location list with original natural order.
|
||||
"""
|
||||
return locations
|
||||
|
@ -74,7 +74,7 @@ def get_ordered_locations(locations, uri_key='url', **kwargs):
|
||||
|
||||
:param locations: The original image location list.
|
||||
:param uri_key: The key name for location URI in image location dictionary.
|
||||
:return: The image location list with preferred store type order.
|
||||
:returns: The image location list with preferred store type order.
|
||||
"""
|
||||
def _foreach_store_type_preference():
|
||||
store_types = CONF.store_type_location_strategy.store_type_preference
|
||||
|
@ -114,7 +114,7 @@ class Controller(object):
|
||||
:params excluded: List of methods to exclude.
|
||||
:params refiner: Callable to use as filter for methods.
|
||||
|
||||
:raises AssertionError: If refiner is not callable.
|
||||
:raises: AssertionError: If refiner is not callable.
|
||||
"""
|
||||
|
||||
funcs = filter(lambda x: not x.startswith("_"), dir(resource))
|
||||
|
@ -95,7 +95,7 @@ def create_verifier_for_pss(signature, hash_method, public_key,
|
||||
:param hash_method: the hash method to use, as a cryptography object
|
||||
:param public_key: the public key to use, as a cryptography object
|
||||
:param image_properties: the key-value properties about the image
|
||||
:return: the verifier to use to verify the signature for RSA-PSS
|
||||
:returns: the verifier to use to verify the signature for RSA-PSS
|
||||
:raises: SignatureVerificationError if the RSA-PSS specific properties
|
||||
are invalid
|
||||
"""
|
||||
@ -142,7 +142,7 @@ def should_verify_signature(image_properties):
|
||||
that signature verification should be done.
|
||||
|
||||
:param image_properties: the key-value properties about the image
|
||||
:return: True, if signature metadata properties exist, False otherwise
|
||||
:returns: True, if signature metadata properties exist, False otherwise
|
||||
"""
|
||||
return (image_properties is not None and
|
||||
CERT_UUID in image_properties and
|
||||
@ -157,7 +157,7 @@ def verify_signature(context, checksum_hash, image_properties):
|
||||
:param context: the user context for authentication
|
||||
:param checksum_hash: the 'checksum' hash of the image data
|
||||
:param image_properties: the key-value properties about the image
|
||||
:return: True if verification succeeds
|
||||
:returns: True if verification succeeds
|
||||
:raises: SignatureVerificationError if verification fails
|
||||
"""
|
||||
if not should_verify_signature(image_properties):
|
||||
@ -201,7 +201,7 @@ def get_signature(signature_data):
|
||||
"""Decode the signature data and returns the signature.
|
||||
|
||||
:param siganture_data: the base64-encoded signature data
|
||||
:return: the decoded signature
|
||||
:returns: the decoded signature
|
||||
:raises: SignatureVerificationError if the signature data is malformatted
|
||||
"""
|
||||
try:
|
||||
@ -217,7 +217,7 @@ def get_hash_method(hash_method_name):
|
||||
"""Verify the hash method name and create the hash method.
|
||||
|
||||
:param hash_method_name: the name of the hash method to retrieve
|
||||
:return: the hash method, a cryptography object
|
||||
:returns: the hash method, a cryptography object
|
||||
:raises: SignatureVerificationError if the hash method name is invalid
|
||||
"""
|
||||
if hash_method_name not in HASH_METHODS:
|
||||
@ -231,7 +231,7 @@ def get_signature_key_type(signature_key_type):
|
||||
"""Verify the signature key type.
|
||||
|
||||
:param signature_key_type: the key type of the signature
|
||||
:return: the validated signature key type
|
||||
:returns: the validated signature key type
|
||||
:raises: SignatureVerificationError if the signature key type is invalid
|
||||
"""
|
||||
if signature_key_type not in SIGNATURE_KEY_TYPES:
|
||||
@ -248,7 +248,7 @@ def get_public_key(context, signature_certificate_uuid, signature_key_type):
|
||||
:param signature_certificate_uuid: the uuid to use to retrieve the
|
||||
certificate
|
||||
:param signature_key_type: the key type of the signature
|
||||
:return: the public key cryptography object
|
||||
:returns: the public key cryptography object
|
||||
:raises: SignatureVerificationError if public key format is invalid
|
||||
"""
|
||||
certificate = get_certificate(context, signature_certificate_uuid)
|
||||
@ -272,7 +272,7 @@ def get_certificate(context, signature_certificate_uuid):
|
||||
:param context: the user context for authentication
|
||||
:param signature_certificate_uuid: the uuid to use to retrieve the
|
||||
certificate
|
||||
:return: the certificate cryptography object
|
||||
:returns: the certificate cryptography object
|
||||
:raises: SignatureVerificationError if the retrieval fails or the format
|
||||
is invalid
|
||||
"""
|
||||
|
@ -127,7 +127,7 @@ def validate_external_location(uri):
|
||||
absent for security reasons, see LP bug #1334196.
|
||||
|
||||
:param uri: The URI of external image location.
|
||||
:return: Whether given URI of external image location are OK.
|
||||
:returns: Whether given URI of external image location are OK.
|
||||
"""
|
||||
|
||||
# TODO(zhiyan): This function could be moved to glance_store.
|
||||
|
@ -657,7 +657,7 @@ def split_filter_op(expression):
|
||||
|
||||
:param expression: the expression to parse
|
||||
|
||||
:returns a tuple (operator, threshold) parsed from expression
|
||||
:returns: a tuple (operator, threshold) parsed from expression
|
||||
"""
|
||||
left, sep, right = expression.partition(':')
|
||||
if sep:
|
||||
@ -679,9 +679,9 @@ def evaluate_filter_op(value, operator, threshold):
|
||||
:param operator: any supported filter operation
|
||||
:param threshold: to compare value against, as right side of expression
|
||||
|
||||
:raises InvalidFilterOperatorValue if an unknown operator is provided
|
||||
:raises: InvalidFilterOperatorValue if an unknown operator is provided
|
||||
|
||||
:returns boolean result of applied comparison
|
||||
:returns: boolean result of applied comparison
|
||||
|
||||
"""
|
||||
if operator == 'gt':
|
||||
|
@ -161,7 +161,7 @@ def get_socket(default_port):
|
||||
|
||||
:param default_port: port to bind to if none is specified in conf
|
||||
|
||||
:returns : a socket object as returned from socket.listen or
|
||||
:returns: a socket object as returned from socket.listen or
|
||||
ssl.wrap_socket if conf specifies cert_file
|
||||
"""
|
||||
bind_addr = get_bind_addr(default_port)
|
||||
|
@ -261,7 +261,7 @@ def user_get_storage_usage(client, owner_id, image_id=None, session=None):
|
||||
@_get_client
|
||||
def task_get(client, task_id, session=None, force_show_deleted=False):
|
||||
"""Get a single task object
|
||||
:return: task dictionary
|
||||
:returns: task dictionary
|
||||
"""
|
||||
return client.task_get(task_id=task_id, session=session,
|
||||
force_show_deleted=force_show_deleted)
|
||||
@ -280,7 +280,7 @@ def task_get_all(client, filters=None, marker=None, limit=None,
|
||||
:param admin_as_user: For backwards compatibility. If true, then return to
|
||||
an admin the equivalent set of tasks which it would see
|
||||
if it were a regular user
|
||||
:return: tasks set
|
||||
:returns: tasks set
|
||||
"""
|
||||
return client.task_get_all(filters=filters, marker=marker, limit=limit,
|
||||
sort_key=sort_key, sort_dir=sort_dir,
|
||||
|
@ -956,7 +956,7 @@ def task_get_all(context, filters=None, marker=None, limit=None,
|
||||
:param limit: maximum number of tasks to return
|
||||
:param sort_key: task attribute by which results should be sorted
|
||||
:param sort_dir: direction in which results should be sorted (asc, desc)
|
||||
:return: tasks set
|
||||
:returns: tasks set
|
||||
"""
|
||||
filters = filters or {}
|
||||
tasks = DATA['tasks'].values()
|
||||
|
@ -133,7 +133,7 @@ def image_update(context, image_id, values, purge_props=False,
|
||||
"""
|
||||
Set the given properties on an image and update it.
|
||||
|
||||
:raises ImageNotFound if image does not exist.
|
||||
:raises: ImageNotFound if image does not exist.
|
||||
"""
|
||||
return _image_update(context, values, image_id, purge_props,
|
||||
from_state=from_state)
|
||||
@ -210,7 +210,7 @@ def _check_image_id(image_id):
|
||||
wrapping the different behaviors between MySql and DB2 when the image id
|
||||
length is longer than the defined length in database model.
|
||||
:param image_id: The id of the image we want to check
|
||||
:return: Raise NoFound exception if given image id is invalid
|
||||
:returns: Raise NoFound exception if given image id is invalid
|
||||
"""
|
||||
if (image_id and
|
||||
len(image_id) > models.Image.id.property.columns[0].type.length):
|
||||
@ -322,7 +322,7 @@ def _paginate_query(query, model, limit, sort_keys, marker=None,
|
||||
:param sort_dirs: per-column array of sort_dirs, corresponding to sort_keys
|
||||
|
||||
:rtype: sqlalchemy.orm.query.Query
|
||||
:return: The query with sorting/pagination added.
|
||||
:returns: The query with sorting/pagination added.
|
||||
"""
|
||||
|
||||
if 'id' not in sort_keys:
|
||||
@ -970,7 +970,7 @@ def _image_child_entry_delete_all(child_model_cls, image_id, delete_time=None,
|
||||
:param session: A SQLAlchemy session to use (if present)
|
||||
|
||||
:rtype: int
|
||||
:return: The number of child entries got soft-deleted.
|
||||
:returns: The number of child entries got soft-deleted.
|
||||
"""
|
||||
session = session or get_session()
|
||||
|
||||
@ -1346,7 +1346,7 @@ def task_get_all(context, filters=None, marker=None, limit=None,
|
||||
:param admin_as_user: For backwards compatibility. If true, then return to
|
||||
an admin the equivalent set of tasks which it would see
|
||||
if it were a regular user
|
||||
:return: tasks set
|
||||
:returns: tasks set
|
||||
"""
|
||||
filters = filters or {}
|
||||
|
||||
|
@ -154,7 +154,7 @@ def publish(context, artifact_id, session, type_name,
|
||||
manually by calling this function.
|
||||
It creates transitive dependencies for the given artifact_id and saves
|
||||
them in DB.
|
||||
:returns artifact dict with Transitive show level
|
||||
:returns: artifact dict with Transitive show level
|
||||
"""
|
||||
values = {'state': 'active'}
|
||||
return _out(_create_or_update(context, values, artifact_id, session,
|
||||
@ -184,7 +184,7 @@ def _out(artifact, show_level=ga.Showlevel.BASIC, show_text_properties=True):
|
||||
:param show_level: constant from Showlevel class
|
||||
:param show_text_properties: for performance optimization it's possible
|
||||
to disable loading of massive text properties
|
||||
:return: generated dict
|
||||
:returns: generated dict
|
||||
"""
|
||||
res = artifact.to_dict(show_level=show_level,
|
||||
show_text_properties=show_text_properties)
|
||||
|
@ -65,7 +65,7 @@ def _normalize_image_location_for_db(image_data):
|
||||
Image object.
|
||||
|
||||
:param image_data: a dict of values representing information in the image
|
||||
:return: a new image data dict
|
||||
:returns: a new image data dict
|
||||
"""
|
||||
if 'locations' not in image_data and 'location_data' not in image_data:
|
||||
image_data['locations'] = None
|
||||
|
@ -824,7 +824,7 @@ class FunctionalTest(test_utils.BaseTestCase):
|
||||
:param expect_launch: Optional, true iff the server(s) are
|
||||
expected to successfully start
|
||||
:param timeout: Optional, defaults to 30 seconds
|
||||
:return: None if launch expectation is met, otherwise an
|
||||
:returns: None if launch expectation is met, otherwise an
|
||||
assertion message
|
||||
"""
|
||||
now = datetime.datetime.now()
|
||||
|
Loading…
Reference in New Issue
Block a user