Exemple #1
0
    def _choose_nodes(self, filtered_nodes, request_spec):
        num_servers = request_spec['num_servers']
        if num_servers > len(filtered_nodes):
            msg = 'Not enough nodes found for servers, request ' \
                  'servers: %s, but only available nodes: %s' \
                  % (str(num_servers), str(len(filtered_nodes)))
            raise exception.NoValidNode(_("Choose Node: %s") % msg)

        return filtered_nodes[:num_servers]
Exemple #2
0
 def _log_and_raise_error(policy):
     LOG.error(
         "No enough nodes filtered, request %(num_svr)s "
         "server(s) with server group %(group)s with %(policy)s "
         "policy specified.", {
             "num_svr": num_servers,
             "group": server_group.name,
             "policy": policy
         })
     msg = (_("No enough nodes filtered, request %(num_svr)s server(s) "
              "with %(policy)s policy specified.") % {
                  "num_svr": num_servers,
                  "policy": policy
              })
     raise exception.NoValidNode(msg)
Exemple #3
0
 def _schedule(self, context, request_spec, filter_properties):
     self._populate_retry(filter_properties, request_spec)
     filtered_nodes = self._get_filtered_nodes(context, request_spec)
     if not filtered_nodes:
         LOG.warning(
             'No filtered nodes found for server '
             'with properties: %s', request_spec.get('flavor'))
         raise exception.NoValidNode(_("No filtered nodes available"))
     dest_nodes = self._choose_nodes(filtered_nodes, request_spec)
     for server_id, node in zip(request_spec['server_ids'], dest_nodes):
         server_obj = objects.Server.get(context, server_id)
         alloc_data = self._get_res_cls_filters(request_spec)
         self.reportclient.put_allocations(node, server_obj.uuid,
                                           alloc_data,
                                           server_obj.project_id,
                                           server_obj.user_id)
     return dest_nodes
Exemple #4
0
    def _populate_retry(self, filter_properties, request_spec):
        """Populate filter properties with history of retries for request.

        If maximum retries is exceeded, raise NoValidNode.
        """
        max_attempts = self.max_attempts
        retry = filter_properties.pop('retry', {})

        if max_attempts == 1:
            # re-scheduling is disabled.
            return

        server_id = request_spec.get('server_ids')[0]
        self._log_server_error(server_id, retry)

        if retry['num_attempts'] > max_attempts:
            raise exception.NoValidNode(
                _("Exceeded max scheduling attempts %(max_attempts)d "
                  "for server %(server_id)s") % {
                      'max_attempts': max_attempts,
                      'server_id': server_id
                  })
Exemple #5
0
        def _schedule(self, context, request_spec, filter_properties):
            self._populate_retry(filter_properties, request_spec)
            filtered_nodes = self._get_filtered_nodes(context, request_spec)

            if not filtered_nodes:
                LOG.warning(
                    'No filtered nodes found for server '
                    'with properties: %s', request_spec.get('flavor'))
                raise exception.NoValidNode(_("No filtered nodes available"))
            dest_nodes = self._choose_nodes(filtered_nodes, request_spec)
            server_group = self._get_server_group_obj(context, request_spec)
            if not server_group:
                for server_id, node in zip(request_spec['server_ids'],
                                           dest_nodes):
                    self._consume_per_server(context, request_spec, node,
                                             server_id)
                return dest_nodes
            else:
                filtered_affzs_nodes = self._get_filtered_affzs_nodes(
                    context, server_group, filtered_nodes,
                    request_spec['num_servers'])
                return self._consume_nodes_with_server_group(
                    context, request_spec, filtered_affzs_nodes, server_group)