Skip to content

Commit 2ff757c

Browse files
committed
replacing old openshift api with new one
1 parent 1dd4620 commit 2ff757c

File tree

1 file changed

+16
-31
lines changed

1 file changed

+16
-31
lines changed

wrapanapi/containers/providers/rhopenshift.py

+16-31
Original file line numberDiff line numberDiff line change
@@ -138,40 +138,25 @@ def __init__(self, hostname, protocol="https", port=8443, k_entry="api/v1", o_en
138138
self.api = self.k_api # default api is the kubernetes one for Kubernetes-class requests
139139
self.list_image_openshift = self.list_docker_image # For backward compatibility
140140

141-
def list_route(self):
141+
def list_route(self, namespace=None):
142142
"""Returns list of routes"""
143-
entities = []
144-
entities_j = self.o_api.get('route')[1]['items']
145-
for entity_j in entities_j:
146-
meta = entity_j['metadata']
147-
entity = Route(self, meta['name'], meta['namespace'])
148-
entities.append(entity)
149-
return entities
143+
if namespace:
144+
routes = self.o_api.list_namespaced_route(namespace=namespace).items
145+
else:
146+
routes = self.o_api.list_route_for_all_namespaces().items
147+
return routes
150148

151-
def list_docker_registry(self):
152-
"""Returns list of docker registries"""
153-
entities = []
154-
entities_j = self.o_api.get('imagestream')[1]['items']
155-
for entity_j in entities_j:
156-
if 'dockerImageRepository' not in entity_j['status']:
157-
continue
158-
meta = entity_j['metadata']
159-
entity = ImageRegistry(self, meta['name'],
160-
entity_j['status']['dockerImageRepository'],
161-
meta['namespace'])
162-
if entity not in entities:
163-
entities.append(entity)
164-
return entities
149+
def list_image_streams(self, namespace=None):
150+
"""Returns list of image streams"""
151+
if namespace:
152+
image_streams = self.o_api.list_namespaced_image_stream(namespace=namespace).items
153+
else:
154+
image_streams = self.o_api.list_image_stream_for_all_namespaces().items
155+
return image_streams
165156

166157
def list_project(self):
167158
"""Returns list of projects"""
168-
entities = []
169-
entities_j = self.o_api.get('project')[1]['items']
170-
for entity_j in entities_j:
171-
meta = entity_j['metadata']
172-
entity = Project(self, meta['name'])
173-
entities.append(entity)
174-
return entities
159+
return self.o_api.list_project().items
175160

176161
def list_template(self, namespace=None):
177162
"""Returns list of templates"""
@@ -1111,15 +1096,15 @@ def in_steady_state(self, vm_name):
11111096
def can_rename(self):
11121097
return hasattr(self, "rename_vm")
11131098

1114-
def list_project_(self):
1099+
def list_project__names(self):
11151100
"""Obtains project names
11161101
11171102
Returns: list of project names
11181103
"""
11191104
projects = self.o_api.list_project().items
11201105
return [proj.metadata.name for proj in projects]
11211106

1122-
list_vm = list_project_
1107+
list_vm = list_project_names
11231108

11241109
def delete_template(self, template_name, namespace='openshift'):
11251110
"""Deletes template

0 commit comments

Comments
 (0)