def _get_weighted_hosts_for_share_type(self, context, request_spec, share_type): config_options = self._get_configuration_options() # NOTE(ameade): Find our local list of acceptable hosts by # filtering and weighing our options. We virtually consume # resources on it so subsequent selections can adjust accordingly. # NOTE(ameade): Remember, we are using an iterator here. So only # traverse this list once. all_hosts = self.host_manager.get_all_host_states_share(context) if not all_hosts: return [] share_type['extra_specs'] = share_type.get('extra_specs', {}) if share_type['extra_specs']: for spec_name in share_types.get_undeletable_extra_specs(): extra_spec = share_type['extra_specs'].get(spec_name) if extra_spec is not None: share_type['extra_specs'][spec_name] = ( "<is> %s" % extra_spec) # Only allow pools that support consistency groups share_type['extra_specs']['consistency_group_support'] = ( "<or> host <or> pool") filter_properties = { 'context': context, 'request_spec': request_spec, 'config_options': config_options, 'share_type': share_type, 'resource_type': share_type, 'size': 0, } # Filter local hosts based on requirements ... hosts = self.host_manager.get_filtered_hosts(all_hosts, filter_properties) if not hosts: return [] LOG.debug("Filtered %s" % hosts) # weighted_host = WeightedHost() ... the best host for the job. weighed_hosts = self.host_manager.get_weighed_hosts( hosts, filter_properties) if not weighed_hosts: return [] return weighed_hosts
def delete(self, req, type_id, id): """Deletes an existing extra spec.""" context = req.environ['manila.context'] self._check_type(context, type_id) if id in share_types.get_undeletable_extra_specs(): msg = _("Extra spec '%s' can't be deleted.") % id raise webob.exc.HTTPForbidden(explanation=msg) try: db.share_type_extra_specs_delete(context, type_id, id) except exception.ShareTypeExtraSpecsNotFound as error: raise webob.exc.HTTPNotFound(explanation=error.msg) notifier_info = dict(type_id=type_id, id=id) notifier = rpc.get_notifier('shareTypeExtraSpecs') notifier.info(context, 'share_type_extra_specs.delete', notifier_info) return webob.Response(status_int=202)