Skip to content

Commit 0ccd4ba

Browse files
author
Ignasi Barrera
committed
Pretty print documentation
1 parent c674462 commit 0ccd4ba

24 files changed

+105
-105
lines changed

examples/skel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414

1515
class SkeletonPlugin(AbsPlugin):
16-
""" An example plugin that prints dummy messages. """
16+
""" An example plugin that prints dummy messages """
1717
def __init__(self):
1818
pass
1919

@@ -23,7 +23,7 @@ def __init__(self):
2323
# print the help of the command.
2424
# The arguments are the options given to the command itself
2525
def dummy(self, args):
26-
""" Prints a dummy message. """
26+
""" Prints a dummy message """
2727
print "This is the print_handler in the example plugin"
2828

2929

kahuna/abstract.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22

33

44
class AbsPlugin:
5-
""" Abstract plugin. """
5+
""" Abstract plugin """
66
def _commands(self):
77
""" Get the list of commands for the current plugin.
88
By default all public methods in the plugin implementation
99
will be used as plugin commands. This method can be overriden
10-
in subclasses to customize the available command list. """
10+
in subclasses to customize the available command list """
1111
attrs = filter(lambda attr: not attr.startswith('_'), dir(self))
1212
commands = {}
1313
for attr in attrs:

kahuna/cli.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44

55

66
class CLI:
7-
""" Main command line interface. """
7+
""" Main command line interface """
88
def __init__(self):
9-
""" Initialize the plugin manager. """
9+
""" Initialize the plugin manager """
1010
self.__pluginmanager = PluginManager()
1111

1212
def parse_input(self):
13-
""" Validates user input and delegates to the plugin manager. """
13+
""" Validates user input and delegates to the plugin manager """
1414
if len(sys.argv) < 2:
1515
print "Usage: kahuna <plugin> <command> [<options>]"
1616
print "The following plugins are available:\n"

kahuna/config.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212

1313
class ConfigLoader:
14-
""" Loads configuration files from a given location. """
14+
""" Loads configuration files from a given location """
1515
def __init__(self, basedir="kahuna"):
16-
""" Initializes the ConfigLoader. """
16+
""" Initializes the ConfigLoader """
1717
self.user_dir = os.environ['HOME'] + "/." + basedir
1818
self.sys_dir = "/etc/" + basedir
1919

2020
def load(self, file_name, default=None):
21-
""" Loads the given configuration file ftom the default locations. """
21+
""" Loads the given configuration file ftom the default locations """
2222
user_config = self.user_dir + "/" + file_name
2323
sys_config = self.sys_dir + "/" + file_name
2424
config_found = user_config
@@ -53,7 +53,7 @@ def load(self, file_name, default=None):
5353

5454
@singleton
5555
class Config:
56-
""" Main configuration. """
56+
""" Main configuration """
5757
def __init__(self):
5858
config = ConfigLoader().load("kahuna.conf", "config/kahuna.conf")
5959

kahuna/pluginmanager.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010

1111

1212
class PluginManager:
13-
""" Manages available plugins. """
13+
""" Manages available plugins """
1414
def __init__(self):
15-
""" Initialize the plugin list. """
15+
""" Initialize the plugin list """
1616
self.__plugins = {}
1717

1818
def load_plugin(self, plugin_name):
19-
""" Loads a single plugin given its name. """
19+
""" Loads a single plugin given its name """
2020
if not plugin_name in __all__:
2121
raise KeyError("Plugin " + plugin_name + " not found")
2222
try:
@@ -36,7 +36,7 @@ def call(self, plugin_name, command_name, args):
3636
return self._call(context, plugin_name, command_name, args)
3737

3838
def _call(self, context, plugin_name, command_name, args):
39-
""" Calls the given command on the given plugin. """
39+
""" Calls the given command on the given plugin """
4040
try:
4141
plugin = self.load_plugin(plugin_name)
4242
plugin._load_context(context)
@@ -54,7 +54,7 @@ def _call(self, context, plugin_name, command_name, args):
5454
self.help_all()
5555

5656
def help(self, plugin):
57-
""" Prints the help for the given plugin. """
57+
""" Prints the help for the given plugin """
5858
commands = plugin._commands()
5959
tokens = plugin.__module__.split('.')
6060
plugin_name = tokens[len(tokens) - 1]
@@ -64,7 +64,7 @@ def help(self, plugin):
6464
commands[command].__doc__)
6565

6666
def help_all(self):
67-
""" Prints the help for all registered plugins. """
67+
""" Prints the help for all registered plugins """
6868
for name in sorted(__all__):
6969
plugin = self.load_plugin(name)
7070
self.help(plugin)
@@ -74,7 +74,7 @@ def help_all(self):
7474
@contextmanager
7575
def opencontext():
7676
""" Loads the context each plugin needs to be initialized
77-
in order to be executed. """
77+
in order to be executed """
7878
log.debug("Loading context for plugin execution")
7979
context = ContextLoader().load()
8080
yield context

