summaryrefslogtreecommitdiff
path: root/nova/db
diff options
context:
space:
mode:
authorStephen Finucane <stephenfin@redhat.com>2021-09-29 10:27:31 +0100
committerStephen Finucane <stephenfin@redhat.com>2021-11-03 17:33:43 +0000
commit2b02b66bae7fba5103839e48bc4c48bb30cffead (patch)
tree62248c223c567c7edf080bb3c8fffbd0bb7ccf3b /nova/db
parent55fe6a7644c2a3a16714b7f42adcaf806a8f6c63 (diff)
downloadnova-2b02b66bae7fba5103839e48bc4c48bb30cffead.tar.gz
objects: Remove 'bandwidth' fields from notifications
Finish up removing these entries from the versioned instance notifications. They're useless since we dropped support for the XenAPI virt driver. The underlying model is retained for now: that will be handled separately. Change-Id: I774c50fca99bc655ca5010e3b9d8247b739293b3 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Diffstat (limited to 'nova/db')
-rw-r--r--nova/db/main/api.py83
1 files changed, 0 insertions, 83 deletions
diff --git a/nova/db/main/api.py b/nova/db/main/api.py
index cc059bfc48..e135c02ef2 100644
--- a/nova/db/main/api.py
+++ b/nova/db/main/api.py
@@ -3548,89 +3548,6 @@ def instance_system_metadata_update(context, instance_uuid, metadata, delete):
####################
-@require_context
-@pick_context_manager_reader_allow_async
-def bw_usage_get(context, uuid, start_period, mac):
- """Return bw usage for instance and mac in a given audit period."""
- values = {'start_period': start_period}
- values = convert_objects_related_datetimes(values, 'start_period')
- return model_query(context, models.BandwidthUsage, read_deleted="yes").\
- filter_by(start_period=values['start_period']).\
- filter_by(uuid=uuid).\
- filter_by(mac=mac).\
- first()
-
-
-@require_context
-@pick_context_manager_reader_allow_async
-def bw_usage_get_by_uuids(context, uuids, start_period):
- """Return bw usages for instance(s) in a given audit period."""
- values = {'start_period': start_period}
- values = convert_objects_related_datetimes(values, 'start_period')
- return (
- model_query(context, models.BandwidthUsage, read_deleted="yes").
- filter(models.BandwidthUsage.uuid.in_(uuids)).
- filter_by(start_period=values['start_period']).
- all()
- )
-
-
-@require_context
-@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
-@pick_context_manager_writer
-def bw_usage_update(
- context, uuid, mac, start_period, bw_in, bw_out, last_ctr_in, last_ctr_out,
- last_refreshed=None,
-):
- """Update cached bandwidth usage for an instance's network based on mac
- address. Creates new record if needed.
- """
-
- if last_refreshed is None:
- last_refreshed = timeutils.utcnow()
-
- # NOTE(comstud): More often than not, we'll be updating records vs
- # creating records. Optimize accordingly, trying to update existing
- # records. Fall back to creation when no rows are updated.
- ts_values = {'last_refreshed': last_refreshed,
- 'start_period': start_period}
- ts_keys = ('start_period', 'last_refreshed')
- ts_values = convert_objects_related_datetimes(ts_values, *ts_keys)
- values = {'last_refreshed': ts_values['last_refreshed'],
- 'last_ctr_in': last_ctr_in,
- 'last_ctr_out': last_ctr_out,
- 'bw_in': bw_in,
- 'bw_out': bw_out}
- # NOTE(pkholkin): order_by() is needed here to ensure that the
- # same record is updated every time. It can be removed after adding
- # unique constraint to this model.
- bw_usage = model_query(context, models.BandwidthUsage,
- read_deleted='yes').\
- filter_by(start_period=ts_values['start_period']).\
- filter_by(uuid=uuid).\
- filter_by(mac=mac).\
- order_by(expression.asc(models.BandwidthUsage.id)).first()
-
- if bw_usage:
- bw_usage.update(values)
- return bw_usage
-
- bwusage = models.BandwidthUsage()
- bwusage.start_period = ts_values['start_period']
- bwusage.uuid = uuid
- bwusage.mac = mac
- bwusage.last_refreshed = ts_values['last_refreshed']
- bwusage.bw_in = bw_in
- bwusage.bw_out = bw_out
- bwusage.last_ctr_in = last_ctr_in
- bwusage.last_ctr_out = last_ctr_out
- bwusage.save(context.session)
-
- return bwusage
-
-
-####################
-
@require_context
@pick_context_manager_reader