diff --git a/novaclient/tests/test_utils.py b/novaclient/tests/test_utils.py index 0bd396a75..9d03c0390 100644 --- a/novaclient/tests/test_utils.py +++ b/novaclient/tests/test_utils.py @@ -69,7 +69,7 @@ class FindResourceTestCase(test_utils.TestCase): self.manager = FakeManager(None) def test_find_none(self): - """Test a few non-valid inputs""" + """Test a few non-valid inputs.""" self.assertRaises(exceptions.CommandError, utils.find_resource, self.manager, diff --git a/novaclient/utils.py b/novaclient/utils.py index 9d1c1916c..532ea976c 100644 --- a/novaclient/utils.py +++ b/novaclient/utils.py @@ -47,7 +47,7 @@ def add_arg(f, *args, **kwargs): def bool_from_str(val): - """Convert a string representation of a bool into a bool value""" + """Convert a string representation of a bool into a bool value.""" if not val: return False @@ -62,7 +62,7 @@ def bool_from_str(val): def add_resource_manager_extra_kwargs_hook(f, hook): - """Adds hook to bind CLI arguments to ResourceManager calls. + """Add hook to bind CLI arguments to ResourceManager calls. The `do_foo` calls in shell.py will receive CLI args and then in turn pass them through to the ResourceManager. Before passing through the args, the diff --git a/novaclient/v1_1/agents.py b/novaclient/v1_1/agents.py index 069662732..550d47ab6 100644 --- a/novaclient/v1_1/agents.py +++ b/novaclient/v1_1/agents.py @@ -36,7 +36,7 @@ class AgentsManager(base.ManagerWithFind): resource_class = Agent def list(self, hypervisor=None): - """Lists all agent builds.""" + """List all agent builds.""" url = "/os-agents" if hypervisor: url = "/os-agents?hypervisor=%s" % hypervisor @@ -53,7 +53,7 @@ class AgentsManager(base.ManagerWithFind): def create(self, os, architecture, version, url, md5hash, hypervisor): - """Creates a new agent build""" + """Create a new agent build.""" body = {'agent': { 'hypervisor': hypervisor, 'os': os, diff --git a/novaclient/v1_1/contrib/baremetal.py b/novaclient/v1_1/contrib/baremetal.py index 36ab047a0..db1f54977 100644 --- a/novaclient/v1_1/contrib/baremetal.py +++ b/novaclient/v1_1/contrib/baremetal.py @@ -181,7 +181,7 @@ class BareMetalNodeManager(base.ManagerWithFind): type=int, help='ShellInABox port?') def do_baremetal_node_create(cs, args): - """Create a baremetal node""" + """Create a baremetal node.""" node = cs.baremetal.create(args.service_host, args.cpus, args.memory_mb, args.local_gb, args.prov_mac_address, pm_address=args.pm_address, pm_user=args.pm_user, @@ -194,7 +194,7 @@ def do_baremetal_node_create(cs, args): metavar='', help='ID of the node to delete.') def do_baremetal_node_delete(cs, args): - """Remove a baremetal node and any associated interfaces""" + """Remove a baremetal node and any associated interfaces.""" node = _find_baremetal_node(cs, args.node) cs.baremetal.delete(node) @@ -216,7 +216,7 @@ def _translate_baremetal_node_keys(collection): def _print_baremetal_nodes_list(nodes): - """Print the list of baremetal nodes""" + """Print the list of baremetal nodes.""" _translate_baremetal_node_keys(nodes) utils.print_list(nodes, [ 'ID', @@ -233,7 +233,7 @@ def _print_baremetal_nodes_list(nodes): def do_baremetal_node_list(cs, _args): - """Print a list of available baremetal nodes""" + """Print list of available baremetal nodes.""" nodes = cs.baremetal.list() _print_baremetal_nodes_list(nodes) @@ -244,13 +244,13 @@ def _find_baremetal_node(cs, node): def _print_baremetal_resource(resource): - """Print the details of a baremetal resource""" + """Print details of a baremetal resource.""" info = resource._info.copy() utils.print_dict(info) def _print_baremetal_node_interfaces(interfaces): - """Print the interfaces of a baremetal node""" + """Print interfaces of a baremetal node.""" utils.print_list(interfaces, [ 'ID', 'Datapath_ID', @@ -263,7 +263,7 @@ def _print_baremetal_node_interfaces(interfaces): metavar='', help="ID of node") def do_baremetal_node_show(cs, args): - """Show information about a baremetal node""" + """Show information about a baremetal node.""" node = _find_baremetal_node(cs, args.node) _print_baremetal_resource(node) @@ -283,7 +283,7 @@ def do_baremetal_node_show(cs, args): metavar='', help="OpenFlow port number of interface") def do_baremetal_interface_add(cs, args): - """Add a network interface to a baremetal node""" + """Add a network interface to a baremetal node.""" bmif = cs.baremetal.add_interface(args.node, args.address, args.datapath_id, args.port_no) _print_baremetal_resource(bmif) @@ -292,12 +292,12 @@ def do_baremetal_interface_add(cs, args): @utils.arg('node', metavar='', help="ID of node") @utils.arg('address', metavar='
', help="MAC address of interface") def do_baremetal_interface_remove(cs, args): - """Remove a network interface from a baremetal node""" + """Remove a network interface from a baremetal node.""" cs.baremetal.remove_interface(args.node, args.address) @utils.arg('node', metavar='', help="ID of node") def do_baremetal_interface_list(cs, args): - """List network interfaces associated with a baremetal node""" + """List network interfaces associated with a baremetal node.""" interfaces = cs.baremetal.list_interfaces(args.node) _print_baremetal_node_interfaces(interfaces) diff --git a/novaclient/v1_1/flavor_access.py b/novaclient/v1_1/flavor_access.py index 851a9db7e..b314040fe 100644 --- a/novaclient/v1_1/flavor_access.py +++ b/novaclient/v1_1/flavor_access.py @@ -42,7 +42,7 @@ class FlavorAccessManager(base.ManagerWithFind): 'flavor_access') def _list_by_tenant(self, tenant): - """Print flavor list shared with the given tenant""" + """Print flavor list shared with the given tenant.""" # TODO(uni): need to figure out a proper URI for list_by_tenant # since current API already provided current tenant_id information raise NotImplementedError('Sorry, query by tenant not supported.') diff --git a/novaclient/v1_1/floating_ip_dns.py b/novaclient/v1_1/floating_ip_dns.py index e45a174e1..f9c9ea4e8 100644 --- a/novaclient/v1_1/floating_ip_dns.py +++ b/novaclient/v1_1/floating_ip_dns.py @@ -74,7 +74,7 @@ class FloatingIPDNSDomainManager(base.Manager): 'domain_entry') def delete(self, fqdomain): - """Delete the specified domain""" + """Delete the specified domain.""" self._delete("/os-floating-ip-dns/%s" % _quote_domain(fqdomain)) diff --git a/novaclient/v1_1/hosts.py b/novaclient/v1_1/hosts.py index 8ea563780..83b4c93db 100644 --- a/novaclient/v1_1/hosts.py +++ b/novaclient/v1_1/hosts.py @@ -57,7 +57,7 @@ class HostManager(base.ManagerWithFind): return self._update("/os-hosts/%s" % host, values) def host_action(self, host, action): - """Performs an action on a host.""" + """Perform an action on a host.""" body = {action: None} url = '/os-hosts/%s/action' % host return self.api.client.post(url, body=body) diff --git a/novaclient/v1_1/limits.py b/novaclient/v1_1/limits.py index 3eba65234..4b4eabc95 100644 --- a/novaclient/v1_1/limits.py +++ b/novaclient/v1_1/limits.py @@ -6,7 +6,7 @@ from novaclient import base class Limits(base.Resource): - """A collection of RateLimit and AbsoluteLimit objects""" + """A collection of RateLimit and AbsoluteLimit objects.""" def __repr__(self): return "" @@ -28,7 +28,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): @@ -54,7 +54,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 @@ -68,7 +68,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 diff --git a/novaclient/v1_1/services.py b/novaclient/v1_1/services.py index ec580caf6..03424026e 100644 --- a/novaclient/v1_1/services.py +++ b/novaclient/v1_1/services.py @@ -51,16 +51,16 @@ class ServiceManager(base.ManagerWithFind): return self._list(url, "services") def enable(self, host, binary): - """Enable the service specified by hostname and binary""" + """Enable the service specified by hostname and binary.""" body = {"host": host, "binary": binary} return self._update("/os-services/enable", body, "service") def disable(self, host, binary): - """Enable the service specified by hostname and binary""" + """Disable the service specified by hostname and binary.""" body = {"host": host, "binary": binary} return self._update("/os-services/disable", body, "service") def disable_log_reason(self, host, binary, reason): - """Disable the service with reason""" + """Disable the service with reason.""" body = {"host": host, "binary": binary, "disabled_reason": reason} return self._update("/os-services/disable-log-reason", body, "service") diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index bf48db324..2c3b00c03 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -341,14 +341,14 @@ def do_cloudpipe_list(cs, _args): @utils.arg('project', metavar='', help='Name of the project.') def do_cloudpipe_create(cs, args): - """Create a cloudpipe instance for the given project""" + """Create a cloudpipe instance for the given project.""" cs.cloudpipe.create(args.project) @utils.arg('address', metavar='', help='New IP Address.') @utils.arg('port', metavar='', help='New Port.') def do_cloudpipe_configure(cs, args): - """Update the VPN IP/port of a cloudpipe instance""" + """Update the VPN IP/port of a cloudpipe instance.""" cs.cloudpipe.update(args.address, args.port) @@ -627,7 +627,7 @@ def do_flavor_access_remove(cs, args): @utils.arg('project_id', metavar='', help='The ID of the project.') def do_scrub(cs, args): - """Deletes data associated with the project""" + """Delete data associated with the project.""" networks_list = cs.networks.list() networks_list = [network for network in networks_list if getattr(network, 'project_id', '') == args.project_id] @@ -1266,7 +1266,7 @@ def do_image_create(cs, args): @utils.arg('rotation', metavar='', help='Int parameter representing how many backups to keep around.') def do_backup(cs, args): - """Backup a instance by create a 'backup' type snapshot """ + """Backup a instance by create a 'backup' type snapshot.""" _find_server(cs, args.server).backup(args.name, args.backup_type, args.rotation) @@ -1789,7 +1789,7 @@ def do_floating_ip_pool_list(cs, _args): @utils.arg('--host', dest='host', metavar='', default=None, help='Filter by host') def do_floating_ip_bulk_list(cs, args): - """List all floating ips""" + """List all floating ips.""" utils.print_list(cs.floating_ips_bulk.list(args.host), ['project_id', 'address', 'instance_uuid', @@ -1803,13 +1803,13 @@ def do_floating_ip_bulk_list(cs, args): @utils.arg('--interface', metavar='', default=None, help='Interface for new Floating IPs') def do_floating_ip_bulk_create(cs, args): - """Bulk create floating ips by range""" + """Bulk create floating ips by range.""" cs.floating_ips_bulk.create(args.ip_range, args.pool, args.interface) @utils.arg('ip_range', metavar='', help='Address range to delete') def do_floating_ip_bulk_delete(cs, args): - """Bulk delete floating ips by range""" + """Bulk delete floating ips by range.""" cs.floating_ips_bulk.delete(args.ip_range) @@ -2143,7 +2143,7 @@ def do_secgroup_delete_group_rule(cs, args): @utils.arg('--pub_key', help=argparse.SUPPRESS) def do_keypair_add(cs, args): - """Create a new key pair for use with instances""" + """Create a new key pair for use with instances.""" name = args.name pub_key = args.pub_key @@ -2164,7 +2164,7 @@ def do_keypair_add(cs, args): @utils.arg('name', metavar='', help='Keypair name to delete.') def do_keypair_delete(cs, args): - """Delete keypair by its name""" + """Delete keypair given by its name.""" name = args.name cs.keypairs.delete(name) @@ -2224,7 +2224,7 @@ def do_rate_limits(cs, args): help='Usage range end date, ex 2012-01-20 (default: tomorrow) ', default=None) def do_usage_list(cs, args): - """List usage data for all tenants""" + """List usage data for all tenants.""" dateformat = "%Y-%m-%d" rows = ["Tenant ID", "Instances", "RAM MB-Hours", "CPU Hours", "Disk GB-Hours"] @@ -2271,7 +2271,7 @@ def do_usage_list(cs, args): default=None, help='UUID or name of tenant to get usage for.') def do_usage(cs, args): - """Show usage data for a single tenant""" + """Show usage data for a single tenant.""" dateformat = "%Y-%m-%d" rows = ["Instances", "RAM MB-Hours", "CPU Hours", "Disk GB-Hours"] @@ -2321,7 +2321,7 @@ def do_usage(cs, args): default='cert.pem', help='Filename for the X.509 certificate [Default: cert.pem]') def do_x509_create_cert(cs, args): - """Create x509 cert for a user in tenant""" + """Create x509 cert for a user in tenant.""" if os.path.exists(args.pk_filename): raise exceptions.CommandError("Unable to write privatekey - %s exists." @@ -2351,7 +2351,7 @@ def do_x509_create_cert(cs, args): default='cacert.pem', help='Filename to write the x509 root cert.') def do_x509_get_root_cert(cs, args): - """Fetches the x509 root cert.""" + """Fetch the x509 root cert.""" if os.path.exists(args.filename): raise exceptions.CommandError("Unable to write x509 root cert - \ %s exists." % args.filename) @@ -2365,7 +2365,7 @@ def do_x509_get_root_cert(cs, args): @utils.arg('--hypervisor', metavar='', default=None, help='type of hypervisor.') def do_agent_list(cs, args): - """List all builds""" + """List all builds.""" result = cs.agents.list(args.hypervisor) columns = ["Agent_id", "Hypervisor", "OS", "Architecture", "Version", 'Md5hash', 'Url'] @@ -2381,7 +2381,7 @@ def do_agent_list(cs, args): @utils.arg('hypervisor', metavar='', default='xen', help='type of hypervisor.') def do_agent_create(cs, args): - """Creates a new agent build.""" + """Create new agent build.""" result = cs.agents.create(args.os, args.architecture, args.version, args.url, args.md5hash, args.hypervisor) @@ -2390,7 +2390,7 @@ def do_agent_create(cs, args): @utils.arg('id', metavar='', help='id of the agent-build') def do_agent_delete(cs, args): - """Deletes an existing agent build.""" + """Delete existing agent build.""" cs.agents.delete(args.id) @@ -2399,7 +2399,7 @@ def do_agent_delete(cs, args): @utils.arg('url', metavar='', help='url') @utils.arg('md5hash', metavar='', help='md5hash') def do_agent_modify(cs, args): - """Modify an existing agent build.""" + """Modify existing agent build.""" result = cs.agents.update(args.id, args.version, args.url, args.md5hash) utils.print_dict(result._info) @@ -2515,7 +2515,7 @@ def _print_aggregate_details(aggregate): action='store_true', help=argparse.SUPPRESS) def do_live_migration(cs, args): - """Migrates a running instance to a new machine.""" + """Migrate running instance to a new machine.""" _find_server(cs, args.server).live_migrate(args.host, args.block_migrate, args.disk_over_commit) @@ -2527,7 +2527,7 @@ def do_live_migration(cs, args): help='Request the instance be reset to "active" state instead ' 'of "error" state (the default).') def do_reset_state(cs, args): - """Reset the state of an instance""" + """Reset the state of an instance.""" _find_server(cs, args.server).reset_state(args.state) @@ -2555,7 +2555,7 @@ def do_service_list(cs, args): @utils.arg('host', metavar='', help='Name of host.') @utils.arg('binary', metavar='', help='Service binary.') def do_service_enable(cs, args): - """Enable the service""" + """Enable the service.""" result = cs.services.enable(args.host, args.binary) utils.print_list([result], ['Host', 'Binary', 'Status']) @@ -2565,7 +2565,7 @@ def do_service_enable(cs, args): @utils.arg('--reason', metavar='', help='Reason for disabling service.') def do_service_disable(cs, args): - """Disable the service""" + """Disable the service.""" if args.reason: result = cs.services.disable_log_reason(args.host, args.binary, args.reason) @@ -2578,26 +2578,26 @@ def do_service_disable(cs, args): @utils.arg('fixed_ip', metavar='', help='Fixed IP Address.') def do_fixed_ip_get(cs, args): - """Get info on a fixed ip""" + """Retrieve info on a fixed ip.""" result = cs.fixed_ips.get(args.fixed_ip) utils.print_list([result], ['address', 'cidr', 'hostname', 'host']) @utils.arg('fixed_ip', metavar='', help='Fixed IP Address.') def do_fixed_ip_reserve(cs, args): - """Reserve a fixed ip""" + """Reserve a fixed IP.""" cs.fixed_ips.reserve(args.fixed_ip) @utils.arg('fixed_ip', metavar='', help='Fixed IP Address.') def do_fixed_ip_unreserve(cs, args): - """Unreserve a fixed ip""" + """Unreserve a fixed IP.""" cs.fixed_ips.unreserve(args.fixed_ip) @utils.arg('host', metavar='', help='Name of host.') def do_host_describe(cs, args): - """Describe a specific host""" + """Describe a specific host.""" result = cs.hosts.get(args.host) columns = ["HOST", "PROJECT", "cpu", "memory_mb", "disk_gb"] utils.print_list(result, columns) @@ -2607,7 +2607,7 @@ def do_host_describe(cs, args): help='Filters the list, returning only those ' 'hosts in the availability zone .') def do_host_list(cs, args): - """List all hosts by service""" + """List all hosts by service.""" columns = ["host_name", "service", "zone"] result = cs.hosts.list(args.zone) utils.print_list(result, columns) @@ -2651,13 +2651,13 @@ def do_host_action(cs, args): default=False, help='Generate a single report for all services.') def do_coverage_start(cs, args): - """Start Nova coverage reporting""" + """Start Nova coverage reporting.""" cs.coverage.start(combine=args.combine) print("Coverage collection started") def do_coverage_stop(cs, args): - """Stop Nova coverage reporting""" + """Stop Nova coverage reporting.""" out = cs.coverage.stop() print("Coverage data file path: %s" % out[-1]['path']) @@ -2674,7 +2674,7 @@ def do_coverage_stop(cs, args): default=False, help='Generate XML reports instead of text ones.') def do_coverage_report(cs, args): - """Generate a coverage report""" + """Generate coverage report.""" if args.html == True and args.xml == True: raise exceptions.CommandError("--html and --xml must not be " "specified together.") @@ -2770,7 +2770,7 @@ def ensure_service_catalog_present(cs): def do_endpoints(cs, _args): - """Discover endpoints that get returned from the authenticate services""" + """Discover endpoints that get returned from the authenticate services.""" ensure_service_catalog_present(cs) catalog = cs.client.service_catalog.catalog for e in catalog['access']['serviceCatalog']: @@ -2780,7 +2780,7 @@ def do_endpoints(cs, _args): @utils.arg('--wrap', dest='wrap', metavar='', default=64, help='wrap PKI tokens to a specified length, or 0 to disable') def do_credentials(cs, _args): - """Show user credentials returned from auth""" + """Show user credentials returned from auth.""" ensure_service_catalog_present(cs) catalog = cs.client.service_catalog.catalog utils.print_dict(catalog['access']['user'], "User Credentials", @@ -3172,7 +3172,7 @@ def do_interface_detach(cs, args): def _treeizeAvailabilityZone(zone): - """Build a tree view for availability zones""" + """Build a tree view for availability zones.""" AvailabilityZone = availability_zones.AvailabilityZone az = AvailabilityZone(zone.manager, diff --git a/tox.ini b/tox.ini index b035bb751..b10c1603f 100644 --- a/tox.ini +++ b/tox.ini @@ -24,6 +24,6 @@ commands = python setup.py testr --coverage --testr-args='{posargs}' downloadcache = ~/cache/pip [flake8] -ignore = E12,E711,E721,E712,F841,F811,F821,H302,H306,H402,H403,H404 +ignore = E12,E711,E721,E712,F841,F811,F821,H302,H306,H403,H404 show-source = True exclude=.venv,.git,.tox,dist,doc,*openstack/common*,*lib/python*,*egg,build