@@ -138,40 +138,25 @@ def __init__(self, hostname, protocol="https", port=8443, k_entry="api/v1", o_en
138
138
self .api = self .k_api # default api is the kubernetes one for Kubernetes-class requests
139
139
self .list_image_openshift = self .list_docker_image # For backward compatibility
140
140
141
- def list_route (self ):
141
+ def list_route (self , namespace = None ):
142
142
"""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
150
148
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
165
156
166
157
def list_project (self ):
167
158
"""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
175
160
176
161
def list_template (self , namespace = None ):
177
162
"""Returns list of templates"""
@@ -1111,15 +1096,15 @@ def in_steady_state(self, vm_name):
1111
1096
def can_rename (self ):
1112
1097
return hasattr (self , "rename_vm" )
1113
1098
1114
- def list_project_ (self ):
1099
+ def list_project__names (self ):
1115
1100
"""Obtains project names
1116
1101
1117
1102
Returns: list of project names
1118
1103
"""
1119
1104
projects = self .o_api .list_project ().items
1120
1105
return [proj .metadata .name for proj in projects ]
1121
1106
1122
- list_vm = list_project_
1107
+ list_vm = list_project_names
1123
1108
1124
1109
def delete_template (self , template_name , namespace = 'openshift' ):
1125
1110
"""Deletes template
0 commit comments