Exemple #1
0
 def rebuild_instance(self,
                      context,
                      instance,
                      orig_image_ref,
                      image_ref,
                      injected_files,
                      new_pass,
                      orig_sys_metadata,
                      bdms,
                      recreate=False,
                      on_shared_storage=False,
                      preserve_ephemeral=False,
                      host=None,
                      kwargs=None):
     # kwargs unused but required for cell compatibility.
     utils.spawn_n(self._manager.rebuild_instance,
                   context,
                   instance=instance,
                   new_pass=new_pass,
                   injected_files=injected_files,
                   image_ref=image_ref,
                   orig_image_ref=orig_image_ref,
                   orig_sys_metadata=orig_sys_metadata,
                   bdms=bdms,
                   recreate=recreate,
                   on_shared_storage=on_shared_storage,
                   host=host,
                   preserve_ephemeral=preserve_ephemeral)
Exemple #2
0
 def build_instances(self, context, instances, image,
         filter_properties, admin_password, injected_files,
         requested_networks, security_groups, block_device_mapping,
         legacy_bdm=True):
     utils.spawn_n(self._manager.build_instances, context,
             instances=instances, image=image,
             filter_properties=filter_properties,
             admin_password=admin_password, injected_files=injected_files,
             requested_networks=requested_networks,
             security_groups=security_groups,
             block_device_mapping=block_device_mapping,
             legacy_bdm=legacy_bdm)
Exemple #3
0
 def rebuild_instance(self, context, instance, orig_image_ref, image_ref,
                      injected_files, new_pass, orig_sys_metadata,
                      bdms, recreate=False, on_shared_storage=False,
                      preserve_ephemeral=False, host=None, kwargs=None):
     # kwargs unused but required for cell compatibility.
     utils.spawn_n(self._manager.rebuild_instance, context,
             instance=instance,
             new_pass=new_pass,
             injected_files=injected_files,
             image_ref=image_ref,
             orig_image_ref=orig_image_ref,
             orig_sys_metadata=orig_sys_metadata,
             bdms=bdms,
             recreate=recreate,
             on_shared_storage=on_shared_storage,
             host=host,
             preserve_ephemeral=preserve_ephemeral)
Exemple #4
0
    def _init_instance_info(self):
        """Creates the initial view of instances for all hosts.

        As this initial population of instance information may take some time,
        we don't wish to block the scheduler's startup while this completes.
        The async method allows us to simply mock out the _init_instance_info()
        method in tests.
        """
        def _async_init_instance_info():
            context = context_module.get_admin_context()
            LOG.debug("START:_async_init_instance_info")
            self._instance_info = {}
            compute_nodes = objects.ComputeNodeList.get_all(context).objects
            LOG.debug("Total number of compute nodes: %s", len(compute_nodes))
            # Break the queries into batches of 10 to reduce the total number
            # of calls to the DB.
            batch_size = 10
            start_node = 0
            end_node = batch_size
            while start_node <= len(compute_nodes):
                curr_nodes = compute_nodes[start_node:end_node]
                start_node += batch_size
                end_node += batch_size
                filters = {
                    "host": [curr_node.host for curr_node in curr_nodes]
                }
                result = objects.InstanceList.get_by_filters(context, filters)
                instances = result.objects
                LOG.debug("Adding %s instances for hosts %s-%s",
                          len(instances), start_node, end_node)
                for instance in instances:
                    host = instance.host
                    if host not in self._instance_info:
                        self._instance_info[host] = {
                            "instances": {},
                            "updated": False
                        }
                    inst_dict = self._instance_info[host]
                    inst_dict["instances"][instance.uuid] = instance
                # Call sleep() to cooperatively yield
                time.sleep(0)
            LOG.debug("END:_async_init_instance_info")

        # Run this async so that we don't block the scheduler start-up
        utils.spawn_n(_async_init_instance_info)
Exemple #5
0
    def _init_instance_info(self):
        """Creates the initial view of instances for all hosts.

        As this initial population of instance information may take some time,
        we don't wish to block the scheduler's startup while this completes.
        The async method allows us to simply mock out the _init_instance_info()
        method in tests.
        """

        def _async_init_instance_info():
            context = context_module.get_admin_context()
            LOG.debug("START:_async_init_instance_info")
            self._instance_info = {}
            compute_nodes = objects.ComputeNodeList.get_all(context).objects
            LOG.debug("Total number of compute nodes: %s", len(compute_nodes))
            # Break the queries into batches of 10 to reduce the total number
            # of calls to the DB.
            batch_size = 10
            start_node = 0
            end_node = batch_size
            while start_node <= len(compute_nodes):
                curr_nodes = compute_nodes[start_node:end_node]
                start_node += batch_size
                end_node += batch_size
                filters = {"host": [curr_node.host
                                    for curr_node in curr_nodes]}
                result = objects.InstanceList.get_by_filters(context,
                                                             filters)
                instances = result.objects
                LOG.debug("Adding %s instances for hosts %s-%s",
                          len(instances), start_node, end_node)
                for instance in instances:
                    host = instance.host
                    if host not in self._instance_info:
                        self._instance_info[host] = {"instances": {},
                                                     "updated": False}
                    inst_dict = self._instance_info[host]
                    inst_dict["instances"][instance.uuid] = instance
                # Call sleep() to cooperatively yield
                time.sleep(0)
            LOG.debug("END:_async_init_instance_info")

        # Run this async so that we don't block the scheduler start-up
        utils.spawn_n(_async_init_instance_info)
Exemple #6
0
 def build_instances(self,
                     context,
                     instances,
                     image,
                     filter_properties,
                     admin_password,
                     injected_files,
                     requested_networks,
                     security_groups,
                     block_device_mapping,
                     legacy_bdm=True):
     utils.spawn_n(self._manager.build_instances,
                   context,
                   instances=instances,
                   image=image,
                   filter_properties=filter_properties,
                   admin_password=admin_password,
                   injected_files=injected_files,
                   requested_networks=requested_networks,
                   security_groups=security_groups,
                   block_device_mapping=block_device_mapping,
                   legacy_bdm=legacy_bdm)
Exemple #7
0
 def unshelve_instance(self, context, instance):
     utils.spawn_n(self._manager.unshelve_instance, context,
             instance=instance)
Exemple #8
0
 def unshelve_instance(self, context, instance):
     utils.spawn_n(self._manager.unshelve_instance,
                   context,
                   instance=instance)