Пример #1
0
    def vol_usage_update(self, context, vol_id, rd_req, rd_bytes, wr_req,
                         wr_bytes, instance, last_refreshed, update_totals):
        vol_usage = self.db.vol_usage_update(
            context, vol_id, rd_req, rd_bytes, wr_req, wr_bytes,
            instance['uuid'], instance['project_id'], instance['user_id'],
            instance['availability_zone'], update_totals)

        # We have just updated the database, so send the notification now
        vol_usage = objects.VolumeUsage._from_db_object(
            context, objects.VolumeUsage(), vol_usage)
        self.notifier.info(context, 'volume.usage',
                           compute_utils.usage_volume_info(vol_usage))
Пример #2
0
 def test_save_update_totals(self, mock_upd):
     vol_usage = objects.VolumeUsage(self.context)
     vol_usage.volume_id = uuids.volume_id
     vol_usage.instance_uuid = uuids.instance
     vol_usage.project_id = 'fake-project-id'
     vol_usage.user_id = 'fake-user-id'
     vol_usage.availability_zone = None
     vol_usage.curr_reads = 10
     vol_usage.curr_read_bytes = 20
     vol_usage.curr_writes = 30
     vol_usage.curr_write_bytes = 40
     vol_usage.save(update_totals=True)
     mock_upd.assert_called_once_with(
         self.context, uuids.volume_id, 10, 20, 30, 40, uuids.instance,
         'fake-project-id', 'fake-user-id', None, update_totals=True)
     self.compare_obj(vol_usage, fake_vol_usage)