Example #1
0
 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)
Example #2
0
    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")
Example #3
0
    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')
Example #4
0
    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')
Example #5
0
 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)
Example #6
0
 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)
Example #7
0
 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)
Example #8
0
 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)
Example #9
0
 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)
Example #10
0
 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)
Example #11
0
 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)
Example #12
0
 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)
Example #13
0
 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)
Example #14
0
 def block_device_mapping_update(self, context, bdm_id, values):
     return db.block_device_mapping_update(context, bdm_id, values)
Example #15
0
File: fake.py Project: pengkui/nova
 def block_device_mapping_update(self, context, bdm_id, values):
     return db.block_device_mapping_update(context, bdm_id, values)