getting closer to working select call
This commit is contained in:
@@ -376,3 +376,5 @@ DEFINE_string('zone_name', 'nova', 'name of this zone')
|
|||||||
DEFINE_list('zone_capabilities',
|
DEFINE_list('zone_capabilities',
|
||||||
['hypervisor=xenserver;kvm', 'os=linux;windows'],
|
['hypervisor=xenserver;kvm', 'os=linux;windows'],
|
||||||
'Key/Multi-value list representng capabilities of this zone')
|
'Key/Multi-value list representng capabilities of this zone')
|
||||||
|
DEFINE_string('build_plan_encryption_key', None,
|
||||||
|
'128bit (hex) encryption key for scheduler build plans.')
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ Handles all requests relating to schedulers.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import novaclient
|
import novaclient
|
||||||
|
import traceback #nuke
|
||||||
|
|
||||||
from nova import db
|
from nova import db
|
||||||
from nova import exception
|
from nova import exception
|
||||||
@@ -124,6 +125,7 @@ def call_zone_method(context, method, errors_to_ignore=None, *args, **kwargs):
|
|||||||
nova = novaclient.OpenStack(zone.username, zone.password,
|
nova = novaclient.OpenStack(zone.username, zone.password,
|
||||||
zone.api_url)
|
zone.api_url)
|
||||||
nova.authenticate()
|
nova.authenticate()
|
||||||
|
LOG.warn(_("*** AUTHENTICATED") % locals())#asdads
|
||||||
except novaclient.exceptions.BadRequest, e:
|
except novaclient.exceptions.BadRequest, e:
|
||||||
url = zone.api_url
|
url = zone.api_url
|
||||||
LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s")
|
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):
|
def _error_trap(*args, **kwargs):
|
||||||
try:
|
try:
|
||||||
|
LOG.warn(_("*** CALLING ZONE") % locals())#asdads
|
||||||
return zone_method(*args, **kwargs)
|
return zone_method(*args, **kwargs)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
if type(e) in errors_to_ignore:
|
if type(e) in errors_to_ignore:
|
||||||
return None
|
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.
|
# TODO (dabo) - want to be able to re-raise here.
|
||||||
# Returning a string now; raising was causing issues.
|
# Returning a string now; raising was causing issues.
|
||||||
# raise e
|
# raise e
|
||||||
|
|||||||
@@ -23,12 +23,16 @@ across zones. There are two expansion points to this class for:
|
|||||||
import operator
|
import operator
|
||||||
import M2Crypto
|
import M2Crypto
|
||||||
|
|
||||||
|
from nova import crypto
|
||||||
from nova import db
|
from nova import db
|
||||||
from nova import rpc
|
from nova import flags
|
||||||
from nova import log as logging
|
from nova import log as logging
|
||||||
|
from nova import rpc
|
||||||
|
|
||||||
from nova.scheduler import api
|
from nova.scheduler import api
|
||||||
from nova.scheduler import driver
|
from nova.scheduler import driver
|
||||||
|
|
||||||
|
FLAGS = flags.FLAGS
|
||||||
LOG = logging.getLogger('nova.scheduler.zone_aware_scheduler')
|
LOG = logging.getLogger('nova.scheduler.zone_aware_scheduler')
|
||||||
|
|
||||||
|
|
||||||
@@ -51,7 +55,8 @@ class ZoneAwareScheduler(driver.Scheduler):
|
|||||||
|
|
||||||
# TODO(sandy): We'll have to look for richer specs at some point.
|
# 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,
|
self.provision_resource(context, request_spec, instance_id,
|
||||||
request_spec, kwargs)
|
request_spec, kwargs)
|
||||||
return None
|
return None
|
||||||
@@ -99,6 +104,8 @@ class ZoneAwareScheduler(driver.Scheduler):
|
|||||||
# 1. valid,
|
# 1. valid,
|
||||||
# 2. intended for this zone or a child zone.
|
# 2. intended for this zone or a child zone.
|
||||||
# if 2 ... forward call to child zone.
|
# if 2 ... forward call to child zone.
|
||||||
|
LOG.debug(_("****** PROVISION IN CHILD %(item)s") % locals())
|
||||||
|
|
||||||
blob = item['blob']
|
blob = item['blob']
|
||||||
decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key)
|
decryptor = crypto.decryptor(FLAGS.build_plan_encryption_key)
|
||||||
host_info = None
|
host_info = None
|
||||||
@@ -182,16 +189,21 @@ class ZoneAwareScheduler(driver.Scheduler):
|
|||||||
#TODO(sandy): how to infer this from OS API params?
|
#TODO(sandy): how to infer this from OS API params?
|
||||||
num_instances = 1
|
num_instances = 1
|
||||||
|
|
||||||
|
LOG.debug(_("XXXXXXX - 1 - _SCHEDULE"))
|
||||||
|
|
||||||
# Filter local hosts based on requirements ...
|
# Filter local hosts based on requirements ...
|
||||||
host_list = self.filter_hosts(num_instances, request_spec)
|
host_list = self.filter_hosts(num_instances, request_spec)
|
||||||
|
|
||||||
|
LOG.debug(_("XXXXXXX - 2 - _SCHEDULE"))
|
||||||
# then weigh the selected hosts.
|
# then weigh the selected hosts.
|
||||||
# weighted = [{weight=weight, name=hostname}, ...]
|
# weighted = [{weight=weight, name=hostname}, ...]
|
||||||
weighted = self.weigh_hosts(num_instances, request_spec, host_list)
|
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 ...
|
# Next, tack on the best weights from the child zones ...
|
||||||
child_results = self._call_zone_method(context, "select",
|
child_results = self._call_zone_method(context, "select",
|
||||||
specs=request_spec)
|
specs=request_spec)
|
||||||
|
LOG.debug(_("XXXXXXX - 4 - _SCHEDULE - CHILD RESULTS %(child_results)s") % locals())
|
||||||
for child_zone, result in child_results:
|
for child_zone, result in child_results:
|
||||||
for weighting in result:
|
for weighting in result:
|
||||||
# Remember the child_zone so we can get back to
|
# Remember the child_zone so we can get back to
|
||||||
@@ -203,6 +215,7 @@ class ZoneAwareScheduler(driver.Scheduler):
|
|||||||
"child_blob": weighting["blob"]}
|
"child_blob": weighting["blob"]}
|
||||||
weighted.append(host_dict)
|
weighted.append(host_dict)
|
||||||
|
|
||||||
|
LOG.debug(_("XXXXXXX - 4 - _SCHEDULE"))
|
||||||
weighted.sort(key=operator.itemgetter('weight'))
|
weighted.sort(key=operator.itemgetter('weight'))
|
||||||
return weighted
|
return weighted
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user