Skip to content

Commit 115ffa6

Browse files
aidaphalvarolopez
authored andcommitted
fix: fix some validation errors to be aligned to latest pydantic v2
1 parent 534d724 commit 115ffa6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

caso/extract/openstack/cinder.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import operator
2020

21+
import datetime
2122
import dateutil.parser
2223
from oslo_config import cfg
2324
from oslo_log import log
@@ -52,7 +53,8 @@ def _build_record(self, volume, extract_from, extract_to):
5253
if vol_created < extract_from:
5354
vol_created = extract_from
5455

55-
active_duration = (extract_to - vol_created).total_seconds()
56+
active_duration_delta = (extract_to - vol_created)
57+
active_duration = (extract_to - vol_created - datetime.timedelta(microseconds=active_duration_delta.microseconds)).total_seconds()
5658

5759
r = record.StorageRecord(
5860
uuid=volume.id,

caso/extract/openstack/nova.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ def _build_record(self, server):
209209
disk = flavor["disk"] + flavor["OS-FLV-EXT-DATA:ephemeral"]
210210
else:
211211
bench_name = bench_value = None
212-
memory = cpu_count = disk = None
212+
memory = cpu_count = disk = 0
213213

214214
if not all([bench_name, bench_value]):
215215
if any([bench_name, bench_value]):

caso/record.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,10 @@ def end_time(self, end_time: datetime.datetime) -> None:
184184
@property
185185
def end_time_epoch(self) -> typing.Optional[int]:
186186
"""Get end time as epoch."""
187-
return int(self.end_time.timestamp())
187+
if self.end_time:
188+
return int(self.end_time.timestamp())
189+
else:
190+
return 0
188191

189192
@pydantic.computed_field() # type: ignore[misc]
190193
@property

0 commit comments

Comments
 (0)