Skip to content
Closed
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
Expand Up @@ -23,12 +23,22 @@
from ansible.module_utils.input_validation.common_utils import en_us_validation_msg
from ansible.module_utils.input_validation.validation_flows import common_validation
import csv
import yaml
from io import StringIO

file_names = config.files
create_error_msg = validation_utils.create_error_msg
create_file_path = validation_utils.create_file_path

def load_oim_metadata(metadata_file_path):
with open(metadata_file_path, 'r') as file:
metadata = yaml.safe_load(file)
return metadata

metadata_file_path = '/opt/omnia/.data/oim_metadata.yml'
metadata = load_oim_metadata(metadata_file_path)
oim_timezone = metadata['oim_timezone']

# Expected header columns (case-insensitive)
required_headers = [
"FUNCTIONAL_GROUP_NAME",
Expand Down Expand Up @@ -232,6 +242,7 @@ def validate_provision_config(
timezone_file_path = os.path.join(
module_utils_base, "input_validation", "common_utils", "timezone.txt"
)

pxe_mapping_file_path = data.get("pxe_mapping_file_path", "")
if pxe_mapping_file_path and validation_utils.verify_path(pxe_mapping_file_path):
try:
Expand All @@ -258,6 +269,19 @@ def validate_provision_config(
create_error_msg("timezone", timezone, en_us_validation_msg.TIMEZONE_FAIL_MSG)
)

# Detect system timezone
input_timezone = timezone

# Compare both timezones
if oim_timezone != input_timezone:
errors.append(
create_error_msg(
"timezone_mismatch",
f"Provided input timezone : {input_timezone}, Detected oim timezone: {oim_timezone}",
"Timezone mismatch detected. Please ensure both timezone matche,s refer file timezone.txt."
)
)

default_lease_time = data["default_lease_time"]
if not validation_utils.validate_default_lease_time(default_lease_time):
errors.append(
Expand Down
8 changes: 7 additions & 1 deletion omnia.sh
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,12 @@ validate_oim() {
exit 1
fi


oim_timezone=$(timedatectl | grep "Time zone" | awk '{print $3}')
Copy link
Collaborator

@abhishek-sa1 abhishek-sa1 Nov 25, 2025

Choose a reason for hiding this comment

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

grep time zone is not safe as it can be changed syntax later. can we have any other way to get timezone of oim in any file or any proper command. case sensitive to be handled?

if [[ -z "$oim_timezone" ]]; then
echo -e "${RED}Timezone is not set!${NC}"
Copy link
Collaborator

Choose a reason for hiding this comment

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

@priti-parate should we fail here or provide warning and proceed with empty timezone?

exit 1
fi

podman --version

# Capture the exit status
Expand Down Expand Up @@ -740,6 +745,7 @@ EOF
echo "oim_hostname: $(hostname)"
echo "oim_node_name: $(hostname -s)"
echo "domain_name: $domain_name"
echo "oim_timezone: $oim_timezone"
echo "omnia_core_hashed_passwd: $hashed_passwd"
echo "omnia_share_option: $share_option"
} >> "$oim_metadata_file"
Expand Down
Loading