Skip to content

Commit 66ef84e

Browse files
authored
Merge pull request #124 from 2ndWatch/fix/license_window
Version bump to 0.3.4
2 parents 5ce585d + 8005cb9 commit 66ef84e

File tree

4 files changed

+26
-22
lines changed

4 files changed

+26
-22
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ SHA1 := $$(git log -1 --pretty=%h)
88
CURRENT_BRANCH := $$(git symbolic-ref -q --short HEAD)
99
LATEST_TAG := ${REPO_NAME}:latest
1010
GIT_TAG := ${REPO_NAME}:${SHA1}
11-
VERSION := v0.3.3
11+
VERSION := v0.3.4
1212

1313
info: ## Show information about the current git state.
1414
@echo "Github Project: https://github.com/${REPO_NAME}\nCurrent Branch: ${CURRENT_BRANCH}\nSHA1: ${SHA1}\n"

cloudendure/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.3.3"
1+
__version__ = "0.3.4"

cloudendure/cloudendure.py

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -419,8 +419,8 @@ def check_licenses(self) -> Dict[str, Any]:
419419
print(f"Checking CloudEndure Licenses - Name: ({self.project_name})")
420420

421421
now: datetime = datetime.datetime.now(datetime.timezone.utc)
422-
expirationday: timedelta = datetime.timedelta(days=90)
423-
expirationwarn: timedelta = datetime.timedelta(days=60)
422+
expirationday: timedelta = datetime.timedelta(days=135)
423+
expirationwarn: timedelta = datetime.timedelta(days=90)
424424
machine_data_dict: Dict[str, Any] = {}
425425
machines_response: Response = self.api.api_call(f"projects/{self.project_id}/machines")
426426
for machine in json.loads(machines_response.text).get("items", []):
@@ -478,9 +478,7 @@ def get_machine_sync_details(self) -> Dict[Any]:
478478
return response_dict
479479

480480
def inspect_ce_project(self, check_type: str) -> Dict[str, Any]:
481-
state_check_types: List[str] = ["not_synced", "not_started"]
482-
time_check_types: List[str] = ["not_current", "is_lagged"]
483-
valid_check_types: List[str] = state_check_types + time_check_types
481+
valid_check_types: List[str] = ["not_synced", "not_started", "not_current", "is_lagged"]
484482
if check_type not in valid_check_types:
485483
print(
486484
f'ERROR: Unknown check_type of "{check_type}"; Please use a valid check_type: [ {", ".join(valid_check_types)} ] ...'
@@ -489,33 +487,39 @@ def inspect_ce_project(self, check_type: str) -> Dict[str, Any]:
489487
result: Dict[str, Any] = {}
490488
sync_report: Dict[str, Any] = self.get_machine_sync_details()
491489
print(f"INFO: Using check '{check_type}' on Project: ({self.project_name})")
492-
if check_type in state_check_types:
493-
inspector1 = getattr(self, check_type)
494-
else:
495-
inspector2 = getattr(self, "time_delta_context")
496-
for item in sync_report.keys():
497-
if inspector2:
498-
mcheck = inspector2(machine=sync_report[item], check_type=check_type)
499-
else:
500-
mcheck = inspector1(machine=sync_report[item])
501-
if mcheck:
502-
result[item] = sync_report[item]
490+
if check_type in valid_check_types:
491+
for item in sync_report.keys():
492+
mcheck = self._inspector(machine=sync_report[item], check_type=check_type)
493+
if mcheck:
494+
result[item] = sync_report[item]
503495
print(f"INFO: Check '{check_type}' completed; {len(result)} machines matched in Project: ({self.project_name})")
504496
return result
505497

506-
def not_synced(self, machine) -> bool:
498+
def _inspector(self, **kwargs):
499+
# this could probably be a switch but I'll just elif this
500+
if "machine" in kwargs.keys():
501+
if "not_synced" in kwargs.values():
502+
return self._not_synced(machine=kwargs.get("machine"))
503+
elif "not_started" in kwargs.values():
504+
return self._not_started(machine=kwargs.get("machine"))
505+
else:
506+
return self._time_delta_context(
507+
machine=kwargs.get("machine", {}), check_type=kwargs.get("check_type", "")
508+
)
509+
510+
def _not_synced(self, machine) -> bool:
507511
if machine["backlogged_storage_bytes"] > 0 or machine["rescanned_storage_bytes"] > 0:
508512
return True
509513
else:
510514
return False
511515

512-
def not_started(self, machine) -> bool:
516+
def _not_started(self, machine) -> bool:
513517
if machine["replication_status"] == "STARTED":
514518
return False
515519
else:
516520
return True
517521

518-
def time_delta_context(self, machine: Dict[str, Any], check_type: str) -> bool:
522+
def _time_delta_context(self, machine: Dict[str, Any], check_type: str) -> bool:
519523
time_contexts: Dict[str, dict] = {
520524
"not_current": {"delta_seconds": 86400, "property": "last_seen_utc"},
521525
"is_lagged": {"delta_seconds": 120, "property": "last_consistency_utc"},

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "cloudendure"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
description = "Python wrapper and CLI for CloudEndure"
55
authors = ["Mark Beacom <[email protected]>", "Tom Warnock <[email protected]>"]
66
maintainers = ["Evan Lucchesi <[email protected]>", "Nick Selpa <[email protected]>"]

0 commit comments

Comments
 (0)