Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vcm vip step, replace bash with python #54070

Merged
merged 2 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/usr/bin/env python

import os
import sys
import json

try:
from pylint.lint import Run
file_path = os.path.realpath(__file__)
Run([file_path], exit=False)
except ImportError:
print("linter not available, run outside of CI")


cluster_profile_name = os.environ.get("CLUSTER_PROFILE_NAME")
leased_resource = os.environ.get("LEASED_RESOURCE")
shared_dir = os.environ.get("SHARED_DIR")

if cluster_profile_name is None:
print("CLUSTER_PROFILE_NAME is undefined")
sys.exit(1)

if cluster_profile_name != "vsphere-elastic":
print("using legacy sibling of this step")
sys.exit(0)

if leased_resource is None:
print("failed to acquire lease")
sys.exit(1)

subnets_config = shared_dir + "/NETWORK_single.json"
machine_cidr_filename = shared_dir + "/machinecidr.txt"
vips_file_name = shared_dir + "/vips.txt"

with open(subnets_config) as f:
subnet_obj = json.load(f)

machine_cidr = subnet_obj["spec"]["machineNetworkCidr"]
api_vip = subnet_obj["spec"]["ipAddresses"][2]
ingress_vip = subnet_obj["spec"]["ipAddresses"][3]

with open(vips_file_name, "w") as vip_file:
print("vip addresses {} {}".format(api_vip, ingress_vip))
vip_file.write("{}\n{}".format(api_vip, ingress_vip))

with open(machine_cidr_filename, "w") as machine_cidr_file:
print("machine cidr {}".format(machine_cidr))
machine_cidr_file.write(machine_cidr)
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ref:
as: ipi-conf-vsphere-vips-vcm
from: tools
commands: ipi-conf-vsphere-vips-vcm-commands.sh
commands: ipi-conf-vsphere-vips-vcm-commands.py
run_as_script: true
resources:
requests:
cpu: 10m
Expand Down