generated from validatedpatterns/multicloud-gitops
-
Notifications
You must be signed in to change notification settings - Fork 20
/
crd.py
64 lines (50 loc) · 1.78 KB
/
crd.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from ocp_resources.resource import NamespacedResource, Resource
class DeploymentConfig(NamespacedResource):
"""
OpenShift DeploymentConfig object.
"""
api_version = "apps.openshift.io/v1"
kind = "DeploymentConfig"
class ArgoCD(NamespacedResource):
"""
OpenShift ArgoCD / GitOps object.
"""
api_group = "argoproj.io"
api_version = NamespacedResource.ApiVersion.V1ALPHA1
kind = "Application"
@property
def health(self):
"""
Check the health of of the argocd application
:return: boolean
"""
if (
self.instance.status.operationState.phase == "Succeeded"
and self.instance.status.health.status == "Healthy"
):
return True
return False
class ManagedCluster(Resource):
"""
OpenShift Managed Cluster object.
"""
api_version = "cluster.open-cluster-management.io/v1"
@property
def self_registered(self):
"""
Check if managed cluster is self registered in to ACM running on hub site
:param name: (str) name of managed cluster
:param namespace: namespace
:return: Tuple of boolean and dict on success
"""
is_joined = False
status = dict()
for condition in self.instance.status.conditions:
if condition["type"] == "HubAcceptedManagedCluster":
status["HubAcceptedManagedCluster"] = condition["status"]
elif condition["type"] == "ManagedClusterConditionAvailable":
status["ManagedClusterConditionAvailable"] = condition["status"]
elif condition["type"] == "ManagedClusterJoined":
is_joined = True
status["ManagedClusterJoined"] = condition["status"]
return is_joined, status