File tree Expand file tree Collapse file tree 2 files changed +41
-0
lines changed
src/codeflare_sdk/cluster Expand file tree Collapse file tree 2 files changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -34,3 +34,9 @@ class ClusterConfiguration:
34
34
instascale : bool = False
35
35
envs : dict = field (default_factory = dict )
36
36
image : str = "ghcr.io/ibm-ai-foundation/base:ray1.13.0-py38-gpu-pytorch1.12.0cu116-20220826-202124"
37
+
38
+ @dataclass
39
+ class OpenShiftConfiguration :
40
+ token : str = "your OpenShift API token"
41
+ server : str = "your OpenShift server"
42
+
Original file line number Diff line number Diff line change
1
+ # Copyright 2022 IBM, Red Hat
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import openshift as oc
16
+ from .config import OpenShiftConfiguration
17
+
18
+
19
+ class OpenShiftCluster :
20
+ def __init__ (self , config : OpenShiftConfiguration ):
21
+ self .config = config
22
+
23
+ def login (self ):
24
+ token = self .config .token
25
+ server = self .config .server
26
+ response = oc .invoke ("login" ,[f'--token={ token } ' , f'--server={ server } :6443' ])
27
+ return response .out ()
28
+
29
+ def select_project (self , project_name : str ):
30
+ response = oc .invoke ("project" , [f"{ project_name } " ])
31
+ return response .out ()
32
+
33
+ def logout (self ):
34
+ response = oc .invoke ("logout" )
35
+ return response .out ()
You can’t perform that action at this time.
0 commit comments