Skip to content

Commit f292f26

Browse files
Changes in docs for release: v0.6.1
1 parent f34697a commit f292f26

11 files changed

+1278
-868
lines changed

docs/cluster/auth.html

+338-143
Large diffs are not rendered by default.

docs/cluster/awload.html

+78-105
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
5151
from os.path import isfile
5252
import errno
5353
import os
54-
import openshift as oc
5554
import yaml
5655

56+
from kubernetes import client, config
57+
from ..utils.kube_api_helpers import _kube_api_error_handling
58+
from .auth import config_check, api_config_handler
59+
5760

5861
class AWManager:
5962
&#34;&#34;&#34;
@@ -71,10 +74,10 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
7174
self.filename = filename
7275
try:
7376
with open(self.filename) as f:
74-
awyaml = yaml.load(f, Loader=yaml.FullLoader)
75-
assert awyaml[&#34;kind&#34;] == &#34;AppWrapper&#34;
76-
self.name = awyaml[&#34;metadata&#34;][&#34;name&#34;]
77-
self.namespace = awyaml[&#34;metadata&#34;][&#34;namespace&#34;]
77+
self.awyaml = yaml.load(f, Loader=yaml.FullLoader)
78+
assert self.awyaml[&#34;kind&#34;] == &#34;AppWrapper&#34;
79+
self.name = self.awyaml[&#34;metadata&#34;][&#34;name&#34;]
80+
self.namespace = self.awyaml[&#34;metadata&#34;][&#34;namespace&#34;]
7881
except:
7982
raise ValueError(
8083
f&#34;{filename } is not a correctly formatted AppWrapper yaml&#34;
@@ -86,19 +89,17 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
8689
Attempts to create the AppWrapper custom resource using the yaml file
8790
&#34;&#34;&#34;
8891
try:
89-
with oc.project(self.namespace):
90-
oc.invoke(&#34;create&#34;, [&#34;-f&#34;, self.filename])
91-
except oc.OpenShiftPythonException as osp: # pragma: no cover
92-
error_msg = osp.result.err()
93-
if &#34;Unauthorized&#34; in error_msg or &#34;Forbidden&#34; in error_msg:
94-
raise PermissionError(
95-
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
96-
)
97-
elif &#34;AlreadyExists&#34; in error_msg:
98-
raise FileExistsError(
99-
f&#34;An AppWrapper of the name {self.name} already exists in namespace {self.namespace}&#34;
100-
)
101-
raise osp
92+
config_check()
93+
api_instance = client.CustomObjectsApi(api_config_handler())
94+
api_instance.create_namespaced_custom_object(
95+
group=&#34;mcad.ibm.com&#34;,
96+
version=&#34;v1beta1&#34;,
97+
namespace=self.namespace,
98+
plural=&#34;appwrappers&#34;,
99+
body=self.awyaml,
100+
)
101+
except Exception as e:
102+
return _kube_api_error_handling(e)
102103

103104
self.submitted = True
104105
print(f&#34;AppWrapper {self.filename} submitted!&#34;)
@@ -113,25 +114,17 @@ <h1 class="title">Module <code>codeflare_sdk.cluster.awload</code></h1>
113114
return
114115

115116
try:
116-
with oc.project(self.namespace):
117-
oc.invoke(&#34;delete&#34;, [&#34;AppWrapper&#34;, self.name])
118-
except oc.OpenShiftPythonException as osp: # pragma: no cover
119-
error_msg = osp.result.err()
120-
if (
121-
&#39;the server doesn\&#39;t have a resource type &#34;AppWrapper&#34;&#39; in error_msg
122-
or &#34;forbidden&#34; in error_msg
123-
or &#34;Unauthorized&#34; in error_msg
124-
or &#34;Missing or incomplete configuration&#34; in error_msg
125-
):
126-
raise PermissionError(
127-
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
128-
)
129-
elif &#34;not found&#34; in error_msg:
130-
self.submitted = False
131-
print(&#34;AppWrapper not found, was deleted in another manner&#34;)
132-
return
133-
else:
134-
raise osp
117+
config_check()
118+
api_instance = client.CustomObjectsApi(api_config_handler())
119+
api_instance.delete_namespaced_custom_object(
120+
group=&#34;mcad.ibm.com&#34;,
121+
version=&#34;v1beta1&#34;,
122+
namespace=self.namespace,
123+
plural=&#34;appwrappers&#34;,
124+
name=self.name,
125+
)
126+
except Exception as e:
127+
return _kube_api_error_handling(e)
135128

136129
self.submitted = False
137130
print(f&#34;AppWrapper {self.name} removed!&#34;)</code></pre>
@@ -175,10 +168,10 @@ <h2 class="section-title" id="header-classes">Classes</h2>
175168
self.filename = filename
176169
try:
177170
with open(self.filename) as f:
178-
awyaml = yaml.load(f, Loader=yaml.FullLoader)
179-
assert awyaml[&#34;kind&#34;] == &#34;AppWrapper&#34;
180-
self.name = awyaml[&#34;metadata&#34;][&#34;name&#34;]
181-
self.namespace = awyaml[&#34;metadata&#34;][&#34;namespace&#34;]
171+
self.awyaml = yaml.load(f, Loader=yaml.FullLoader)
172+
assert self.awyaml[&#34;kind&#34;] == &#34;AppWrapper&#34;
173+
self.name = self.awyaml[&#34;metadata&#34;][&#34;name&#34;]
174+
self.namespace = self.awyaml[&#34;metadata&#34;][&#34;namespace&#34;]
182175
except:
183176
raise ValueError(
184177
f&#34;{filename } is not a correctly formatted AppWrapper yaml&#34;
@@ -190,19 +183,17 @@ <h2 class="section-title" id="header-classes">Classes</h2>
190183
Attempts to create the AppWrapper custom resource using the yaml file
191184
&#34;&#34;&#34;
192185
try:
193-
with oc.project(self.namespace):
194-
oc.invoke(&#34;create&#34;, [&#34;-f&#34;, self.filename])
195-
except oc.OpenShiftPythonException as osp: # pragma: no cover
196-
error_msg = osp.result.err()
197-
if &#34;Unauthorized&#34; in error_msg or &#34;Forbidden&#34; in error_msg:
198-
raise PermissionError(
199-
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
200-
)
201-
elif &#34;AlreadyExists&#34; in error_msg:
202-
raise FileExistsError(
203-
f&#34;An AppWrapper of the name {self.name} already exists in namespace {self.namespace}&#34;
204-
)
205-
raise osp
186+
config_check()
187+
api_instance = client.CustomObjectsApi(api_config_handler())
188+
api_instance.create_namespaced_custom_object(
189+
group=&#34;mcad.ibm.com&#34;,
190+
version=&#34;v1beta1&#34;,
191+
namespace=self.namespace,
192+
plural=&#34;appwrappers&#34;,
193+
body=self.awyaml,
194+
)
195+
except Exception as e:
196+
return _kube_api_error_handling(e)
206197

207198
self.submitted = True
208199
print(f&#34;AppWrapper {self.filename} submitted!&#34;)
@@ -217,25 +208,17 @@ <h2 class="section-title" id="header-classes">Classes</h2>
217208
return
218209

219210
try:
220-
with oc.project(self.namespace):
221-
oc.invoke(&#34;delete&#34;, [&#34;AppWrapper&#34;, self.name])
222-
except oc.OpenShiftPythonException as osp: # pragma: no cover
223-
error_msg = osp.result.err()
224-
if (
225-
&#39;the server doesn\&#39;t have a resource type &#34;AppWrapper&#34;&#39; in error_msg
226-
or &#34;forbidden&#34; in error_msg
227-
or &#34;Unauthorized&#34; in error_msg
228-
or &#34;Missing or incomplete configuration&#34; in error_msg
229-
):
230-
raise PermissionError(
231-
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
232-
)
233-
elif &#34;not found&#34; in error_msg:
234-
self.submitted = False
235-
print(&#34;AppWrapper not found, was deleted in another manner&#34;)
236-
return
237-
else:
238-
raise osp
211+
config_check()
212+
api_instance = client.CustomObjectsApi(api_config_handler())
213+
api_instance.delete_namespaced_custom_object(
214+
group=&#34;mcad.ibm.com&#34;,
215+
version=&#34;v1beta1&#34;,
216+
namespace=self.namespace,
217+
plural=&#34;appwrappers&#34;,
218+
name=self.name,
219+
)
220+
except Exception as e:
221+
return _kube_api_error_handling(e)
239222

240223
self.submitted = False
241224
print(f&#34;AppWrapper {self.name} removed!&#34;)</code></pre>
@@ -262,25 +245,17 @@ <h3>Methods</h3>
262245
return
263246

264247
try:
265-
with oc.project(self.namespace):
266-
oc.invoke(&#34;delete&#34;, [&#34;AppWrapper&#34;, self.name])
267-
except oc.OpenShiftPythonException as osp: # pragma: no cover
268-
error_msg = osp.result.err()
269-
if (
270-
&#39;the server doesn\&#39;t have a resource type &#34;AppWrapper&#34;&#39; in error_msg
271-
or &#34;forbidden&#34; in error_msg
272-
or &#34;Unauthorized&#34; in error_msg
273-
or &#34;Missing or incomplete configuration&#34; in error_msg
274-
):
275-
raise PermissionError(
276-
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
277-
)
278-
elif &#34;not found&#34; in error_msg:
279-
self.submitted = False
280-
print(&#34;AppWrapper not found, was deleted in another manner&#34;)
281-
return
282-
else:
283-
raise osp
248+
config_check()
249+
api_instance = client.CustomObjectsApi(api_config_handler())
250+
api_instance.delete_namespaced_custom_object(
251+
group=&#34;mcad.ibm.com&#34;,
252+
version=&#34;v1beta1&#34;,
253+
namespace=self.namespace,
254+
plural=&#34;appwrappers&#34;,
255+
name=self.name,
256+
)
257+
except Exception as e:
258+
return _kube_api_error_handling(e)
284259

285260
self.submitted = False
286261
print(f&#34;AppWrapper {self.name} removed!&#34;)</code></pre>
@@ -300,19 +275,17 @@ <h3>Methods</h3>
300275
Attempts to create the AppWrapper custom resource using the yaml file
301276
&#34;&#34;&#34;
302277
try:
303-
with oc.project(self.namespace):
304-
oc.invoke(&#34;create&#34;, [&#34;-f&#34;, self.filename])
305-
except oc.OpenShiftPythonException as osp: # pragma: no cover
306-
error_msg = osp.result.err()
307-
if &#34;Unauthorized&#34; in error_msg or &#34;Forbidden&#34; in error_msg:
308-
raise PermissionError(
309-
&#34;Action not permitted, have you put in correct/up-to-date auth credentials?&#34;
310-
)
311-
elif &#34;AlreadyExists&#34; in error_msg:
312-
raise FileExistsError(
313-
f&#34;An AppWrapper of the name {self.name} already exists in namespace {self.namespace}&#34;
314-
)
315-
raise osp
278+
config_check()
279+
api_instance = client.CustomObjectsApi(api_config_handler())
280+
api_instance.create_namespaced_custom_object(
281+
group=&#34;mcad.ibm.com&#34;,
282+
version=&#34;v1beta1&#34;,
283+
namespace=self.namespace,
284+
plural=&#34;appwrappers&#34;,
285+
body=self.awyaml,
286+
)
287+
except Exception as e:
288+
return _kube_api_error_handling(e)
316289

317290
self.submitted = True
318291
print(f&#34;AppWrapper {self.filename} submitted!&#34;)</code></pre>

0 commit comments

Comments
 (0)