Enable H40* rules in pep/flake
First part of pep/flake fixies, that enables H40* group of rules. Change-Id: Ia85b49645b3bf634e99877855e6b31a404331b7f Related-Bug: #1333290
This commit is contained in:
parent
c6b3c90c53
commit
b87c55d5fc
@ -37,9 +37,10 @@ except NameError:
|
||||
|
||||
|
||||
def getid(obj):
|
||||
"""
|
||||
Abstracts the common pattern of allowing both an object or an object's ID
|
||||
as a parameter when dealing with relationships.
|
||||
"""Searches for id in provided object.
|
||||
|
||||
Abstracts the common pattern of allowing both an object or an
|
||||
object's ID as a parameter when dealing with relationships.
|
||||
"""
|
||||
try:
|
||||
return obj.id
|
||||
@ -48,8 +49,9 @@ def getid(obj):
|
||||
|
||||
|
||||
class Manager(utils.HookableMixin):
|
||||
"""
|
||||
Managers interact with a particular type of API (servers, flavors, images,
|
||||
"""Manager for CRUD operations.
|
||||
|
||||
Managers interact with a particular type of API (shares, snapshots,
|
||||
etc.) and provide CRUD operations for them.
|
||||
"""
|
||||
resource_class = None
|
||||
@ -83,7 +85,8 @@ class Manager(utils.HookableMixin):
|
||||
|
||||
@contextlib.contextmanager
|
||||
def completion_cache(self, cache_type, obj_class, mode):
|
||||
"""
|
||||
"""Bash autocompletion items storage.
|
||||
|
||||
The completion cache store items that can be used for bash
|
||||
autocompletion, like UUIDs or human-friendly IDs.
|
||||
|
||||
@ -170,12 +173,9 @@ class Manager(utils.HookableMixin):
|
||||
|
||||
|
||||
class ManagerWithFind(Manager):
|
||||
"""
|
||||
Like a `Manager`, but with additional `find()`/`findall()` methods.
|
||||
"""
|
||||
"""Like a `Manager`, but with additional `find()`/`findall()` methods."""
|
||||
def find(self, **kwargs):
|
||||
"""
|
||||
Find a single item with attributes matching ``**kwargs``.
|
||||
"""Find a single item with attributes matching ``**kwargs``.
|
||||
|
||||
This isn't very efficient: it loads the entire list then filters on
|
||||
the Python side.
|
||||
@ -191,8 +191,7 @@ class ManagerWithFind(Manager):
|
||||
return matches[0]
|
||||
|
||||
def findall(self, **kwargs):
|
||||
"""
|
||||
Find all items with attributes matching ``**kwargs``.
|
||||
"""Find all items with attributes matching ``**kwargs``.
|
||||
|
||||
This isn't very efficient: it loads the entire list then filters on
|
||||
the Python side.
|
||||
@ -215,9 +214,10 @@ class ManagerWithFind(Manager):
|
||||
|
||||
|
||||
class Resource(object):
|
||||
"""
|
||||
A resource represents a particular instance of an object (server, flavor,
|
||||
etc). This is pretty much just a bag for attributes.
|
||||
"""Resource as instance of an object.
|
||||
|
||||
A resource represents a particular instance of an object (share,
|
||||
snapshot, etc). This is pretty much just a bag for attributes.
|
||||
|
||||
:param manager: Manager object
|
||||
:param info: dictionary representing resource attributes
|
||||
|
@ -202,8 +202,10 @@ class HTTPClient(object):
|
||||
|
||||
def _extract_service_catalog(self, url, resp, body, extract_token=True):
|
||||
"""See what the auth service told us and process the response.
|
||||
|
||||
We may get redirected to another site, fail or actually get
|
||||
back a service catalog with a token and our endpoints."""
|
||||
back a service catalog with a token and our endpoints.
|
||||
"""
|
||||
|
||||
if resp.status_code == 200: # content must always present
|
||||
try:
|
||||
|
@ -5,8 +5,11 @@ Exception definitions.
|
||||
|
||||
|
||||
class UnsupportedVersion(Exception):
|
||||
"""Indicates that the user is trying to use an unsupported
|
||||
version of the API"""
|
||||
"""Usage of unsupported API version.
|
||||
|
||||
Indicates that the user is trying to use an unsupported version
|
||||
of the API.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@ -23,8 +26,11 @@ class NoUniqueMatch(Exception):
|
||||
|
||||
|
||||
class NoTokenLookupException(Exception):
|
||||
"""This form of authentication does not support looking up
|
||||
endpoints from an existing token."""
|
||||
"""No support for looking up endpoints.
|
||||
|
||||
This form of authentication does not support looking up
|
||||
endpoints from an existing token.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@ -43,9 +49,7 @@ class AmbiguousEndpoints(Exception):
|
||||
|
||||
|
||||
class ClientException(Exception):
|
||||
"""
|
||||
The base exception class for all exceptions this library raises.
|
||||
"""
|
||||
"""The base exception class for all exceptions this library raises."""
|
||||
def __init__(self, code, message=None, details=None, request_id=None):
|
||||
self.code = code
|
||||
self.message = message or self.__class__.message
|
||||
@ -61,41 +65,36 @@ class ClientException(Exception):
|
||||
|
||||
|
||||
class BadRequest(ClientException):
|
||||
"""
|
||||
HTTP 400 - Bad request: you sent some malformed data.
|
||||
"""
|
||||
"""HTTP 400 - Bad request: you sent some malformed data."""
|
||||
http_status = 400
|
||||
message = "Bad request"
|
||||
|
||||
|
||||
class Unauthorized(ClientException):
|
||||
"""
|
||||
HTTP 401 - Unauthorized: bad credentials.
|
||||
"""
|
||||
"""HTTP 401 - Unauthorized: bad credentials."""
|
||||
http_status = 401
|
||||
message = "Unauthorized"
|
||||
|
||||
|
||||
class Forbidden(ClientException):
|
||||
"""
|
||||
HTTP 403 - Forbidden: your credentials don't give you access to this
|
||||
resource.
|
||||
"""HTTP 403.
|
||||
|
||||
Forbidden: your credentials don't give you access to this resource.
|
||||
"""
|
||||
http_status = 403
|
||||
message = "Forbidden"
|
||||
|
||||
|
||||
class NotFound(ClientException):
|
||||
"""
|
||||
HTTP 404 - Not found
|
||||
"""
|
||||
"""HTTP 404 - Not found."""
|
||||
http_status = 404
|
||||
message = "Not found"
|
||||
|
||||
|
||||
class OverLimit(ClientException):
|
||||
"""
|
||||
HTTP 413 - Over limit: you're over the API limits for this time period.
|
||||
"""HTTP 413.
|
||||
|
||||
Over limit: you're over the API limits for this time period.
|
||||
"""
|
||||
http_status = 413
|
||||
message = "Over limit"
|
||||
@ -103,8 +102,9 @@ class OverLimit(ClientException):
|
||||
|
||||
# NotImplemented is a python keyword.
|
||||
class HTTPNotImplemented(ClientException):
|
||||
"""
|
||||
HTTP 501 - Not Implemented: the server does not support this operation.
|
||||
"""HTTP 501.
|
||||
|
||||
Not Implemented: the server does not support this operation.
|
||||
"""
|
||||
http_status = 501
|
||||
message = "Not Implemented"
|
||||
@ -122,9 +122,10 @@ _code_map = dict((c.http_status, c) for c in [BadRequest, Unauthorized,
|
||||
|
||||
|
||||
def from_response(response, body):
|
||||
"""
|
||||
Return an instance of an ClientException or subclass
|
||||
based on an requests response.
|
||||
"""Parse response and return Exception based on it.
|
||||
|
||||
Return an instance of an ClientException or subclass based
|
||||
on an requests response.
|
||||
|
||||
Usage::
|
||||
|
||||
|
@ -34,9 +34,12 @@ class ServiceCatalog(object):
|
||||
def url_for(self, attr=None, filter_value=None,
|
||||
service_type=None, endpoint_type='publicURL',
|
||||
service_name=None, share_service_name=None):
|
||||
"""Fetch the public URL from the Compute service for
|
||||
a particular endpoint attribute. If none given, return
|
||||
the first. See tests for sample service catalog."""
|
||||
"""Returns url for specified endpoint type.
|
||||
|
||||
Fetch the public URL from the Compute service for
|
||||
a particular endpoint attribute.
|
||||
If none given, return the first. See tests for sample service catalog.
|
||||
"""
|
||||
matching_endpoints = []
|
||||
if 'endpoints' in self.catalog:
|
||||
# We have a bastardized service catalog. Treat it special. :/
|
||||
|
@ -432,9 +432,7 @@ class OpenStackManilaShell(object):
|
||||
@utils.arg('command', metavar='<subcommand>', nargs='?',
|
||||
help='Display help for <subcommand>')
|
||||
def do_help(self, args):
|
||||
"""
|
||||
Display help about this program or one of its subcommands.
|
||||
"""
|
||||
"""Display help about this program or one of its subcommands."""
|
||||
if args.command:
|
||||
if args.command in self.subcommands:
|
||||
self.subcommands[args.command].print_help()
|
||||
|
@ -17,9 +17,10 @@ def arg(*args, **kwargs):
|
||||
|
||||
|
||||
def env(*vars, **kwargs):
|
||||
"""
|
||||
returns the first environment variable set
|
||||
if none are non-empty, defaults to '' or keyword arg default
|
||||
"""Returns value of env var if exist.
|
||||
|
||||
Returns the first environment variable set if none are non-empty,
|
||||
defaults to '' or keyword arg default.
|
||||
"""
|
||||
for v in vars:
|
||||
value = os.environ.get(v, None)
|
||||
@ -78,8 +79,8 @@ def get_resource_manager_extra_kwargs(f, args, allow_conflicts=False):
|
||||
|
||||
|
||||
def unauthenticated(f):
|
||||
"""
|
||||
Adds 'unauthenticated' attribute to decorated function.
|
||||
"""Adds 'unauthenticated' attribute to decorated function.
|
||||
|
||||
Usage:
|
||||
@unauthenticated
|
||||
def mymethod(f):
|
||||
@ -90,17 +91,18 @@ def unauthenticated(f):
|
||||
|
||||
|
||||
def isunauthenticated(f):
|
||||
"""
|
||||
"""Verifies whether function requires authentication or not.
|
||||
|
||||
Checks to see if the function is marked as not requiring authentication
|
||||
with the @unauthenticated decorator. Returns True if decorator is
|
||||
set to True, False otherwise.
|
||||
with the @unauthenticated decorator.
|
||||
Returns True if decorator is set to True, False otherwise.
|
||||
"""
|
||||
return getattr(f, 'unauthenticated', False)
|
||||
|
||||
|
||||
def service_type(stype):
|
||||
"""
|
||||
Adds 'service_type' attribute to decorated function.
|
||||
"""Adds 'service_type' attribute to decorated function.
|
||||
|
||||
Usage:
|
||||
@service_type('share')
|
||||
def mymethod(f):
|
||||
@ -113,9 +115,7 @@ def service_type(stype):
|
||||
|
||||
|
||||
def get_service_type(f):
|
||||
"""
|
||||
Retrieves service type from function
|
||||
"""
|
||||
"""Retrieves service type from function."""
|
||||
return getattr(f, 'service_type', None)
|
||||
|
||||
|
||||
@ -250,10 +250,7 @@ def import_class(import_str):
|
||||
|
||||
|
||||
def make_metadata_dict(metadata):
|
||||
"""
|
||||
Converts given metadata in form of list of 'key=value' strings into
|
||||
{'key': 'value'} dictionary
|
||||
"""
|
||||
"""Converts cli key=value data to python dict as {'key': 'value'}."""
|
||||
metadata_dict = {}
|
||||
for item in metadata:
|
||||
try:
|
||||
|
@ -39,9 +39,7 @@ class ListExtManager(base.Manager):
|
||||
|
||||
@utils.service_type('share')
|
||||
def do_list_extensions(client, _args):
|
||||
"""
|
||||
List all the os-api extensions that are available.
|
||||
"""
|
||||
"""List all the os-api extensions that are available."""
|
||||
extensions = client.list_extensions.show_all()
|
||||
fields = ["Name", "Summary", "Alias", "Updated"]
|
||||
utils.print_list(extensions, fields)
|
||||
|
@ -4,7 +4,7 @@ from manilaclient import base
|
||||
|
||||
|
||||
class Limits(base.Resource):
|
||||
"""A collection of RateLimit and AbsoluteLimit objects"""
|
||||
"""A collection of RateLimit and AbsoluteLimit objects."""
|
||||
|
||||
def __repr__(self):
|
||||
return "<Limits>"
|
||||
@ -26,7 +26,7 @@ class Limits(base.Resource):
|
||||
|
||||
|
||||
class RateLimit(object):
|
||||
"""Data model that represents a flattened view of a single rate limit"""
|
||||
"""Data model that represents a flattened view of a single rate limit."""
|
||||
|
||||
def __init__(self, verb, uri, regex, value, remain,
|
||||
unit, next_available):
|
||||
@ -52,7 +52,7 @@ class RateLimit(object):
|
||||
|
||||
|
||||
class AbsoluteLimit(object):
|
||||
"""Data model that represents a single absolute limit"""
|
||||
"""Data model that represents a single absolute limit."""
|
||||
|
||||
def __init__(self, name, value):
|
||||
self.name = name
|
||||
@ -66,7 +66,7 @@ class AbsoluteLimit(object):
|
||||
|
||||
|
||||
class LimitsManager(base.Manager):
|
||||
"""Manager object used to interact with limits resource"""
|
||||
"""Manager object used to interact with limits resource."""
|
||||
|
||||
resource_class = Limits
|
||||
|
||||
|
@ -20,7 +20,7 @@ class QuotaClassSet(base.Resource):
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Needed by base.Resource to self-refresh and be indexed"""
|
||||
"""Needed by base.Resource to self-refresh and be indexed."""
|
||||
return self.class_name
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
|
@ -20,7 +20,7 @@ class QuotaSet(base.Resource):
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
"""Needed by base.Resource to self-refresh and be indexed"""
|
||||
"""Needed by base.Resource to self-refresh and be indexed."""
|
||||
return self.tenant_id
|
||||
|
||||
def update(self, *args, **kwargs):
|
||||
|
@ -24,13 +24,14 @@ RESOURCES_NAME = 'security_services'
|
||||
|
||||
|
||||
class SecurityService(base.Resource):
|
||||
"""Security service for Manila shares """
|
||||
"""Security service for Manila shares."""
|
||||
def __repr__(self):
|
||||
return "<SecurityService: %s>" % self.id
|
||||
|
||||
|
||||
class SecurityServiceManager(base.Manager):
|
||||
"""Manage :class:`SecurityService` resources."""
|
||||
|
||||
resource_class = SecurityService
|
||||
|
||||
def create(self, type, dns_ip=None, server=None, domain=None, sid=None,
|
||||
|
@ -24,7 +24,7 @@ RESOURCES_NAME = 'share_networks'
|
||||
|
||||
|
||||
class ShareNetwork(base.Resource):
|
||||
"""Network info for Manila shares """
|
||||
"""Network info for Manila shares."""
|
||||
def __repr__(self):
|
||||
return "<ShareNetwork: %s>" % self.id
|
||||
|
||||
|
@ -220,16 +220,14 @@ class ShareManager(base.ManagerWithFind):
|
||||
return []
|
||||
|
||||
def get_metadata(self, share):
|
||||
"""
|
||||
Get a shares metadata.
|
||||
"""Get a shares metadata.
|
||||
|
||||
:param share: The :class:`Share`.
|
||||
"""
|
||||
return self._get("/shares/%s/metadata" % base.getid(share), "metadata")
|
||||
|
||||
def set_metadata(self, share, metadata):
|
||||
"""
|
||||
Update/Set a shares metadata.
|
||||
"""Update/Set a shares metadata.
|
||||
|
||||
:param share: The :class:`Share`.
|
||||
:param metadata: A list of keys to be set.
|
||||
@ -239,8 +237,7 @@ class ShareManager(base.ManagerWithFind):
|
||||
body, "metadata")
|
||||
|
||||
def delete_metadata(self, share, keys):
|
||||
"""
|
||||
Delete specified keys from volumes metadata.
|
||||
"""Delete specified keys from volumes metadata.
|
||||
|
||||
:param share: The :class:`Share`.
|
||||
:param keys: A list of keys to be removed.
|
||||
|
@ -101,14 +101,14 @@ def _extract_metadata(args):
|
||||
|
||||
|
||||
def do_endpoints(cs, args):
|
||||
"""Discover endpoints that get returned from the authenticate services"""
|
||||
"""Discover endpoints that get returned from the authenticate services."""
|
||||
catalog = cs.client.service_catalog.catalog
|
||||
for e in catalog['access']['serviceCatalog']:
|
||||
utils.print_dict(e['endpoints'][0], e['name'])
|
||||
|
||||
|
||||
def do_credentials(cs, args):
|
||||
"""Show user credentials returned from auth"""
|
||||
"""Show user credentials returned from auth."""
|
||||
catalog = cs.client.service_catalog.catalog
|
||||
utils.print_dict(catalog['access']['user'], "User Credentials")
|
||||
utils.print_dict(catalog['access']['token'], "Token")
|
||||
@ -731,7 +731,7 @@ def do_reset_state(cs, args):
|
||||
default=None,
|
||||
help="Share network description.")
|
||||
def do_share_network_create(cs, args):
|
||||
"""Create description for network used by the tenant"""
|
||||
"""Create description for network used by the tenant."""
|
||||
values = {'neutron_net_id': args.neutron_net_id,
|
||||
'neutron_subnet_id': args.neutron_subnet_id,
|
||||
'name': args.name,
|
||||
@ -767,7 +767,7 @@ def do_share_network_create(cs, args):
|
||||
default=None,
|
||||
help="Share network description.")
|
||||
def do_share_network_update(cs, args):
|
||||
"""Update share network data"""
|
||||
"""Update share network data."""
|
||||
values = {'neutron_net_id': args.neutron_net_id,
|
||||
'neutron_subnet_id': args.neutron_subnet_id,
|
||||
'name': args.name,
|
||||
@ -783,7 +783,7 @@ def do_share_network_update(cs, args):
|
||||
metavar='<share-network>',
|
||||
help='Name or ID of the share network to show.')
|
||||
def do_share_network_show(cs, args):
|
||||
"""Get a description for network used by the tenant"""
|
||||
"""Get a description for network used by the tenant."""
|
||||
share_network = _find_share_network(cs, args.share_network)
|
||||
info = share_network._info.copy()
|
||||
utils.print_dict(info)
|
||||
@ -804,7 +804,7 @@ def do_share_network_show(cs, args):
|
||||
default=None,
|
||||
help='Filter results by status')
|
||||
def do_share_network_list(cs, args):
|
||||
"""Get a list of network info"""
|
||||
"""Get a list of network info."""
|
||||
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
|
||||
search_opts = {
|
||||
'all_tenants': all_tenants,
|
||||
@ -824,7 +824,7 @@ def do_share_network_list(cs, args):
|
||||
metavar='<security-service>',
|
||||
help='Security service to associate with.')
|
||||
def do_share_network_security_service_add(cs, args):
|
||||
"""Associate security service with share network"""
|
||||
"""Associate security service with share network."""
|
||||
share_network = _find_share_network(cs, args.share_network)
|
||||
cs.share_networks.add_security_service(share_network,
|
||||
args.security_service)
|
||||
@ -839,7 +839,7 @@ def do_share_network_security_service_add(cs, args):
|
||||
metavar='<security-service>',
|
||||
help='Security service to dissociate.')
|
||||
def do_share_network_security_service_remove(cs, args):
|
||||
"""Dissociate security service from share network"""
|
||||
"""Dissociate security service from share network."""
|
||||
share_network = _find_share_network(cs, args.share_network)
|
||||
cs.share_networks.remove_security_service(share_network,
|
||||
args.security_service)
|
||||
@ -850,7 +850,7 @@ def do_share_network_security_service_remove(cs, args):
|
||||
metavar='<share-network>',
|
||||
help='Share network name or ID.')
|
||||
def do_share_network_security_service_list(cs, args):
|
||||
"""Get a list of security services associated with a given share network"""
|
||||
"""Get list of security services associated with a given share network."""
|
||||
share_network = _find_share_network(cs, args.share_network)
|
||||
search_opts = {
|
||||
'share_network_id': share_network.id,
|
||||
@ -865,7 +865,7 @@ def do_share_network_security_service_list(cs, args):
|
||||
metavar='<share-network>',
|
||||
help='Name or ID of share network to be deleted.')
|
||||
def do_share_network_delete(cs, args):
|
||||
"""Delete share network"""
|
||||
"""Delete share network."""
|
||||
_find_share_network(cs, args.share_network).delete()
|
||||
|
||||
|
||||
@ -909,7 +909,7 @@ def do_share_network_delete(cs, args):
|
||||
default=None,
|
||||
help="security service description")
|
||||
def do_security_service_create(cs, args):
|
||||
"""Create security service used by tenant"""
|
||||
"""Create security service used by tenant."""
|
||||
values = {'dns_ip': args.dns_ip,
|
||||
'server': args.server,
|
||||
'domain': args.domain,
|
||||
@ -962,7 +962,7 @@ def do_security_service_create(cs, args):
|
||||
default=None,
|
||||
help="security service description")
|
||||
def do_security_service_update(cs, args):
|
||||
"""Update security service"""
|
||||
"""Update security service."""
|
||||
values = {'dns_ip': args.dns_ip,
|
||||
'server': args.server,
|
||||
'domain': args.domain,
|
||||
@ -981,7 +981,7 @@ def do_security_service_update(cs, args):
|
||||
metavar='<security-service>',
|
||||
help='Security service to show.')
|
||||
def do_security_service_show(cs, args):
|
||||
"""Show security service"""
|
||||
"""Show security service."""
|
||||
security_service = cs.security_services.get(args.security_service)
|
||||
info = security_service._info.copy()
|
||||
utils.print_dict(info)
|
||||
@ -1002,7 +1002,7 @@ def do_security_service_show(cs, args):
|
||||
default=None,
|
||||
help='Filter results by status')
|
||||
def do_security_service_list(cs, args):
|
||||
"""Get a list of security services"""
|
||||
"""Get a list of security services."""
|
||||
all_tenants = int(os.environ.get("ALL_TENANTS", args.all_tenants))
|
||||
search_opts = {
|
||||
'all_tenants': all_tenants,
|
||||
@ -1018,7 +1018,7 @@ def do_security_service_list(cs, args):
|
||||
metavar='<security-service>',
|
||||
help='Security service to delete.')
|
||||
def do_security_service_delete(cs, args):
|
||||
"""Delete security service"""
|
||||
"""Delete security service."""
|
||||
cs.security_services.delete(args.security_service)
|
||||
|
||||
|
||||
|
@ -22,15 +22,13 @@ from manilaclient import base
|
||||
|
||||
|
||||
class VolumeType(base.Resource):
|
||||
"""
|
||||
A Volume Type is the type of volume to be created
|
||||
"""
|
||||
"""A Volume Type is the type of volume to be created."""
|
||||
|
||||
def __repr__(self):
|
||||
return "<VolumeType: %s>" % self.name
|
||||
|
||||
def get_keys(self):
|
||||
"""
|
||||
Get extra specs from a volume type.
|
||||
"""Get extra specs from a volume type.
|
||||
|
||||
:param vol_type: The :class:`VolumeType` to get extra specs from
|
||||
"""
|
||||
@ -40,8 +38,7 @@ class VolumeType(base.Resource):
|
||||
return body["extra_specs"]
|
||||
|
||||
def set_keys(self, metadata):
|
||||
"""
|
||||
Set extra specs on a volume type.
|
||||
"""Set extra specs on a volume type.
|
||||
|
||||
:param type : The :class:`VolumeType` to set extra spec on
|
||||
:param metadata: A dict of key/value pairs to be set
|
||||
@ -54,8 +51,7 @@ class VolumeType(base.Resource):
|
||||
return_raw=True)
|
||||
|
||||
def unset_keys(self, keys):
|
||||
"""
|
||||
Unset extra specs on a volume type.
|
||||
"""Unset extra specs on a volume type.
|
||||
|
||||
:param type_id: The :class:`VolumeType` to unset extra spec on
|
||||
:param keys: A list of keys to be unset
|
||||
@ -74,22 +70,19 @@ class VolumeType(base.Resource):
|
||||
|
||||
|
||||
class VolumeTypeManager(base.ManagerWithFind):
|
||||
"""
|
||||
Manage :class:`VolumeType` resources.
|
||||
"""
|
||||
"""Manage :class:`VolumeType` resources."""
|
||||
|
||||
resource_class = VolumeType
|
||||
|
||||
def list(self, search_opts=None):
|
||||
"""
|
||||
Get a list of all volume types.
|
||||
"""Get a list of all volume types.
|
||||
|
||||
:rtype: list of :class:`VolumeType`.
|
||||
"""
|
||||
return self._list("/types", "volume_types")
|
||||
|
||||
def get(self, volume_type):
|
||||
"""
|
||||
Get a specific volume type.
|
||||
"""Get a specific volume type.
|
||||
|
||||
:param volume_type: The ID of the :class:`VolumeType` to get.
|
||||
:rtype: :class:`VolumeType`
|
||||
@ -97,16 +90,14 @@ class VolumeTypeManager(base.ManagerWithFind):
|
||||
return self._get("/types/%s" % base.getid(volume_type), "volume_type")
|
||||
|
||||
def delete(self, volume_type):
|
||||
"""
|
||||
Delete a specific volume_type.
|
||||
"""Delete a specific volume_type.
|
||||
|
||||
:param volume_type: The name or ID of the :class:`VolumeType` to get.
|
||||
"""
|
||||
self._delete("/types/%s" % base.getid(volume_type))
|
||||
|
||||
def create(self, name):
|
||||
"""
|
||||
Create a volume type.
|
||||
"""Create a volume type.
|
||||
|
||||
:param name: Descriptive name of the volume type
|
||||
:rtype: :class:`VolumeType`
|
||||
|
@ -21,9 +21,7 @@ def assert_has_keys(dict, required=[], optional=[]):
|
||||
class FakeClient(object):
|
||||
|
||||
def assert_called(self, method, url, body=None, pos=-1, **kwargs):
|
||||
"""
|
||||
Assert than an API method was just called.
|
||||
"""
|
||||
"""Assert than an API method was just called."""
|
||||
expected = (method, url)
|
||||
called = self.client.callstack[pos][0:2]
|
||||
|
||||
@ -37,9 +35,7 @@ class FakeClient(object):
|
||||
assert self.client.callstack[pos][2] == body
|
||||
|
||||
def assert_called_anytime(self, method, url, body=None):
|
||||
"""
|
||||
Assert than an API method was called anytime in the test.
|
||||
"""
|
||||
"""Assert than an API method was called anytime in the test."""
|
||||
expected = (method, url)
|
||||
|
||||
assert self.client.callstack, ("Expected %s %s but no calls "
|
||||
|
@ -23,8 +23,11 @@ class TestCase(testtools.TestCase):
|
||||
|
||||
|
||||
class TestResponse(requests.Response):
|
||||
""" Class used to wrap requests.Response and provide some
|
||||
convenience to initialize with a dict """
|
||||
"""Class used to wrap requests.Response.
|
||||
|
||||
Class used to wrap requests.Response and provide some
|
||||
convenience to initialize with a dict.
|
||||
"""
|
||||
|
||||
def __init__(self, data):
|
||||
self._text = None
|
||||
|
@ -46,7 +46,8 @@ def check_python_version():
|
||||
|
||||
|
||||
def run_command_with_code(cmd, redirect_output=True, check_exit_code=True):
|
||||
"""
|
||||
"""Runs a command in an out-of-process shell.
|
||||
|
||||
Runs a command in an out-of-process shell, returning the
|
||||
output of that command. Working directory is ROOT.
|
||||
"""
|
||||
@ -91,7 +92,8 @@ class Distro(object):
|
||||
"""Any distribution-specific post-processing gets done here.
|
||||
|
||||
In particular, this is useful for applying patches to code inside
|
||||
the venv."""
|
||||
the venv.
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@ -121,7 +123,8 @@ class Debian(Distro):
|
||||
class Fedora(Distro):
|
||||
"""This covers all Fedora-based distributions.
|
||||
|
||||
Includes: Fedora, RHEL, CentOS, Scientific Linux"""
|
||||
Includes: Fedora, RHEL, CentOS, Scientific Linux.
|
||||
"""
|
||||
|
||||
def check_pkg(self, pkg):
|
||||
return run_command_with_code(['rpm', '-q', pkg],
|
||||
@ -223,7 +226,7 @@ def print_help():
|
||||
|
||||
|
||||
def parse_args():
|
||||
"""Parse command-line arguments"""
|
||||
"""Parse command-line arguments."""
|
||||
parser = optparse.OptionParser()
|
||||
parser.add_option("-n", "--no-site-packages", dest="no_site_packages",
|
||||
default=False, action="store_true",
|
||||
|
Loading…
Reference in New Issue
Block a user