Example #1
0
 def test_migration_get_in_progress_by_host_and_node(self):
     self.mox.StubOutWithMock(db,
                              'migration_get_in_progress_by_host_and_node')
     db.migration_get_in_progress_by_host_and_node(
         self.context, 'fake-host', 'fake-node').AndReturn('fake-result')
     self.mox.ReplayAll()
     result = self.conductor.migration_get_in_progress_by_host_and_node(
         self.context, 'fake-host', 'fake-node')
     self.assertEqual(result, 'fake-result')
Example #2
0
 def test_migration_get_in_progress_by_host_and_node(self):
     self.mox.StubOutWithMock(db,
                              'migration_get_in_progress_by_host_and_node')
     db.migration_get_in_progress_by_host_and_node(
         self.context, 'fake-host', 'fake-node').AndReturn('fake-result')
     self.mox.ReplayAll()
     result = self.conductor.migration_get_in_progress_by_host_and_node(
         self.context, 'fake-host', 'fake-node')
     self.assertEqual(result, 'fake-result')
Example #3
0
 def test_get_in_progress_by_host_and_node(self):
     ctxt = context.get_admin_context()
     db_migrations = [fake_migration, dict(fake_migration, id=456)]
     self.mox.StubOutWithMock(db,
                              'migration_get_in_progress_by_host_and_node')
     db.migration_get_in_progress_by_host_and_node(
         ctxt, 'host', 'node').AndReturn(db_migrations)
     self.mox.ReplayAll()
     migrations = (migration.MigrationList.get_in_progress_by_host_and_node(
         ctxt, 'host', 'node'))
     self.assertEqual(2, len(migrations))
     for index, db_migration in enumerate(db_migrations):
         self._compare(migrations[index], db_migration)
Example #4
0
 def test_get_in_progress_by_host_and_node(self):
     ctxt = context.get_admin_context()
     db_migrations = [fake_migration, dict(fake_migration, id=456)]
     self.mox.StubOutWithMock(
         db, 'migration_get_in_progress_by_host_and_node')
     db.migration_get_in_progress_by_host_and_node(
         ctxt, 'host', 'node').AndReturn(db_migrations)
     self.mox.ReplayAll()
     migrations = (
         migration.MigrationList.get_in_progress_by_host_and_node(
             ctxt, 'host', 'node'))
     self.assertEqual(2, len(migrations))
     for index, db_migration in enumerate(db_migrations):
         self._compare(migrations[index], db_migration)
Example #5
0
    def update_available_resource(self, context):
        """Override in-memory calculations of compute node resource usage based
        on data audited from the hypervisor layer.

        Add in resource claims in progress to account for operations that have
        declared a need for resources, but not necessarily retrieved them from
        the hypervisor layer yet.
        """
        LOG.audit(_("Auditing locally available compute resources"))
        resources = self.driver.get_available_resource(self.nodename)
        if not resources:
            # The virt driver does not support this function
            LOG.audit(_("Virt driver does not support " "'get_available_resource'  Compute tracking is disabled."))
            self.compute_node = None
            return

        self._verify_resources(resources)

        self._report_hypervisor_resource_view(resources)

        # Grab all instances assigned to this node:
        instances = db.instance_get_all_by_host_and_node(context, self.host, self.nodename)

        # Now calculate usage based on instance utilization:
        self._update_usage_from_instances(resources, instances)

        # Grab all in-progress migrations:
        migrations = db.migration_get_in_progress_by_host_and_node(context, self.host, self.nodename)

        self._update_usage_from_migrations(resources, migrations)

        self._report_final_resource_view(resources)

        self._sync_compute_node(context, resources)
Example #6
0
    def update_available_resource(self, context):
        """Override in-memory calculations of compute node resource usage based
        on data audited from the hypervisor layer.

        Add in resource claims in progress to account for operations that have
        declared a need for resources, but not necessarily retrieved them from
        the hypervisor layer yet.
        """
        LOG.audit(_("Auditing locally available compute resources"))
        resources = self.driver.get_available_resource(self.nodename)
        if not resources:
            # The virt driver does not support this function
            LOG.audit(
                _("Virt driver does not support "
                  "'get_available_resource'  Compute tracking is disabled."))
            self.compute_node = None
            return

        self._verify_resources(resources)

        self._report_hypervisor_resource_view(resources)

        # Grab all instances assigned to this node:
        instances = db.instance_get_all_by_host_and_node(
            context, self.host, self.nodename)

        # Now calculate usage based on instance utilization:
        self._update_usage_from_instances(resources, instances)

        # Grab all in-progress migrations:
        migrations = db.migration_get_in_progress_by_host_and_node(
            context, self.host, self.nodename)

        self._update_usage_from_migrations(resources, migrations)

        # Detect and account for orphaned instances that may exist on the
        # hypervisor, but are not in the DB:
        orphans = self._find_orphaned_instances()
        self._update_usage_from_orphans(resources, orphans)

        self._report_final_resource_view(resources)

        self._sync_compute_node(context, resources)
Example #7
0
 def get_in_progress_by_host_and_node(cls, context, host, node):
     db_migrations = db.migration_get_in_progress_by_host_and_node(
         context, host, node)
     return _make_list(context, MigrationList(), Migration, db_migrations)
Example #8
0
 def get_in_progress_by_host_and_node(cls, context, host, node):
     db_migrations = db.migration_get_in_progress_by_host_and_node(
         context, host, node)
     return base.obj_make_list(context, cls(context), objects.Migration,
                               db_migrations)
Example #9
0
 def get_in_progress_by_host_and_node(cls, context, host, node):
     db_migrations = db.migration_get_in_progress_by_host_and_node(
         context, host, node)
     return _make_list(context, MigrationList(), Migration, db_migrations)
Example #10
0
 def get_in_progress_by_host_and_node(cls, context, host, node):
     db_migrations = db.migration_get_in_progress_by_host_and_node(
         context, host, node)
     return base.obj_make_list(context, cls(context), objects.Migration,
                               db_migrations)