remove argument help from docstrings + minor fix

This commit is contained in:
Lvov Maxim
2011-07-15 11:13:21 +04:00
parent 0c4e9fddd6
commit 36476f9ee4

View File

@@ -131,9 +131,8 @@ class VpnCommands(object):
@args('--project', dest="project", metavar='<Project name>', help='Project name')
def list(self, project=None):
"""Print a listing of the VPN data for one or all projects.
"""Print a listing of the VPN data for one or all projects."""
args: [project=all]"""
print "%-12s\t" % 'project',
print "%-20s\t" % 'ip:port',
print "%-20s\t" % 'private_ip',
@@ -181,13 +180,15 @@ class VpnCommands(object):
self.pipe.launch_vpn_instance(project_id)
@args('--project', dest="project_id", metavar='<Project name>', help='Project name')
@args('--ip', dest="ip", metavar='<IP Address>', help='IP Address')
@args('--port', dest="port", metavar='<Port>', help='Port')
def change(self, project_id, ip, port):
"""Change the ip and port for a vpn.
this will update all networks associated with a project
not sure if that's the desired behavior or not, patches accepted
args: project, ip, port"""
"""
# TODO(tr3buchet): perhaps this shouldn't update all networks
# associated with a project in the future
project = self.manager.get_project(project_id)
@@ -224,9 +225,7 @@ class ShellCommands(object):
@args('--shell', dest="shell", metavar='<bpython|ipython|python >', help='Python shell')
def run(self, shell=None):
"""Runs a Python interactive interpreter.
args: [shell=bpython]"""
"""Runs a Python interactive interpreter."""
if not shell:
shell = 'bpython'
@@ -278,8 +277,7 @@ class RoleCommands(object):
@args('--project', dest="project", metavar='<Project name>', help='Project name')
def add(self, user, role, project=None):
"""adds role to user
if project is specified, adds project specific role
arguments: user, role [project]"""
if project is specified, adds project specific role"""
if project:
projobj = self.manager.get_project(project)
if not projobj.has_member(user):
@@ -293,8 +291,7 @@ class RoleCommands(object):
def has(self, user, role, project=None):
"""checks to see if user has role
if project is specified, returns True if user has
the global role and the project role
arguments: user, role [project]"""
the global role and the project role"""
print self.manager.has_role(user, role, project)
@args('--user', dest="user", metavar='<user name>', help='User name')
@@ -302,8 +299,7 @@ class RoleCommands(object):
@args('--project', dest="project", metavar='<Project name>', help='Project name')
def remove(self, user, role, project=None):
"""removes role from user
if project is specified, removes project specific role
arguments: user, role [project]"""
if project is specified, removes project specific role"""
self.manager.remove_role(user, role, project)
@@ -331,8 +327,7 @@ class UserCommands(object):
@args('--access', dest="access", metavar='<access>', help='Access')
@args('--secret', dest="secret", metavar='<secret>', help='Secret')
def admin(self, name, access=None, secret=None):
"""creates a new admin and prints exports
arguments: name [access] [secret]"""
"""creates a new admin and prints exports"""
try:
user = self.manager.create_user(name, access, secret, True)
except exception.DBError, e:
@@ -343,8 +338,7 @@ class UserCommands(object):
@args('--access', dest="access", metavar='<access>', help='Access')
@args('--secret', dest="secret", metavar='<secret>', help='Secret')
def create(self, name, access=None, secret=None):
"""creates a new user and prints exports
arguments: name [access] [secret]"""
"""creates a new user and prints exports"""
try:
user = self.manager.create_user(name, access, secret, False)
except exception.DBError, e:
@@ -359,8 +353,7 @@ class UserCommands(object):
@args('--name', dest="name", metavar='<admin name>', help='User name')
def exports(self, name):
"""prints access and secrets for user in export format
arguments: name"""
"""prints access and secrets for user in export format"""
user = self.manager.get_user(name)
if user:
self._print_export(user)
@@ -368,8 +361,7 @@ class UserCommands(object):
print "User %s doesn't exist" % name
def list(self):
"""lists all users
arguments: <none>"""
"""lists all users"""
for user in self.manager.get_users():
print user.name
@@ -393,8 +385,7 @@ class UserCommands(object):
@args('--name', dest="user_id", metavar='<name>', help='User name')
@args('--project', dest="project_id", metavar='<Project name>', help='Project name')
def revoke(self, user_id, project_id=None):
"""revoke certs for a user
arguments: user_id [project_id]"""
"""revoke certs for a user"""
if project_id:
crypto.revoke_certs_by_user_and_project(user_id, project_id)
else:
@@ -410,8 +401,7 @@ class ProjectCommands(object):
@args('--project', dest="project_id", metavar='<Project name>', help='Project name')
@args('--user', dest="user_id", metavar='<name>', help='User name')
def add(self, project_id, user_id):
"""Adds user to project
arguments: project_id user_id"""
"""Adds user to project"""
try:
self.manager.add_to_project(user_id, project_id)
except exception.UserNotFound as ex:
@@ -422,8 +412,7 @@ class ProjectCommands(object):
@args('--user', dest="project_manager", metavar='<user>', help='Project manager')
@args('--desc', dest="description", metavar='<description>', help='Description')
def create(self, name, project_manager, description=None):
"""Creates a new project
arguments: name project_manager [description]"""
"""Creates a new project"""
try:
self.manager.create_project(name, project_manager, description)
except exception.UserNotFound as ex:
@@ -434,8 +423,7 @@ class ProjectCommands(object):
@args('--user', dest="project_manager", metavar='<user>', help='Project manager')
@args('--desc', dest="description", metavar='<description>', help='Description')
def modify(self, name, project_manager, description=None):
"""Modifies a project
arguments: name project_manager [description]"""
"""Modifies a project"""
try:
self.manager.modify_project(name, project_manager, description)
except exception.UserNotFound as ex:
@@ -444,8 +432,7 @@ class ProjectCommands(object):
@args('--project', dest="name", metavar='<Project name>', help='Project name')
def delete(self, name):
"""Deletes an existing project
arguments: name"""
"""Deletes an existing project"""
try:
self.manager.delete_project(name)
except exception.ProjectNotFound as ex:
@@ -456,8 +443,7 @@ class ProjectCommands(object):
@args('--user', dest="user_id", metavar='<name>', help='User name')
@args('--file', dest="filename", metavar='<filename>', help='File name(Default: novarc)')
def environment(self, project_id, user_id, filename='novarc'):
"""Exports environment variables to an sourcable file
arguments: project_id user_id [filename='novarc]"""
"""Exports environment variables to an sourcable file"""
try:
rc = self.manager.get_environment_rc(user_id, project_id)
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
@@ -468,8 +454,7 @@ class ProjectCommands(object):
@args('--user', dest="username", metavar='<username>', help='User name')
def list(self, username=None):
"""Lists all projects
arguments: [username]"""
"""Lists all projects"""
for project in self.manager.get_projects(username):
print project.name
@@ -477,8 +462,7 @@ class ProjectCommands(object):
@args('--key', dest="key", metavar='<key>', help='Key')
@args('--value', dest="value", metavar='<value>', help='Value')
def quota(self, project_id, key=None, value=None):
"""Set or display quotas for project
arguments: project_id [key] [value]"""
"""Set or display quotas for project"""
ctxt = context.get_admin_context()
if key:
if value.lower() == 'unlimited':
@@ -496,8 +480,7 @@ class ProjectCommands(object):
@args('--project', dest="project_id", metavar='<Project name>', help='Project name')
@args('--user', dest="user_id", metavar='<name>', help='User name')
def remove(self, project_id, user_id):
"""Removes user from project
arguments: project_id user_id"""
"""Removes user from project"""
try:
self.manager.remove_from_project(user_id, project_id)
except (exception.UserNotFound, exception.ProjectNotFound) as ex:
@@ -506,8 +489,7 @@ class ProjectCommands(object):
@args('--project', dest="project_id", metavar='<Project name>', help='Project name')
def scrub(self, project_id):
"""Deletes data associated with project
arguments: project_id"""
"""Deletes data associated with project"""
admin_context = context.get_admin_context()
networks = db.project_get_networks(admin_context, project_id)
for network in networks:
@@ -520,8 +502,7 @@ class ProjectCommands(object):
@args('--user', dest="user_id", metavar='<name>', help='User name')
@args('--file', dest="filename", metavar='<filename>', help='File name(Default: nova.zip)')
def zipfile(self, project_id, user_id, filename='nova.zip'):
"""Exports credentials for project to a zip file
arguments: project_id user_id [filename='nova.zip]"""
"""Exports credentials for project to a zip file"""
try:
zip_file = self.manager.get_credentials(user_id, project_id)
with open(filename, 'w') as f:
@@ -547,7 +528,7 @@ class FixedIpCommands(object):
@args('--host', dest="host", metavar='<host>', help='Host')
def list(self, host=None):
"""Lists all fixed ips (optionally by host) arguments: [host]"""
"""Lists all fixed ips (optionally by host)"""
ctxt = context.get_admin_context()
try:
@@ -584,16 +565,14 @@ class FloatingIpCommands(object):
@args('--ip_range', dest="range", metavar='<range>', help='IP range')
def create(self, range):
"""Creates floating ips for zone by range
arguments: ip_range"""
"""Creates floating ips for zone by range"""
for address in netaddr.IPNetwork(range):
db.floating_ip_create(context.get_admin_context(),
{'address': str(address)})
@args('--ip_range', dest="ip_range", metavar='<range>', help='IP range')
def delete(self, ip_range):
"""Deletes floating ips by range
arguments: range"""
"""Deletes floating ips by range"""
for address in netaddr.IPNetwork(ip_range):
db.floating_ip_destroy(context.get_admin_context(),
str(address))
@@ -601,7 +580,6 @@ class FloatingIpCommands(object):
@args('--host', dest="host", metavar='<host>', help='Host')
def list(self, host=None):
"""Lists all floating ips (optionally by host)
arguments: [host]
Note: if host is given, only active floating IPs are returned"""
ctxt = context.get_admin_context()
if host is None:
@@ -635,10 +613,6 @@ class NetworkCommands(object):
vpn_start=None, fixed_range_v6=None, gateway_v6=None,
flat_network_bridge=None, bridge_interface=None):
"""Creates fixed ips for host by range
arguments: label, fixed_range, [num_networks=FLAG],
[network_size=FLAG], [vlan_start=FLAG],
[vpn_start=FLAG], [fixed_range_v6=FLAG], [gateway_v6=FLAG],
[flat_network_bridge=FLAG], [bridge_interface=FLAG]
If you wish to use a later argument fill in the gaps with 0s
Ex: network create private 10.0.0.0/8 1 15 0 0 0 0 xenbr1 eth1
network create private 10.0.0.0/8 1 15
@@ -716,11 +690,8 @@ class VmCommands(object):
@args('--host', dest="host", metavar='<host>', help='Host')
def list(self, host=None):
"""Show a list of all instances
"""Show a list of all instances"""
:param host: show all instance on specified host.
:param instance: show specificed instance.
"""
print "%-10s %-15s %-10s %-10s %-26s %-9s %-9s %-9s" \
" %-10s %-10s %-10s %-5s" % (
_('instance'),
@@ -761,12 +732,7 @@ class VmCommands(object):
@args('--ec2_id', dest='ec2_id', metavar='<ec2 id>', help='EC2 ID')
@args('--dest', dest='dest', metavar='<Destanation>', help='destanation node')
def live_migration(self, ec2_id, dest):
"""Migrates a running instance to a new machine.
:param ec2_id: instance id which comes from euca-describe-instance.
:param dest: destination host name.
"""
"""Migrates a running instance to a new machine."""
ctxt = context.get_admin_context()
instance_id = ec2utils.ec2_id_to_id(ec2_id)
@@ -799,8 +765,7 @@ class ServiceCommands(object):
@args('--host', dest='host', metavar='<host>', help='Host')
@args('--service', dest='service', metavar='<service>', help='Nova service')
def list(self, host=None, service=None):
"""Show a list of all running services. Filter by host & service name.
args: [host] [service]"""
"""Show a list of all running services. Filter by host & service name."""
ctxt = context.get_admin_context()
now = utils.utcnow()
services = db.service_get_all(ctxt)
@@ -822,8 +787,7 @@ class ServiceCommands(object):
@args('--host', dest='host', metavar='<host>', help='Host')
@args('--service', dest='service', metavar='<service>', help='Nova service')
def enable(self, host, service):
"""Enable scheduling for a service
args: host service"""
"""Enable scheduling for a service"""
ctxt = context.get_admin_context()
svc = db.service_get_by_args(ctxt, host, service)
if not svc:
@@ -834,8 +798,7 @@ class ServiceCommands(object):
@args('--host', dest='host', metavar='<host>', help='Host')
@args('--service', dest='service', metavar='<service>', help='Nova service')
def disable(self, host, service):
"""Disable scheduling for a service
args: host service"""
"""Disable scheduling for a service"""
ctxt = context.get_admin_context()
svc = db.service_get_by_args(ctxt, host, service)
if not svc:
@@ -845,11 +808,7 @@ class ServiceCommands(object):
@args('--host', dest='host', metavar='<host>', help='Host')
def describe_resource(self, host):
"""Describes cpu/memory/hdd info for host.
:param host: hostname.
"""
"""Describes cpu/memory/hdd info for host."""
result = rpc.call(context.get_admin_context(),
FLAGS.scheduler_topic,
@@ -879,11 +838,7 @@ class ServiceCommands(object):
@args('--host', dest='host', metavar='<host>', help='Host')
def update_resource(self, host):
"""Updates available vcpu/memory/disk info for host.
:param host: hostname.
"""
"""Updates available vcpu/memory/disk info for host."""
ctxt = context.get_admin_context()
service_refs = db.service_get_all_by_host(ctxt, host)
@@ -935,8 +890,7 @@ class VolumeCommands(object):
@args('--volume', dest='volume_id', metavar='<volume id>', help='Volume ID')
def delete(self, volume_id):
"""Delete a volume, bypassing the check that it
must be available.
args: volume_id"""
must be available."""
ctxt = context.get_admin_context()
volume = db.volume_get(ctxt, param2id(volume_id))
host = volume['host']
@@ -961,8 +915,7 @@ class VolumeCommands(object):
def reattach(self, volume_id):
"""Re-attach a volume that has previously been attached
to an instance. Typically called after a compute host
has been rebooted.
args: volume_id_id"""
has been rebooted."""
ctxt = context.get_admin_context()
volume = db.volume_get(ctxt, param2id(volume_id))
if not volume['instance_id']:
@@ -999,10 +952,7 @@ class InstanceTypeCommands(object):
@args('--rxtx_cap', dest='rxtx_cap', metavar='<rxtx_cap>', help='rxtx_cap')
def create(self, name, memory, vcpus, local_gb, flavorid,
swap=0, rxtx_quota=0, rxtx_cap=0):
"""Creates instance types / flavors
arguments: name memory vcpus local_gb flavorid [swap] [rxtx_quota]
[rxtx_cap]
"""
"""Creates instance types / flavors"""
try:
instance_types.create(name, memory, vcpus, local_gb,
flavorid, swap, rxtx_quota, rxtx_cap)
@@ -1027,8 +977,7 @@ class InstanceTypeCommands(object):
@args('--name', dest='name', metavar='<name>', help='Name of instance type/flavor')
def delete(self, name, purge=None):
"""Marks instance types / flavors as deleted
arguments: name"""
"""Marks instance types / flavors as deleted"""
try:
if purge == "--purge":
instance_types.purge(name)
@@ -1049,8 +998,7 @@ class InstanceTypeCommands(object):
@args('--name', dest='name', metavar='<name>', help='Name of instance type/flavor')
def list(self, name=None):
"""Lists all active or specific instance types / flavors
arguments: [name]"""
"""Lists all active or specific instance types / flavors"""
try:
if name is None:
inst_types = instance_types.get_all_types()
@@ -1107,9 +1055,7 @@ class ImageCommands(object):
@args('--arch', dest='architecture', metavar='<arch>', help='Architecture')
def all_register(self, image, kernel, ramdisk, owner, name=None,
is_public='T', architecture='x86_64'):
"""Uploads an image, kernel, and ramdisk into the image_service
arguments: image kernel ramdisk owner [name] [is_public='T']
[architecture='x86_64']"""
"""Uploads an image, kernel, and ramdisk into the image_service"""
kernel_id = self.kernel_register(kernel, owner, None,
is_public, architecture)
ramdisk_id = self.ramdisk_register(ramdisk, owner, None,
@@ -1130,11 +1076,7 @@ class ImageCommands(object):
def image_register(self, path, owner, name=None, is_public='T',
architecture='x86_64', container_format='bare',
disk_format='raw', kernel_id=None, ramdisk_id=None):
"""Uploads an image into the image_service
arguments: path owner [name] [is_public='T'] [architecture='x86_64']
[container_format='bare'] [disk_format='raw']
[kernel_id=None] [ramdisk_id=None]
"""
"""Uploads an image into the image_service"""
return self._register(container_format, disk_format, path,
owner, name, is_public, architecture,
kernel_id, ramdisk_id)
@@ -1146,9 +1088,7 @@ class ImageCommands(object):
@args('--arch', dest='architecture', metavar='<arch>', help='Architecture')
def kernel_register(self, path, owner, name=None, is_public='T',
architecture='x86_64'):
"""Uploads a kernel into the image_service
arguments: path owner [name] [is_public='T'] [architecture='x86_64']
"""
"""Uploads a kernel into the image_service"""
return self._register('aki', 'aki', path, owner, name,
is_public, architecture)
@@ -1159,9 +1099,7 @@ class ImageCommands(object):
@args('--arch', dest='architecture', metavar='<arch>', help='Architecture')
def ramdisk_register(self, path, owner, name=None, is_public='T',
architecture='x86_64'):
"""Uploads a ramdisk into the image_service
arguments: path owner [name] [is_public='T'] [architecture='x86_64']
"""
"""Uploads a ramdisk into the image_service"""
return self._register('ari', 'ari', path, owner, name,
is_public, architecture)
@@ -1212,8 +1150,7 @@ class ImageCommands(object):
@args('--dir', dest='directory', metavar='<path>', help='Images directory')
def convert(self, directory):
"""Uploads old objectstore images in directory to new service
arguments: directory"""
"""Uploads old objectstore images in directory to new service"""
machine_images = {}
other_images = {}
directory = os.path.abspath(directory)
@@ -1238,8 +1175,7 @@ class AgentBuildCommands(object):
def create(self, os, architecture, version, url, md5hash,
hypervisor='xen'):
"""Creates a new agent build.
arguments: os architecture version url md5hash [hypervisor='xen']"""
"""Creates a new agent build."""
ctxt = context.get_admin_context()
agent_build = db.agent_build_create(ctxt,
{'hypervisor': hypervisor,
@@ -1250,8 +1186,7 @@ class AgentBuildCommands(object):
'md5hash': md5hash})
def delete(self, os, architecture, hypervisor='xen'):
"""Deletes an existing agent build.
arguments: os architecture [hypervisor='xen']"""
"""Deletes an existing agent build."""
ctxt = context.get_admin_context()
agent_build_ref = db.agent_build_get_by_triple(ctxt,
hypervisor, os, architecture)
@@ -1285,9 +1220,7 @@ class AgentBuildCommands(object):
def modify(self, os, architecture, version, url, md5hash,
hypervisor='xen'):
"""Update an existing agent build.
arguments: os architecture version url md5hash [hypervisor='xen']
"""
"""Update an existing agent build."""
ctxt = context.get_admin_context()
agent_build_ref = db.agent_build_get_by_triple(ctxt,
hypervisor, os, architecture)
@@ -1397,9 +1330,9 @@ def main():
action, fn = matches[0]
# For not decorated methods
options = getattr(fn, 'options', '')
options = getattr(fn, 'options', [])
usage = "%prog " + "%s %s <args> [options]" % (sys.argv[2], sys.argv[3])
usage = "%%prog %s %s <args> [options]" % (sys.argv[2], sys.argv[3])
parser = OptionParser(usage=usage)
for ar, kw in options:
parser.add_option(*ar, **kw)