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

Backport | Initial fix for failting customization #1001

Merged
merged 3 commits into from
Aug 29, 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
3 changes: 1 addition & 2 deletions virt-v2v/cold/entrypoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ func main() {
// If needed, customize the VM
err = customizeVM(source, xmlFilePath)
if err != nil {
fmt.Println("Error customizing the VM:", err)
os.Exit(1)
fmt.Println("Warning customizing the VM failed:", err)
}

http.HandleFunc("/vm", vmHandler)
Expand Down
22 changes: 20 additions & 2 deletions virt-v2v/cold/scripts/rhel/run/network_config_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ NETWORK_SCRIPTS_DIR="${NETWORK_SCRIPTS_DIR:-/etc/sysconfig/network-scripts}"
NETWORK_CONNECTIONS_DIR="${NETWORK_CONNECTIONS_DIR:-/etc/NetworkManager/system-connections}"
UDEV_RULES_FILE="${UDEV_RULES_FILE:-/etc/udev/rules.d/70-persistent-net.rules}"

# Check if mapping file does not exist
if [ ! -f "$V2V_MAP_FILE" ]; then
echo "File $V2V_MAP_FILE does not exist. Exiting."
exit 0
fi

# Check if udev rules file exists
if [ -f "$UDEV_RULES_FILE" ]; then
echo "File $UDEV_RULES_FILE already exists. Exiting."
Expand All @@ -30,6 +36,12 @@ extract_mac_ip() {

# Create udev rules based on the macToip mapping + ifcfg network scripts
udev_from_ifcfg() {
# Check if the network scripts directory exists
if [[ ! -d "$NETWORK_SCRIPTS_DIR" ]]; then
echo "Warning: Directory $NETWORK_SCRIPTS_DIR does not exist."
return 0
fi

# Read the mapping file line by line
while IFS= read -r line; do
# Extract S_HW and S_IP
Expand All @@ -50,6 +62,12 @@ udev_from_ifcfg() {

# Create udev rules based on the macToip mapping + network manager connections
udev_from_nm() {
# Check if the network connections directory exists
if [[ ! -d "$NETWORK_CONNECTIONS_DIR" ]]; then
echo "Warning: Directory $NETWORK_CONNECTIONS_DIR does not exist."
return 0
fi

# Read the mapping file line by line
while IFS= read -r line; do
# Extract S_HW and S_IP
Expand Down Expand Up @@ -79,8 +97,8 @@ check_dupe_hws() {

# If duplicates are found, print an error and exit
if [ -n "$dupes" ]; then
echo "ERR: Duplicate hw: $dupes"
exit 2
echo "Warning: Duplicate hw: $dupes"
return 0
fi

echo "$input"
Expand Down
Loading