diff options
| author | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-03-16 19:04:27 -0700 |
|---|---|---|
| committer | Sandy Walsh <sandy.walsh@rackspace.com> | 2011-03-16 19:04:27 -0700 |
| commit | c9158dfcf4efd2cf22df9aed7b1bb01e037e8eb2 (patch) | |
| tree | 70525af2ba2c0e3139849566f2eb3774958e1de4 /nova/scheduler | |
| parent | 4d057c9c2df77816ead6f30fa2795148aa8148d3 (diff) | |
| download | nova-c9158dfcf4efd2cf22df9aed7b1bb01e037e8eb2.tar.gz nova-c9158dfcf4efd2cf22df9aed7b1bb01e037e8eb2.tar.xz nova-c9158dfcf4efd2cf22df9aed7b1bb01e037e8eb2.zip | |
moved scheduler API check into db.api decorator
Diffstat (limited to 'nova/scheduler')
| -rw-r--r-- | nova/scheduler/api.py | 23 |
1 files changed, 6 insertions, 17 deletions
diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 073784f31..2da2dabfe 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -78,30 +78,16 @@ class API(object): capabilities=capabilities)) return rpc.fanout_cast(context, 'scheduler', kwargs) - @classmethod - def get_instance_or_reroute(cls, context, instance_id): - """Return an instance from the db or throw a ZoneRouteException - if not found.""" - try: - instance = db.instance_get(context, instance_id) - return instance - except exception.InstanceNotFound, e: - LOG.debug(_("Instance %(instance_id)s not found locally: '%(e)s'" % - locals())) - - # Throw a reroute Exception for the middleware to pick up. - LOG.debug("Firing ZoneRouteException") - zones = db.zone_get_all(context) - raise exception.ZoneRouteException(zones) - def _wrap_method(function, self): + """Wrap method to supply 'self'.""" def _wrap(*args, **kwargs): return function(self, *args, **kwargs) return _wrap def _process(self, zone): + """Worker stub for green thread pool""" nova = client.OpenStackClient(zone.username, zone.password, zone.api_url) nova.authenticate() @@ -114,10 +100,13 @@ class ChildZoneHelper(object): plug-ins to query the children.""" def start(self, zone_list): + """Spawn a green thread for each child zone, calling the + derived classes process() method as the worker. Returns + a list of HTTP Responses. 1 per child.""" self.green_pool = greenpool.GreenPool() return [ result for result in self.green_pool.imap( _wrap_method(_process, self), zone_list)] def process(self, client, zone): - """Derived class must override.""" + """Worker Method. Derived class must override.""" pass |
