forked from CCI-MOC/openstack-billing-from-db
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for not billing during outages
Currently hardcoded values for the MGHPCC shutdown during May 2024. Implemented via subtraction of the runtime of instances during the outage.
- Loading branch information
Showing
5 changed files
with
49 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/openstack_billing_db/tests/unit/test_instance_runtime.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
from openstack_billing_db.model import InstanceRuntime | ||
|
||
|
||
def test_instance_runtime_subtract(): | ||
a = InstanceRuntime( | ||
total_seconds_running=1000, | ||
total_seconds_stopped=1000 | ||
) | ||
b = InstanceRuntime( | ||
total_seconds_running=100, | ||
total_seconds_stopped=200 | ||
) | ||
c = a - b | ||
assert c.total_seconds_running == 900 | ||
assert c.total_seconds_running == a.total_seconds_running - b.total_seconds_running | ||
assert c.total_seconds_stopped == 800 | ||
assert c.total_seconds_stopped == a.total_seconds_stopped - b.total_seconds_stopped |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from datetime import datetime | ||
|
||
|
||
def parse_time_from_string(time_str: str) -> datetime: | ||
return datetime.strptime(time_str, "%Y-%m-%d") |