~rackspace-titan/nova/api-profiling

« back to all changes in this revision

Viewing changes to nova/scheduler/zone_manager.py

  • Committer: William Wolf
  • Date: 2011-05-11 19:16:37 UTC
  • mfrom: (1063 nova)
  • mto: This revision was merged to the branch mainline in revision 1071.
  • Revision ID: throughnothing@gmail.com-20110511191637-ubm342cc2y6v4v5r
merge from trunk and update .mailmap file

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    def __init__(self):
107
107
        self.last_zone_db_check = datetime.min
108
108
        self.zone_states = {}  # { <zone_id> : ZoneState }
109
 
        self.service_states = {}  # { <service> : { <host> : { cap k : v }}}
 
109
        self.service_states = {}  # { <host> : { <service> : { cap k : v }}}
110
110
        self.green_pool = greenpool.GreenPool()
111
111
 
112
112
    def get_zone_list(self):
113
113
        """Return the list of zones we know about."""
114
114
        return [zone.to_dict() for zone in self.zone_states.values()]
115
115
 
116
 
    def get_zone_capabilities(self, context, service=None):
 
116
    def get_zone_capabilities(self, context):
117
117
        """Roll up all the individual host info to generic 'service'
118
118
           capabilities. Each capability is aggregated into
119
119
           <cap>_min and <cap>_max values."""
120
 
        service_dict = self.service_states
121
 
        if service:
122
 
            service_dict = {service: self.service_states.get(service, {})}
 
120
        hosts_dict = self.service_states
123
121
 
124
122
        # TODO(sandy) - be smarter about fabricating this structure.
125
123
        # But it's likely to change once we understand what the Best-Match
126
124
        # code will need better.
127
125
        combined = {}  # { <service>_<cap> : (min, max), ... }
128
 
        for service_name, host_dict in service_dict.iteritems():
129
 
            for host, caps_dict in host_dict.iteritems():
130
 
                for cap, value in caps_dict.iteritems():
 
126
        for host, host_dict in hosts_dict.iteritems():
 
127
            for service_name, service_dict in host_dict.iteritems():
 
128
                for cap, value in service_dict.iteritems():
131
129
                    key = "%s_%s" % (service_name, cap)
132
130
                    min_value, max_value = combined.get(key, (value, value))
133
131
                    min_value = min(min_value, value)
171
169
        """Update the per-service capabilities based on this notification."""
172
170
        logging.debug(_("Received %(service_name)s service update from "
173
171
                            "%(host)s: %(capabilities)s") % locals())
174
 
        service_caps = self.service_states.get(service_name, {})
175
 
        service_caps[host] = capabilities
176
 
        self.service_states[service_name] = service_caps
 
172
        service_caps = self.service_states.get(host, {})
 
173
        service_caps[service_name] = capabilities
 
174
        self.service_states[host] = service_caps