fixups backed on merge comments
This commit is contained in:
@@ -316,6 +316,5 @@ DEFINE_string('node_availability_zone', 'nova',
|
||||
'availability zone of this node')
|
||||
|
||||
DEFINE_string('zone_name', 'nova', 'name of this zone')
|
||||
DEFINE_string('zone_capabilities', 'xen, linux',
|
||||
'comma-delimited list of tags which represent boolean'
|
||||
' capabilities of this zone')
|
||||
DEFINE_string('zone_capabilities', 'kypervisor:xenserver;os:linux',
|
||||
'Key/Value tags which represent capabilities of this zone')
|
||||
|
||||
49
nova/scheduler/api.py
Normal file
49
nova/scheduler/api.py
Normal file
@@ -0,0 +1,49 @@
|
||||
# Copyright (c) 2011 Openstack, LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Handles all requests relating to schedulers.
|
||||
"""
|
||||
|
||||
from nova import flags
|
||||
from nova import log as logging
|
||||
from nova import rpc
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
LOG = logging.getLogger('nova.scheduler.api')
|
||||
|
||||
|
||||
class API:
|
||||
"""API for interacting with the scheduler."""
|
||||
|
||||
def _call_scheduler(self, method, context, params=None):
|
||||
"""Generic handler for RPC calls to the scheduler.
|
||||
|
||||
:param params: Optional dictionary of arguments to be passed to the
|
||||
scheduler worker
|
||||
|
||||
:retval: Result returned by scheduler worker
|
||||
"""
|
||||
if not params:
|
||||
params = {}
|
||||
queue = FLAGS.scheduler_topic
|
||||
kwargs = {'method': method, 'args': params}
|
||||
return rpc.call(context, queue, kwargs)
|
||||
|
||||
def get_zone_list(self, context):
|
||||
items = self._call_scheduler('get_zone_list', context)
|
||||
for item in items:
|
||||
item['api_url'] = item['api_url'].replace('\\/', '/')
|
||||
return items
|
||||
@@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2010 Openstack, LLC.
|
||||
# Copyright (c) 2011 Openstack, LLC.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
@@ -87,8 +87,8 @@ class ZoneState(object):
|
||||
|
||||
def _call_novatools(zone):
|
||||
"""Call novatools. Broken out for testing purposes."""
|
||||
os = novatools.OpenStack(zone.username, zone.password, zone.api_url)
|
||||
return os.zones.info()._info
|
||||
client = novatools.OpenStack(zone.username, zone.password, zone.api_url)
|
||||
return client.zones.info()._info
|
||||
|
||||
|
||||
def _poll_zone(zone):
|
||||
@@ -105,6 +105,7 @@ class ZoneManager(object):
|
||||
def __init__(self):
|
||||
self.last_zone_db_check = datetime.min
|
||||
self.zone_states = {}
|
||||
self.green_pool = GreenPool()
|
||||
|
||||
def get_zone_list(self):
|
||||
"""Return the list of zones we know about."""
|
||||
@@ -123,20 +124,20 @@ class ZoneManager(object):
|
||||
self.zone_states[zone.id].update_credentials(zone)
|
||||
|
||||
# Cleanup zones removed from db ...
|
||||
for zone_id in self.zone_states.keys():
|
||||
keys = self.zone_states.keys() # since we're deleting
|
||||
for zone_id in keys:
|
||||
if zone_id not in db_keys:
|
||||
del self.zone_states[zone_id]
|
||||
|
||||
def _poll_zones(self, context):
|
||||
"""Try to connect to each child zone and get update."""
|
||||
green_pool = GreenPool()
|
||||
green_pool.imap(_poll_zone, self.zone_states.values())
|
||||
self.green_pool.imap(_poll_zone, self.zone_states.values())
|
||||
|
||||
def ping(self, context=None):
|
||||
"""Ping should be called periodically to update zone status."""
|
||||
diff = datetime.now() - self.last_zone_db_check
|
||||
if diff.seconds >= FLAGS.zone_db_check_interval:
|
||||
logging.debug("Updating zone cache from db.")
|
||||
logging.debug(_("Updating zone cache from db."))
|
||||
self.last_zone_db_check = datetime.now()
|
||||
self._refresh_from_db(context)
|
||||
self._poll_zones(context)
|
||||
|
||||
Reference in New Issue
Block a user