Exemplo n.º 1
0
    def save(self):
        if self.status == fields.PciDeviceStatus.REMOVED:
            self.status = fields.PciDeviceStatus.DELETED
            db.pci_device_destroy(self._context, self.compute_node_id,
                                  self.address)
        elif self.status != fields.PciDeviceStatus.DELETED:
            updates = self.obj_get_changes()
            if not self.should_migrate_data():
                # NOTE(ndipanov): If we are not migrating data yet, make sure
                # that any changes to parent_addr are also in the old location
                # in extra_info
                if 'parent_addr' in updates and updates['parent_addr']:
                    extra_update = updates.get('extra_info', {})
                    if not extra_update and self.obj_attr_is_set('extra_info'):
                        extra_update = self.extra_info
                    extra_update['phys_function'] = updates['parent_addr']
                    updates['extra_info'] = extra_update
            else:
                # NOTE(ndipanov): Once we start migrating, meaning all control
                # plane has been upgraded - aggressively migrate on every save
                pf_extra = self.extra_info.pop('phys_function', None)
                if pf_extra and 'parent_addr' not in updates:
                    updates['parent_addr'] = pf_extra
                updates['extra_info'] = self.extra_info

            if 'extra_info' in updates:
                updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
            if updates:
                db_pci = db.pci_device_update(self._context,
                                              self.compute_node_id,
                                              self.address, updates)
                self._from_db_object(self._context, self, db_pci)
Exemplo n.º 2
0
    def save(self):
        if self.status == fields.PciDeviceStatus.REMOVED:
            self.status = fields.PciDeviceStatus.DELETED
            db.pci_device_destroy(self._context, self.compute_node_id,
                                  self.address)
        elif self.status != fields.PciDeviceStatus.DELETED:
            updates = self.obj_get_changes()
            if not self.should_migrate_data():
                # NOTE(ndipanov): If we are not migrating data yet, make sure
                # that any changes to parent_addr are also in the old location
                # in extra_info
                if 'parent_addr' in updates and updates['parent_addr']:
                    extra_update = updates.get('extra_info', {})
                    if not extra_update and self.obj_attr_is_set('extra_info'):
                        extra_update = self.extra_info
                    extra_update['phys_function'] = updates['parent_addr']
                    updates['extra_info'] = extra_update
            else:
                # NOTE(ndipanov): Once we start migrating, meaning all control
                # plane has been upgraded - aggressively migrate on every save
                pf_extra = self.extra_info.pop('phys_function', None)
                if pf_extra and 'parent_addr' not in updates:
                    updates['parent_addr'] = pf_extra
                updates['extra_info'] = self.extra_info

            if 'extra_info' in updates:
                updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
            if updates:
                db_pci = db.pci_device_update(self._context,
                                              self.compute_node_id,
                                              self.address, updates)
                self._from_db_object(self._context, self, db_pci)
Exemplo n.º 3
0
 def test_save_removed(self):
     ctxt = context.get_admin_context()
     self._create_fake_pci_device(ctxt=ctxt)
     self.pci_device.status = 'removed'
     self.mox.StubOutWithMock(db, 'pci_device_destroy')
     db.pci_device_destroy(ctxt, 1, 'a')
     self.mox.ReplayAll()
     self.pci_device.save()
     self.assertEqual(self.pci_device.status, 'deleted')
Exemplo n.º 4
0
 def test_save_removed(self):
     ctxt = context.get_admin_context()
     self._create_fake_pci_device(ctxt=ctxt)
     self.pci_device.status = 'removed'
     self.mox.StubOutWithMock(db, 'pci_device_destroy')
     db.pci_device_destroy(ctxt, 1, 'a')
     self.mox.ReplayAll()
     self.pci_device.save()
     self.assertEqual(self.pci_device.status, 'deleted')
Exemplo n.º 5
0
 def test_save_removed(self):
     ctxt = context.get_admin_context()
     self._create_fake_pci_device(ctxt=ctxt)
     self.pci_device.status = fields.PciDeviceStatus.REMOVED
     self.mox.StubOutWithMock(db, "pci_device_destroy")
     db.pci_device_destroy(ctxt, 1, "a")
     self.mox.ReplayAll()
     self.pci_device.save()
     self.assertEqual(self.pci_device.status, fields.PciDeviceStatus.DELETED)
Exemplo n.º 6
0
 def test_save_removed(self):
     ctxt = context.get_admin_context()
     self._create_fake_pci_device(ctxt=ctxt)
     self.pci_device.status = fields.PciDeviceStatus.REMOVED
     self.mox.StubOutWithMock(db, 'pci_device_destroy')
     db.pci_device_destroy(ctxt, 1, 'a')
     self.mox.ReplayAll()
     self.pci_device.save()
     self.assertEqual(self.pci_device.status,
                      fields.PciDeviceStatus.DELETED)
Exemplo n.º 7
0
 def test_save_removed(self):
     ctxt = context.get_admin_context()
     self._create_fake_pci_device(ctxt=ctxt)
     self.pci_device.status = "removed"
     self.mox.StubOutWithMock(db, "pci_device_destroy")
     db.pci_device_destroy(ctxt, 1, "a")
     self.mox.ReplayAll()
     self.pci_device.save()
     self.assertEqual(self.pci_device.status, "deleted")
     self.assertRemotes()
Exemplo n.º 8
0
 def save(self, context):
     if self.status == "removed":
         self.status = "deleted"
         db.pci_device_destroy(context, self.compute_node_id, self.address)
     elif self.status != "deleted":
         updates = self.obj_get_changes()
         if "extra_info" in updates:
             updates["extra_info"] = jsonutils.dumps(updates["extra_info"])
         if updates:
             db_pci = db.pci_device_update(context, self.compute_node_id, self.address, updates)
             self._from_db_object(context, self, db_pci)
