Fix H404/405 violations in novaclient/v2/[a-f]

There is a lot of H404/405 violations in novaclient, and it is better
to fix those to have a better doc string for class/methods.

This patch fixes these violations for [a-f] files under  novaclient/v2
folder.

As there are lot of violations and cannot be fixed in single patches,
So separating those in multiple patches for easy review.

Change-Id: Ibe5afef349d1be6d70903e06bee402ca30738ea1
Partial-Bug: #1521899
This commit is contained in:
Ghanshyam 2015-12-07 17:35:19 +09:00
parent 573bdaa290
commit a37c4328a1
11 changed files with 56 additions and 108 deletions

View File

@ -22,9 +22,7 @@ from novaclient import base
class AvailabilityZone(base.Resource):
"""
An availability zone object.
"""
"""An availability zone object."""
NAME_ATTR = 'display_name'
def __repr__(self):
@ -32,17 +30,15 @@ class AvailabilityZone(base.Resource):
class AvailabilityZoneManager(base.ManagerWithFind):
"""
Manage :class:`AvailabilityZone` resources.
"""
"""Manage :class:`AvailabilityZone` resources."""
resource_class = AvailabilityZone
return_parameter_name = "availabilityZoneInfo"
def list(self, detailed=True):
"""
Get a list of all availability zones.
"""Get a list of all availability zones.
:rtype: list of :class:`AvailabilityZone`
:param detailed: If True, list availability zones with details.
:returns: list of :class:`AvailabilityZone`
"""
if detailed is True:
return self._list("/os-availability-zone/detail",

View File

@ -30,19 +30,13 @@ class Certificate(base.Resource):
class CertificateManager(base.Manager):
"""
Manage :class:`Certificate` resources.
"""
"""Manage :class:`Certificate` resources."""
resource_class = Certificate
def create(self):
"""
Create a x509 certificate for a user in tenant.
"""
"""Create a x509 certificate for a user in tenant."""
return self._create('/os-certificates', {}, 'certificate')
def get(self):
"""
Get root certificate.
"""
"""Get root certificate."""
return self._get("/os-certificates/root", 'certificate')

View File

@ -52,8 +52,7 @@ from novaclient.v2 import volumes
class Client(object):
"""
Top-level object to access the OpenStack Compute API.
"""Top-level object to access the OpenStack Compute API.
.. warning:: All scripts and projects should not initialize this class
directly. It should be done via `novaclient.client.Client` interface.
@ -70,7 +69,8 @@ class Client(object):
cacert=None, tenant_id=None, user_id=None,
connection_pool=False, session=None, auth=None,
api_version=None, direct_use=True, **kwargs):
"""
"""Initialization of Client object.
:param str username: Username
:param str api_key: API Key
:param str project_id: Project ID
@ -226,8 +226,7 @@ class Client(object):
@client._original_only
def authenticate(self):
"""
Authenticate against the server.
"""Authenticate against the server.
Normally this is called automatically when you first access the API,
but you can call this method to force authentication right now.

View File

@ -32,8 +32,7 @@ class CloudpipeManager(base.ManagerWithFind):
resource_class = Cloudpipe
def create(self, project):
"""
Launch a cloudpipe instance.
"""Launch a cloudpipe instance.
:param project: UUID of the project (tenant) for the cloudpipe
"""
@ -42,13 +41,12 @@ class CloudpipeManager(base.ManagerWithFind):
return_raw=True)
def list(self):
"""
Get a list of cloudpipe instances.
"""
"""Get a list of cloudpipe instances."""
return self._list('/os-cloudpipe', 'cloudpipes')
def update(self, address, port):
"""
"""Configure cloudpipe parameters for the project.
Update VPN address and port for all networks associated
with the project defined by authentication

View File

