summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSandy Walsh <sandy.walsh@rackspace.com>2011-05-23 22:32:15 -0700
committerSandy Walsh <sandy.walsh@rackspace.com>2011-05-23 22:32:15 -0700
commit758d60ccede696c1ef52488c90da7b80b807dedf (patch)
tree06351f63ad68e5ac9398c012e3824f9f91d68901
parent5d5aad97c3c12ca304cc2b9eb46cf7f25d996b4a (diff)
parent0ed410621b3c2d621aa3fa52ca7ac46c6a5f0b70 (diff)
downloadnova-758d60ccede696c1ef52488c90da7b80b807dedf.tar.gz
nova-758d60ccede696c1ef52488c90da7b80b807dedf.tar.xz
nova-758d60ccede696c1ef52488c90da7b80b807dedf.zip
merge
-rw-r--r--nova/api/openstack/__init__.py2
-rw-r--r--nova/api/openstack/servers.py3
-rw-r--r--nova/api/openstack/zones.py18
-rw-r--r--nova/compute/api.py18
-rw-r--r--nova/flags.py2
-rw-r--r--nova/rpc.py1
-rw-r--r--nova/scheduler/api.py7
-rw-r--r--nova/scheduler/manager.py9
-rw-r--r--nova/scheduler/zone_aware_scheduler.py14
-rw-r--r--nova/service.py2
10 files changed, 49 insertions, 27 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py
index 5d45efde6..5a93d0d75 100644
--- a/nova/api/openstack/__init__.py
+++ b/nova/api/openstack/__init__.py
@@ -99,7 +99,7 @@ class APIRouter(wsgi.Router):
mapper.resource("zone", "zones", controller=zones.Controller(),
collection={'detail': 'GET', 'info': 'GET',
- 'select': 'GET'}),
+ 'select': 'POST'}),
mapper.resource("user", "users", controller=users.Controller(),
collection={'detail': 'GET'})
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 738910bc8..474695d98 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -189,6 +189,9 @@ class Controller(common.OpenstackController):
inst['instance_type'] = inst_type
inst['image_id'] = requested_image_id
+ # TODO(sandy): REMOVE THIS
+ LOG.debug(_("***** INST = %(inst)s") % locals())
+
builder = self._get_view_builder(req)
server = builder.build(inst, is_detail=True)
server['server']['adminPass'] = password
diff --git a/nova/api/openstack/zones.py b/nova/api/openstack/zones.py
index 70653dc0e..f9d933a50 100644
--- a/nova/api/openstack/zones.py
+++ b/nova/api/openstack/zones.py
@@ -18,6 +18,7 @@ import urlparse
from nova import crypto
from nova import db
+from nova import exception
from nova import flags
from nova import log as logging
from nova.api.openstack import common
@@ -25,11 +26,6 @@ from nova.scheduler import api
FLAGS = flags.FLAGS
-flags.DEFINE_string('build_plan_encryption_key',
- None,
- '128bit (hex) encryption key for scheduler build plans.')
-
-
LOG = logging.getLogger('nova.api.openstack.zones')
@@ -121,15 +117,9 @@ class Controller(common.OpenstackController):
"""Returns a weighted list of costs to create instances
of desired capabilities."""
ctx = req.environ['nova.context']
- qs = req.environ['QUERY_STRING']
- param_dict = urlparse.parse_qs(qs)
- param_dict.pop("fresh", None)
- # parse_qs returns a dict where the values are lists,
- # since query strings can have multiple values for the
- # same key. We need to convert that to single values.
- for key in param_dict:
- param_dict[key] = param_dict[key][0]
- build_plan = api.select(ctx, specs=param_dict)
+ LOG.debug("INCOMING SELECT '%s'" % req.environ)
+ specs = json.loads(req.body)
+ build_plan = api.select(ctx, specs=specs)
cooked = self._scrub_build_plan(build_plan)
return {"weights": cooked}
diff --git a/nova/compute/api.py b/nova/compute/api.py
index 785aff397..301c777bb 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -257,19 +257,21 @@ class API(base.Base):
# we'll be ripping this whole for-loop out and deferring the
# creation of the Instance record. At that point all this will
# change.
+ filter_driver = 'nova.scheduler.host_filter.InstanceTypeFilter'
+ request_spec = {
+ 'instance_properties': base_options,
+ 'instance_type': instance_type,
+ 'filter_driver': filter_driver,
+ 'blob': zone_blob
+ }
+ LOG.debug(_("**** REQUEST SPEC: %(request_spec)s") % locals())
+
rpc.cast(context,
FLAGS.scheduler_topic,
{"method": "run_instance",
"args": {"topic": FLAGS.compute_topic,
"instance_id": instance_id,
- "request_spec": {
- 'instance_properties': instance,
- 'instance_type': instance_type,
- 'filter_driver':
- 'nova.scheduler.host_filter.'
- 'InstanceTypeFilter',
- 'blob': zone_blob
- },
+ "request_spec": request_spec,
"availability_zone": availability_zone,
"injected_files": injected_files}})
diff --git a/nova/flags.py b/nova/flags.py
index 32cb6efa8..cae2be7ba 100644
--- a/nova/flags.py
+++ b/nova/flags.py
@@ -379,3 +379,5 @@ DEFINE_string('zone_name', 'nova', 'name of this zone')
DEFINE_list('zone_capabilities',
['hypervisor=xenserver;kvm', 'os=linux;windows'],
'Key/Multi-value list representng capabilities of this zone')
+DEFINE_string('build_plan_encryption_key', None,
+ '128bit (hex) encryption key for scheduler build plans.')
diff --git a/nova/rpc.py b/nova/rpc.py
index 2116f22c3..af3625eee 100644
--- a/nova/rpc.py
+++ b/nova/rpc.py
@@ -194,6 +194,7 @@ class AdapterConsumer(Consumer):
node_func = getattr(self.proxy, str(method))
node_args = dict((str(k), v) for k, v in args.iteritems())
# NOTE(vish): magic is fun!
+ logging.exception('CALLING %s on SCHEDULER with %s' % (node_func, node_args))
try:
rval = node_func(context=ctxt, **node_args)
if msg_id:
diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py
index 55f8e0a6d..147a64798 100644
--- a/nova/scheduler/api.py
+++ b/nova/scheduler/api.py
@@ -18,6 +18,7 @@ Handles all requests relating to schedulers.
"""
import novaclient
+import traceback #nuke
from nova import db
from nova import exception
@@ -84,7 +85,7 @@ def get_zone_capabilities(context):
def select(context, specs=None):
"""Returns a list of hosts."""
return _call_scheduler('select', context=context,
- params={"specs": specs})
+ params={"request_spec": specs})
def update_service_capabilities(context, service_name, host, capabilities):
@@ -124,6 +125,7 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs):
nova = novaclient.OpenStack(zone.username, zone.password,
zone.api_url)
nova.authenticate()
+ LOG.warn(_("*** AUTHENTICATED") % locals())#asdads
except novaclient.exceptions.BadRequest, e:
url = zone.api_url
LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s")
@@ -135,10 +137,13 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs):
def _error_trap(*args, **kwargs):
try:
+ LOG.warn(_("*** CALLING ZONE") % locals())#asdads
return zone_method(*args, **kwargs)
except Exception as e:
if type(e) in errors_to_ignore:
return None
+ ex = traceback.format_exc(e)
+ LOG.warn(_("*** CAUGHT EXCEPTION %(ex)s") % locals())#asdads
# TODO (dabo) - want to be able to re-raise here.
# Returning a string now; raising was causing issues.
# raise e
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index bd40e73c0..ba0d5b962 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -70,17 +70,24 @@ class SchedulerManager(manager.Manager):
self.zone_manager.update_service_capabilities(service_name,
host, capabilities)
+ def select(self, context=None, *args, **kwargs):
+ """Select a list of hosts best matching the provided specs."""
+ return self.driver.select(context, *args, **kwargs)
+
def _schedule(self, method, context, topic, *args, **kwargs):
"""Tries to call schedule_* method on the driver to retrieve host.
Falls back to schedule(context, topic) if method doesn't exist.
"""
driver_method = 'schedule_%s' % method
+ LOG.debug(_("CALLING %(driver_method)s handled in Scheduler") % locals()) # nuke
elevated = context.elevated()
try:
host = getattr(self.driver, driver_method)(elevated, *args,
**kwargs)
- except AttributeError:
+ except AttributeError, e:
+ LOG.exception(_("Driver Method %(driver_method)s missing: %(e)s")
+ % locals())
host = self.driver.schedule(elevated, topic, *args, **kwargs)
if not host:
diff --git a/nova/scheduler/zone_aware_scheduler.py b/nova/scheduler/zone_aware_scheduler.py
index 3f967e18e..8a3f6d64e 100644
--- a/nova/scheduler/zone_aware_scheduler.py
+++ b/nova/scheduler/zone_aware_scheduler.py
@@ -55,12 +55,14 @@ class ZoneAwareScheduler(driver.Scheduler):
# TODO(sandy): We'll have to look for richer specs at some point.
- if 'blob' in request_spec:
+ blob = request_spec['blob']
+ if blob:
self.provision_resource(context, request_spec, instance_id,
request_spec, kwargs)
return None
# Create build plan and provision ...
+ LOG.debug(_("****** SCHEDULE RUN INSTANCE") % locals())
build_plan = self.select(context, request_spec)
if not build_plan:
raise driver.NoValidHost(_('No hosts were available'))
@@ -162,7 +164,8 @@ class ZoneAwareScheduler(driver.Scheduler):
"""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."""
+ anything about the children."""
+ LOG.debug(_("XXXXXXX - SELECT %(request_spec)s") % locals()) # nuke this !!!
return self._schedule(context, "compute", request_spec,
*args, **kwargs)
@@ -173,6 +176,7 @@ class ZoneAwareScheduler(driver.Scheduler):
"""The schedule() contract requires we return the one
best-suited host for this request.
"""
+ LOG.debug(_("XXXXXXX - DEFAULT SCHEDULE %(request_spec)s") % locals()) # nuke this !!!
raise driver.NoValidHost(_('No hosts were available'))
def _schedule(self, context, topic, request_spec, *args, **kwargs):
@@ -187,16 +191,21 @@ class ZoneAwareScheduler(driver.Scheduler):
#TODO(sandy): how to infer this from OS API params?
num_instances = 1
+ LOG.debug(_("XXXXXXX - 1 - _SCHEDULE"))
+
# Filter local hosts based on requirements ...
host_list = self.filter_hosts(num_instances, request_spec)
+ LOG.debug(_("XXXXXXX - 2 - _SCHEDULE"))
# then weigh the selected hosts.
# weighted = [{weight=weight, name=hostname}, ...]
weighted = self.weigh_hosts(num_instances, request_spec, host_list)
+ LOG.debug(_("XXXXXXX - 3 - _SCHEDULE"))
# Next, tack on the best weights from the child zones ...
child_results = self._call_zone_method(context, "select",
specs=request_spec)
+ LOG.debug(_("XXXXXXX - 4 - _SCHEDULE - CHILD RESULTS %(child_results)s") % locals())
for child_zone, result in child_results:
for weighting in result:
# Remember the child_zone so we can get back to
@@ -208,6 +217,7 @@ class ZoneAwareScheduler(driver.Scheduler):
"child_blob": weighting["blob"]}
weighted.append(host_dict)
+ LOG.debug(_("XXXXXXX - 4 - _SCHEDULE"))
weighted.sort(key=operator.itemgetter('weight'))
return weighted
diff --git a/nova/service.py b/nova/service.py
index 2532b9df2..93020d94f 100644
--- a/nova/service.py
+++ b/nova/service.py
@@ -132,7 +132,9 @@ class Service(object):
self.service_id = service_ref['id']
def __getattr__(self, key):
+ logging.warn(_('SERVICE __GETATTR__ %s') % (key, ))
manager = self.__dict__.get('manager', None)
+ logging.warn(_('SERVICE MANAGER %s') % (manager, ))
return getattr(manager, key)
@classmethod