Exemplo n.º 9
0
 def save(self, context):
     if self.status == 'removed':
         self.status = 'deleted'
         db.pci_device_destroy(context, self.compute_node_id, self.address)
     elif self.status != 'deleted':
         updates = self.obj_get_changes()
         if 'extra_info' in updates:
             updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
         if updates:
             db_pci = db.pci_device_update(context, self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(context, self, db_pci)
Exemplo n.º 10
0
 def save(self):
     if self.status == fields.PciDeviceStatus.REMOVED:
         self.status = fields.PciDeviceStatus.DELETED
         db.pci_device_destroy(self._context, self.compute_node_id,
                               self.address)
     elif self.status != fields.PciDeviceStatus.DELETED:
         updates = self.obj_get_changes()
         if 'extra_info' in updates:
             updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
         if updates:
             db_pci = db.pci_device_update(self._context,
                                           self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(self._context, self, db_pci)
Exemplo n.º 11
0
 def save(self):
     if self.status == 'removed':
         self.status = 'deleted'
         db.pci_device_destroy(self._context, self.compute_node_id,
                               self.address)
     elif self.status != 'deleted':
         updates = self.obj_get_changes()
         if 'extra_info' in updates:
             updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
         if updates:
             db_pci = db.pci_device_update(self._context,
                                           self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(self._context, self, db_pci)
Exemplo n.º 12
0
 def save(self):
     if self.status == fields.PciDeviceStatus.REMOVED:
         self.status = fields.PciDeviceStatus.DELETED
         db.pci_device_destroy(self._context, self.compute_node_id,
                               self.address)
     elif self.status != fields.PciDeviceStatus.DELETED:
         updates = self.obj_get_changes()
         if 'extra_info' in updates:
             updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
         if updates:
             db_pci = db.pci_device_update(self._context,
                                           self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(self._context, self, db_pci)
Exemplo n.º 13
0
 def save(self, context):
     if self.status == "removed":
         self.status = "deleted"
         db.pci_device_destroy(context, self.compute_node_id, self.address)
     elif self.status != "deleted":
         updates = {}
         for field in self.obj_what_changed():
             if field == "extra_info":
                 updates["extra_info"] = jsonutils.dumps(self.extra_info)
             else:
                 updates[field] = self[field]
         if updates:
             db_pci = db.pci_device_update(context, self.compute_node_id, self.address, updates)
             self._from_db_object(context, self, db_pci)
Exemplo n.º 14
0
 def save(self, context):
     if self.status == 'removed':
         self.status = 'deleted'
         db.pci_device_destroy(context, self.compute_node_id, self.address)
     elif self.status != 'deleted':
         updates = {}
         for field in self.obj_what_changed():
             if field == 'extra_info':
                 updates['extra_info'] = jsonutils.dumps(self.extra_info)
             else:
                 updates[field] = self[field]
         if updates:
             db_pci = db.pci_device_update(context, self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(context, self, db_pci)
Exemplo n.º 15
0
 def save(self):
     if self.status == 'removed':
         self.status = 'deleted'
         db.pci_device_destroy(self._context, self.compute_node_id,
                               self.address)
     elif self.status != 'deleted':
         updates = self.obj_get_changes()
         if 'extra_info' in updates:
             numa_node_extra = updates['extra_info'].pop('numa_node', None)
             # NOTE (ndipanov): Never overwrite an acual value with legacy
             #                  RHOS 6 data from 'extra_info'
             if (updates.get('numa_node') is None and self.numa_node is None
                     and numa_node_extra is not None):
                 updates['numa_node'] = int(numa_node_extra)
             updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
         if updates:
             db_pci = db.pci_device_update(self._context,
                                           self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(self._context, self, db_pci)
Exemplo n.º 16
0
    def save(self):
        if self.status == fields.PciDeviceStatus.REMOVED:
            self.status = fields.PciDeviceStatus.DELETED
            db.pci_device_destroy(self._context, self.compute_node_id,
                                  self.address)
        elif self.status != fields.PciDeviceStatus.DELETED:
            # TODO(jaypipes): Remove in 2.0 version of object. This does an
            # inline migration to populate the uuid field. A similar migration
            # is done in the _from_db_object() method to migrate objects as
            # they are read from the DB.
            if 'uuid' not in self:
                self.uuid = uuidutils.generate_uuid()
            updates = self.obj_get_changes()

            if 'extra_info' in updates:
                updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
            if updates:
                db_pci = db.pci_device_update(self._context,
                                              self.compute_node_id,
                                              self.address, updates)
                self._from_db_object(self._context, self, db_pci)
Exemplo n.º 17
0
 def save(self):
     if self.status == 'removed':
         self.status = 'deleted'
         db.pci_device_destroy(self._context, self.compute_node_id,
                               self.address)
     elif self.status != 'deleted':
         updates = self.obj_get_changes()
         if 'extra_info' in updates:
             numa_node_extra = updates['extra_info'].pop('numa_node', None)
             # NOTE (ndipanov): Never overwrite an acual value with legacy
             #                  RHOS 6 data from 'extra_info'
             if (updates.get('numa_node') is None and
                     self.numa_node is None and
                     numa_node_extra is not None):
                 updates['numa_node'] = int(numa_node_extra)
             updates['extra_info'] = jsonutils.dumps(updates['extra_info'])
         if updates:
             db_pci = db.pci_device_update(self._context,
                                           self.compute_node_id,
                                           self.address, updates)
             self._from_db_object(self._context, self, db_pci)