def test_block_device_mapping_update_or_create(self): fake_bdm = {"id": "fake-id"} self.mox.StubOutWithMock(db, "block_device_mapping_create") self.mox.StubOutWithMock(db, "block_device_mapping_update") self.mox.StubOutWithMock(db, "block_device_mapping_update_or_create") db.block_device_mapping_create(self.context, fake_bdm) db.block_device_mapping_update(self.context, fake_bdm["id"], fake_bdm) db.block_device_mapping_update_or_create(self.context, fake_bdm) self.mox.ReplayAll() self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm, create=True) self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm, create=False) self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm)
def test_block_device_mapping_update_or_create(self): self.mox.StubOutWithMock(db, "block_device_mapping_create") self.mox.StubOutWithMock(db, "block_device_mapping_update") self.mox.StubOutWithMock(db, "block_device_mapping_update_or_create") db.block_device_mapping_create(self.context, "fake-bdm") db.block_device_mapping_update(self.context, "fake-id", {"id": "fake-id"}) db.block_device_mapping_update_or_create(self.context, "fake-bdm") self.mox.ReplayAll() self.conductor.block_device_mapping_create(self.context, "fake-bdm") self.conductor.block_device_mapping_update(self.context, "fake-id", {}) self.conductor.block_device_mapping_update_or_create(self.context, "fake-bdm")
def test_block_device_mapping_update_or_create(self): self.mox.StubOutWithMock(db, 'block_device_mapping_create') self.mox.StubOutWithMock(db, 'block_device_mapping_update') self.mox.StubOutWithMock(db, 'block_device_mapping_update_or_create') db.block_device_mapping_create(self.context, 'fake-bdm') db.block_device_mapping_update(self.context, 'fake-id', {'id': 'fake-id'}) db.block_device_mapping_update_or_create(self.context, 'fake-bdm') self.mox.ReplayAll() self.conductor.block_device_mapping_create(self.context, 'fake-bdm') self.conductor.block_device_mapping_update(self.context, 'fake-id', {}) self.conductor.block_device_mapping_update_or_create(self.context, 'fake-bdm')
def test_block_device_mapping_update_or_create(self): self.mox.StubOutWithMock(db, 'block_device_mapping_create') self.mox.StubOutWithMock(db, 'block_device_mapping_update') self.mox.StubOutWithMock(db, 'block_device_mapping_update_or_create') db.block_device_mapping_create(self.context, 'fake-bdm') db.block_device_mapping_update(self.context, 'fake-id', {'id': 'fake-id'}) db.block_device_mapping_update_or_create(self.context, 'fake-bdm') self.mox.ReplayAll() self.conductor.block_device_mapping_create(self.context, 'fake-bdm') self.conductor.block_device_mapping_update(self.context, 'fake-id', {}) self.conductor.block_device_mapping_update_or_create( self.context, 'fake-bdm')
def save(self): updates = self.obj_get_changes() if 'instance' in updates: raise exception.ObjectActionError(action='save', reason='instance changed') updates.pop('id', None) updated = db.block_device_mapping_update(self._context, self.id, updates, legacy=False) if not updated: raise exception.BDMNotFound(id=self.id) self._from_db_object(self._context, self, updated) cell_type = cells_opts.get_cell_type() if cell_type == 'compute': create = False # NOTE(alaski): If the device name has just been set this bdm # likely does not exist in the parent cell and we should create it. # If this is a modification of the device name we should update # rather than create which is why None is used here instead of True if 'device_name' in updates: create = None cells_api = cells_rpcapi.CellsAPI() cells_api.bdm_update_or_create_at_top(self._context, self, create=create)
def test_block_device_mapping_update_or_create(self): fake_bdm = {'id': 'fake-id'} self.mox.StubOutWithMock(db, 'block_device_mapping_create') self.mox.StubOutWithMock(db, 'block_device_mapping_update') self.mox.StubOutWithMock(db, 'block_device_mapping_update_or_create') db.block_device_mapping_create(self.context, fake_bdm) db.block_device_mapping_update(self.context, fake_bdm['id'], fake_bdm) db.block_device_mapping_update_or_create(self.context, fake_bdm) self.mox.ReplayAll() self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm, create=True) self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm, create=False) self.conductor.block_device_mapping_update_or_create( self.context, fake_bdm)
def test_block_device_mapping_update_or_create(self): fake_bdm = {'id': 'fake-id'} self.mox.StubOutWithMock(db, 'block_device_mapping_create') self.mox.StubOutWithMock(db, 'block_device_mapping_update') self.mox.StubOutWithMock(db, 'block_device_mapping_update_or_create') db.block_device_mapping_create(self.context, fake_bdm) db.block_device_mapping_update(self.context, fake_bdm['id'], fake_bdm) db.block_device_mapping_update_or_create(self.context, fake_bdm) self.mox.ReplayAll() self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm, create=True) self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm, create=False) self.conductor.block_device_mapping_update_or_create(self.context, fake_bdm)
def save(self, context): updates = self.obj_get_changes() if 'instance' in updates: raise exception.ObjectActionError(action='save', reason='instance changed') updates.pop('id', None) updated = db.block_device_mapping_update(self._context, self.id, updates, legacy=False) cells_api = cells_rpcapi.CellsAPI() cells_api.bdm_update_or_create_at_top(context, updated) self._from_db_object(context, self, updated)
def save(self, context): updates = self.obj_get_changes() if "instance" in updates: raise exception.ObjectActionError(action="save", reason="instance changed") updates.pop("id", None) updated = db.block_device_mapping_update(self._context, self.id, updates, legacy=False) self._from_db_object(context, self, updated) cell_type = cells_opts.get_cell_type() if cell_type == "compute": cells_api = cells_rpcapi.CellsAPI() cells_api.bdm_update_or_create_at_top(context, self)
def save(self): updates = self.obj_get_changes() if 'instance' in updates: raise exception.ObjectActionError(action='save', reason='instance changed') updates.pop('id', None) updated = db.block_device_mapping_update(self._context, self.id, updates, legacy=False) if not updated: raise exception.BDMNotFound(id=self.id) self._from_db_object(self._context, self, updated) cell_type = cells_opts.get_cell_type() if cell_type == 'compute': cells_api = cells_rpcapi.CellsAPI() cells_api.bdm_update_or_create_at_top(self._context, self)
def save(self): updates = self.obj_get_changes() if "instance" in updates: raise exception.ObjectActionError(action="save", reason="instance changed") updates.pop("id", None) updated = db.block_device_mapping_update(self._context, self.id, updates, legacy=False) if not updated: raise exception.BDMNotFound(id=self.id) self._from_db_object(self._context, self, updated) cell_type = cells_opts.get_cell_type() if cell_type == "compute": create = False # NOTE(alaski): If the device name has just been set this bdm # likely does not exist in the parent cell and we should create it. # If this is a modification of the device name we should update # rather than create which is why None is used here instead of True if "device_name" in updates: create = None cells_api = cells_rpcapi.CellsAPI() cells_api.bdm_update_or_create_at_top(self._context, self, create=create)
def block_device_mapping_update(self, context, bdm_id, values): return db.block_device_mapping_update(context, bdm_id, values)