Skip to content

Commit

Permalink
Fix issue where toggle Foreman build fails.
Browse files Browse the repository at this point in the history
Due to what looks like a Foreman bug or artifacts from when puppet
collects facts about a host that adds additional interfaces,
sometimes this causes multiple, non-primary interfaces to be
collected under the Foreman host profile.  If Foreman doesn't
have control of these additional interfaces it can cause the build
flag toggle to fail.

patchset #3: fix spacing

Fixes #29

Change-Id: Ie5a538dd0928a2a7643b1f356b30504c853fbb70
  • Loading branch information
sadsfae committed Feb 9, 2017
1 parent 902d800 commit eb535a7
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions bin/move-and-rebuild-host.sh
Original file line number Diff line number Diff line change
Expand Up @@ -241,22 +241,37 @@ fi
hammer user update --login $new_cloud --password $foreman_user_password

#### END FOREMAN VIEWS
#### BEGIN FOREMAN REBUILD

if $rebuild ; then

# also first ensure PXE enabled on the host .... for foreman
# first ensure PXE enabled on the host .... for foreman
$bindir/pxe-foreman-config.sh $host_to_move

# also determine whether or not to leverage post snipper for PXE disablement
$bindir/pxe-director-config.sh $host_to_move

# either puppet facts or Foreman sometimes collect additional interface info
# this is needed sometimes as a workaround: clean all non-primary interfaces previously collected
skip_id=$(hammer host info --name $host_to_move | egrep -B 3 "nterface .primary, provision" | grep Id: | awk '{ print $NF }')
TMPIFFILE=$(mktemp /tmp/IFXXXXXXX)
hammer host info --name $host_to_move > $TMPIFFILE

# remove extraneous interfaces collected prior to previous host usage
for interface in $(grep Id $TMPIFFILE | grep '\)' | grep -v $skip_id | awk '{ print $NF }') ; do
hammer host interface delete --host $host_to_move --id $interface
done
rm -f $TMPIFFILE

# perform host rebuild, in future the OS here should be a variable, fix me.
hammer host update --name $host_to_move --build 1 --operatingsystem "RHEL 7"
ipmitool -I lanplus -H mgmt-$host_to_move -U $ipmi_username -P $ipmi_password chassis power off
sleep 30
ipmitool -I lanplus -H mgmt-$host_to_move -U $ipmi_username -P $ipmi_password chassis power on

fi

#### END FOREMAN REBUILD
# DONT update the wiki here. This is costly and slows down the
# move of a large number of nodes. Instead, run the wiki regeneration
# more frequently (via cron). There's a lock file regardless so you
Expand All @@ -265,4 +280,3 @@ fi
# $bindir/regenerate-wiki.sh 1>/dev/null 2>&1

exit 0

0 comments on commit eb535a7

Please sign in to comment.