@ -29,8 +29,7 @@ class FixedIPsManager(base.Manager):
resource_class = FixedIP
def get(self, fixed_ip):
"""
Show information for a Fixed IP
"""Show information for a Fixed IP.
:param fixed_ip: Fixed IP address to get info for
"""
@ -38,7 +37,7 @@ class FixedIPsManager(base.Manager):
"fixed_ip")
def reserve(self, fixed_ip):
"""Reserve a Fixed IP
"""Reserve a Fixed IP.
:param fixed_ip: Fixed IP address to reserve
"""
@ -47,7 +46,7 @@ class FixedIPsManager(base.Manager):
body=body)
def unreserve(self, fixed_ip):
"""Unreserve a Fixed IP
"""Unreserve a Fixed IP.
:param fixed_ip: Fixed IP address to unreserve
"""

View File

@ -26,9 +26,7 @@ class FlavorAccess(base.Resource):
class FlavorAccessManager(base.ManagerWithFind):
"""
Manage :class:`FlavorAccess` resources.
"""
"""Manage :class:`FlavorAccess` resources."""
resource_class = FlavorAccess
def list(self, **kwargs):

View File

@ -26,9 +26,7 @@ from novaclient import utils
class Flavor(base.Resource):
"""
A flavor is an available hardware configuration for a server.
"""
"""A flavor is an available hardware configuration for a server."""
HUMAN_ID = True
def __repr__(self):
@ -36,29 +34,22 @@ class Flavor(base.Resource):
@property
def ephemeral(self):
"""
Provide a user-friendly accessor to OS-FLV-EXT-DATA:ephemeral
"""
"""Provide a user-friendly accessor to OS-FLV-EXT-DATA:ephemeral."""
return self._info.get("OS-FLV-EXT-DATA:ephemeral", 'N/A')
@property
def is_public(self):
"""
Provide a user-friendly accessor to os-flavor-access:is_public
"""
"""Provide a user-friendly accessor to os-flavor-access:is_public."""
return self._info.get("os-flavor-access:is_public", 'N/A')
def get_keys(self):
"""
Get extra specs from a flavor.
"""
"""Get extra specs from a flavor."""
_resp, body = self.manager.api.client.get(
"/flavors/%s/os-extra_specs" % base.getid(self))
return body["extra_specs"]
def set_keys(self, metadata):
"""
Set extra specs on a flavor.
"""Set extra specs on a flavor.
:param metadata: A dict of key/value pairs to be set
"""
@ -70,8 +61,7 @@ class Flavor(base.Resource):
"extra_specs", return_raw=True)
def unset_keys(self, keys):
"""
Unset extra specs on a flavor.
"""Unset extra specs on a flavor.
:param keys: A list of keys to be unset
"""
@ -80,30 +70,30 @@ class Flavor(base.Resource):
"/flavors/%s/os-extra_specs/%s" % (base.getid(self), k))
def delete(self):
"""
Delete this flavor.
"""
"""Delete this flavor."""
self.manager.delete(self)
class FlavorManager(base.ManagerWithFind):
"""
Manage :class:`Flavor` resources.
"""
"""Manage :class:`Flavor` resources."""
resource_class = Flavor
is_alphanum_id_allowed = True
def list(self, detailed=True, is_public=True, marker=None, limit=None,
sort_key=None, sort_dir=None):
"""
Get a list of all flavors.
"""Get a list of all flavors.
:rtype: list of :class:`Flavor`.
:param limit: maximum number of flavors to return (optional).
:param detailed: Whether flavor needs to be return with details
(optional).
:param is_public: Filter flavors with provided access type (optional).
None means give all flavors and only admin has query
access to all flavor types.
:param marker: Begin returning flavors that appear later in the flavor
list than that represented by this flavor id (optional).
:param limit: maximum number of flavors to return (optional).
:param sort_key: Flavors list sort key (optional).
:param sort_dir: Flavors list sort direction (optional).
:returns: list of :class:`Flavor`.
"""
qparams = {}
# is_public is ternary - None means give all flavors.
@ -129,17 +119,15 @@ class FlavorManager(base.ManagerWithFind):
return self._list("/flavors%s%s" % (detail, query_string), "flavors")
def get(self, flavor):
"""
Get a specific flavor.
"""Get a specific flavor.
:param flavor: The ID of the :class:`Flavor` to get.
:rtype: :class:`Flavor`
:returns: :class:`Flavor`
"""
return self._get("/flavors/%s" % base.getid(flavor), "flavor")
def delete(self, flavor):
"""
Delete a specific flavor.
"""Delete a specific flavor.
:param flavor: The ID of the :class:`Flavor` to get.
"""
@ -163,8 +151,7 @@ class FlavorManager(base.ManagerWithFind):
def create(self, name, ram, vcpus, disk, flavorid="auto",
ephemeral=0, swap=0, rxtx_factor=1.0, is_public=True):
"""
Create a flavor.
"""Create a flavor.
:param name: Descriptive name of the flavor
:param ram: Memory in MB for the flavor
@ -175,7 +162,7 @@ class FlavorManager(base.ManagerWithFind):
flavor in cases where you cannot simply pass ``None``.
:param swap: Swap space in MB
:param rxtx_factor: RX/TX factor
:rtype: :class:`Flavor`
:returns: :class:`Flavor`
"""
try:

View File

@ -26,7 +26,5 @@ class FloatingIPPoolManager(base.ManagerWithFind):
resource_class = FloatingIPPool
def list(self):
"""
Retrieve a list of all floating ip pools.
"""
"""Retrieve a list of all floating ip pools."""
return self._list('/os-floating-ip-pools', 'floating_ip_pools')

View File

@ -19,9 +19,7 @@ from novaclient import base
class FloatingIP(base.Resource):
def delete(self):
"""
Delete this floating IP
"""
"""Delete this floating IP"""
self.manager.delete(self)
@ -29,28 +27,21 @@ class FloatingIPManager(base.ManagerWithFind):
resource_class = FloatingIP
def list(self):
"""
List floating IPs
"""
"""List floating IPs"""
return self._list("/os-floating-ips", "floating_ips")
def create(self, pool=None):
"""
Create (allocate) a floating IP for a tenant
"""
"""Create (allocate) a floating IP for a tenant"""
return self._create("/os-floating-ips", {'pool': pool}, "floating_ip")
def delete(self, floating_ip):
"""
Delete (deallocate) a floating IP for a tenant
"""Delete (deallocate) a floating IP for a tenant
:param floating_ip: The floating IP address to delete.
"""
self._delete("/os-floating-ips/%s" % base.getid(floating_ip))
def get(self, floating_ip):
"""
Retrieve a floating IP
"""
"""Retrieve a floating IP"""
return self._get("/os-floating-ips/%s" % base.getid(floating_ip),
"floating_ip")

