def create(self, context):
     topology = self.topology_from_obj()
     if not topology:
         return
     values = {'numa_topology': topology.to_json()}
     db.instance_extra_update_by_uuid(context, self.instance_uuid, values)
     self.obj_reset_changes()
    def _save(self):
        primitive = self.obj_to_primitive()
        payload = jsonutils.dumps(primitive)

        values = {"migration_context": payload}
        db.instance_extra_update_by_uuid(self._context, self.instance_uuid, values)
        self.obj_reset_changes()
    def _save(self):
        primitive = self.obj_to_primitive()
        payload = jsonutils.dumps(primitive)

        values = {'migration_context': payload}
        db.instance_extra_update_by_uuid(self._context, self.instance_uuid,
                                         values)
        self.obj_reset_changes()
 def create(self, context):
     topology = self.topology_from_obj()
     if not topology:
         return
     values = {'numa_topology': topology.to_json()}
     db.instance_extra_update_by_uuid(context, self.instance_uuid,
                                      values)
     self.obj_reset_changes()
 def save(self, context):
     blob = [{'count': x.count,
              'spec': x.spec,
              'alias_name': x.alias_name,
              'is_new': x.is_new,
              'request_id': x.request_id} for x in self.requests]
     requests = jsonutils.dumps(blob)
     db.instance_extra_update_by_uuid(context, self.instance_uuid,
                                      {'pci_requests': requests})
 def save(self, context):
     blob = [{'count': x.count,
              'spec': x.spec,
              'alias_name': x.alias_name,
              'is_new': x.is_new,
              'request_id': x.request_id} for x in self.requests]
     requests = jsonutils.dumps(blob)
     db.instance_extra_update_by_uuid(context, self.instance_uuid,
                                      {'pci_requests': requests})
Beispiel #7
0
 def _save_vcpu_model(self, context):
     # TODO(yjiang5): should merge the db accesses for all the extra
     # fields
     if "vcpu_model" in self.obj_what_changed():
         if self.vcpu_model:
             update = jsonutils.dumps(self.vcpu_model.obj_to_primitive())
         else:
             update = None
         db.instance_extra_update_by_uuid(context, self.uuid, {"vcpu_model": update})
Beispiel #8
0
 def _save_flavor(self, context):
     # FIXME(danms): We can do this smarterly by updating this
     # with all the other extra things at the same time
     flavor_info = {
         "cur": self.flavor.obj_to_primitive(),
         "old": (self.old_flavor and self.old_flavor.obj_to_primitive() or None),
         "new": (self.new_flavor and self.new_flavor.obj_to_primitive() or None),
     }
     db.instance_extra_update_by_uuid(context, self.uuid, {"flavor": jsonutils.dumps(flavor_info)})
     self.obj_reset_changes(["flavor", "old_flavor", "new_flavor"])
Beispiel #9
0
 def _save_vcpu_model(self, context):
     # TODO(yjiang5): should merge the db accesses for all the extra
     # fields
     if 'vcpu_model' in self.obj_what_changed():
         if self.vcpu_model:
             update = jsonutils.dumps(self.vcpu_model.obj_to_primitive())
         else:
             update = None
         db.instance_extra_update_by_uuid(context, self.uuid,
                                          {'vcpu_model': update})
Beispiel #10
0
 def _save_flavor(self, context):
     if not any([x in self.obj_what_changed() for x in
                 ('flavor', 'old_flavor', 'new_flavor')]):
         return
     # FIXME(danms): We can do this smarterly by updating this
     # with all the other extra things at the same time
     flavor_info = {
         'cur': self.flavor.obj_to_primitive(),
         'old': (self.old_flavor and
                 self.old_flavor.obj_to_primitive() or None),
         'new': (self.new_flavor and
                 self.new_flavor.obj_to_primitive() or None),
     }
     db.instance_extra_update_by_uuid(
         context, self.uuid,
         {'flavor': jsonutils.dumps(flavor_info)})
     self.obj_reset_changes(['flavor', 'old_flavor', 'new_flavor'])
