-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathisoDeployer.py
75 lines (67 loc) · 2.89 KB
/
isoDeployer.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
66
67
68
69
70
71
72
73
74
75
import host
import common
from logger import logger
from arguments import PRE_STEP, MASTERS_STEP, POST_STEP
import marvell
import ipu
from baseDeployer import BaseDeployer
from clustersConfig import ClustersConfig
from concurrent.futures import ThreadPoolExecutor
from dpuVendor import detect_dpu
import sys
class IsoDeployer(BaseDeployer):
def __init__(self, cc: ClustersConfig, steps: list[str]):
super().__init__(cc, steps)
if len(self._cc.masters) != 1:
logger.error("Masters must be of length one for deploying from iso")
sys.exit(-1)
self._master = self._cc.masters[0]
self._futures[self._master.name] = common.empty_future(host.Result)
self._validate()
def _validate(self) -> None:
if self._master.mac is None:
logger.error_and_exit(f"No MAC address provided for cluster {self._cc.name}, exiting")
if self._master.ip is None:
logger.error_and_exit(f"No IP address provided for cluster {self._cc.name}, exiting")
if self._master.name is None:
logger.error_and_exit(f"No name provided for cluster {self._cc.name}, exiting")
if not self._cc.network_api_port or self._cc.network_api_port == "auto":
logger.error_and_exit(f"Network API port with connection to {self._cc.name} must be specified, exiting")
def deploy(self) -> None:
duration = self._empty_timers()
if self._cc.masters:
if PRE_STEP in self.steps:
duration[PRE_STEP].start()
self._preconfig()
duration[PRE_STEP].stop()
else:
logger.info("Skipping pre configuration.")
if MASTERS_STEP in self.steps:
duration[MASTERS_STEP].start()
self._deploy_master()
duration[MASTERS_STEP].stop()
else:
logger.info("Skipping master creation.")
if POST_STEP in self.steps:
duration[POST_STEP].start()
self._postconfig()
duration[POST_STEP].stop()
else:
logger.info("Skipping post configuration.")
for k, v in duration.items():
logger.info(f"{k}: {v.duration()}")
def _deploy_master(self) -> None:
assert self._master.kind == "dpu"
assert self._master.bmc is not None
dpu_kind = detect_dpu(self._master)
if dpu_kind == "ipu":
node = ipu.IPUClusterNode(self._master, self._cc.get_external_port(), self._cc.network_api_port)
executor = ThreadPoolExecutor(max_workers=len(self._cc.masters))
future = executor.submit(node.start, self._cc.install_iso)
future.result()
node.post_boot()
elif dpu_kind == "marvell":
marvell.MarvellIsoBoot(self._cc, self._master, self._cc.install_iso)
else:
logger.error("Unknown DPU")
sys.exit(-1)