kahuna/plugins/env.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717

1818

1919
class EnvironmentPlugin(AbsPlugin):
20-
""" Environment generator plugin. """
20+
""" Environment generator plugin """
2121
def __init__(self):
2222
self.__config = ConfigLoader().load("env.conf", "config/env.conf")
2323

2424
def create(self, args):
25-
""" Creates the environment. """
25+
""" Creates the environment """
2626
try:
2727
apply_default_configuration(self.__config, self._context)
2828
dc = create_infrastructure_compute(self.__config, self._context)
@@ -35,7 +35,7 @@ def create(self, args):
3535
print "Error: %s" % ex.getMessage()
3636

3737
def clean(self, args):
38-
""" Cleans up the environment. """
38+
""" Cleans up the environment """
3939
try:
4040
cleanup_cloud_compute(self.__config, self._context)
4141
cleanup_default_tenants(self.__config, self._context)

kahuna/plugins/environment/cloud/compute.py

+10-10
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414

1515

1616
class CloudCompute:
17-
""" Provides access to cloud compute features. """
17+
""" Provides access to cloud compute features """
1818

1919
def __init__(self, context):
20-
""" Initialize the cloud creator with an existent context. """
20+
""" Initialize the cloud creator with an existent context """
2121
self.__context = context.getApiContext()
2222

