Skip to content
This repository has been archived by the owner on Oct 19, 2020. It is now read-only.

MGMT-1722 Modify 2nd ignition to create parameter file to Openshift for DHCP automatic VIP allocation #16

Merged
merged 1 commit into from
Aug 18, 2020
Merged
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
21 changes: 21 additions & 0 deletions render_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,22 @@ def upload_to_aws(s3_client, local_file, bucket, s3_file):
return False


def add_dhcp_allocation_file(ignition_file, dhcp_allocation_file):
try:
with open(ignition_file, "r") as file_obj:
data = json.load(file_obj)
storage_files = data['storage']['files']
entry = {"filesystem": "root",
"path": "/etc/keepalived/unsupported-monitor.conf",
"mode": 644,
"contents": {"source": dhcp_allocation_file}}
data['storage']['files'] = storage_files + [entry] if storage_files else [entry]
with open(ignition_file, "w") as file_obj:
json.dump(data, file_obj)
except Exception as ex:
raise Exception('Failed to add DHCP allocation file to master ignition, exception: {}'.format(ex))


def update_bmh_files(ignition_file, cluster_id, inventory_endpoint, token,
skip_cert_verification=False, ca_cert_path=None):
try:
Expand Down Expand Up @@ -175,6 +191,7 @@ def main():
install_config = os.environ.get("INSTALLER_CONFIG")
cluster_id = os.environ.get("CLUSTER_ID")
inventory_endpoint = os.environ.get("INVENTORY_ENDPOINT")
dhcp_allocation_file = os.environ.get("DHCP_ALLOCATION_FILE")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how does it related to BMH? and I would call DHCP_ALLOCATION_FILE diffrently @ori-amizur

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not. Why do you think it is?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's in the same function?

s3_endpoint_url = os.environ.get("S3_ENDPOINT_URL", args.s3_endpoint_url)
bucket = os.environ.get('S3_BUCKET', args.s3_bucket)
aws_access_key_id = os.environ.get("aws_access_key_id", "accessKey1")
Expand Down Expand Up @@ -204,6 +221,10 @@ def main():
update_bmh_files("%s/bootstrap.ign" % config_dir, cluster_id, inventory_endpoint, openshift_token(config_dir),
skip_cert_verification, ca_cert_path)

if dhcp_allocation_file:
# Add dhcp allocation file if needed to ignition
add_dhcp_allocation_file("%s/master.ign" % config_dir, dhcp_allocation_file)

if s3_endpoint_url:
upload_to_s3(s3_endpoint_url, bucket, aws_access_key_id, aws_secret_access_key, config_dir, cluster_id)
else:
Expand Down