Skip to content

Commit a222d13

Browse files
Refactor infra discovery script to align with WDT discover.py and remove Internal WDT dependencies JCS-15086
* topic_mb_JCS-15086_refactor_infra_discovery * topic_mb_JCS-15086_refactor_infra_discovery * topic_mb_JCS-15086_refactor_infra_discovery * topic_mb_JCS-15086_refactor_infra_discovery * topic_mb_JCS-15086_refactor_infra_discovery * topic_mb_JCS-15086_refactor_infra_discovery
1 parent b27513d commit a222d13

File tree

5 files changed

+440
-1472
lines changed

5 files changed

+440
-1472
lines changed

bin/owm.sh

Lines changed: 39 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -102,32 +102,45 @@ discover_online(){
102102
log "info" "<discoverDomain><discover_online><exit> success"
103103
}
104104

105-
discover_infra_local(){
106-
log "info" "<discoverDomain><discover_infra_local><entry> args: $*"
107-
wls_inventory_file=$1
108-
local file_timestamp=`date +%Y%m%d%H%M`
109-
local SCRIPT_PATH="$toolHome/bin/discoverInfra.sh"
110-
local model_file_arg=""
111-
if [[ -f $wls_inventory_file ]]; then
112-
model_file_arg="-model_file $wls_inventory_file"
113-
elif [[ -f "$toolHome/out/$wls_inventory_file" ]]; then
114-
model_file_arg="-model_file $toolHome/out/$wls_inventory_file"
115-
else
116-
log "error" "<discoverDomain><discover_infra_local><error> model_file $wls_inventory_file not found. exiting."
117-
exit 2
118-
fi
119-
local ssh_args
120-
ssh_args=$(get_ssh_args) # Get SSH options from helper
121-
discover "local" "$SCRIPT_PATH" "$model_file_arg" "-archive_file $toolHome/out/infra_output_$file_timestamp.json" "$ssh_args"
122-
exit_code=$?
123-
log "info" "Executed discover infra with exit code [$exit_code]"
124-
if [ $exit_code -ne 0 ] && [ $exit_code -ne 1 ]; then
125-
log "error" "<discoverDomain><discover_infra_local><error> Error executing discover infra"
126-
exit $exit_code
127-
fi
128-
log "info" "<discoverDomain><discover_infra_local><exit> infrastructure_file : $toolHome/out/infra_output_$file_timestamp.json"
129-
DISCOVERED_INFRA_JSON="$toolHome/out/infra_output_$file_timestamp.json"
130-
update_migration_data_json "infra_json" "$DISCOVERED_INFRA_JSON"
105+
discover_infra_local() {
106+
log "info" "<discoverDomain><discover_infra_local><entry> args: $*"
107+
108+
wls_inventory_file="$1"
109+
file_timestamp=$(date +%Y%m%d%H%M)
110+
111+
# Validate input file
112+
if [[ -f "$wls_inventory_file" ]]; then
113+
input_file="$wls_inventory_file"
114+
elif [[ -f "$toolHome/out/$wls_inventory_file" ]]; then
115+
input_file="$toolHome/out/$wls_inventory_file"
116+
else
117+
log "error" "<discoverDomain><discover_infra_local><error> model_file $wls_inventory_file not found. exiting."
118+
exit 2
119+
fi
120+
121+
# Output file
122+
output_file="$toolHome/out/infra_output_${file_timestamp}.json"
123+
124+
# Python script for patching
125+
PYTHON_SCRIPT="$toolHome/lib/python/patch_discover_infra_model.py"
126+
127+
# Call Python script to patch the model file
128+
log "info" "Executing patch_discover_infra_mode.py on $input_file"
129+
python3 "$PYTHON_SCRIPT" \
130+
--input_model "$input_file" \
131+
--output_model "$output_file" \
132+
--env_file "$ON_PREM_ENV_FILE"
133+
exit_code=$?
134+
log "info" "Executed Python patch script with exit code [$exit_code]"
135+
if [[ $exit_code -ne 0 ]]; then
136+
log "error" "<discoverDomain><discover_infra_local><error> Python script failed"
137+
exit $exit_code
138+
fi
139+
log "info" "<discoverDomain><discover_infra_local><exit> infrastructure_file : $output_file"
140+
141+
# Update migration metadata
142+
DISCOVERED_INFRA_JSON="$output_file"
143+
update_migration_data_json "infra_json" "$DISCOVERED_INFRA_JSON"
131144
}
132145

133146
discover_infra_remote(){

0 commit comments

Comments
 (0)