Beispiel #11
0
 def _save_flavor(self, context):
     if not any([x in self.obj_what_changed() for x in
                 ('flavor', 'old_flavor', 'new_flavor')]):
         return
     # FIXME(danms): We can do this smarterly by updating this
     # with all the other extra things at the same time
     flavor_info = {
         'cur': self.flavor.obj_to_primitive(),
         'old': (self.old_flavor and
                 self.old_flavor.obj_to_primitive() or None),
         'new': (self.new_flavor and
                 self.new_flavor.obj_to_primitive() or None),
     }
     db.instance_extra_update_by_uuid(
         context, self.uuid,
         {'flavor': jsonutils.dumps(flavor_info)})
     self.obj_reset_changes(['flavor', 'old_flavor', 'new_flavor'])
Beispiel #12
0
 def test_archive_deleted_rows_with_undeleted_residue(self):
     # Boots a server, deletes it, and then tries to archive it.
     server = self._create_server()
     server_id = server['id']
     # Assert that there are instance_actions. instance_actions are
     # interesting since we don't soft delete them but they have a foreign
     # key back to the instances table.
     actions = self.api.get_instance_actions(server_id)
     self.assertTrue(len(actions),
                     'No instance actions for server: %s' % server_id)
     self._delete_server(server_id)
     # Verify we have the soft deleted instance in the database.
     admin_context = context.get_admin_context(read_deleted='yes')
     # This will raise InstanceNotFound if it's not found.
     instance = db.instance_get_by_uuid(admin_context, server_id)
     # Make sure it's soft deleted.
     self.assertNotEqual(0, instance.deleted)
     # Undelete the instance_extra record to make sure we delete it anyway
     extra = db.instance_extra_get_by_instance_uuid(admin_context,
                                                    instance.uuid)
     self.assertNotEqual(0, extra.deleted)
     db.instance_extra_update_by_uuid(admin_context, instance.uuid,
                                      {'deleted': 0})
     extra = db.instance_extra_get_by_instance_uuid(admin_context,
                                                    instance.uuid)
     self.assertEqual(0, extra.deleted)
     # Verify we have some system_metadata since we'll check that later.
     self.assertTrue(len(instance.system_metadata),
                     'No system_metadata for instance: %s' % server_id)
     # Now try and archive the soft deleted records.
     results, deleted_instance_uuids = db.archive_deleted_rows(max_rows=100)
     # verify system_metadata was dropped
     self.assertIn('instance_system_metadata', results)
     self.assertEqual(len(instance.system_metadata),
                      results['instance_system_metadata'])
     # Verify that instances rows are dropped
     self.assertIn('instances', results)
     # Verify that instance_actions and actions_event are dropped
     # by the archive
     self.assertIn('instance_actions', results)
     self.assertIn('instance_actions_events', results)
Beispiel #13
0
 def save(self, context):
     blob = self.to_json()
     db.instance_extra_update_by_uuid(context, self.instance_uuid,
                                      {'pci_requests': blob})
Beispiel #14
0
 def _destroy(cls, context, instance_uuid):
     values = {'migration_context': None}
     db.instance_extra_update_by_uuid(context, instance_uuid, values)
 def delete_by_instance_uuid(cls, context, instance_uuid):
     values = {'numa_topology': None}
     db.instance_extra_update_by_uuid(context, instance_uuid, values)
 def save(self):
     blob = self.to_json()
     db.instance_extra_update_by_uuid(self._context, self.instance_uuid,
                                      {'pci_requests': blob})
Beispiel #17
0
 def delete_by_instance_uuid(cls, context, instance_uuid):
     values = {'numa_topology': None}
     db.instance_extra_update_by_uuid(context, instance_uuid,
                                      values)
 def _destroy(cls, context, instance_uuid):
     values = {'migration_context': None}
     db.instance_extra_update_by_uuid(context, instance_uuid, values)
 def create(self):
     values = {'numa_topology': self._to_json()}
     db.instance_extra_update_by_uuid(self._context, self.instance_uuid,
                                      values)
     self.obj_reset_changes()
Beispiel #20
0
 def _save(self):
     values = {'numa_topology': self._to_json()}
     db.instance_extra_update_by_uuid(self._context, self.instance_uuid,
                                      values)
     self.obj_reset_changes()