Skip to content

Commit

Permalink
Refactor config / main for iso cluster deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Salvatore Daniele <[email protected]>
  • Loading branch information
SalDaniele committed May 17, 2024
1 parent 8b3531b commit d68d521
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 24 deletions.
19 changes: 14 additions & 5 deletions cda.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@
from clusterSnapshotter import ClusterSnapshotter
from virtualBridge import VirBridge


def main_deploy(args: argparse.Namespace) -> None:
cc = ClustersConfig(args.config, args.worker_range)

def main_deploy_openshift(cc: ClustersConfig, args: argparse.Namespace):
# Make sure the local virtual bridge base configuration is correct.
local_bridge = VirBridge(host.LocalHost(), cc.local_bridge_config)
local_bridge.configure(api_port=None)

# microshift does not use assisted installer so we don't need this check
if args.url == cc.ip_range[0] and cc.kind == "openshift":
if args.url == cc.ip_range[0]:
ais = AssistedInstallerService(cc.version, args.url, cc.proxy, cc.noproxy)
ais.start()
else:
Expand All @@ -46,6 +43,18 @@ def main_deploy(args: argparse.Namespace) -> None:
if args.teardown_full and ais:
ais.stop()

def main_deploy_iso(cc: ClustersConfig, args: argparse.Namespace):
cd = ClusterDeployer(cc, None, args.steps, args.secrets_path)
cd.deploy()

def main_deploy(args: argparse.Namespace) -> None:
cc = ClustersConfig(args.config, args.worker_range)

if cc.kind == "openshift":
main_deploy_openshift(cc, args)
else:
main_deploy_iso(cc, args)


def main_snapshot(args: argparse.Namespace) -> None:
args = parse_args()
Expand Down
43 changes: 24 additions & 19 deletions clustersConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,30 @@ def __init__(self, yaml_path: str, worker_range: common.RangeList):
self.configured_workers = [NodeConfig(self.name, **w) for w in cc["workers"]]
self.workers = [NodeConfig(self.name, **w) for w in worker_range.filter_list(cc["workers"])]

if self.kind == "openshift":
self.configure_ip_range()

# creates hosts entries for each referenced node name
node_names = {x["name"] for x in cc["hosts"]}
for node in self.all_nodes():
if node.node not in node_names:
cc["hosts"].append({"name": node.node})
node_names.add(node.node)

if not self.is_sno():
self.api_vip = {'ip': cc["api_vip"]}
self.ingress_vip = {'ip': cc["ingress_vip"]}

for e in cc["hosts"]:
self.hosts.append(HostConfig(self.network_api_port, **e))

for c in cc["preconfig"]:
self.preconfig.append(ExtraConfigArgs(**c))
for c in cc["postconfig"]:
self.postconfig.append(ExtraConfigArgs(**c))

def configure_ip_range(self):
cc = self.fullConfig
# Reserve IPs for AI, masters and workers.
ip_mask = cc["ip_mask"]
ip_range = cc["ip_range"].split("-")
Expand Down Expand Up @@ -230,25 +254,6 @@ def __init__(self, yaml_path: str, worker_range: common.RangeList):
self.local_bridge_config = BridgeConfig(ip=self.ip_range[0], mask=ip_mask, dynamic_ip_range=dynamic_ip_range)
self.remote_bridge_config = BridgeConfig(ip=ip_range[1], mask=ip_mask)

# creates hosts entries for each referenced node name
node_names = {x["name"] for x in cc["hosts"]}
for node in self.all_nodes():
if node.node not in node_names:
cc["hosts"].append({"name": node.node})
node_names.add(node.node)

if not self.is_sno():
self.api_vip = {'ip': cc["api_vip"]}
self.ingress_vip = {'ip': cc["ingress_vip"]}

for e in cc["hosts"]:
self.hosts.append(HostConfig(self.network_api_port, **e))

for c in cc["preconfig"]:
self.preconfig.append(ExtraConfigArgs(**c))
for c in cc["postconfig"]:
self.postconfig.append(ExtraConfigArgs(**c))

def get_last_ip(self) -> str:
hostconn = host.LocalHost()
last_ip = "0.0.0.0"
Expand Down

0 comments on commit d68d521

Please sign in to comment.