diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-05-27 07:24:02 -0700 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-05-27 07:24:02 -0700 |
| commit | 3f911877a2a9facdf153f173b3fb76a18e44a2ac (patch) | |
| tree | ea20bdc0d274d8820737fba870f9915868c6aae2 | |
| parent | bd19bd2edd612dfea09e4230c59422e59c6de181 (diff) | |
| download | nova-3f911877a2a9facdf153f173b3fb76a18e44a2ac.tar.gz nova-3f911877a2a9facdf153f173b3fb76a18e44a2ac.tar.xz nova-3f911877a2a9facdf153f173b3fb76a18e44a2ac.zip | |
docstrings again and import ordering
| -rw-r--r-- | nova/compute/api.py | 30 | ||||
| -rw-r--r-- | nova/scheduler/host_filter.py | 18 | ||||
| -rw-r--r-- | nova/scheduler/zone_aware_scheduler.py | 20 |
3 files changed, 23 insertions, 45 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index 3e5105050..35d60446c 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -88,8 +88,7 @@ class API(base.Base): {"method": "get_network_topic", "args": {'fake': 1}}) def _check_injected_file_quota(self, context, injected_files): - """ - Enforce quota limits on injected files. + """Enforce quota limits on injected files. Raises a QuotaError if any limit is exceeded. """ @@ -137,8 +136,7 @@ class API(base.Base): availability_zone=None, user_data=None, metadata={}, injected_files=None, admin_password=None): - """ - Create the number and type of instances requested. + """Create the number and type of instances requested. Verifies that quota and other arguments are valid. """ @@ -293,8 +291,7 @@ class API(base.Base): return False def ensure_default_security_group(self, context): - """ - Ensure that a context has a security group. + """Ensure that a context has a security group. Creates a security group for the security context if it does not already exist. @@ -328,8 +325,7 @@ class API(base.Base): "args": {"security_group_id": security_group.id}}) def trigger_security_group_members_refresh(self, context, group_id): - """ - Called when a security group gains a new or loses a member. + """Called when a security group gains a new or loses a member. Sends an update request to each compute node for whom this is relevant. @@ -370,8 +366,7 @@ class API(base.Base): "args": {"security_group_id": group_id}}) def update(self, context, instance_id, **kwargs): - """ - Updates the instance in the datastore. + """Updates the instance in the datastore. :param context: The security context :param instance_id: ID of the instance to update @@ -424,8 +419,7 @@ class API(base.Base): @scheduler_api.reroute_compute("get") def routing_get(self, context, instance_id): - """ - A version of get with special routing characteristics. + """A version of get with special routing characteristics. Use this method instead of get() if this is the only operation you intend to to. It will route to novaclient.get if the instance is not @@ -435,8 +429,7 @@ class API(base.Base): def get_all(self, context, project_id=None, reservation_id=None, fixed_ip=None): - """ - Get all instances filtered by one of the given parameters. + """Get all instances filtered by one of the given parameters. If there is no filter and the context is an admin, it will retreive all instances in the system. @@ -463,8 +456,7 @@ class API(base.Base): def _cast_compute_message(self, method, context, instance_id, host=None, params=None): - """ - Generic handler for RPC casts to compute. + """Generic handler for RPC casts to compute. :param params: Optional dictionary of arguments to be passed to the compute worker @@ -483,8 +475,7 @@ class API(base.Base): def _call_compute_message(self, method, context, instance_id, host=None, params=None): - """ - Generic handler for RPC calls to compute. + """Generic handler for RPC calls to compute. :param params: Optional dictionary of arguments to be passed to the compute worker @@ -517,8 +508,7 @@ class API(base.Base): % instance_id) def snapshot(self, context, instance_id, name): - """ - Snapshot the given instance. + """Snapshot the given instance. :returns: A dict containing image metadata """ diff --git a/nova/scheduler/host_filter.py b/nova/scheduler/host_filter.py index 89faace45..4260cbf42 100644 --- a/nova/scheduler/host_filter.py +++ b/nova/scheduler/host_filter.py @@ -69,8 +69,7 @@ class HostFilter(object): class AllHostsFilter(HostFilter): - """ - NOP host filter. Returns all hosts in ZoneManager. + """ NOP host filter. Returns all hosts in ZoneManager. This essentially does what the old Scheduler+Chance used to give us. """ @@ -135,8 +134,7 @@ class InstanceTypeFilter(HostFilter): class JsonFilter(HostFilter): - """ - Host Filter to allow simple JSON-based grammar for + """Host Filter to allow simple JSON-based grammar for selecting hosts. """ @@ -233,8 +231,7 @@ class JsonFilter(HostFilter): return (self._full_name(), json.dumps(query)) def _parse_string(self, string, host, services): - """ - Strings prefixed with $ are capability lookups in the + """Strings prefixed with $ are capability lookups in the form '$service.capability[.subcap*]' """ if not string: @@ -283,8 +280,7 @@ FILTERS = [AllHostsFilter, InstanceTypeFilter, JsonFilter] def choose_host_filter(filter_name=None): - """ - Since the caller may specify which filter to use we need + """Since the caller may specify which filter to use we need to have an authoritative list of what is permissible. This function checks the filter name against a predefined set of acceptable filters. @@ -300,8 +296,7 @@ def choose_host_filter(filter_name=None): class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): - """ - The HostFilterScheduler uses the HostFilter to filter + """The HostFilterScheduler uses the HostFilter to filter hosts for weighing. The particular filter used may be passed in as an argument or the default will be used. @@ -322,8 +317,7 @@ class HostFilterScheduler(zone_aware_scheduler.ZoneAwareScheduler): return host_filter.filter_hosts(self.zone_manager, query) def weigh_hosts(self, num, request_spec, hosts): - """ - Derived classes must override this method and return + """Derived classes must override this method and return a lists of hosts in [{weight, hostname}] format. """ return [dict(weight=1, hostname=host) for host, caps in hosts] diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py index 236907626..bc67c7794 100644 --- a/nova/scheduler/zone_aware_scheduler.py +++ b/nova/scheduler/zone_aware_scheduler.py @@ -23,8 +23,8 @@ across zones. There are two expansion points to this class for: import operator from nova import db -from nova import rpc from nova import log as logging +from nova import rpc from nova.scheduler import api from nova.scheduler import driver @@ -40,8 +40,7 @@ class ZoneAwareScheduler(driver.Scheduler): def schedule_run_instance(self, context, instance_id, request_spec, *args, **kwargs): - """ - This method is called from nova.compute.api to provision + """This method is called from nova.compute.api to provision an instance. However we need to look at the parameters being passed in to see if this is a request to: 1. Create a Build Plan and then provision, or @@ -85,8 +84,7 @@ class ZoneAwareScheduler(driver.Scheduler): pass def select(self, context, request_spec, *args, **kwargs): - """ - Select returns a list of weights and zone/host information + """Select returns a list of weights and zone/host information corresponding to the best hosts to service the request. Any child zone information has been encrypted so as not to reveal anything about the children. @@ -98,15 +96,13 @@ class ZoneAwareScheduler(driver.Scheduler): # so we don't implement the default "schedule()" method required # of Schedulers. def schedule(self, context, topic, request_spec, *args, **kwargs): - """ - The schedule() contract requires we return the one + """The schedule() contract requires we return the one best-suited host for this request. """ raise driver.NoValidHost(_('No hosts were available')) def _schedule(self, context, topic, request_spec, *args, **kwargs): - """ - Returns a list of hosts that meet the required specs, + """Returns a list of hosts that meet the required specs, ordered by their fitness. """ @@ -142,15 +138,13 @@ class ZoneAwareScheduler(driver.Scheduler): return weighted def filter_hosts(self, num, request_spec): - """ - Derived classes must override this method and return + """Derived classes must override this method and return a list of hosts in [(hostname, capability_dict)] format. """ raise NotImplemented() def weigh_hosts(self, num, request_spec, hosts): - """ - Derived classes must override this method and return + """Derived classes must override this method and return a lists of hosts in [{weight, hostname}] format. """ raise NotImplemented() |
