Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial implementation for hive #468

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions wrapanapi/systems/container/rhopenshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ def _connect(self):
self.k_api = kubeclient.CoreV1Api(api_client=self.kapi_client)
self.security_api = self.ociclient.SecurityOpenshiftIoV1Api(api_client=self.oapi_client)
self.batch_api = self.kclient.BatchV1Api(api_client=self.kapi_client) # for job api
self.custom_api = kubeclient.CustomObjectsApi(api_client=self.kapi_client)

def info(self):
url = '{proto}://{host}:{port}'.format(proto=self.protocol, host=self.hostname,
Expand Down Expand Up @@ -320,6 +321,40 @@ def list_image_registry(self, namespace=None):
# returns only the image registry name, without the port number in case of local registry
return sorted(set([status.image.split('/')[0].split(':')[0] for status in statuses]))

def list_hive_cluster_deployments(self, namespace=None, clusterpool=None):
# get namespaces
namespaces = []
if namespace:
namespaces.append(namespace)
else:
list_ns = self.k_api.list_namespace().items
for ns in list_ns:
if clusterpool:
ns_clusterpool = ns.metadata.labels.get('hive.openshift.io/cluster-pool-name')
if clusterpool != ns_clusterpool:
continue
namespaces.append(ns.metadata.name)
# get cluster deployments
clusterdeployments = []
for ns in namespaces:
try:
result = self.custom_api.list_namespaced_custom_object(
namespace=ns,
group='hive.openshift.io',
version='v1',
plural='clusterdeployments'
)
for cd in list(result.items())[1][1]:
if clusterpool:
cd_clusterpool = cd.get('spec').get('clusterPoolRef').get('poolName')
if clusterpool != cd_clusterpool:
continue
clusterdeployments.append(cd)
except:
# to some namespaces we do not have access
pass
return clusterdeployments

def expose_db_ip(self, namespace):
"""Creates special service in appliance project (namespace) which makes internal appliance
db be available outside.
Expand Down
Loading