2323
def create_virtual_datacenter(self, datacenter, enterprise, type,
2424
name, netname, netaddress, netmask, netgateway):
25-
""" Creates a new virtual datacenter. """
25+
""" Creates a new virtual datacenter """
2626
log.info("Creating virtual datacenter %s of type %s..." % (name, type))
2727
network = PrivateNetwork.builder(self.__context) \
2828
.name(netname) \
@@ -40,7 +40,7 @@ def create_virtual_datacenter(self, datacenter, enterprise, type,
4040
return vdc
4141

4242
def create_virtual_appliance(self, vdc, name):
43-
""" Creates a new virtual appliance inside a virtual datacenter. """
43+
""" Creates a new virtual appliance inside a virtual datacenter """
4444
log.info("Creating virtual appliance %s..." % name)
4545
vapp = VirtualAppliance.builder(self.__context, vdc) \
4646
.name(name) \
@@ -49,21 +49,21 @@ def create_virtual_appliance(self, vdc, name):
4949
return vapp
5050

5151
def create_virtual_machine(self, vapp, template):
52-
""" Create a virtual machine based on the given template. """
52+
""" Create a virtual machine based on the given template """
5353
log.info(("Creating virtual machine from "
5454
"template: %s...") % template.getName())
5555
vm = VirtualMachine.builder(self.__context, vapp, template).build()
5656
vm.save()
5757
return vm
5858

5959
def refresh_template_repository(self, enterprise, datacenter):
60-
""" Refresh the virtual machines templates in the given repository. """
60+
""" Refresh the virtual machines templates in the given repository """
6161
log.info("Refreshing template repository...")
6262
enterprise.refreshTemplateRepository(datacenter)
6363

6464

6565
def find_smallest_template(context, vdc):
66-
""" Finds the smallest template available to the virtual datacenter. """
66+
""" Finds the smallest template available to the virtual datacenter """
6767
log.info("Looking for the smallest available template...")
6868
templates = sorted(vdc.listAvailableTemplates(),
6969
key=lambda t: t.getDiskFileSize())
@@ -76,7 +76,7 @@ def find_smallest_template(context, vdc):
7676

7777

7878
def find_template_by_name(context, vdc, name):
79-
""" Finds the template with the given name. """
79+
""" Finds the template with the given name """
8080
template = vdc.findAvailableTemplate(
8181
VirtualMachineTemplatePredicates.name(name))
8282
if template:
@@ -88,7 +88,7 @@ def find_template_by_name(context, vdc, name):
8888

8989

9090
def create_cloud_compute(config, context, dc):
91-
""" Creates the default cloud compute entities. """
91+
""" Creates the default cloud compute entities """
9292
log.info("### Configuring the cloud ###")
9393
cloud = CloudCompute(context)
9494
# Create it into the 'abiquo' enterprise, to make it easier to use
@@ -111,7 +111,7 @@ def create_cloud_compute(config, context, dc):
111111

112112

113113
def cleanup_cloud_compute(config, context):
114-
""" Cleans up a previously created cloud compute resources. """
114+
""" Cleans up a previously created cloud compute resources """
115115
log.info("### Cleaning up the cloud ###")
116116
cloud = context.getCloudService()
117117
for vdc in cloud.listVirtualDatacenters():

kahuna/plugins/environment/cloud/storage.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@
88

99

1010
class CloudStorage:
11-
""" Provides access to cloud storage features. """
11+
""" Provides access to cloud storage features """
1212

1313
def __init__(self, context):
14-
""" Initialize the cloud creator with an existent context. """
14+
""" Initialize the cloud creator with an existent context """
1515
self.__context = context.getApiContext()
1616

1717
def create_volume(self, vdc, tier, name, size):
18-
""" Creates a new volume in the given virtual datacenter. """
18+
""" Creates a new volume in the given virtual datacenter """
1919
log.info("Creating volume %s of %s MB..." % (name, size))
2020
volume = Volume.builder(self.__context, vdc, tier) \
2121
.name(name) \
@@ -26,7 +26,7 @@ def create_volume(self, vdc, tier, name, size):
2626

2727

2828
def create_cloud_storage(config, context, vdc):
29-
""" Creates the default cloud storage entities. """
29+
""" Creates the default cloud storage entities """
3030
log.info("### Adding persistent storage ###")
3131
storage = CloudStorage(context)
3232
tier = vdc.findStorageTier(TierPredicates.name(config.get("tier", "name")))
@@ -36,7 +36,7 @@ def create_cloud_storage(config, context, vdc):
3636

3737

3838
def cleanup_cloud_storage(config, context, vdc):
39-
""" Cleans up a previously created cloud storage resources. """
39+
""" Cleans up a previously created cloud storage resources """
4040
log.info(("Removing persistent volumes in "
4141
"virtual datacenter %s...") % vdc.getName())
4242
for volume in vdc.listVolumes():

kahuna/plugins/environment/config/sysconfig.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,24 @@ class SystemConfig:
1313
"""
1414

1515
def __init__(self, context):
16-
""" Initialize with an existing context. """
16+
""" Initialize with an existing context """
1717
self.__context = context
1818

1919
def get(self, property_name):
20-
""" Returns value if a given configuration property. """
20+
""" Returns value if a given configuration property """
2121
admin = self.__context.getAdministrationService()
2222
return admin.getSystemProperty(property_name)
2323

2424
def set(self, property_name, property_value):
25-
""" Set a value to a given configuration property. """
25+
""" Set a value to a given configuration property """
2626
admin = self.__context.getAdministrationService()
2727
prop = admin.getSystemProperty(property_name)
2828
prop.setValue(property_value)
2929
prop.update()
3030

3131

3232
def apply_default_configuration(config, context):
33-
""" Applies the default platform configuration. """
33+
""" Applies the default platform configuration """
3434
log.info("### Applying default configuration ###")
3535
sysconf = SystemConfig(context)
3636
log.info("Disabling initial popup...")

kahuna/plugins/environment/infrastructure/compute.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@
1212

1313

1414
class InfrastructureCompute:
15-
""" Provides access to infrastructure compute features. """
15+
""" Provides access to infrastructure compute features """
1616

1717
def __init__(self, context):
18-
""" Initialize with an existent context. """
18+
""" Initialize with an existent context """
1919
self.__context = context.getApiContext()
2020

2121
def create_datacenter(self, name, location):
22-
""" Creates a new datacenter. """
22+
""" Creates a new datacenter """
2323
log.info("Creating datacenter %s at %s..." % (name, location))
2424
rs_address = self.__context.getEndpoint().getHost()
2525
datacenter = Datacenter.builder(self.__context) \
@@ -31,7 +31,7 @@ def create_datacenter(self, name, location):
3131
return datacenter
3232

3333
def create_rack(self, datacenter, name, vlan_id_min, vlan_id_max, nrsq):
34-
""" Creates a new rack. """
34+
""" Creates a new rack """
3535
log.info("Adding rack %s..." % name)
3636
rack = Rack.builder(self.__context, datacenter) \
3737
.name(name) \
@@ -44,7 +44,7 @@ def create_rack(self, datacenter, name, vlan_id_min, vlan_id_max, nrsq):
4444

4545
def create_machine(self, rack, hyp, address, user, password,
4646
datastore, vswitch):
47-
""" Creates a new machine. """
47+
""" Creates a new machine """
4848
log.info("Adding %s hypervisor at %s..." % (hyp, address))
4949
datacenter = rack.getDatacenter()
5050

@@ -66,7 +66,7 @@ def create_machine(self, rack, hyp, address, user, password,
6666

6767

6868
def create_infrastructure_compute(config, context):
69-
""" Creates the default infrastructure compute entities.. """
69+
""" Creates the default infrastructure compute entities. """
7070
log.info("### Configuring infrastructure ###")
7171
comp = InfrastructureCompute(context)
7272
dc = comp.create_datacenter(config.get("datacenter", "name"),
@@ -89,7 +89,7 @@ def create_infrastructure_compute(config, context):
8989

9090

9191
def cleanup_infrastructure_compute(config, context):
92-
""" Cleans up previously created infrastructure compute resources. """
92+
""" Cleans up previously created infrastructure compute resources """
9393
log.info("### Cleaning up infrastructure ###")
9494
admin = context.getAdministrationService()
9595
for datacenter in admin.listDatacenters():

kahuna/plugins/environment/infrastructure/network.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99

1010

1111
class InfrastructureNetwork:
12-
""" Provides access to infrastructure network features. """
12+
""" Provides access to infrastructure network features """
1313

1414
def __init__(self, context):
15-
""" Initialize with an existent context. """
15+
""" Initialize with an existent context """
1616
self.__context = context.getApiContext()
1717

1818
def create_public_network(self, datacenter, netname, netaddress,
1919
netmask, netgateway, nettag, netdns):
20-
""" Creates a new public network . """
20+
""" Creates a new public network """
2121
log.info(("Adding public network %s (%s) to "
2222
"datacenter %s...") % (netname, netaddress, datacenter.getName()))
2323
network = PublicNetwork.builder(self.__context, datacenter) \
@@ -33,7 +33,7 @@ def create_public_network(self, datacenter, netname, netaddress,
3333

3434
def create_external_network(self, datacenter, enterprise, netname,
3535
netaddress, netmask, netgateway, nettag, netdns):
36-
""" Creates a new external network . """
36+
""" Creates a new external network """
3737
log.info(("Adding external network %s (%s) to "
3838
"enterprise %s...") % (netname, netaddress, enterprise.getName()))
3939
network = ExternalNetwork \
@@ -50,7 +50,7 @@ def create_external_network(self, datacenter, enterprise, netname,
5050

5151

5252
def create_infrastructure_network(config, context, dc):
53-
""" Creates the default infrastructure network entities. """
53+
""" Creates the default infrastructure network entities """
5454
log.info("### Configuring networking ###")
5555
admin = context.getAdministrationService()
5656
enterprise = admin.findEnterprise(EnterprisePredicates.name("Abiquo"))
@@ -73,7 +73,7 @@ def create_infrastructure_network(config, context, dc):
7373

7474

7575
def cleanup_infrastructure_network(config, dc):
76-
""" Cleans up previously created infrastructure networking resources. """
76+
""" Cleans up previously created infrastructure networking resources """
7777
log.info("Removing networks in datacenter %s..." % dc.getName())
7878
for network in dc.listNetworks():
7979
network.delete()

0 commit comments

Comments
 (0)