View File

@ -29,9 +29,7 @@ class FloatingIPBulkManager(base.ManagerWithFind):
resource_class = FloatingIPRange
def list(self, host=None):
"""
List all floating IPs
"""
"""List all floating IPs."""
if host is None:
return self._list('/os-floating-ips-bulk',
'floating_ip_info',
@ -42,9 +40,7 @@ class FloatingIPBulkManager(base.ManagerWithFind):
obj_class=floating_ips.FloatingIP)
def create(self, ip_range, pool=None, interface=None):
"""
Create floating IPs by range
"""
"""Create floating IPs by range."""
body = {"floating_ips_bulk_create": {'ip_range': ip_range}}
if pool is not None:
body['floating_ips_bulk_create']['pool'] = pool
@ -55,8 +51,6 @@ class FloatingIPBulkManager(base.ManagerWithFind):
'floating_ips_bulk_create')
def delete(self, ip_range):
"""
Delete floating IPs by range
"""
"""Delete floating IPs by range."""
body = {"ip_range": ip_range}
return self._update('/os-floating-ips-bulk/delete', body)

View File

@ -21,9 +21,7 @@ from novaclient import base
class Fping(base.Resource):
"""
A server to fping.
"""
"""A server to fping."""
HUMAN_ID = True
def __repr__(self):
@ -31,16 +29,13 @@ class Fping(base.Resource):
class FpingManager(base.ManagerWithFind):
"""
Manage :class:`Fping` resources.
"""
"""Manage :class:`Fping` resources."""
resource_class = Fping
def list(self, all_tenants=False, include=[], exclude=[]):
"""
Fping all servers.
"""Fping all servers.
:rtype: list of :class:`Fping`.
:returns: list of :class:`Fping`.
"""
params = []
if all_tenants:
@ -55,10 +50,9 @@ class FpingManager(base.ManagerWithFind):
return self._list(uri, "servers")
def get(self, server):
"""
Fping a specific server.
"""Fping a specific server.
:param server: ID of the server to fping.
:rtype: :class:`Fping`
:returns: :class:`Fping`
"""
return self._get("/os-fping/%s" % base.getid(server), "server")