-
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.
- Loading branch information
Showing
3 changed files
with
36 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class KubenodeCannotBeParsedFromJson(Exception): | ||
pass |
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,27 @@ | ||
import json | ||
|
||
|
||
class KubeNode: | ||
def __init__(self, node_json): | ||
# Parse meta informations | ||
self.name = node_json.metadata.name | ||
self.uid = node_json.metadata.uid | ||
|
||
# Parse node conditions | ||
for condition_json in node_json.status.conditions: | ||
type = condition_json.type | ||
if type == 'MemoryPressure': | ||
self.memory_pressure = condition_json.status == 'True' | ||
|
||
if type == 'DiskPressure': | ||
self.disk_pressure = condition_json.status == 'True' | ||
|
||
if type == 'PIDPressure': | ||
self.pid_pressure = condition_json.status == 'True' | ||
|
||
if type == 'Ready': | ||
self.ready = condition_json.status == 'True' | ||
|
||
def __str__(self): | ||
attrs = {str(i): getattr(self, i) for i in dir(self) if not i.startswith('__')} | ||
return json.dumps(attrs) |
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