-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.py
65 lines (59 loc) · 2.45 KB
/
script.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from PyInquirer import prompt, print_json
from utils.configurations import loadConfigurations
from utils.pull_secret_util import get_pull_secret
from utils.first_run import isFirstRun, performFirstRun
from utils.prompts import welcomeMessage, mainMenuPrompt, selectClusterPrompt, localClustersPrompt
from utils.setupCluster import setupCluster
from utils.ClusterInquirer import ClusterInquirer
from utils.dateHandler import getAvailableClusters
from utils.run_ocs_install import LocalClusterHandler
class Manager:
def __init__(self):
if isFirstRun():
welcomeMessage()
performFirstRun()
self.configurations = loadConfigurations()
self.clusterInquirer = ClusterInquirer(self.configurations)
self.LocalClusterHandler = LocalClusterHandler(self.clusterInquirer.getManager(),
self.configurations)
def setupCluster(self,selected, local=False):
if not local:
self.clusterInquirer.setupKube(selected)
else:
self.clusterInquirer.setupLocalKube(selected)
def createCluster(self):
self.LocalClusterHandler.startInstallation()
def getClustersStatus(self):
return self.clusterInquirer.getStatus()
if __name__ == '__main__':
#Declare a variable to maintain a program loop
manager = Manager()
showLocalClusters = False
while True:
localClusters = manager.LocalClusterHandler.getLocalUsableClusters()
if len(localClusters) > 0:
showLocalClusters=True
choice = mainMenuPrompt(showLocalClusters)
#List available clusters
if choice == 0:
#Get all clusters
clusters = manager.getClustersStatus()
healthyClusters = getAvailableClusters(clusters)
if len(healthyClusters) > 0:
selectedCluster = selectClusterPrompt( healthyClusters )
manager.setupCluster(selectedCluster)
print("The selected cluster has been setup")
else:
print("\nNo clusters available right now\n")
# Create new cluster
if choice == 1:
manager.createCluster()
#Show local clusters
if choice == 2:
#Selected cluster is the path to cluster
selectedCluster = localClustersPrompt(localClusters)
manager.setupCluster(selectedCluster, local=True)
print("Local cluster is setup!")
# Quit
if choice == 3:
break